@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
    --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --warning-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --danger-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --dark-gradient: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --focus-ring: rgba(79, 70, 229, 0.2);
    
    --sidebar-width: 260px;
    --transition-speed: 0.3s;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, .brand-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

/* ====================================================
   LAYOUT & STRUCTURE
   ==================================================== */

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    color: var(--text-main);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all var(--transition-speed) ease;
    z-index: 1000;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.05);
}

.sidebar .brand-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}

.sidebar .brand-logo {
    width: 40px;
    height: 40px;
    background: var(--primary-gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.25rem;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.sidebar .brand-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex-grow: 1;
}

.sidebar-nav .nav-link {
    color: #475569;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.sidebar-nav .nav-link:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-main);
    transform: translateX(3px);
}

.sidebar-nav .nav-link.active {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.sidebar-nav .nav-link i {
    font-size: 1.1rem;
}

.sidebar .user-profile-widget {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.85rem;
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-profile-widget img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid #6366f1;
}

/* Main Content Area */
.main-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents flex items from overflowing */
}

.main-header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 999;
}

.content-body {
    padding: 2rem;
    flex-grow: 1;
}

/* ====================================================
   CARDS & CONTAINERS
   ==================================================== */

.crm-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px -1px rgba(0, 0, 0, 0.01);
    transition: all 0.3s ease;
    /* overflow: hidden; */
}

.crm-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
}

.crm-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.crm-card-body {
    padding: 1.5rem;
}

/* ====================================================
   BUTTONS & CONTROLS
   ==================================================== */

.btn-crm-primary {
    background: var(--primary-gradient);
    color: #ffffff;
    border: none;
    font-weight: 600;
    border-radius: 10px;
    padding: 0.6rem 1.25rem;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
    transition: all 0.2s ease;
}

.btn-crm-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3);
    color: #ffffff;
}

.btn-crm-secondary {
    background: #ffffff;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    font-weight: 500;
    border-radius: 10px;
    padding: 0.6rem 1.25rem;
    transition: all 0.2s ease;
}

.btn-crm-secondary:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

/* Inputs and Forms */
.form-crm-control {
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    color: var(--text-main);
}

.form-crm-control:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 4px var(--focus-ring);
    outline: none;
}

.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* ====================================================
   KPI METRICS WIDGETS
   ==================================================== */

.kpi-card {
    border-radius: 16px;
    padding: 1.5rem;
    color: #ffffff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.kpi-card .kpi-icon {
    position: absolute;
    right: 1.25rem;
    bottom: 0.5rem;
    font-size: 4rem;
    opacity: 0.12;
}

.kpi-card .kpi-title {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.85;
}

.kpi-card .kpi-value {
    font-size: 2.25rem;
    font-weight: 800;
    margin-top: 0.5rem;
    font-family: 'Outfit', sans-serif;
}

.kpi-blue { background: var(--primary-gradient); }
.kpi-green { background: var(--success-gradient); }
.kpi-orange { background: var(--warning-gradient); }
.kpi-red { background: var(--danger-gradient); }

/* ====================================================
   COLOR CODED STATUS BADGES & FLAGS
   ==================================================== */

.badge-won {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.2);
    font-weight: 600;
    padding: 0.35em 0.8em;
    border-radius: 6px;
}

.badge-lost {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
    font-weight: 600;
    padding: 0.35em 0.8em;
    border-radius: 6px;
}

.badge-followup {
    background: rgba(245, 153, 11, 0.12);
    color: #d97706;
    border: 1px solid rgba(245, 153, 11, 0.2);
    font-weight: 600;
    padding: 0.35em 0.8em;
    border-radius: 6px;
}

/* Timeline Components */
.timeline {
    border-left: 2px solid var(--border-color);
    padding-left: 1.5rem;
    position: relative;
    margin-left: 0.75rem;
}

.timeline-item {
    position: relative;
    margin-bottom: 1.5rem;
}

.timeline-item::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: #ffffff;
    border: 3px solid #6366f1;
    border-radius: 50%;
    left: -32.5px;
    top: 4px;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.timeline-time {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.timeline-body {
    background: #f8fafc;
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    margin-top: 0.35rem;
}

/* ====================================================
   MOBILE & STICKY FOOTER PREFERENCES
   ==================================================== */

.sticky-action-bar {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
    padding: 0.85rem 1.5rem;
    z-index: 1020;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    transition: left var(--transition-speed) ease;
}

.sticky-action-bar-space {
    height: 75px; /* Creates spacing at the bottom of forms to prevent sticky bar overlap */
}

/* ====================================================
   MEDIA QUERIES (MOBILE FIRST COMPLIANT)
   ==================================================== */

@media (max-width: 991.98px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        padding: 0.75rem 1rem;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        height: auto;
        position: relative;
    }
    
    .sidebar .brand-area {
        margin-bottom: 0;
        border-bottom: none;
        padding-bottom: 0;
    }
    
    .sidebar-nav {
        display: none;
    }
    
    .sidebar .user-profile-widget {
        display: none;
    }
    
    .content-body {
        padding: 1rem;
    }
    
    .main-header {
        padding: 0.75rem 1rem;
    }

    /* KPI cards font size reduction on mobile */
    .kpi-card .kpi-value {
        font-size: 1.75rem;
    }

    .sticky-action-bar {
        left: 0 !important;
    }
}

/* Slide Out Mobile Drawer Menu (If triggered) */
.mobile-nav-active .sidebar-nav {
    display: flex !important;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    padding: 1rem;
    z-index: 1050;
    border-bottom: 2px solid var(--border-color);
    box-shadow: 0 10px 20px rgba(0,0,0,0.08);
}

/* Utility: valid padding replacement for py-2.5 (Tailwind-style classes not valid in Bootstrap) */
.py-2-5 { padding-top: 0.625rem !important; padding-bottom: 0.625rem !important; }
.px-2-5 { padding-left: 0.625rem !important; padding-right: 0.625rem !important; }
.p-2-5 { padding: 0.625rem !important; }

/* Search Dropdown / Autocomplete */
.search-suggest-box {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    z-index: 1050;
    max-height: 250px;
    overflow-y: auto;
}

.search-suggest-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.2s ease;
}

.search-suggest-item:hover {
    background: #f8fafc;
}

.search-suggest-item:last-child {
    border-bottom: none;
}
