:root {
    --primary-color: #1e1b4b; /* Deep Indigo Navy */
    --secondary-color: #334155; /* Slate Gray */
    --accent-color: #2563eb; /* Royal Blue */
    --success-color: #059669; /* Emerald Forest */
    --danger-color: #dc2626; /* Master Ruby */
    --warning-color: #d97706; /* Burnt Orange */
    --light-bg: #f1f5f9; /* Executive Slate Light */
    --white: #ffffff;
    --text-dark: #0f172a; /* Deep Slate Text */
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --sidebar-width: 260px;
    --header-height: 70px;
    --shadow: 0 4px 6px rgba(0,0,0,0.05);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#custom-title-bar {
    height: 32px;
    background: transparent;
    color: #333;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    -webkit-app-region: drag;
    position: absolute;
    top: 0; right: 0; left: 0;
    z-index: 10000;
}

.window-title {
    display: none;
}

.window-controls {
    display: flex;
    -webkit-app-region: no-drag;
}

.window-controls button {
    background: none;
    border: none;
    color: #1e293b;
    width: 45px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: 0.2s;
    font-size: 11px;
    opacity: 0.9;
}

.window-controls button:hover {
    background: rgba(0, 0, 0, 0.05);
    opacity: 1;
}

.window-controls button.close:hover {
    background: #e81123;
    color: white;
}

body {
    background-color: var(--light-bg);
    color: var(--text-dark);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Global Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.content-area > * {
    animation: fadeIn 0.4s ease-out;
}

/* Custom Context Menu */
#context-menu {
    position: fixed;
    z-index: 10001;
    width: 220px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    display: none;
    padding: 8px;
    transform-origin: top left;
    animation: contextMenuFade 0.2s ease-out;
}

@keyframes contextMenuFade {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.context-menu-item {
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #1e293b;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.context-menu-item:hover {
    background: #1e1b4b;
    color: white;
}

.context-menu-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    opacity: 0.8;
}

.context-menu-separator {
    height: 1px;
    background: rgba(0,0,0,0.05);
    margin: 5px 8px;
}

/* Modern Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1a252f 0%, #2c3e50 100%);
    color: var(--white);
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 4px 0 15px rgba(0,0,0,0.1);
}

.sidebar-header {
    height: 80px;
    display: flex;
    align-items: center;
    padding: 0 25px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-header h1 {
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(to right, #3498db, #2ecc71);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    padding: 10px 15px;
    gap: 4px;
}

.menu-category {
    font-size: 0.65rem;
    font-weight: 800;
    color: rgba(255,255,255,0.45); /* Increased contrast */
    margin: 25px 0 10px 15px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: 10px;
    transition: 0.3s;
    font-size: 0.9rem;
    position: relative;
}

.menu-item i {
    width: 25px;
    margin-right: 15px;
    font-size: 1.1rem;
    opacity: 0.8;
}

.menu-item:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.menu-item.active {
    background: linear-gradient(90deg, var(--accent-color), #1e40af);
    color: white;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

.nav-badge {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 800;
}

.bg-primary { background: #3498db; color: white; }
.bg-danger { background: #e74c3c; color: white; }

.logout-link { color: #ff6b6b !important; }
.logout-link:hover { background: rgba(231, 76, 60, 0.1) !important; }

/* Modern Glass Modals */
.modal-overlay {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 10000;
    justify-content: center;
    align-items: center;
    overflow-y: auto; /* Allow overlay to scroll if content is too large */
    padding: 20px;
}

.modal-content {
    background: white;
    padding: 0; /* Handled by modal-inner-content */
    border-radius: 20px;
    width: 500px;
    max-width: 90%;
    box-shadow: 0 25px 50px rgba(0,0,0,0.3);
    border-top: 5px solid var(--accent-color);
    position: relative; 
    animation: fadeIn 0.3s ease-out;
    overflow: hidden; /* Ensure rounded corners clip inner content */
}

.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #f1f5f9;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #475569;
    transition: 0.2s;
    font-size: 0.8rem;
    z-index: 10;
}

.modal-close-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* Premium Buttons */
.btn {
    padding: 12px 24px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.95rem;
}

.btn-primary {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.2);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.3);
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
}

/* Form Styling - Executive Contrast */
label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 0.8rem;
    color: #475569; /* Master Slate Gray for contrast */
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    padding: 12px 15px;
    background: #fdfdfd;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    transition: all 0.3s;
    width: 100%;
    color: #1e293b;
    font-size: 0.95rem;
}

.form-control:focus {
    border-color: #2563eb;
    background: white;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    outline: none;
}

#global-search:focus {
    width: 450px !important;
    border-color: var(--accent-color) !important;
    background: white !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

/* Main Content */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-header {
    height: var(--header-height);
    background-color: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    box-shadow: var(--shadow);
    z-index: 90;
}

/* Individualized Vibrant Background Themes */
.theme-dashboard  { background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%); }
.theme-students   { background: linear-gradient(135deg, #f5f3ff 0%, #ddd6fe 100%); } /* Light Indigo */
.theme-staff      { background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%); } /* Light Amber */
.theme-fees       { background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%); } /* Light Sky */
.theme-attendance { background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%); } /* Light Emerald */
.theme-exams      { background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%); } /* Light Rose */
.theme-homework   { background: linear-gradient(135deg, #f8fafc 0%, #cbd5e1 100%); } /* Light Slate/Blue */
.theme-library    { background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%); } /* Light Teal */
.theme-accounts   { background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%); } /* Light Purple */
.theme-reports    { background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%); } /* Light Blue */
.theme-settings   { background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%); } /* Light Slate */

.content-area {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    transition: background 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enhanced KPI Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
    color: #2c3e50;
    transition: transform 0.3s;
}

.stat-card:hover { transform: translateY(-8px); }

.stat-card::after {
    content: '';
    position: absolute;
    right: -20px;
    top: -20px;
    width: 100px;
    height: 100px;
    background: rgba(0,0,0,0.03);
    border-radius: 50%;
}

.stat-icon {
    width: 65px;
    height: 65px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-right: 25px;
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
}

/* Executive Stats Card Polish */
.card-blue   { background: linear-gradient(45deg, #1e3a8a, #3b82f6); color: white; }
.card-green  { background: linear-gradient(45deg, #064e3b, #10b981); color: white; }
.card-gold   { background: linear-gradient(45deg, #7c2d12, #d97706); color: white; }
.card-purple { background: linear-gradient(45deg, #4c1d95, #7c3ae9); color: white; }

.stat-card.card-blue .stat-icon { background: rgba(255,255,255,0.15); color: white; }
.stat-card.card-green .stat-icon { background: rgba(255,255,255,0.15); color: white; }
.stat-card.card-gold .stat-icon { background: rgba(255,255,255,0.15); color: white; }
.stat-card.card-purple .stat-icon { background: rgba(255,255,255,0.15); color: white; }

/* Enhanced Tables */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.data-table thead tr {
    background: #1a252f;
    color: white;
}

.data-table th {
    padding: 18px 20px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

.data-table td {
    padding: 15px 20px;
    border-bottom: 1px solid #f1f1f1;
}

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

/* Glassmorphism Utilities */
.glass {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.glass-dark {
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Vibrant Badges */
.badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success { background: #dcfce7; color: #166534; font-weight: 800; } /* Darkened for contrast */
.badge-danger  { background: #fee2e2; color: #991b1b; font-weight: 800; }
.badge-warning { background: #fef3c7; color: #92400e; font-weight: 800; }
.badge-info    { background: #e0f2fe; color: #075985; font-weight: 800; }

/* Dashboard Pulse */
@keyframes pulse-ring {
    0% { transform: scale(0.33); }
    80%, 100% { opacity: 0; }
}

.live-indicator {
    position: relative;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #4caf50;
    display: inline-block;
    margin-right: 8px;
}

.live-indicator::after {
    content: '';
    position: absolute;
    top: -8px; left: -8px; width: 26px; height: 26px;
    border: 4px solid #4caf50;
    border-radius: 50%;
    animation: pulse-ring 1.25s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

/* Premium Card Hover */
.premium-hover {
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.premium-hover:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0,0,0,0.1) !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
::-webkit-scrollbar-thumb { background: #c3cfe2; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #a1b0c8; }

/* Theme-specific Table Headers - Professional Executive Gradients */
.theme-students   .data-table thead tr { background: linear-gradient(90deg, #1e1b4b 0%, #4338ca 100%); }
.theme-staff      .data-table thead tr { background: linear-gradient(90deg, #7c2d12 0%, #d97706 100%); }
.theme-fees       .data-table thead tr { background: linear-gradient(90deg, #1e3a8a 0%, #2563eb 100%); }
.theme-attendance .data-table thead tr { background: linear-gradient(90deg, #064e3b 0%, #059669 100%); }
.theme-exams      .data-table thead tr { background: linear-gradient(90deg, #7f1d1d 0%, #dc2626 100%); }
.theme-homework   .data-table thead tr { background: linear-gradient(90deg, #172554 0%, #1e40af 100%); }
.theme-library    .data-table thead tr { background: linear-gradient(90deg, #134e4a 0%, #0d9488 100%); }
.theme-accounts   .data-table thead tr { background: linear-gradient(90deg, #4c1d95 0%, #7c3ae9 100%); }
.theme-reports    .data-table thead tr { background: linear-gradient(90deg, #0f172a 0%, #334155 100%); }
.theme-settings   .data-table thead tr { background: linear-gradient(90deg, #1e293b 0%, #475569 100%); }

/* Institutional Toast System */
#toast-container {
    position: fixed;
    top: 50px;
    right: 30px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: rgba(30, 41, 59, 0.95);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 300px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    animation: toastIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transition: 0.3s;
}

.toast.success { border-left: 6px solid #10b981; }
.toast.error   { border-left: 6px solid #ef4444; }
.toast.warning { border-left: 6px solid #f59e0b; }
.toast.info    { border-left: 6px solid #3b82f6; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.fade-out {
    opacity: 0;
    transform: translateX(50px);
}

/* Attendance Matrix Chips */
.att-chip {
    cursor: pointer;
}

.chip-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 800;
    color: #64748b;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.att-chip input:checked + .chip-label.present { background: #dcfce7; color: #166534; border-color: #22c55e; box-shadow: 0 2px 8px rgba(34, 197, 94, 0.2); transform: scale(1.1); }
.att-chip input:checked + .chip-label.absent  { background: #fee2e2; color: #991b1b; border-color: #ef4444; box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2); transform: scale(1.1); }
.att-chip input:checked + .chip-label.late    { background: #fef3c7; color: #92400e; border-color: #f59e0b; box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2); transform: scale(1.1); }
.att-chip input:checked + .chip-label.leave   { background: #e0f2fe; color: #075985; border-color: #3b82f6; box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2); transform: scale(1.1); }

.chip-label:hover {
    border-color: #94a3b8;
    background: #e2e8f0;
}
