/* =========================================
   DESIGN TOKENS & VARIABLES
   ========================================= */
:root {
    /* Warm Color Palette */
    --primary: #FBBF24;        
    --primary-dark: #F59E0B;   
    --primary-light: #FEF3C7;  
    
    --success: #10B981;
    --success-bg: #D1FAE5;
    --danger: #EF4444;
    --danger-bg: #FEE2E2;
    --info: #3B82F6;
    --info-bg: #DBEAFE;
    --purple: #8B5CF6;
    --purple-bg: #EDE9FE;

    /* Backgrounds & Surfaces */
    --bg: #F9FAFB;             
    --surface: #FFFFFF;        
    --surface-2: #F3F4F6;      
    --border: #F3F4F6;
    --border-strong: #E5E7EB;

    /* Text Colors */
    --text: #111827;           
    --text-muted: #6B7280;     
    --text-light: #9CA3AF;     

    /* Borders & Shadows */
    --radius: 20px;            
    --radius-sm: 12px;         
    --radius-lg: 24px;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,.05);
    --shadow-lg: 0 12px 32px rgba(15,23,42,.10);

    /* Layout Sizes */
    --sidebar-w: 260px;
    --topbar-h: 72px;

    /* Animations */
    --transition: 180ms cubic-bezier(.4, 0, .2, 1);
}

/* =========================================
   RESET & BASE
   ========================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* =========================================
   APP LAYOUT
   ========================================= */
.app {
    display: flex;
    min-height: 100vh;
}

/* =========================================
   SIDEBAR
   ========================================= */
/* =========================================
   SIDEBAR
   ========================================= */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border-strong);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50; /* 👈 INCREASED TO 50 SO IT SITS ABOVE OVERLAY */
    transition: transform 0.3s ease; /* Smoother animation */
}

.sidebar-brand {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-strong);
    height: var(--topbar-h);
}

.brand-logo {
    width: 44px; 
    height: 44px;
    flex-shrink: 0;
    display: grid; 
    place-items: center;
    overflow: hidden;
    border-radius: 50%;
}

.brand-text { min-width: 0; }
.brand-text strong { display: block; font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: #059669; font-weight: 600; font-size: 11px; }

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}
.nav-section { margin-bottom: 20px; }
.nav-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-light);
    padding: 0 12px 8px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 13.5px;
    transition: all var(--transition);
    position: relative;
}
.nav-item:hover {
    background: var(--surface-2);
    color: var(--text);
}
.nav-item.active {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: -12px; top: 8px; bottom: 8px;
    width: 3px;
    background: var(--primary-dark);
    border-radius: 0 3px 3px 0;
}
.nav-item i { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-strong);
}
.user-mini {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
}
.user-mini .avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    display: grid; place-items: center;
    font-weight: 700;
    font-size: 14px;
}
.user-mini .user-meta { flex: 1; min-width: 0; }
.user-mini .user-meta strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-mini .user-meta small { color: var(--text-muted); font-size: 11px; }
.user-mini a { color: var(--text-muted); padding: 6px; border-radius: 6px; }
.user-mini a:hover { background: var(--surface-2); color: var(--danger); }

/* =========================================
   MAIN CONTENT AREA
   ========================================= */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Topbar */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border-strong);
    padding: 0 28px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 30;
}
.menu-btn { display: none; }
.page-title h1 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -.01em;
}
.page-title p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
    font-weight: 500;
}
.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-btn {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all var(--transition);
}
.icon-btn:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--text-light);
}
.icon-btn i { width: 18px; height: 18px; }

/* Content padding */
.content {
    padding: 28px;
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* =========================================
   BUTTONS
   ========================================= */
.btn, .btn-secondary, .btn-danger, .btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    border: 1px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn {
    background: var(--primary);
    color: #111;
    box-shadow: 0 1px 2px rgba(251,191,36,.3);
}
.btn:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--text-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn i { width: 16px; height: 16px; }

.btn-sm, .btn-xs {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: all var(--transition);
}
.btn-sm { background: var(--primary-light); color: var(--primary-dark); }
.btn-sm:hover { background: var(--primary); color: #111; }
.btn-sm.wa { background: var(--success-bg); color: #065F46; }
.btn-sm.wa:hover { background: #25D366; color: #fff; }
.btn-sm.danger { background: var(--danger-bg); color: #991b1b; }
.btn-sm.danger:hover { background: var(--danger); color: #fff; }

/* =========================================
   CARDS & GRIDS (MOBILE FIRST)
   ========================================= */
.card {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

/* Dashboard Layout (Mobile) */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.two-col {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

/* Section Header */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.section-header h3 {
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-header h3 i { width: 18px; height: 18px; color: var(--primary-dark); }

/* =========================================
   TABLES
   ========================================= */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-light);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
}
tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-strong);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--surface-2); }
tbody td:last-child { text-align: right; }

.cell-student { display: flex; align-items: center; gap: 10px; }
.cell-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary-dark);
    display: grid; place-items: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}
.cell-student .meta strong { display: block; font-weight: 600; color: var(--text); }
.cell-student .meta small { color: var(--text-muted); font-size: 12px; }

/* =========================================
   BADGES & TAGS
   ========================================= */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .01em;
}
.badge.cash, .badge.active { background: var(--success-bg); color: #065F46; }
.badge.upi, .badge.info { background: var(--info-bg); color: #1e40af; }
.badge.inactive { background: var(--danger-bg); color: #991b1b; }
.badge.warning { background: var(--primary-light); color: #92400e; }
.badge.neutral { background: var(--surface-2); color: var(--text-muted); }

/* =========================================
   FORMS & SEARCH
   ========================================= */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 24px;
}
.form-card label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 14px;
}
.form-card label span { color: var(--danger); margin-left: 2px; }
.form-card input,
.form-card select,
.form-card textarea {
    width: 100%;
    padding: 10px 12px;
    margin-top: 6px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    background: var(--surface);
    color: var(--text);
    transition: all var(--transition);
}
.form-card input:focus,
.form-card select:focus,
.form-card textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-card textarea { resize: vertical; min-height: 70px; }

.form-actions {
    display: flex;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--border-strong);
    margin-top: 16px;
}

.search-bar { display: flex; gap: 10px; margin-bottom: 16px; }
.search-input { flex: 1; position: relative; }
.search-input i {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; color: var(--text-light); pointer-events: none;
}
.search-input input {
    width: 100%; padding: 10px 14px 10px 38px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 13.5px;
}
.search-input input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* =========================================
   ALERTS & TOASTS
   ========================================= */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13.5px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
}
.alert i { width: 18px; height: 18px; flex-shrink: 0; }
.alert.info { background: var(--info-bg); color: #1e40af; border-color: #bfdbfe; }
.alert.success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert.warning { background: var(--primary-light); color: #92400e; border-color: #fde68a; }
.alert.error, .alert.danger { background: var(--danger-bg); color: #991b1b; border-color: #fecaca; }

.toast-container {
    position: fixed;
    bottom: 24px; right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    min-width: 280px;
    box-shadow: var(--shadow-lg);
    animation: slideIn .3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13.5px;
    font-weight: 500;
}
.toast svg { width: 20px !important; height: 20px !important; }
.toast.success { border-left-color: var(--success); } .toast.success svg { color: var(--success); }
.toast.error { border-left-color: var(--danger); } .toast.error svg { color: var(--danger); }
.toast.warning { border-left-color: var(--primary-dark); } .toast.warning svg { color: var(--primary-dark); }
.toast.info { border-left-color: var(--info); } .toast.info svg { color: var(--info); }

@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { transform: translateX(120%); opacity: 0; } }
.toast.leaving { animation: fadeOut .3s ease forwards; }

/* =========================================
   EMPTY STATES & MISC
   ========================================= */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state i { width: 48px; height: 48px; color: var(--text-light); margin-bottom: 12px; }
.empty-state h3 { font-size: 15px; color: var(--text); margin-bottom: 4px; }
.empty-state p { font-size: 13px; margin-bottom: 16px; }

.detail-list { display: flex; flex-direction: column; gap: 0; }
.detail-row {
    display: flex; justify-content: space-between; padding: 10px 0;
    border-bottom: 1px solid var(--border-strong); font-size: 13.5px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row span:first-child { color: var(--text-muted); }
.detail-row span:last-child { font-weight: 600; }

.amount { font-weight: 700; letter-spacing: -.01em; }
.amount.positive { color: var(--success); }
.amount.negative { color: var(--danger); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }

/* =========================================
   LOGIN PAGE
   ========================================= */
.login-page {
    display: grid; place-items: center; min-height: 100vh;
    background: radial-gradient(circle at 20% 30%, rgba(251,191,36,.15), transparent 40%), radial-gradient(circle at 80% 70%, rgba(245,158,11,.15), transparent 40%), linear-gradient(135deg, #111827 0%, #374151 100%);
    padding: 20px;
}
.login-box { background: var(--surface); padding: 40px 36px; border-radius: var(--radius-lg); width: 100%; max-width: 400px; box-shadow: var(--shadow-lg); }
.login-logo { width: 56px; height: 56px; border-radius: 14px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); display: grid; place-items: center; font-size: 26px; color: #111; margin: 0 auto 16px; }
.login-box h2 { text-align: center; font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.login-box > p { text-align: center; color: var(--text-muted); font-size: 13.5px; margin-bottom: 28px; }
.login-box label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 14px; }
.login-box input { width: 100%; padding: 11px 14px; margin-top: 6px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 14px; transition: all var(--transition); }
.login-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.login-box button[type=submit] { width: 100%; padding: 12px; margin-top: 8px; background: var(--primary); color: #111; border: none; border-radius: var(--radius-sm); font-size: 14px; font-weight: 700; transition: all var(--transition); }
.login-box button[type=submit]:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* =========================================
   🔥 PREMIUM DESKTOP OVERRIDES 🔥
   ========================================= */
@media (min-width: 1024px) {
    /* 1. Stats become a sleek, wide banner */
    .dashboard-stats {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
        margin-bottom: 32px;
    }
    
    .dashboard-stats .stat-card {
        padding: 24px !important;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    .dashboard-stats .stat-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 12px 24px rgba(0,0,0,0.06) !important;
    }
    .dashboard-stats h3 {
        font-size: 32px !important;
    }

    /* 2. Quick Actions become a perfect 6-column grid */
    .quick-actions-grid {
        display: grid;
        grid-template-columns: repeat(6, 1fr);
        gap: 16px;
        margin-bottom: 40px;
    }
    
    /* Make the card horizontal (Icon next to text) */
    .quick-actions-grid .card {
        flex-direction: row !important;
        justify-content: flex-start !important;
        padding: 16px !important;
        border-radius: 16px !important;
        gap: 12px;
    }
    
    /* Force the icon wrapper to stay small */
    .quick-actions-grid .card > div:first-child {
        margin-bottom: 0 !important;
        width: 36px !important;
        height: 36px !important;
        flex-shrink: 0;
    }
    .quick-actions-grid .card span {
        font-size: 13px !important;
        white-space: nowrap;
    }

    /* 3. Two-column tables side-by-side */
    .two-col {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 24px;
    }
}

/* =========================================
   MOBILE SUPPORT (Keep app-look on phone)
   ========================================= */
@media (max-width: 1024px) {
    .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .main { margin-left: 0; }
    .menu-btn { display: grid; }
    .content { padding: 20px 16px; }
    .topbar { padding: 0 16px; }
    .page-title h1 { font-size: 17px; }
    .page-title p { display: none; }
    table { font-size: 13px; }
    thead th, tbody td { padding: 10px 12px; }
    .grid-2 { grid-template-columns: 1fr; }
}

/* =========================================
   TOPBAR HEADER FIXES
   ========================================= */
.menu-btn {
    display: none; /* Hidden on desktop */
    cursor: pointer;
}

/* Desktop Search visibility */
.desktop-search-form {
    display: block;
}

@media (max-width: 900px) {
    /* Hide the top search bar on tablets and phones to save space */
    .desktop-search-form {
        display: none !important;
    }
}

@media (max-width: 768px) {
    /* Show the hamburger button only on mobile */
    .menu-btn {
        display: grid !important;
    }
    
    /* Make topbar actions align properly on mobile */
    .topbar-actions {
        gap: 6px;
    }
    
    /* Make action buttons smaller on mobile */
    .topbar-actions .btn, 
    .topbar-actions .btn-secondary {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    /* Hide the text inside buttons on mobile, show only icons (Optional, keeps it clean) */
    .topbar-actions .btn i,
    .topbar-actions .btn-secondary i {
        margin: 0;
    }
}