:root {
    /* Premium Color Palette */
    --primary-color: #0056b3;
    /* Deep Blue */
    --secondary-color: #004494;
    /* Darker Blue */
    --accent-color: #ffc107;
    /* Vibrant Yellow/Orange */
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --bg-light: #f3f4f6;
    --white: #ffffff;
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-light);
    color: var(--text-dark);
}

/* Layout */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: #1e293b;
    /* Dark Slate */
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: all 0.3s;
    z-index: 100;
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 95;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    background-color: #0f172a;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 0.5px;
    justify-content: space-between;
    /* Added for close button positioning */
}

.sidebar-menu {
    padding: 1.5rem 0;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: #94a3b8;
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

.menu-item:hover,
.menu-item.active {
    background-color: #334155;
    color: white;
    border-left: 4px solid var(--accent-color);
}

.menu-item i {
    width: 24px;
    margin-right: 10px;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s;
}

.top-header {
    height: var(--header-height);
    background: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 90;
}

.content-body {
    padding: 2rem;
}

/* Cards & Widgets */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-widget {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-info h4 {
    color: var(--text-light);
    font-size: 0.875rem;
    font-weight: 500;
}

.stat-info h2 {
    font-size: 1.75rem;
    margin-top: 0.25rem;
    color: var(--text-dark);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Charts Section */
.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Dashboard Splitted Row (Messages & Todo) */
.dashboard-grid-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 2rem;
}

/* Filter Bar */
.filter-bar {
    margin-bottom: 2rem;
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.filter-form {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
}

.chart-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* Forms & Tables */
.form-control {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #d1d5db;
    border-radius: var(--radius-md);
}

.btn {
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Action Button Styles (Premium Icons) */
.btn-icon {
    width: 35px;
    height: 35px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    /* Rounded Square */
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-size: 0.9rem;
}

.btn-icon-sm {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-size: 0.8rem;
}

.btn-icon:hover,
.btn-icon-sm:hover {
    transform: translateY(-2px);
    filter: brightness(0.95);
}

.btn-view {
    background-color: #e2e8f0;
    /* Slate 200 */
    color: #1e293b;
    /* Slate 800 */
}

.btn-edit {
    background-color: #dbeafe;
    /* Blue 100 */
    color: #1e40af;
    /* Blue 800 */
}

.btn-delete {
    background-color: #fee2e2;
    /* Red 100 */
    color: #991b1b;
    /* Red 800 */
}

.btn-msg {
    background-color: #0056b3;
    /* Primary Solid */
    color: #ffffff;
    /* White */
}

.btn-scan {
    background-color: #f3e8ff;
    /* Purple 100 */
    color: #7e22ce;
    /* Purple 800 */
}

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

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    white-space: nowrap;
    /* Prevent awkward wrapping */
}

/* Responsive Table Wrapper */
.table-wrapper {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
}

/* Stackable Forms for Mobile */
@media (max-width: 768px) {
    .responsive-form {
        flex-direction: column;
        align-items: stretch !important;
    }

    .responsive-form .form-control,
    .responsive-form .btn {
        width: 100% !important;
        margin-bottom: 10px;
    }

    /* Messages Mobile */
    .msg-container {
        height: calc(100vh - 70px) !important;
        flex-direction: column;
    }

    .msg-sidebar {
        width: 100% !important;
        max-width: none !important;
        height: 100%;
        display: flex;
        /* Default show sidebar */
    }

    .msg-content {
        display: none !important;
        /* Default hide content */
        width: 100%;
        height: 100%;
    }

    /* When a student is selected, hide sidebar and show content */
    .msg-container.chat-active .msg-sidebar {
        display: none !important;
    }

    .msg-container.chat-active .msg-content {
        display: flex !important;
    }

    /* Message Bubbles on Mobile */
    .message {
        max-width: 85% !important;
    }
}

th {
    background-color: #f8fafc;
    font-weight: 600;
}

/* Default hidden on desktop */
.mobile-menu-btn {
    display: none;
}

.sidebar-close-btn {
    display: none;
}

.mobile-strip {
    display: none;
}

/* Responsive Admin */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        z-index: 1000;
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .top-header {
        padding: 0 1rem;
    }

    .content-body {
        padding: 1rem;
    }

    .stats-grid,
    .charts-row,
    .dashboard-grid-row {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        justify-content: center;
    }

    .filter-form {
        flex-direction: column;
        width: 100%;
        align-items: stretch;
    }

    .filter-form>div {
        display: flex;
        flex-direction: column;
        width: 100%;
        margin-bottom: 10px;
    }

    .filter-form label {
        margin-bottom: 5px;
    }

    .filter-form select,
    .filter-form input {
        width: 100% !important;
    }

    .sidebar-header {
        justify-content: space-between;
    }

    .sidebar-close-btn {
        display: block;
        background: none;
        border: none;
        color: white;
        font-size: 1.2rem;
        cursor: pointer;
    }

    .mobile-menu-btn {
        display: block !important;
        background: none;
        border: none;
        font-size: 1.5rem;
        cursor: pointer;
        color: var(--text-dark);
        margin-right: 10px;
    }
}

/* --- DARK MODE (Fees Page) --- */
body.dark-mode {
    background-color: #0f172a !important;
    /* Slate 900 */
    color: #f1f5f9 !important;
    /* Slate 100 */
}

body.dark-mode .chart-card,
body.dark-mode .stat-widget,
body.dark-mode .table-wrapper {
    background-color: #1e293b !important;
    /* Slate 800 */
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}

body.dark-mode .top-header {
    background-color: #1e293b !important;
    border-bottom: 1px solid #334155;
    color: #f1f5f9 !important;
}

body.dark-mode .top-header h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode strong {
    color: #f1f5f9 !important;
}

body.dark-mode th {
    background-color: #0f172a !important;
    color: #cbd5e1 !important;
    border-bottom: 1px solid #334155 !important;
}

body.dark-mode td {
    border-bottom: 1px solid #334155 !important;
    color: #e2e8f0 !important;
}

body.dark-mode .form-control {
    background-color: #334155 !important;
    border-color: #475569 !important;
    color: white !important;
}

body.dark-mode .btn:not(.btn-primary):not(#darkModeBtn) {
    background-color: #334155 !important;
    color: white !important;
    border: 1px solid #475569 !important;
}

body.dark-mode .mobile-menu-btn {
    color: white !important;
}

/* Modal Dark Mode overrides */
body.dark-mode #paymentModal>div,
body.dark-mode #waModal>div,
body.dark-mode #trackerModal>div,
body.dark-mode #historyModal>div {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
    border: 1px solid #334155;
}

body.dark-mode #paymentModal label,
body.dark-mode .modal-title {
    color: #f1f5f9 !important;
}