:root {
    --bg-header: #0f172a;
    --primary: #2563eb;
    --accent-orange: #ea580c;
    --bg-body: #f8fafc;
    --text-dark: #0f172a;
    --text-muted: #64748b;
    --border: #cbd5e1;
    --success: #10b981;
}

* { 
    box-sizing: border-box; 
    font-family: 'Segoe UI', system-ui, sans-serif; 
}

body { 
    margin: 0; 
    padding: 0; 
    background-color: var(--bg-body); 
    color: var(--text-dark); 
}

/* BANNIÈRE FIXE / STICKY */
header {
    position: sticky; 
    top: 0; 
    left: 0; 
    width: 100%; 
    z-index: 1000;
    background-color: var(--bg-header); 
    color: white; 
    padding: 12px 30px;
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.logo { 
    font-size: 22px; 
    font-weight: bold; 
    color: #38bdf8; 
    text-decoration: none; 
}

.nav-links { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
}

.nav-links a, .dropdown-btn {
    color: white; 
    text-decoration: none; 
    padding: 8px 16px; 
    border-radius: 4px;
    background: rgba(255,255,255,0.1); 
    font-size: 14px; 
    font-weight: 500; 
    border: none; 
    cursor: pointer;
    display: flex; 
    align-items: center; 
    gap: 6px;
}

.nav-links a.active, .nav-links a:hover, .dropdown-btn:hover { 
    background: var(--primary); 
}

.dropdown { 
    position: relative; 
    display: inline-block; 
}

.dropdown-content {
    display: none; 
    position: absolute; 
    right: 0; 
    top: 100%; 
    background-color: white;
    min-width: 240px; 
    box-shadow: 0px 8px 16px rgba(0,0,0,0.2); 
    border-radius: 6px; 
    overflow: hidden;
    z-index: 1001; 
    border: 1px solid var(--border); 
    margin-top: 5px;
}

.dropdown-content a { 
    color: var(--text-dark); 
    padding: 12px 16px; 
    text-decoration: none; 
    display: block; 
    font-size: 13px; 
    border-bottom: 1px solid #f1f5f9; 
}

.dropdown-content a:hover { 
    background-color: #f1f5f9; 
    color: var(--primary); 
}

.dropdown:hover .dropdown-content { 
    display: block; 
}

.main-container { 
    max-width: 1200px; 
    margin: 25px auto; 
    padding: 0 15px; 
}

.kpi-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); 
    gap: 20px; 
    margin-bottom: 25px; 
}

.kpi-card { 
    background: white; 
    border: 1px solid var(--border); 
    border-radius: 8px; 
    padding: 20px; 
    text-align: center; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); 
}

.kpi-title { 
    font-size: 13px; 
    color: var(--text-muted); 
    font-weight: 600; 
    text-transform: uppercase; 
}

.kpi-value { 
    font-size: 28px; 
    font-weight: 800; 
    color: var(--primary); 
    margin-top: 8px; 
}

.ui-card { 
    background: white; 
    border: 1px solid var(--border); 
    border-radius: 8px; 
    padding: 20px; 
    margin-bottom: 25px; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); 
}

.ui-card h2 { 
    font-size: 18px; 
    margin-top: 0; 
    border-bottom: 1px solid var(--border); 
    padding-bottom: 12px; 
}

.catalog-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); 
    gap: 25px; 
}

.course-card { 
    background: white; 
    border-radius: 8px; 
    border: 1px solid var(--border); 
    overflow: hidden; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); 
}

.video-thumb { 
    background: #020617; 
    height: 160px; 
    position: relative; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    color: white; 
}

.play-btn { 
    font-size: 14px; 
    background: var(--primary); 
    padding: 8px 16px; 
    border-radius: 20px; 
    color: white; 
    text-decoration: none; 
    font-weight: bold; 
}

.card-body { 
    padding: 18px; 
}

.card-title { 
    font-size: 16px; 
    font-weight: bold; 
    margin: 0 0 8px 0; 
}

.card-author { 
    font-size: 12px; 
    color: #64748b; 
    margin-bottom: 10px; 
}

.progress-bar-bg { 
    width: 100%; 
    background: #e2e8f0; 
    height: 8px; 
    border-radius: 4px; 
    overflow: hidden; 
    margin: 8px 0; 
}

.progress-bar-fill { 
    height: 100%; 
    background: var(--success); 
}

.btn-pdf { 
    display: inline-block; 
    background: #f1f5f9; 
    border: 1px solid var(--border); 
    color: var(--text-dark); 
    padding: 6px 12px; 
    border-radius: 4px; 
    text-decoration: none; 
    font-size: 12px; 
    font-weight: bold; 
    margin-top: 10px; 
}
/* --- COMPOSANTS DE TABLEAUX ET SITES ADMIN / ENSEIGNANTS --- */

/* Tables de données */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 14px;
}

.data-table th, .data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background-color: #f1f5f9;
    color: var(--text-dark);
    font-weight: 600;
}

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

/* Badges de Statut */
.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.badge-success { background-color: #d1fae5; color: #065f46; }
.badge-warning { background-color: #fef3c7; color: #92400e; }
.badge-danger  { background-color: #fee2e2; color: #991b1b; }
.badge-info    { background-color: #e0f2fe; color: #075985; }

/* Boutons d'action */
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: #1d4ed8; }

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

.btn-outline { background-color: transparent; border: 1px solid var(--border); color: var(--text-dark); }
.btn-outline:hover { background-color: #f1f5f9; }/* Test d ecriture */
/* ==========================================
   STYLES SPECIFIQUES : ADMIN & ENSEIGNANTS
   ========================================== */

/* Structure & Layout de page */
.main-content {
    padding: 30px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-dark, #1e293b);
    margin-bottom: 20px;
}

/* Grilles & Formulaires */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: #475569;
}

.form-control, input[type="text"], input[type="email"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
}

.form-control:focus, input:focus, select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Tableaux de données (Gestion, Validations, Reporting) */
.table-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow-x: auto;
    margin-top: 20px;
}

table, .data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

table th, .data-table th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 2px solid #e2e8f0;
}

table td, .data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    color: #334155;
}

table tr:hover, .data-table tr:hover {
    background-color: #f1f5f9;
}

/* Badges de Statut */
.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}
.badge-success, .badge-valide { background: #d1fae5; color: #065f46; }
.badge-warning, .badge-attente { background: #fef3c7; color: #92400e; }
.badge-danger, .badge-refuse  { background: #fee2e2; color: #991b1b; }
.badge-info                     { background: #e0f2fe; color: #075985; }

/* Boutons d'actions */
.btn {
    padding: 8px 14px;
    border-radius: 6px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}
.btn-primary { background: #2563eb; color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-success { background: #10b981; color: white; }
.btn-success:hover { background: #059669; }
.btn-danger  { background: #ef4444; color: white; }
.btn-danger:hover  { background: #dc2626; }
.btn-sm { padding: 4px 8px; font-size: 12px; }
/* --- DARK MODE RULES --- */
body.dark-mode { background-color: #0f172a !important; color: #f8fafc !important; }
body.dark-mode header, body.dark-mode .sub-nav, body.dark-mode .card, body.dark-mode .kpi-card { background-color: #1e293b !important; border-color: #334155 !important; color: #f8fafc !important; }
body.dark-mode .sub-nav a { color: #94a3b8 !important; }
body.dark-mode .sub-nav a:hover, body.dark-mode .sub-nav a.active { color: #60a5fa !important; background-color: #1e293b !important; }
body.dark-mode .data-table th { background-color: #334155 !important; color: #f8fafc !important; }
body.dark-mode .data-table td { border-bottom-color: #334155 !important; color: #cbd5e1 !important; }
body.dark-mode .form-control { background-color: #0f172a !important; border-color: #334155 !important; color: #f8fafc !important; }

/* --- DARK MODE --- */
body.dark-mode { background-color: #0f172a !important; color: #f8fafc !important; }
body.dark-mode header, body.dark-mode .sub-nav, body.dark-mode .card, body.dark-mode .kpi-card { background-color: #1e293b !important; border-color: #334155 !important; color: #f8fafc !important; }
body.dark-mode .sub-nav a { color: #94a3b8 !important; }
body.dark-mode .sub-nav a:hover, body.dark-mode .sub-nav a.active { color: #60a5fa !important; background-color: #1e293b !important; }
body.dark-mode .data-table th { background-color: #334155 !important; color: #f8fafc !important; }
body.dark-mode .data-table td { border-bottom-color: #334155 !important; color: #cbd5e1 !important; }
body.dark-mode .form-control { background-color: #0f172a !important; border-color: #334155 !important; color: #f8fafc !important; }

/* --- RÈGLES GLOBALES DARK MODE --- */
body.dark-mode {
    background-color: #0f172a !important;
    color: #f8fafc !important;
}

body.dark-mode header, 
body.dark-mode .sub-nav, 
body.dark-mode .card, 
body.dark-mode .kpi-card, 
body.dark-mode .course-card,
body.dark-mode .login-card,
body.dark-mode .register-card,
body.dark-mode .modal-card {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

body.dark-mode h1, 
body.dark-mode h2, 
body.dark-mode h3, 
body.dark-mode strong,
body.dark-mode label {
    color: #f8fafc !important;
}

body.dark-mode .sub-nav a {
    color: #94a3b8 !important;
}

body.dark-mode .sub-nav a:hover, 
body.dark-mode .sub-nav a.active {
    color: #60a5fa !important;
    background-color: #334155 !important;
}

body.dark-mode .data-table th {
    background-color: #334155 !important;
    color: #f8fafc !important;
}

body.dark-mode .data-table td {
    border-bottom-color: #334155 !important;
    color: #cbd5e1 !important;
}

body.dark-mode .form-control,
body.dark-mode input,
body.dark-mode select {
    background-color: #0f172a !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

/* === CORRECTIF DEFINITIF DARK MODE === */
html.dark-mode, 
html.dark-mode body {
    background-color: #0f172a !important;
    color: #f8fafc !important;
}

html.dark-mode header, 
html.dark-mode .sub-nav, 
html.dark-mode .card, 
html.dark-mode .kpi-card, 
html.dark-mode .course-card,
html.dark-mode .login-card,
html.dark-mode .register-card,
html.dark-mode .modal-card,
html.dark-mode .table-container {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

html.dark-mode h1, 
html.dark-mode h2, 
html.dark-mode h3, 
html.dark-mode h4,
html.dark-mode strong,
html.dark-mode span,
html.dark-mode label,
html.dark-mode td {
    color: #f8fafc !important;
}

html.dark-mode .sub-nav a {
    color: #94a3b8 !important;
}

html.dark-mode .sub-nav a:hover, 
html.dark-mode .sub-nav a.active {
    color: #60a5fa !important;
    background-color: #334155 !important;
}

html.dark-mode table,
html.dark-mode .data-table {
    background-color: #1e293b !important;
    color: #f8fafc !important;
}

html.dark-mode .data-table th {
    background-color: #334155 !important;
    color: #f8fafc !important;
    border-bottom-color: #475569 !important;
}

html.dark-mode .data-table td {
    border-bottom-color: #334155 !important;
}

html.dark-mode .form-control,
html.dark-mode input,
html.dark-mode select,
html.dark-mode textarea {
    background-color: #0f172a !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}
/* --- MENU VERTICAL ESPACE ADMIN ---
   Scopé à .admin-shell (wrapper autour de .sub-nav + .main-content sur les pages admin
   uniquement) pour ne pas affecter les sous-menus horizontaux des espaces élève/enseignant/
   parents. Spécificité 0-2-0 (.admin-shell .sub-nav) > 0-1-0 (le <style> local de chaque page
   qui redéfinit .sub-nav{display:flex...}), donc pas besoin de !important ici. */
.admin-shell {
    display: flex;
    align-items: flex-start;
}
.admin-shell .sub-nav {
    flex-direction: column;
    align-items: stretch;
    width: 230px;
    flex-shrink: 0;
    overflow-x: visible;
    border-bottom: none;
    border-right: 1px solid #e2e8f0;
    padding: 16px 12px;
    gap: 2px;
}
.admin-shell .sub-nav a {
    padding: 10px 14px;
}
.admin-shell .main-content {
    flex: 1;
    min-width: 0;
    margin: 0;
    max-width: none;
}
body.dark-mode .admin-shell .sub-nav {
    border-right-color: #334155;
}

/* --- COMPOSANTS MOBILES & BARS --- */
.mobile-nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: white; /* le bouton vit dans le header sombre (--bg-header) */
    padding: 4px 8px;
}

@media (max-width: 768px) {
    .mobile-nav-toggle {
        display: block;
    }

    .sub-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        padding: 8px 16px;
    }

    .form-grid {
        grid-template-columns: 1fr !important;
    }

    /* Menu principal (injecté par ui-components.js) : replié en tiroir sous le header,
       ouvert/fermé par .mobile-nav-toggle qui bascule la classe .nav-open. */
    .header-nav-links {
        display: none !important;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 4px !important;
        margin-left: 0 !important;
        padding: 12px 20px 16px;
        background: var(--bg-header, #0f172a);
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    }

    .header-nav-links.nav-open {
        display: flex !important;
    }

    .header-nav-links a {
        padding: 10px 4px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .header-nav-links #themeToggleBtn {
        align-self: flex-start;
        margin-top: 4px;
    }

    /* Sous-menu de section (admin/élève/enseignant) : la barre d'onglets qui défile devient un
       <select> natif, plus lisible dès qu'il y a plus de 3-4 entrées (voir ui-components.js).
       !important nécessaire : chaque page redéfinit .sub-nav{display:flex} dans son propre
       <style> local, chargé après main.css avec la même spécificité. */
    .sub-nav {
        display: none !important;
    }

    .admin-shell {
        display: block;
    }
}

.sub-nav-mobile-select {
    display: none;
}

@media (max-width: 768px) {
    .sub-nav-mobile-select {
        display: block;
        width: 100%;
        padding: 14px 16px;
        border: none;
        border-radius: 0;
        border-bottom: 1px solid var(--border);
        background: white;
        color: var(--text-dark);
        font-size: 14px;
        font-weight: 600;
    }
}

/* --- SYSTEME DE TOAST NOTIFICATIONS --- */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 280px;
    padding: 12px 18px;
    border-radius: 8px;
    background: #1e293b;
    color: white;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideIn 0.3s ease-out;
}

.toast-success { border-left: 4px solid #10b981; }
.toast-error { border-left: 4px solid #ef4444; }
.toast-info { border-left: 4px solid #2563eb; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* --- SKELETON LOADERS --- */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 6px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card {
    height: 320px;
    width: 100%;
    border-radius: 10px;
}

/* COMPOSANTS UI / MOBILE / TOASTS */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { min-width: 280px; padding: 12px 18px; border-radius: 8px; background: #1e293b; color: white; font-size: 14px; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.15); display: flex; align-items: center; justify-content: space-between; animation: slideIn 0.3s ease-out; }
.toast-success { border-left: 4px solid #10b981; }
.toast-error { border-left: 4px solid #ef4444; }
.toast-info { border-left: 4px solid #2563eb; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.skeleton { background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%); background-size: 200% 100%; animation: skeleton-loading 1.5s infinite; border-radius: 6px; }
@keyframes skeleton-loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-card { height: 320px; width: 100%; border-radius: 10px; }
