/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --secondary: #0ea5e9;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1e293b;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --white: #ffffff;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-100);
    color: var(--dark);
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 40px;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header .logo {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.login-header .logo i {
    font-size: 32px;
    color: var(--white);
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 4px;
}

.login-header p {
    color: var(--gray-500);
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper i {
    position: absolute;
    left: 14px;
    color: var(--gray-400);
    font-size: 16px;
}

.input-wrapper input {
    width: 100%;
    padding: 12px 14px 12px 44px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 15px;
    transition: all 0.2s;
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.toggle-password {
    position: absolute;
    right: 14px;
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px;
}

.toggle-password:hover {
    color: var(--gray-600);
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--gray-600);
    cursor: pointer;
}

.remember-me input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.forgot-password {
    font-size: 14px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.forgot-password:hover {
    text-decoration: underline;
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.login-footer {
    margin-top: 24px;
    text-align: center;
}

.login-footer p {
    font-size: 12px;
    color: var(--gray-400);
}

/* Dashboard Layout */
.dashboard {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--dark);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100dvh;
    min-height: 100svh;
    /* fallback */
    height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 100;
    transition: transform 0.3s;
    will-change: transform;
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--gray-700);
}

.sidebar-header i {
    font-size: 28px;
    color: var(--primary-light);
}

.sidebar-header span {
    font-size: 22px;
    font-weight: 700;
}
 
.sidebar-collapse {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--gray-300);
    font-size: 18px;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
}

.sidebar-collapse:hover {
    background: var(--gray-700);
    color: var(--white);
}

.sidebar-close {
    display: none;
    margin-left: 4px;
    background: transparent;
    border: none;
    color: var(--gray-300);
    font-size: 18px;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
}

.sidebar-close:hover {
    background: var(--gray-700);
    color: var(--white);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: var(--gray-300);
    text-decoration: none;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--gray-700);
    color: var(--white);
}

.nav-item.active {
    background: var(--primary);
    color: var(--white);
}

.nav-item.disabled {
    opacity: 0.55;
    cursor: not-allowed;
    text-decoration: line-through;
}

.nav-item.disabled:hover {
    background: transparent;
    color: var(--gray-300);
}

.nav-item i {
    font-size: 18px;
    width: 24px;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--gray-700);
}

.btn-logout {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: transparent;
    border: 1px solid var(--gray-600);
    color: var(--gray-300);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--white);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    width: 72px;
}

.sidebar.collapsed .sidebar-header span {
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
}

.sidebar.collapsed .nav-item span {
    display: none;
}

.sidebar.collapsed .sidebar-footer span {
    display: none;
}

.sidebar.collapsed ~ .main-content {
    margin-left: 72px;
}

/* Header */
.header {
    background: var(--white);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--gray-600);
    cursor: pointer;
    padding: 8px;
}

.header-left h2 {
    font-size: 20px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.notifications {
    position: relative;
    cursor: pointer;
}

.notifications i {
    font-size: 20px;
    color: var(--gray-500);
}

.notifications .badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--danger);
    color: var(--white);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-profile img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.user-profile span {
    font-weight: 500;
    color: var(--gray-700);
}

/* Content Area */
.content-area {
    padding: 24px;
    flex: 1;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon i {
    font-size: 24px;
    color: var(--white);
}

.stat-icon.blue { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.stat-icon.green { background: linear-gradient(135deg, #22c55e, #16a34a); }
.stat-icon.orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-icon.purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

.stat-info h3 {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
}

.stat-info p {
    color: var(--gray-500);
    font-size: 14px;
}

/* Cards */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header h3 i {
    color: var(--primary);
}

.card-header a {
    font-size: 14px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.card-body {
    padding: 20px 24px;
}

/* Announcements */
.announcement-item {
    padding: 16px 0;
    border-bottom: 1px solid var(--gray-100);
}

.announcement-item:last-child {
    border-bottom: none;
}

.announcement-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.announcement-badge.urgent {
    background: #fef2f2;
    color: var(--danger);
}

.announcement-badge.info {
    background: #eff6ff;
    color: var(--secondary);
}

.announcement-badge.event {
    background: #f0fdf4;
    color: var(--success);
}

.announcement-item h4 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
}

.announcement-item p {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.announcement-item .date {
    font-size: 12px;
    color: var(--gray-400);
}

.announcement-item .date i {
    margin-right: 4px;
}

/* Gallery */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.gallery-item {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
}

.gallery-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    transition: transform 0.3s;
}

.gallery-item:hover img {
    transform: scale(1.1);
}

.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    padding: 12px;
}

.gallery-overlay span {
    color: var(--white);
    font-size: 13px;
    font-weight: 500;
}

/* Documents Table */
.documents-table {
    width: 100%;
    border-collapse: collapse;
}

.documents-table th,
.documents-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

.documents-table th {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
}

.documents-table td {
    font-size: 14px;
}

.documents-table i.pdf { color: #ef4444; }
.documents-table i.word { color: #3b82f6; }
.documents-table i.excel { color: #22c55e; }

.category-badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--gray-100);
    border-radius: 20px;
    font-size: 12px;
    color: var(--gray-600);
}

.btn-download {
    background: var(--gray-100);
    border: none;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--gray-600);
    transition: all 0.2s;
}

.btn-download:hover {
    background: var(--primary);
    color: var(--white);
}

/* Absence Tab */
.absence-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.absence-info h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.absence-info p {
    color: var(--gray-500);
    font-size: 14px;
}

.absence-actions {
    display: flex;
    gap: 12px;
}

.select-student {
    padding: 10px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--white);
    cursor: pointer;
    min-width: 240px;
}

.select-student:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-export {
    padding: 10px 20px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-export:hover {
    background: var(--primary-dark);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    font-weight: 500;
    color: var(--gray-700);
}

.user-badge i {
    font-size: 20px;
    color: var(--primary);
}

.absence-legend {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--gray-600);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.legend-color.present { background: #22c55e; }
.legend-color.absent { background: #ef4444; }
.legend-color.justified { background: #f59e0b; }
.legend-color.na { background: #e2e8f0; }

.absence-table-container {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
    margin-bottom: 24px;
}

.absence-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1200px;
}

.absence-table th,
.absence-table td {
    padding: 12px 8px;
    text-align: center;
    border: 1px solid var(--gray-200);
    font-size: 13px;
}

.absence-table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
    position: sticky;
    top: 0;
}

.absence-table th.sticky-col,
.absence-table td.sticky-col {
    position: sticky;
    left: 0;
    background: var(--white);
    z-index: 10;
    min-width: 150px;
    text-align: left;
    font-weight: 600;
}

.absence-table th.sticky-col {
    background: var(--gray-100);
    z-index: 20;
}

.absence-table td.sticky-col {
    background: var(--gray-50);
}

.absence-table th.session-header {
    background: var(--primary);
    color: var(--white);
    font-weight: 600;
    border-bottom: none;
}

.absence-table th.sub-header {
    background: var(--gray-200);
    font-size: 12px;
    padding: 8px 6px;
}

.absence-table td.single-hour {
    font-weight: 600;
}

.cell-na {
    background: var(--gray-100);
    color: var(--gray-400);
}

.loading-attendance,
.error-attendance {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    font-size: 16px;
    color: var(--gray-500);
}

.loading-attendance i {
    font-size: 24px;
    color: var(--primary);
}

.error-attendance {
    color: var(--danger);
}

.error-attendance i {
    font-size: 24px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius);
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-lg {
    max-width: 700px;
}

.modal-xl {
    max-width: 1000px;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header h3 i {
    color: var(--primary);
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gray-100);
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--danger);
    color: var(--white);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* Gallery Modal */
.gallery-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 20px;
    border: 2px solid var(--gray-200);
    background: var(--white);
    border-radius: 25px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

.full-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.full-gallery-grid .gallery-item {
    height: 180px;
}

.full-gallery-grid .gallery-item img {
    height: 100%;
}

/* Documents Modal */
.documents-search {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.documents-search input {
    flex: 1;
    min-width: 200px;
    padding: 10px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.documents-search input:focus {
    outline: none;
    border-color: var(--primary);
}

.documents-search select {
    padding: 10px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--white);
    cursor: pointer;
}

.documents-search select:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-body .documents-table {
    font-size: 14px;
}

.modal-body .announcement-item {
    border-bottom: 1px solid var(--gray-100);
}

.modal-body .announcement-item:last-child {
    border-bottom: none;
}

/* Lock body scroll when content fits viewport (absence tab) */
body.no-scroll {
    overflow-y: hidden !important;
}

/* Image preview in modal */
.image-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}
.image-preview img {
    max-width: 100%;
    height: auto;
    max-height: 70vh;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.modal-actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
}

@media (max-width: 768px) {
    .modal-content {
        margin: 10px;
        max-height: 95vh;
    }
    
    .full-gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .documents-search {
        flex-direction: column;
    }
    
    .documents-search input,
    .documents-search select {
        width: 100%;
    }
}

.cell-present {
    background: #dcfce7;
    color: #166534;
}

.cell-absent {
    background: #fee2e2;
    color: #991b1b;
}

.cell-justified {
    background: #fef3c7;
    color: #92400e;
}

.cell-late {
    background: #dbeafe;
    color: #1e40af;
}

.absence-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.summary-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

.summary-card h4 {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.summary-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
}

.summary-value.green { color: var(--success); }
.summary-value.red { color: var(--danger); }
.summary-value.orange { color: var(--warning); }
.summary-value.blue { color: var(--primary); }

/* Schedule Tab */
.schedule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.schedule-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.schedule-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.schedule-nav span {
    font-weight: 500;
    color: var(--gray-600);
}

.btn-nav {
    width: 36px;
    height: 36px;
    border: 1px solid var(--gray-200);
    background: var(--white);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-nav:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

.schedule-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}

.schedule-day {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.day-header {
    background: var(--gray-100);
    padding: 14px;
    font-weight: 600;
    text-align: center;
    border-bottom: 2px solid var(--primary);
}

.schedule-item {
    padding: 14px;
    border-bottom: 1px solid var(--gray-100);
    border-left: 4px solid transparent;
}

.schedule-item:last-child {
    border-bottom: none;
}

.schedule-item .time {
    display: block;
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.schedule-item .subject {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.schedule-item .room {
    display: block;
    font-size: 12px;
    color: var(--gray-400);
}

.schedule-item.analyse { border-left-color: #ef4444; }
.schedule-item.algebre { border-left-color: #3b82f6; }
.schedule-item.english { border-left-color: #22c55e; }
.schedule-item.french { border-left-color: #f59e0b; }
.schedule-item.thermo { border-left-color: #8b5cf6; }
.schedule-item.fablab { border-left-color: #ec4899; }
.schedule-item.info { border-left-color: #14b8a6; }
.schedule-item.cd { border-left-color: #f97316; }
.schedule-item.electro { border-left-color: #06b6d4; }
.schedule-item.es { border-left-color: #d40651; }

/* Account Tab */
.account-grid {
    grid-template-columns: 360px 1fr;
    align-items: start;
}

@media (max-width: 1024px) {
    .account-grid {
        grid-template-columns: 1fr;
    }
}

.account-profile-card {
    overflow: hidden;
}

.account-hero {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.14) 0%, rgba(14, 165, 233, 0.12) 100%);
    border-bottom: 1px solid var(--gray-200);
}

.account-avatar {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: var(--white);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    letter-spacing: 0.5px;
    box-shadow: 0 12px 24px rgba(79, 70, 229, 0.20);
    animation: accountFloat 4s ease-in-out infinite;
    flex: 0 0 auto;
}

@keyframes accountFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

.account-hero-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--dark);
    margin-bottom: 6px;
}

.account-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.account-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 800;
    background: var(--white);
    border: 1px solid var(--gray-200);
    color: var(--gray-700);
}

.account-badge.primary {
    background: rgba(79, 70, 229, 0.10);
    border-color: rgba(79, 70, 229, 0.25);
    color: #3730a3;
}

.account-badge.online {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.28);
    color: #166534;
}

.account-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 14px 16px 16px 16px;
}

.account-stat {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 12px 12px;
    box-shadow: var(--shadow);
}

.account-stat .k {
    font-size: 12px;
    font-weight: 800;
    color: var(--gray-500);
    margin-bottom: 6px;
}

.account-stat .v {
    font-size: 14px;
    font-weight: 800;
    color: var(--dark);
}

@media (max-width: 768px) {
    .account-stats {
        grid-template-columns: 1fr;
    }
}

.account-details-card .card-body {
    display: grid;
    gap: 14px;
}

.account-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 14px;
}

@media (max-width: 768px) {
    .account-fields {
        grid-template-columns: 1fr;
    }
}

.account-field label {
    display: block;
    font-size: 13px;
    font-weight: 800;
    color: var(--gray-600);
    margin-bottom: 6px;
}

.account-field-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

#accountTab input[type="text"],
#accountTab input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--dark);
    font-size: 14px;
    font-weight: 600;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

#accountTab input[type="text"]:disabled {
    background: var(--gray-50);
    color: var(--gray-700);
    opacity: 1;
}

.account-field-span {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
}

.account-action-btn {
    width: 44px;
    height: 44px;
    border-radius: 9999px;
    border: 2px solid var(--gray-200);
    background: var(--white);
    color: var(--primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    flex: 0 0 auto;
}

.account-action-btn:hover {
    transform: translateY(-1px);
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

.account-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.account-soft-btn {
    height: 46px;
    padding: 12px 16px;
    border-radius: 9999px;
    border: 2px solid var(--gray-200);
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.08) 0%, rgba(14, 165, 233, 0.10) 100%);
    color: var(--primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 900;
    box-shadow: var(--shadow);
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.account-soft-btn:hover {
    transform: translateY(-1px);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-color: transparent;
    color: var(--white);
}

.account-toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    padding: 10px 14px;
    border-radius: 9999px;
    background: rgba(17, 24, 39, 0.92);
    color: var(--white);
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 18px 40px rgba(0,0,0,0.22);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
    z-index: 9999;
}

.account-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.account-extras-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
}

@media (max-width: 1024px) {
    .account-extras-grid {
        grid-template-columns: 1fr;
    }
}

.account-hint {
    margin-top: 12px;
    font-size: 12px;
    font-weight: 800;
    color: var(--gray-500);
}

.account-payments {
    display: grid;
    grid-template-columns: 170px 1fr;
    gap: 14px;
    align-items: center;
}

@media (max-width: 768px) {
    .account-payments {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }
}

.account-donut-wrap {
    width: 150px;
    height: 150px;
    position: relative;
    display: grid;
    place-items: center;
}

.account-donut {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: conic-gradient(#22c55e 0deg 0deg, rgba(148, 163, 184, 0.35) 0deg 360deg);
    box-shadow: 0 18px 40px rgba(0,0,0,0.10);
    position: relative;
}

.account-donut::after {
    content: '';
    position: absolute;
    inset: 16px;
    border-radius: 50%;
    background: var(--white);
    border: 1px solid var(--gray-200);
}

.account-donut-center {
    position: absolute;
    display: grid;
    place-items: center;
    gap: 2px;
    z-index: 2;
    pointer-events: none;
}

.account-donut-center .t {
    font-size: 22px;
    font-weight: 900;
    color: var(--dark);
}

.account-donut-center .s {
    font-size: 12px;
    font-weight: 900;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.account-money-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--gray-50);
    box-shadow: var(--shadow);
}

.account-money-row .k {
    font-size: 12px;
    font-weight: 900;
    color: var(--gray-600);
}

.account-money-row .v {
    font-size: 14px;
    font-weight: 900;
    color: var(--dark);
}

#accountTab .v.green { color: #166534; }
#accountTab .v.red { color: #991b1b; }

.account-messages {
    display: grid;
    gap: 12px;
}

.account-message-item {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 12px 12px;
    background: var(--white);
    box-shadow: var(--shadow);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.account-message-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.account-message-item .top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.account-message-item .tag {
    font-size: 11px;
    font-weight: 900;
    padding: 5px 9px;
    border-radius: 9999px;
    border: 1px solid var(--gray-200);
    background: var(--gray-50);
    color: var(--gray-700);
}

.account-message-item .date {
    font-size: 12px;
    font-weight: 800;
    color: var(--gray-500);
}

.account-message-item .title {
    font-size: 14px;
    font-weight: 900;
    color: var(--dark);
    margin-bottom: 6px;
}

.account-message-item .body {
    font-size: 13px;
    font-weight: 700;
    color: var(--gray-700);
    line-height: 1.35;
}

.account-message-item.urgent {
    border-color: rgba(239, 68, 68, 0.30);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.06) 0%, rgba(255,255,255,1) 65%);
}

.account-message-item.urgent .tag {
    background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.25);
    color: #991b1b;
}

.account-message-item.info {
    border-color: rgba(14, 165, 233, 0.30);
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.06) 0%, rgba(255,255,255,1) 65%);
}

.account-message-item.info .tag {
    background: rgba(14, 165, 233, 0.10);
    border-color: rgba(14, 165, 233, 0.25);
    color: #075985;
}

.account-message-item.event {
    border-color: rgba(79, 70, 229, 0.28);
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.06) 0%, rgba(255,255,255,1) 65%);
}

.account-message-item.event .tag {
    background: rgba(79, 70, 229, 0.10);
    border-color: rgba(79, 70, 229, 0.25);
    color: #3730a3;
}

.account-housing {
    display: grid;
    gap: 12px;
}

.account-housing-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--gray-50);
    box-shadow: var(--shadow);
}

.account-housing-title {
    font-size: 13px;
    font-weight: 900;
    color: var(--gray-700);
}

.account-badge.approved {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.28);
    color: #166534;
}

.account-badge.pending {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.28);
    color: #92400e;
}

.account-housing-list {
    display: grid;
    gap: 10px;
}

.account-housing-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
    box-shadow: var(--shadow);
}

.account-housing-item .k {
    font-size: 12px;
    font-weight: 900;
    color: var(--gray-600);
}

.account-housing-item .v {
    font-size: 13px;
    font-weight: 900;
    color: var(--dark);
    text-align: right;
}

.account-warning {
    border: 1px solid rgba(245, 158, 11, 0.30);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.10) 0%, rgba(255,255,255,1) 70%);
    border-radius: var(--radius);
    padding: 12px 12px;
    box-shadow: var(--shadow);
}

.account-warning .h {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 900;
    color: #92400e;
    margin-bottom: 6px;
}

.account-warning .b {
    font-size: 13px;
    font-weight: 800;
    color: var(--gray-800);
    line-height: 1.35;
}

.account-housing-blurred {
    position: relative;
    overflow: hidden;
    min-height: 180px;
}

.account-housing-blurred > *:not(.account-housing-overlay) {
    filter: blur(5px);
    pointer-events: none;
    user-select: none;
}

.account-housing-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.4);
    color: var(--gray-600);
}

.account-housing-overlay i {
    font-size: 32px;
    color: var(--primary);
    opacity: 0.8;
}

.account-housing-overlay span {
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 0.5px;
    color: var(--dark);
    text-transform: uppercase;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }
    
    .sidebar.collapsed {
        width: 260px;
    }
    
    .sidebar.collapsed ~ .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: block;
    }
    
    .sidebar-close {
        display: inline-flex;
    }

    .schedule-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .content-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .schedule-grid {
        grid-template-columns: 1fr;
    }

    .user-profile span {
        display: none;
    }

    .absence-actions {
        flex-direction: column;
        width: 100%;
    }

    .select-student {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 24px;
    }
}
@media (max-width: 768px) {

    .sidebar {
        position: fixed !important;
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100dvh !important;
        min-height: 100svh !important;
        /* fallback */
        height: 100vh !important;

    body {
        min-height: 100vh;
    }

}

/* Force desktop layout regardless of viewport: used for Absence tab */
body.force-desktop .sidebar {
    transform: none !important;
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
}
body.force-desktop .main-content {
    margin-left: 260px !important;
}
body.force-desktop .sidebar-backdrop {
    display: none !important;
}
body.force-desktop .menu-toggle {
    display: none !important;
}
body.force-desktop {
    overflow: auto !important;
}
}

/* Topbar layout */
body.topbar .sidebar {
    width: clamp(320px, 92vw, 1100px);
    height: 64px !important;
    min-height: 64px !important;
    position: fixed !important;
    top: 0;
    left: 50%;
    right: auto;
    bottom: auto;
    flex-direction: row;
    align-items: center;
    overflow-y: hidden;
    overflow-x: auto;
    transform: translateX(-50%) !important;
    border-radius: 12px;
    box-shadow: var(--shadow);
}
body.topbar .sidebar-header {
    display: none;
}
body.topbar .sidebar-nav {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    white-space: nowrap;
    width: 100%;
    justify-content: center;
}
body.topbar .nav-item {
    display: inline-flex;
    margin-bottom: 0;
    padding: 10px 12px;
    border-radius: 8px;
}
body.topbar .nav-item.nav-logout i {
    color: var(--danger);
}
body.topbar .nav-item.nav-logout:hover {
    background: rgba(239, 68, 68, 0.15);
}
body.topbar .sidebar-footer {
    display: none;
}
body.topbar .btn-logout-topbar {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: 1px solid var(--gray-600);
    color: var(--gray-200);
    padding: 8px 12px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    white-space: nowrap;
}
body.topbar .btn-logout-topbar:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--white);
}
body.topbar .main-content {
    margin-left: 0 !important;
    padding-top: 72px;
}
body.topbar .menu-toggle,
body.topbar .sidebar-close {
    display: none !important;
}
@media (max-width: 768px) {
    body.topbar .main-content {
        padding-top: 64px;
    }
    body.topbar .sidebar {
        height: 56px !important;
        min-height: 56px !important;
    }
    body.topbar .btn-logout-topbar span {
        display: none;
    }
    body.topbar .nav-item span {
        display: none;
    }
    body.topbar .nav-item i {
        margin-right: 0;
    }
}
/* Courses */
.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 8px;
}
.course-box {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    background: var(--white);
    border-left: 4px solid transparent;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    box-shadow: var(--shadow);
}
.course-title {
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
}
.course-videos {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-wrap: wrap;
}
.video-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--secondary);
    text-decoration: none;
    font-weight: 500;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    padding: 8px 12px;
    border-radius: 9999px;
}
.video-link:hover {
    color: var(--white);
    background: var(--primary);
    border-color: var(--primary);
}
.video-link i {
    color: #ff0000;
}
.video-link:hover i {
    color: var(--white);
}
.course-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(0,0,0,0.08);
}
.course-box.electro {
    border-left-color: #06b6d4;
}
.course-box.electro .course-title {
    background: rgba(6, 182, 212, 0.12);
    color: #0e7490;
}
.course-box.analyse {
    border-left-color: #ef4444;
}
.course-box.analyse .course-title {
    background: rgba(239, 68, 68, 0.12);
    color: #991b1b;
}
.course-box.info {
    border-left-color: #14b8a6;
}
.course-box.info .course-title {
    background: rgba(20, 184, 166, 0.12);
    color: #0f766e;
}
