/* =========================================
   LeadManagementSystem – Professional Theme
   Palette: Indigo/Slate, clean surfaces
   ========================================= */
:root {
    --brand:      #4f46e5;
    --brand-dark: #4338ca;
    --brand-soft: #eef2ff;
    --brand-mid:  #6366f1;
    --sidebar-bg: #1e1e2d;
    --sidebar-txt:#a8a8c0;
    --surface:    #f5f6fa;
    --card-bg:    #ffffff;
    --border:     #e5e7eb;
    --text-main:  #111827;
    --text-muted: #6b7280;
    --success:    #10b981;
    --warning:    #f59e0b;
    --danger:     #ef4444;
}
/* 🔥 GLOBAL RESPONSIVE (ALL AUTH PAGES) */

.auth-card {
    width: 100%;
    max-width: 440px;
}

.auth-card .card-body {
    padding: clamp(20px, 4vw, 32px);
}

.auth-title {
    font-size: clamp(18px, 4vw, 22px);
}

.form-control {
    font-size: clamp(13px, 3.5vw, 14.5px);
}

.btn-brand {
    font-size: clamp(13px, 3.5vw, 14.5px);
    padding: clamp(10px, 3vw, 12px);
}

@media (max-width: 360px) {
    .auth-card {
        border-radius: 14px;
    }

    .auth-card .card-body {
        padding: 18px 14px;
    }

    .auth-logo {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
}
*, *::before, *::after { box-sizing: border-box; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--surface); color: var(--text-main); margin: 0; }

/* WRAPPER */
#wrapper { display: flex; min-height: 100vh; }

/* SIDEBAR */
#sidebar {
    width: 230px; min-height: 100vh; background: var(--sidebar-bg);
    display: flex; flex-direction: column; flex-shrink: 0;
    transition: width .22s ease; position: sticky; top: 0; height: 100vh;
    overflow-y: auto; overflow-x: hidden;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand-icon {
    width: 34px; height: 34px; background: var(--brand); border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; color: #fff; flex-shrink: 0;
}
.brand-text { font-weight: 700; font-size: .93rem; color: #fff; }
.brand-sub  { font-size: .67rem; color: var(--sidebar-txt); }
.nav-section-label {
    padding: 16px 16px 5px; font-size: .63rem; font-weight: 700;
    letter-spacing: 1px; text-transform: uppercase; color: rgba(168,168,192,.45);
}
#sidebar .nav-link {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 16px; margin: 1px 8px; border-radius: 8px;
    font-size: .81rem; font-weight: 500; color: var(--sidebar-txt);
    text-decoration: none; transition: all .15s; white-space: nowrap;
}
#sidebar .nav-link i { font-size: .9rem; flex-shrink: 0; width: 17px; text-align: center; }
#sidebar .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
#sidebar .nav-link.active { background: var(--brand); color: #fff; }

/* Tooltip for collapsed sidebar */
#sidebar .nav-link { position: relative; }
#sidebar .nav-link .nav-tooltip {
    display: none; position: absolute; left: calc(100% + 10px); top: 50%;
    transform: translateY(-50%); background: #111827; color: #fff;
    font-size: .75rem; font-weight: 500; white-space: nowrap;
    padding: 5px 10px; border-radius: 6px; pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,.25); z-index: 9999;
}
#sidebar .nav-link .nav-tooltip::before {
    content: ''; position: absolute; right: 100%; top: 50%;
    transform: translateY(-50%); border: 5px solid transparent;
    border-right-color: #111827;
}
.sidebar-footer {
    margin-top: auto; padding: 12px;
    border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-user {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 9px; border-radius: 8px;
    background: rgba(255,255,255,.05); margin-bottom: 7px;
}
.sidebar-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--brand); color: #fff; font-size: .77rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-user-info .u-name { font-size: .78rem; font-weight: 600; color: #fff; line-height: 1.2; }
.sidebar-user-info .u-role {
    font-size: .62rem; padding: 1px 6px; border-radius: 20px; font-weight: 600;
    background: rgba(79,70,229,.3); color: #a5b4fc; display: inline-block;
}
.u-role.admin { background: rgba(245,158,11,.18); color: #fcd34d; }
.btn-logout {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    width: 100%; padding: 7px; border-radius: 8px;
    background: rgba(239,68,68,.1); color: #fca5a5;
    border: none; font-size: .78rem; font-weight: 500;
    text-decoration: none; transition: background .15s; cursor: pointer;
}
.btn-logout:hover { background: rgba(239,68,68,.22); color: #fca5a5; }
.btn-logout-form { width: 100%; }

/* COLLAPSED */
/* Desktop collapsed state is handled in the @media (min-width: 992px) block below */

/* Show tooltip when sidebar is collapsed (desktop) */
#wrapper.sidebar-collapsed #sidebar .nav-link:hover .nav-tooltip { display: block; }

/* PAGE CONTENT */
#page-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* TOP NAV */
.top-navbar {
    background: #fff; border-bottom: 1px solid var(--border);
    padding: 0 22px; height: 56px;
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 100;
}
.page-title { font-weight: 600; font-size: .92rem; color: var(--text-main); }
.btn-toggle {
    background: none; border: 1px solid var(--border); border-radius: 8px;
    width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); cursor: pointer; flex-shrink: 0; transition: all .15s;
}
.btn-toggle:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }

/* MAIN */
.main-content { padding: 24px; flex: 1; }

/* PAGE HEADER */
.page-header { margin-bottom: 22px; }
.page-header h4 { font-weight: 700; font-size: 1.15rem; margin: 0 0 4px; }
.page-header p  { color: var(--text-muted); font-size: .81rem; margin: 0; }

/* CARDS */
.card { 
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; 
    box-shadow: 0 1px 3px rgba(0,0,0,.04); 
    transition: all .2s ease;
}
.card-header-clean {
    padding: 16px 18px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 10px;
    background: #fff; border-radius: 12px 12px 0 0;
}
.card-header-clean h6 { font-weight: 600; font-size: .88rem; margin: 0; }

/* QUICK LINK CARDS */
.quick-link-card { 
    transition: all .2s ease; 
    border: 1px solid var(--border);
    text-decoration: none !important;
    display: block;
}
.quick-link-card:hover { 
    box-shadow: 0 8px 24px rgba(79,70,229,.15); 
    transform: translateY(-3px);
    border-color: var(--brand-soft);
}
.quick-link-card .card-body { 
    display: flex; align-items: center; gap: 12px; 
    padding: 14px 16px !important;
}
.quick-link-card .stat-icon { 
    flex-shrink: 0; 
    margin-bottom: 0;
    width: 40px; 
    height: 40px;
}
.quick-link-card-text { 
    flex: 1; 
    min-width: 0;
}
.quick-link-card-title { 
    font-weight: 600; 
    font-size: .87rem; 
    color: var(--text-main);
}
.quick-link-card i.bi-chevron-right { 
    color: var(--text-muted); 
    font-size: .85rem;
    transition: transform .2s ease;
}
.quick-link-card:hover i.bi-chevron-right { 
    transform: translateX(3px);
}

/* STAT CARDS */
.stat-card { 
    border-radius: 12px; padding: 18px; 
    transition: all .2s ease; 
    position: relative; 
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 120px; height: 120px;
    background: radial-gradient(circle, rgba(255,255,255,.4) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}
.stat-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08) !important; transform: translateY(-2px); }
.stat-icon { 
    width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; 
    justify-content: center; font-size: 1.05rem; margin-bottom: 8px;
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; margin: 6px 0 4px; letter-spacing: -0.5px; }
.stat-label { font-size: .75rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.si-indigo .stat-icon { background: var(--brand-soft); color: var(--brand); }
.si-green  .stat-icon { background: #ecfdf5; color: var(--success); }
.si-amber  .stat-icon { background: #fffbeb; color: var(--warning); }
.si-rose   .stat-icon { background: #fff1f2; color: var(--danger); }
.si-blue   .stat-icon { background: #eff6ff; color: #0284c7; }
.si-cyan   .stat-icon { background: #ecf8ff; color: #06b6d4; }
.si-teal   .stat-icon { background: #e5f8f4; color: #14b8a6; }

/* BUTTONS */
.btn-brand  { background: var(--brand); color: #fff; border: none; border-radius: 8px; font-size: .82rem; font-weight: 500; }
.btn-brand:hover { background: var(--brand-dark); color: #fff; }
.btn-sm-icon { width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 7px; font-size: .78rem; }

/* TABLE ACTIONS */
.table-actions { display: flex; gap: 4px; align-items: center; justify-content: flex-end; flex-wrap: nowrap; }

/* TABLES */
.table-clean { font-size: .82rem; }
.table-clean thead th {
    background: var(--surface); font-size: .7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .4px;
    color: var(--text-muted); border-bottom: 1px solid var(--border); padding: 11px 12px;
}
.table-clean tbody td { padding: 11px 12px; font-size: .83rem; vertical-align: middle; border-color: var(--border); }
.table-clean tbody tr:hover { background: #fafbff; }
.table-responsive { -webkit-overflow-scrolling: touch; }

/* BADGES */
.badge-active   { background: #d1fae5; color: #065f46; font-size: .7rem; padding: 3px 9px; border-radius: 20px; font-weight: 600; }
.badge-inactive { background: #fee2e2; color: #991b1b; font-size: .7rem; padding: 3px 9px; border-radius: 20px; font-weight: 600; }
.badge-admin    { background: #ede9fe; color: #5b21b6; font-size: .7rem; padding: 3px 9px; border-radius: 20px; font-weight: 600; }
.badge-user     { background: #e0f2fe; color: #0369a1; font-size: .7rem; padding: 3px 9px; border-radius: 20px; font-weight: 600; }

/* FORMS */
.form-control, .form-select {
    border-radius: 8px; border: 1px solid var(--border);
    font-size: .84rem; padding: 8px 11px; transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.11); outline: none;
}
.form-label { font-weight: 500; font-size: .81rem; margin-bottom: 5px; }

/* TABS */
.nav-tabs-custom {
    border-bottom: 2px solid var(--border); margin-bottom: 22px; gap: 2px;
    display: flex; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.nav-tabs-custom::-webkit-scrollbar { display: none; }
.nav-tabs-custom .nav-link {
    border: none; padding: 8px 16px; font-size: .83rem; font-weight: 500;
    color: var(--text-muted); border-radius: 0; border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: all .15s; background: none; white-space: nowrap; flex-shrink: 0;
}
.nav-tabs-custom .nav-link:hover { color: var(--brand); }
.nav-tabs-custom .nav-link.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* AUTH */
.auth-page { min-height: 100vh; background: linear-gradient(135deg,#f0f0ff 0%,#eef2ff 50%,#f5f5ff 100%); display: flex; align-items: center; justify-content: center; }
.auth-card { width: 420px; border-radius: 16px; box-shadow: 0 8px 40px rgba(79,70,229,.12); }
.auth-logo { width: 50px; height: 50px; background: var(--brand); border-radius: 13px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; color: #fff; margin: 0 auto 14px; }

/* MODAL */
.modal-content { border-radius: 13px; border: none; box-shadow: 0 20px 60px rgba(0,0,0,.13); }
.modal-header { border-bottom: 1px solid var(--border); padding: 15px 18px; }
.modal-footer { border-top: 1px solid var(--border); padding: 11px 18px; }

/* ALERTS */
.alert { border-radius: 9px; font-size: .83rem; border: none; }
.alert-success { background: #ecfdf5; color: #065f46; }
.alert-danger  { background: #fef2f2; color: #991b1b; }
.alert-info    { background: var(--brand-soft); color: #3730a3; }

/* RESPONSIVE UTILITIES */
.row.g-2  { --bs-gutter-x: 8px; --bs-gutter-y: 8px; }
.row.g-3  { --bs-gutter-x: 12px; --bs-gutter-y: 12px; }
.row.g-4  { --bs-gutter-x: 16px; --bs-gutter-y: 16px; }

/* Better margins for different viewports */
.mb-md-4 { margin-bottom: 16px; }
@media (min-width: 768px) {
    .mb-md-4 { margin-bottom: 24px; }
}

/* ================================
   RESPONSIVE – MOBILE OVERLAY SIDEBAR
   ================================ */
#sidebarOverlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1040;
    backdrop-filter: blur(1px);
}

/* ── BOTTOM NAV BAR (mobile only, hidden by default) ── */
#mobileBottomNav {
    display: none;
}

/* ── MOBILE (< 768px) ── */
@media (max-width: 767.98px) {

    /* Sidebar: hidden off-screen, slides in as overlay */
    #sidebar {
        position: fixed !important; top: 0; left: 0; height: 100vh;
        z-index: 1045; width: 260px !important;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 6px 0 30px rgba(0,0,0,.28);
    }
    /* Restore all hidden text when sidebar is open on mobile */
    #sidebar .nav-link span,
    .brand-text, .brand-sub,
    .nav-section-label,
    .sidebar-user-info,
    .btn-logout span { display: flex !important; }
    .nav-section-label { display: block !important; }
    .sidebar-user-info { display: block !important; }
    #sidebar .nav-link { justify-content: flex-start !important; padding: 10px 16px !important; margin: 2px 8px !important; font-size:.85rem !important; }
    #sidebar .nav-link i { font-size:1rem !important; }
    .sidebar-user { justify-content: flex-start !important; }
    .btn-logout { justify-content: center !important; }

    /* Open state */
    body.sidebar-open #sidebar { transform: translateX(0); }
    body.sidebar-open #sidebarOverlay { display: block; }

    /* Page content: full width on mobile */
    #wrapper { display: block; }
    #page-content { width: 100%; }

    /* Top navbar – compact, show only toggle + title + role badge */
    .top-navbar { padding: 0 12px; height: 50px; }
    .top-navbar .ms-auto { display: flex !important; align-items: center !important; gap: 8px !important; }
    .top-navbar .u-name-text { display: none !important; }
    .top-navbar .u-role-badge { display: flex !important; }
    .page-title { font-size: .85rem; }
    .btn-toggle { width: 36px; height: 36px; }

    /* Main content padding – tight on mobile, extra bottom for bottom-nav */
    .main-content { padding: 14px 14px 80px; }

    /* Page header: stack vertically */
    .page-header { margin-bottom: 16px; }
    .page-header h4 { font-size: 1.05rem; margin-bottom: 4px; }
    .page-header p { font-size: .78rem; }
    .page-header.d-flex,
    .page-header.d-flex.align-items-start { flex-direction: column !important; align-items: stretch !important; gap: 10px; }
    .page-header .d-flex.gap-2 { flex-wrap: wrap; }
    .page-header .btn { flex: 1 1 auto; justify-content: center; font-size:.82rem; }
    .page-header .btn-brand { min-width: 0; }

    /* Cards – rounded, proper shadow, improved spacing */
    .card { border-radius: 10px; margin-bottom: 12px; }
    .card-header-clean { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
    .card-header-clean h6 { font-size: .83rem; }
    .card-body { padding: 14px !important; }

    /* Tables – responsive card view on mobile */
    .table-mobile-hide { display: none !important; }
    .table-clean { margin-bottom: 0; }
    .table-clean thead th { padding: 10px 12px; font-size: .7rem; }
    .table-clean tbody td { padding: 12px; font-size: .83rem; }
    .table-responsive { border-radius: 0 0 10px 10px; overflow-x: auto; }
    
    /* Improve table readability on mobile */
    .table-clean tbody tr { border-bottom: 1px solid var(--border); }
    .table-clean tbody tr:last-child { border-bottom: none; }

    /* Quick links – stack on mobile */
    .quick-link-card { margin-bottom: 8px; }
    .quick-link-card .card-body { padding: 12px 14px !important; }

    /* Filter form – stack all fields vertically */
    .card.mb-4 { margin-bottom: 12px !important; }
    .card-body form { flex-direction: column !important; }
    .card-body form > div, 
    .card-body form .input-group { width: 100% !important; min-width: auto !important; }
    .card-body form .form-select,
    .card-body form .form-control,
    .card-body form .input-group { width: 100% !important; }
    .card-body form .d-flex { width: 100% !important; gap: 8px !important; }
    .card-body form .d-flex .btn { flex: 1; min-height: 38px; font-size: .85rem; }

    /* Page header on mobile */
    .page-header .d-flex.gap-2 { width: 100% !important; flex-direction: column !important; }
    .page-header .d-flex.gap-2 .btn { width: 100% !important; justify-content: center; font-size: .84rem; min-height: 40px; }

    /* Row gutters – tighter on mobile */
    .row.g-4 { --bs-gutter-x: 8px; --bs-gutter-y: 8px; }
    .row.g-3 { --bs-gutter-x: 6px;  --bs-gutter-y: 6px; }
    .row.g-2 { --bs-gutter-x: 6px;  --bs-gutter-y: 6px; }

    /* Action buttons – touch-friendly */
    .btn-sm-icon { width: 34px; height: 34px; font-size: .82rem; min-height: 34px; }
    .table-actions { gap: 6px; }

    /* Forms – larger tap targets */
    .form-control, .form-select {
        font-size: .88rem; padding: 11px 12px; min-height: 42px;
    }
    .form-label { font-size: .83rem; }
    .btn { min-height: 42px; font-size: .84rem; }

    /* Modal – nearly full width */
    .modal-dialog { margin: 8px !important; max-width: calc(100% - 16px) !important; }

    /* Badges – readable on small screens */
    .badge-active, .badge-inactive, .badge-admin, .badge-user { font-size: .7rem; padding: 4px 9px; }

    /* Alert – compact */
    .alert { font-size: .83rem; padding: 11px 14px; }

    /* Progress bar label */
    .progress { height: 7px !important; }

    /* Bottom nav bar – show on mobile */
    #mobileBottomNav {
        display: flex;
        position: fixed; bottom: 0; left: 0; right: 0;
        height: 58px; background: #fff;
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 16px rgba(0,0,0,.08);
        z-index: 1030;
        align-items: stretch;
    }
    #mobileBottomNav a {
        flex: 1; display: flex; flex-direction: column;
        align-items: center; justify-content: center; gap: 2px;
        color: var(--text-muted); text-decoration: none;
        font-size: .6rem; font-weight: 500;
        transition: color .15s; -webkit-tap-highlight-color: transparent;
        padding: 6px 0;
    }
    #mobileBottomNav a i { font-size: 1.15rem; line-height: 1; }
    #mobileBottomNav a.active { color: var(--brand); }
    #mobileBottomNav a:active { background: var(--brand-soft); border-radius: 8px; }
}

/* ── TABLET (768px – 991px) ── */
@media (min-width: 768px) and (max-width: 991.98px) {
    #sidebar { width: 60px; }
    .brand-text, .brand-sub, .nav-section-label,
    #sidebar .nav-link span, .sidebar-user-info,
    .btn-logout span { display: none !important; }
    #sidebar .nav-link { justify-content: center; padding: 9px 0; margin: 1px 6px; }
    .sidebar-user { justify-content: center; }
    .btn-logout { padding: 8px 0; }
    .main-content { padding: 20px; }
    .filter-row > * { min-width: 140px; }
    #sidebar .nav-link:hover .nav-tooltip { display: block; }
    
    /* Tablet stat cards */
    .stat-card { padding: 16px; }
    .stat-value { font-size: 1.45rem; }
    .stat-icon { width: 40px; height: 40px; }
}

/* ── DESKTOP (992px+) ── */
@media (min-width: 992px) {
    .main-content { padding: 28px; }
    
    /* Larger stat cards on desktop */
    .stat-card { padding: 22px; }
    .stat-value { font-size: 1.7rem; }
    .stat-icon { width: 46px; height: 46px; font-size: 1.15rem; }
    
    /* Better desktop tables */
    .table-clean thead th { padding: 12px 16px; font-size: .75rem; }
    .table-clean tbody td { padding: 12px 16px; font-size: .85rem; }
    
    /* Cards with better spacing */
    .card { margin-bottom: 16px; }
    
    /* Hover effects on desktop */
    .card { transition: all .2s ease; }
    .card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.08); }
}

/* ── DESKTOP collapsed state ── */
@media (min-width: 992px) {
    #wrapper.sidebar-collapsed #sidebar { width: 60px; }
    #wrapper.sidebar-collapsed .brand-text,
    #wrapper.sidebar-collapsed .brand-sub,
    #wrapper.sidebar-collapsed .nav-section-label,
    #wrapper.sidebar-collapsed #sidebar .nav-link span,
    #wrapper.sidebar-collapsed .sidebar-user-info,
    #wrapper.sidebar-collapsed .btn-logout span { display: none !important; }
    #wrapper.sidebar-collapsed #sidebar .nav-link { justify-content: center; padding: 9px 0; margin: 1px 6px; }
    #wrapper.sidebar-collapsed .sidebar-user { justify-content: center; }
    #wrapper.sidebar-collapsed .btn-logout { padding: 8px 0; }
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }