:root {
    /* Colors */
    --bg-color: #f9fafb;
    --surface-color: #ffffff;
    --primary-color: #1a56db;
    --primary-hover: #1e40af;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    
    /* Status Colors */
    --status-active-bg: #def7ec;
    --status-active-text: #03543f;
    --status-expense-bg: #fde8e8;
    --status-expense-text: #9b1c1c;
    --status-scheduled-bg: #e0f2fe;
    --status-scheduled-text: #0369a1;
    --status-exam-bg: #f3e8ff;
    --status-exam-text: #6b21a8;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    
    /* Typography */
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
    --bg-color: #111827;
    --surface-color: #1f2937;
    --primary-color: #3b82f6;
    --primary-hover: #60a5fa;
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --border-color: #374151;
    
    --status-active-bg: #064e3b;
    --status-active-text: #34d399;
    --status-expense-bg: #7f1d1d;
    --status-expense-text: #fca5a5;
    --status-scheduled-bg: #0c4a6e;
    --status-scheduled-text: #7dd3fc;
    --status-exam-bg: #4c1d95;
    --status-exam-text: #c084fc;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

.mobile-menu-button {
    display: none;
}

.sidebar {
    width: 220px;
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    flex-shrink: 0;
    transition: width 0.3s ease;
    overflow: hidden;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed .sidebar-header h2,
.sidebar.collapsed .sidebar-header p,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-item span {
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
}

.sidebar.collapsed .nav-item i {
    margin: 0;
}

.sidebar-header {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.sidebar-header p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.sidebar-nav {
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s;
}

.nav-item i {
    width: 20px;
    height: 20px;
}

.nav-item:hover, .nav-item.active {
    background-color: #eff6ff;
    color: var(--primary-color);
}

/* User Profile at bottom of sidebar */
.sidebar-footer {
    padding: 24px 16px;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #dbeafe;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.125rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info strong {
    font-size: 0.875rem;
    color: var(--text-main);
}

.user-info span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Content Wrapper */
.main-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 32px 48px;
}

/* View Header */
.view-header {
    margin-bottom: 32px;
}

.view-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.view-header p {
    color: var(--text-muted);
    margin-top: 4px;
}

/* Tabs */
.tabs-container {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
    display: flex;
    gap: 20px;
}

.tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 0 16px 0;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 500;
    position: relative;
}

.tab i {
    width: 18px;
    height: 18px;
}

.tab.active {
    color: var(--primary-color);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--primary-color);
}

/* Action Bar (Search + Button) */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.search-wrapper {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.search-wrapper i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 18px;
    height: 18px;
}

.search-input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    font-family: inherit;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s;
}

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

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-icon {
    padding: 6px;
    border-radius: 6px;
    background: transparent;
    color: var(--primary-color);
    cursor: pointer;
    border: none;
}
.btn-icon.danger {
    color: var(--status-expense-text);
}
/* Table */
.data-table-container {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    background-color: var(--surface-color);
    padding: 16px 24px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 16px 24px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
}
.data-table td.strong-text {
    color: var(--text-main);
}
.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background-color: #f9fafb;
}

/* Actions Cell */
.actions-cell {
    display: flex;
    gap: 12px;
}

/* Badge */
.badge {
    display: inline-flex;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    background-color: #f3f4f6;
    color: #374151;
}

.badge.active, .badge.income, .badge.completed {
    background-color: var(--status-active-bg);
    color: var(--status-active-text);
}

.badge.expense {
    background-color: var(--status-expense-bg);
    color: var(--status-expense-text);
}

.badge.scheduled {
    background-color: var(--status-scheduled-bg);
    color: var(--status-scheduled-text);
}

.badge.exam {
    background-color: var(--status-exam-bg);
    color: var(--status-exam-text);
}

/* Finance Dashboard Widgets */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 12px;
}

.stat-header i {
    width: 20px;
    height: 20px;
}

.stat-header i.green { color: #10b981; }
.stat-header i.red { color: #ef4444; }
.stat-header i.blue { color: #3b82f6; }
.stat-header i.orange { color: #f97316; }

.stat-value {
    font-size: 1.875rem;
    font-weight: 700;
}

.stat-value.green { color: #10b981; }
.stat-value.red { color: #ef4444; }
.stat-value.blue { color: #3b82f6; }
.stat-value.orange { color: #f97316; }

/* Reports Grid */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
    padding: 24px;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.report-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.report-names h3 {
    font-size: 1rem;
    color: var(--text-main);
}

.report-grade {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.report-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.report-card .btn {
    justify-content: center;
    width: 100%;
}

.report-header .badge {
    background-color: var(--status-active-bg);
    color: var(--status-active-text);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-container {
    background-color: var(--surface-color);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
    transform: translateY(20px);
    transition: transform 0.2s;
}

.modal-overlay.open .modal-container {
    transform: translateY(0);
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.25rem;
    color: var(--text-main);
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.875rem;
    background-color: var(--surface-color);
    color: var(--text-main);
}

.form-control:focus {
    border-color: var(--primary-color);
    outline: none;
}

.form-row {
    display: flex;
    gap: 16px;
}
.form-row .form-group {
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-secondary {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: #f9fafb;
}

.reports-header-box {
    padding: 24px 0 16px 0;
}
.reports-header-box h2 {
    font-size: 1.125rem;
    font-weight: 600;
}
.reports-header-box p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* =========================================
   Mobile Optimization
   ========================================= */
@media (max-width: 768px) {
    .app-container {
        position: relative;
    }
    
    .sidebar {
        position: absolute;
        top: 0;
        left: -100%;
        height: 100vh;
        z-index: 1000;
        box-shadow: var(--shadow-md);
        transition: left 0.3s ease;
        width: 260px;
    }
    
    .sidebar.mobile-open {
        left: 0;
    }

    .sidebar.collapsed {
        width: 260px; /* Disable standard collapsed mode on mobile */
    }
    
    .mobile-menu-button {
        display: none;
        position: fixed;
        top: 16px;
        left: 16px;
        z-index: 1101;
        width: 44px;
        height: 44px;
        border: none;
        border-radius: 12px;
        background: var(--surface-color);
        color: var(--text-main);
        box-shadow: var(--shadow-md);
        cursor: pointer;
        align-items: center;
        justify-content: center;
    }

    .mobile-menu-button i {
        width: 20px;
        height: 20px;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .sidebar-overlay.mobile-open {
        display: block;
    }

    .main-content {
        padding: 20px 16px;
        min-height: 100vh;
    }
    
    .mobile-menu-button {
        display: flex;
    }

    .view-header h1 {
        font-size: 1.5rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .dashboard-cards, .reports-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }
    
    .data-table-container {
        overflow-x: auto;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .header-controls {
        flex-wrap: wrap;
    }
    
    .action-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .search-wrapper {
        max-width: 100%;
    }
    
    .tabs-container {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 4px;
    }
    
    /* Layout fix for admin dashboard actions vs distribution */
    div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Modal width for mobile */
    .modal-container {
        max-width: 95% !important;
        max-height: 95vh !important;
    }
}
