:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --secondary: #10B981;
    --bg: #F3F4F6;
    --surface: #FFFFFF;
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --th-bg: #F9FAFB;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

body.dark-mode {
    --primary: #818CF8;
    --primary-hover: #6366F1;
    --secondary: #34D399;
    --bg: #111827;
    --surface: #1F2937;
    --text-main: #F9FAFB;
    --text-muted: #9CA3AF;
    --border: #374151;
    --glass-bg: rgba(31, 41, 55, 0.7);
    --glass-border: rgba(55, 65, 81, 0.5);
    --th-bg: #111827;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Prompt', 'Inter', sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    background-color: var(--bg);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Glassmorphism utilities */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--card-shadow);
}

/* Auth Page */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

body.dark-mode .auth-wrapper {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
}

.auth-card {
    background: var(--surface);
    backdrop-filter: blur(20px);
    padding: 3rem 2.5rem;
    border-radius: 1.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.auth-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.auth-logo {
    max-width: 120px;
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.auth-header h1 {
    font-size: 1.5rem;
    color: var(--text-main);
    font-weight: 600;
}

.form-group {
    margin-bottom: 1.25rem;
}

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

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: var(--bg);
    color: var(--text-main);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    font-size: 1rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.4);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.5);
    color: white;
}

.btn-modern-back {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(79, 70, 229, 0.1) 100%);
    color: #8B5CF6;
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 9999px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0.6rem 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(139, 92, 246, 0.05);
}

.btn-modern-back:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(79, 70, 229, 0.2) 100%);
    color: #6D28D9;
    border-color: rgba(139, 92, 246, 0.5);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 10px 15px -3px rgba(139, 92, 246, 0.2), 0 4px 6px -2px rgba(139, 92, 246, 0.1);
}

.btn-modern-back i {
    transition: transform 0.3s ease;
}

.btn-modern-back:hover i {
    transform: translateX(-4px);
}

.btn-block {
    width: 100%;
}

.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: #EF4444;
    border: 1px solid #EF4444;
}

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

.sidebar {
    width: 260px;
    background: #0F172A; /* Slate 900 for a distinct sidebar */
    border-right: 1px solid #1E293B; /* Slate 800 */
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Override variables for dark theme inside sidebar */
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --primary: #818CF8;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        transform: translateX(-100%);
    }
    .sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    }
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.sidebar-logo {
    max-width: 80px;
    margin-bottom: 0.5rem;
}

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

.nav-links {
    list-style: none;
    padding: 1rem 0;
}

.nav-links li a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    position: relative;
}

.nav-links li.active a {
    background: rgba(79, 70, 229, 0.12);
    color: var(--primary);
    font-weight: 600;
    border-left: 4px solid var(--primary);
    padding-left: calc(1.5rem - 4px);
}

.nav-links li.active a i {
    color: var(--primary);
}

.nav-links li a i {
    margin-right: 0.75rem;
    width: 20px;
    text-align: center;
    color: var(--text-muted);
}

.nav-links li a:hover {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary);
    padding-left: 1.75rem;
}

.nav-links li a:hover i {
    color: var(--primary);
}

.text-danger {
    color: #EF4444 !important;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 64px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 5;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    transition: color 0.3s ease;
    padding: 0.5rem;
    border-radius: 50%;
}

.theme-toggle:hover {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.1);
}

.role-badge {
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.role-badge.admin { background: rgba(245, 158, 11, 0.2); color: #D97706; }
.role-badge.teacher { background: rgba(79, 70, 229, 0.2); color: #4F46E5; }
.role-badge.director { background: rgba(16, 185, 129, 0.2); color: #10B981; }

.content-body {
    padding: 2.5rem;
    flex: 1;
}

/* Cards & Tables */
.card {
    background: var(--surface);
    border-radius: 1rem;
    box-shadow: var(--card-shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.table-responsive {
    overflow-x: auto;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

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

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--th-bg);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    font-size: 0.9rem;
    background: var(--surface);
}

tr:hover td {
    background: rgba(79, 70, 229, 0.02);
}

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

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    box-shadow: var(--card-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

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

.stat-icon.primary { background: rgba(79, 70, 229, 0.12); color: var(--primary); }
.stat-icon.success { background: rgba(16, 185, 129, 0.12); color: var(--secondary); }
.stat-icon.warning { background: rgba(245, 158, 11, 0.12); color: #F59E0B; }
.stat-icon.purple  { background: rgba(139, 92, 246, 0.12); color: #8B5CF6; }
.stat-icon.danger  { background: rgba(239, 68, 68, 0.12);  color: #EF4444; }

.stat-info h3 {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.stat-info .stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}

.badge-primary { background: rgba(79, 70, 229, 0.15); color: var(--primary); }
.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--secondary); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #D97706; }
.badge-danger  { background: rgba(239, 68, 68, 0.15);  color: #EF4444; }
.badge-info    { background: rgba(59, 130, 246, 0.15); color: #2563EB; }
.badge-gray    { background: rgba(107, 114, 128, 0.15); color: var(--text-muted); }

/* Buttons */
.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    border-radius: 0.375rem;
}

.btn-danger {
    background: #EF4444;
    color: white;
}
.btn-danger:hover {
    background: #DC2626;
    color: white;
    transform: translateY(-1px);
}

.btn-warning {
    background: #F59E0B;
    color: white;
}
.btn-warning:hover {
    background: #D97706;
    color: white;
}

.btn-success {
    background: var(--secondary);
    color: white;
}
.btn-success:hover {
    background: #059669;
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}
.btn-outline:hover {
    background: var(--bg);
    border-color: var(--text-muted);
}

.btn-outline-primary {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}
.btn-outline-primary:hover {
    background: var(--primary);
    color: white;
}

.btn-outline-danger {
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #EF4444;
}
.btn-outline-danger:hover {
    background: #EF4444;
    color: white;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}
.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}
.empty-state h4 {
    font-size: 1.15rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}
.empty-state p {
    font-size: 0.9rem;
}

/* SweetAlert2 Modern Dark/Light Customization */
.swal2-popup {
    font-family: 'Prompt', 'Inter', sans-serif !important;
    border-radius: 1.25rem !important;
    background: var(--surface) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow) !important;
}

.swal2-title {
    color: var(--text-main) !important;
    font-weight: 600 !important;
}

.swal2-html-container {
    color: var(--text-muted) !important;
    font-size: 0.95rem !important;
}

.swal2-confirm.btn-primary {
    background: var(--primary) !important;
    border-radius: 0.5rem !important;
    padding: 0.65rem 1.5rem !important;
}

.swal2-cancel {
    border-radius: 0.5rem !important;
    padding: 0.65rem 1.5rem !important;
}
