/* =====================================================================
   IPFPS_apps — Thème UI Branding & Dark Mode
   Charte : bleu électrique + vert école. Clair par défaut, sombre via
   [data-theme="dark"] sur <html>. Toutes les classes historiques sont
   conservées et thémées via variables.
   ===================================================================== */

:root {
    /* ----- Charte école ----- */
    --primary-blue: #2563eb;
    --primary-blue-dark: #1d4ed8;
    --primary-green: #16a34a;
    --primary-green-dark: #15803d;

    /* ----- Fonds / cartes / textes (clair & sombre) ----- */
    --bg-light: #f5f8fe;
    --bg-dark: #0b1220;
    --card-light: #ffffff;
    --card-dark: #141f38;
    --text-light: #1e293b;
    --text-dark: #e6edf7;

    /* ----- Tokens actifs (mode clair par défaut) ----- */
    --bg: var(--bg-light);
    --surface: var(--card-light);
    --text: var(--text-light);
    --muted: #64748b;
    --border: #e4e9f2;
    --hover: #f5f8fc;
    --th-bg: #f1f5fb;

    --primary: var(--primary-blue);
    --primary-dark: var(--primary-blue-dark);
    --primary-light: #dbe6ff;

    --success: var(--primary-green);
    --success-bg: #e9faf0;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --warning: #f59e0b;
    --warning-bg: #fff7e8;

    /* ----- Habillage ----- */
    --sidebar-bg: #0c1730;
    --sidebar-text: #c5d2e6;
    --sidebar-muted: #8b9bb5;
    --glass: rgba(255, 255, 255, .72);
    --ring: rgba(37, 99, 235, .28);
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 10px 28px rgba(15, 23, 42, .07);
    --shadow-hover: 0 6px 14px rgba(15, 23, 42, .10), 0 18px 40px rgba(15, 23, 42, .12);
    --sidebar-w: 252px;

    /* ----- Phase 1 — tokens additifs (aucun renommage) ----- */
    --radius-lg: 20px;
    --ring-success: rgba(22, 163, 74, .26);
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --content-max: 1480px;
}

html[data-theme="dark"] {
    --bg: var(--bg-dark);
    --surface: var(--card-dark);
    --text: var(--text-dark);
    --muted: #93a3bd;
    --border: #243450;
    --hover: #1a2742;
    --th-bg: #172339;

    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: rgba(59, 130, 246, .20);

    --success: #34d399;
    --success-bg: rgba(16, 185, 129, .16);
    --danger: #f87171;
    --danger-bg: rgba(239, 68, 68, .16);
    --warning: #fbbf24;
    --warning-bg: rgba(245, 158, 11, .16);

    --sidebar-bg: #0a1424;
    --glass: rgba(16, 25, 45, .62);
    --ring: rgba(59, 130, 246, .35);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 30px rgba(0, 0, 0, .45);
    --shadow-hover: 0 8px 18px rgba(0, 0, 0, .5), 0 22px 46px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 15px;
    transition: background .25s ease, color .25s ease;
}

a { color: var(--primary); text-decoration: none; transition: color .15s; }
a:hover { text-decoration: underline; }
code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .9em; background: var(--hover);
    padding: 1px 6px; border-radius: 6px;
}

/* ---------- Auth layout (aligné sur le login clair ; theme-aware) ---------- */
.auth-wrap {
    position: relative;
    overflow: hidden;
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    /* Base sombre par défaut (dark mode) ; surchargée en clair ci-dessous */
    background:
        radial-gradient(1100px 600px at 12% -10%, rgba(37, 99, 235, .28), transparent 60%),
        radial-gradient(900px 500px at 110% 110%, rgba(22, 163, 74, .22), transparent 55%),
        linear-gradient(135deg, #0c1730 0%, #122544 100%);
}
/* Mode clair : fond blanc + lavis bleu/vert doux (comme .login-page) */
html:not([data-theme="dark"]) .auth-wrap {
    background:
        radial-gradient(900px 600px at 12% 8%, rgba(37, 99, 235, .10), transparent 55%),
        radial-gradient(820px 560px at 92% 96%, rgba(22, 163, 74, .10), transparent 55%),
        #ffffff;
}
/* Orbes flous flottants (clair uniquement, derrière la carte) */
html:not([data-theme="dark"]) .auth-wrap::before,
html:not([data-theme="dark"]) .auth-wrap::after {
    content: ""; position: absolute; border-radius: 50%;
    filter: blur(60px); pointer-events: none; z-index: 0;
}
html:not([data-theme="dark"]) .auth-wrap::before {
    width: 340px; height: 340px; left: -90px; top: -70px;
    background: radial-gradient(circle, rgba(37, 99, 235, .22), transparent 70%);
    animation: loginFloat 9s ease-in-out infinite;
}
html:not([data-theme="dark"]) .auth-wrap::after {
    width: 300px; height: 300px; right: -80px; bottom: -80px;
    background: radial-gradient(circle, rgba(22, 163, 74, .20), transparent 70%);
    animation: loginFloat 11s ease-in-out infinite reverse;
}
.auth-card {
    position: relative; z-index: 2;
    width: 100%; max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(2, 8, 23, .35);
    padding: 40px 36px;
    animation: loginUp .5s ease both;
}
/* Carte glassmorphism en clair (comme .login-card) */
html:not([data-theme="dark"]) .auth-card {
    background: rgba(255, 255, 255, .80);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    backdrop-filter: blur(14px) saturate(140%);
    border: 1px solid rgba(37, 99, 235, .14);
    box-shadow: 0 24px 60px rgba(15, 23, 42, .12), 0 2px 6px rgba(15, 23, 42, .05);
}
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-brand .logo {
    width: 72px; height: 72px; margin: 0 auto 14px;
    border-radius: 18px; overflow: hidden;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-green));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; font-weight: 800;
    box-shadow: 0 10px 24px rgba(37, 99, 235, .35);
}
.auth-brand .logo img { width: 100%; height: 100%; object-fit: contain; }
.auth-brand h1 { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.auth-brand p { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text); }
.form-control {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s, background .25s;
}
.form-control::placeholder { color: var(--muted); }
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring);
}
/* Affordance survol (bordure seule → conserve la flèche custom du select) */
.form-control:hover:not(:disabled):not(:focus) {
    border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
}
/* État désactivé lisible (background-color : ne réinitialise pas la flèche du select) */
.form-control:disabled {
    background-color: var(--hover);
    color: var(--muted);
    cursor: not-allowed;
}
select.form-control { background: var(--surface); appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
    background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px;
}
textarea.form-control { resize: vertical; min-height: 80px; }
input[type="file"].form-control { padding: 8px 10px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 18px; }
@media (max-width: 640px){ .form-row, .form-row-3 { grid-template-columns: 1fr; } }
.form-actions { margin-top: 12px; display: flex; gap: 10px; }
.req { color: var(--danger); }

/* Bouton du sélecteur de fichier (look bouton léger, sans toucher au markup) */
input[type="file"].form-control::-webkit-file-upload-button {
    margin-right: 12px; padding: 7px 12px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--hover); color: var(--text);
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: background .15s, border-color .15s;
    -webkit-appearance: none;
}
input[type="file"].form-control::file-selector-button {
    margin-right: 12px; padding: 7px 12px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--hover); color: var(--text);
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: background .15s, border-color .15s;
    appearance: none;
}
input[type="file"].form-control:hover::-webkit-file-upload-button {
    border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
}
input[type="file"].form-control:hover::file-selector-button {
    border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
}

/* Cases à cocher / radios aux couleurs de la charte (markup inchangé) */
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); cursor: pointer; }

/* Séparateurs de sections dans un formulaire (h3 à l'intérieur d'un <form>) */
.card form h3 {
    margin-top: var(--space-5); padding-top: var(--space-4);
    border-top: 1px solid var(--border);
    font-size: 15px; letter-spacing: -.01em;
}
.card form h3:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }

/* Zone d'actions des formulaires (scopée à <form> → exclut les cartes de cours) */
.card form .form-actions {
    margin-top: var(--space-5); padding-top: var(--space-4);
    border-top: 1px solid var(--border);
}
.thumb { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--primary-light); box-shadow: 0 0 0 2px var(--surface), 0 1px 4px rgba(15, 23, 42, .12); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 18px;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    font-size: 15px; font-weight: 600; cursor: pointer;
    transition: transform .08s ease, box-shadow .18s ease, background .18s ease, filter .18s ease;
}
.btn:hover { text-decoration: none; box-shadow: var(--shadow); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-block { width: 100%; }
.btn-primary { background: linear-gradient(135deg, var(--primary-blue), #3b82f6); color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 235, .28); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-success { background: linear-gradient(135deg, var(--primary-green), #22c55e); color: #fff; }
.btn-success:hover { filter: brightness(1.06); }
.btn-danger { background: linear-gradient(135deg, #dc2626, #ef4444); color: #fff; }
.btn-danger:hover { filter: brightness(1.06); }
.btn-warning { background: linear-gradient(135deg, #f59e0b, #fbbf24); color: #1f2937; }
.btn-warning:hover { filter: brightness(1.04); }
.btn-light { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-light:hover { background: var(--hover); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.inline-form { display: inline; margin: 0; }

/* ---------- Alerts ---------- */
.alert { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 14px; border: 1px solid transparent; }
.alert svg { width: 18px; height: 18px; flex: 0 0 auto; }
.alert > span { min-width: 0; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.alert-success { background: var(--success-bg); color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w);
    background:
        radial-gradient(600px 220px at 20% -5%, rgba(37, 99, 235, .25), transparent 60%),
        var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed; top: 0; left: 0; bottom: 0;
    display: flex; flex-direction: column;
    padding: 18px 0; overflow-y: auto;
    border-right: 1px solid rgba(255, 255, 255, .05);
}
.sidebar .brand {
    padding: 0 20px 18px;
    font-size: 18px; font-weight: 800; color: #fff;
    display: flex; align-items: center; gap: 11px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    margin-bottom: 14px;
}
.sidebar .brand .logo {
    width: 40px; height: 40px; border-radius: 11px; overflow: hidden; flex: 0 0 40px;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-green));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 800; box-shadow: 0 6px 16px rgba(37, 99, 235, .4);
}
.sidebar .brand .logo img { width: 100%; height: 100%; object-fit: contain; }
.sidebar nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 11px 20px; margin: 1px 10px; border-radius: 10px;
    color: var(--sidebar-text); font-size: 14px; font-weight: 500;
    transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.sidebar nav a.active {
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-green));
    color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 235, .35);
}
.sidebar .role-tag {
    margin: 14px 16px 0; padding: 8px 12px;
    background: rgba(255, 255, 255, .06); border-radius: 10px;
    font-size: 12px; color: var(--sidebar-muted);
}

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
    height: 64px;
    background: var(--glass);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    backdrop-filter: blur(12px) saturate(140%);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; position: sticky; top: 0; z-index: 10;
}
.topbar h2 { font-size: 17px; }
.topbar .user { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.topbar .user .who { text-align: right; line-height: 1.2; }
.topbar .user .who small { color: var(--muted); }
.avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-green));
    color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.theme-toggle {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 50%; width: 38px; height: 38px; cursor: pointer;
    font-size: 17px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
    transition: background .15s, transform .15s, box-shadow .15s; color: var(--text);
}
.theme-toggle:hover { background: var(--hover); transform: rotate(-12deg); box-shadow: var(--shadow); }

/* Titre de la navbar : prend l'espace dispo (permet l'ellipsis en mobile). */
.topbar-title { flex: 1; min-width: 0; }
/* Bloc nom/prénom + icône logout = mobile uniquement (cachés en desktop). */
.who-mobile { display: none; }
.logout-icon { display: none; }

.content { padding: 26px; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    transition: background .25s, border-color .25s;
}
.card h3 { font-size: 16px; margin-bottom: 6px; }
.card .muted { color: var(--muted); font-size: 14px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-5); margin-top: 6px; }
.stat {
    position: relative; overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform .18s cubic-bezier(0.23, 1, 0.32, 1), box-shadow .18s ease;
}
.stat::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: linear-gradient(180deg, var(--primary-blue), var(--primary-green));
}
.stat::after {
    content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px;
    background: radial-gradient(circle, rgba(37, 99, 235, .12), transparent 70%);
}
@media (hover: hover) and (pointer: fine) {
    .stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
}
.stat .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat .value {
    font-size: 26px; font-weight: 800; margin-top: 8px; line-height: 1.1;
    font-variant-numeric: tabular-nums;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-green));
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.stat .soon { display: inline-block; margin-top: 8px; font-size: 11px; color: var(--muted); background: var(--hover); padding: 3px 8px; border-radius: 20px; }

.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 22px; }
.page-head p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 14px; }

/* ---------- Tables ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
/* Groupe d'actions de la toolbar (boutons multiples) — espacement homogène */
.toolbar > div:not(.page-head) { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { background: var(--th-bg); color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--hover); }
table.data td.actions { white-space: nowrap; text-align: right; }
table.data td.actions > * + * { margin-left: var(--space-2); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-on { background: var(--success-bg); color: var(--success); }
.badge-off { background: var(--hover); color: var(--muted); }
.badge-info { background: var(--primary-light); color: var(--primary); }

/* ---------- Détails (fiche) ---------- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: var(--space-4); }
.detail-grid .item {
    background: var(--hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}
.detail-grid .item .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing:.03em; }
.detail-grid .item .v { font-size: 15px; margin-top: 4px; }

/* ---------- Emploi du temps (grille) ---------- */
.edt-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.edt-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.edt-day { background: linear-gradient(135deg, var(--primary-blue), var(--primary-green)); color: #fff; text-align: center; padding: 10px; font-weight: 700; font-size: 13px; }
.edt-empty { text-align: center; color: var(--muted); padding: 18px 0; }
.edt-slot { border-bottom: 1px solid var(--border); padding: 10px 11px; }
.edt-slot:last-child { border-bottom: none; }
.edt-time { font-size: 12px; font-weight: 700; color: var(--primary); }
.edt-module { font-weight: 600; margin-top: 3px; font-size: 14px; }
.edt-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
@media (max-width: 900px) { .edt-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Dashboard ---------- */
.dash-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--space-5); margin-top: 18px; }
.dash-item { padding: var(--space-3) 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.dash-item:last-child { border-bottom: none; }
.dash-item small { font-size: 12px; }

/* Section header hierarchy inside dashboard panels (scoped — global .card h3 untouched) */
.dash-cols .card h3 {
    padding-bottom: var(--space-3);
    margin-bottom: var(--space-2);
    border-bottom: 1px solid var(--border);
    letter-spacing: -.01em;
}

/* En-tête de panneau de formulaire dans une carte (h3 suivi d'un <form>) —
   scopé via :has(+ form) : affectations + passages, jamais le .card h3 global. */
.card > h3:has(+ form) {
    padding-bottom: var(--space-3);
    margin-bottom: var(--space-3);
    border-bottom: 1px solid var(--border);
    letter-spacing: -.01em;
}

/* Link affordance inside dashboard panels */
.dash-cols .dash-item a { transition: color .15s ease; }
@media (hover: hover) and (pointer: fine) {
    .dash-cols .dash-item a:hover { color: var(--primary); }
    .dash-cols .dash-item:hover { background: var(--hover); border-radius: var(--radius-sm); }
}

/* Entrance motion (one-shot, reduced-motion safe via global kill-switch) */
@keyframes dashFadeUp { to { opacity: 1; transform: translateY(0); } }
.grid .stat, .grid .card, .dash-cols .card {
    opacity: 0; transform: translateY(8px);
    animation: dashFadeUp .26s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}
.grid .stat:nth-child(1), .grid .card:nth-child(1), .dash-cols .card:nth-child(1) { animation-delay: 0ms; }
.grid .stat:nth-child(2), .grid .card:nth-child(2), .dash-cols .card:nth-child(2) { animation-delay: 50ms; }
.grid .stat:nth-child(3), .grid .card:nth-child(3), .dash-cols .card:nth-child(3) { animation-delay: 100ms; }
.grid .stat:nth-child(4), .grid .card:nth-child(4), .dash-cols .card:nth-child(4) { animation-delay: 150ms; }
.grid .stat:nth-child(5), .grid .card:nth-child(5) { animation-delay: 200ms; }
.grid .stat:nth-child(6), .grid .card:nth-child(6) { animation-delay: 250ms; }
.grid .stat:nth-child(7), .grid .card:nth-child(7) { animation-delay: 300ms; }
.grid .stat:nth-child(8), .grid .card:nth-child(8) { animation-delay: 350ms; }
/* Interactivité des cartes en grille (galerie de cours) — gated pointeur fin */
@media (hover: hover) and (pointer: fine) {
    .grid .card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
}
/* Reduced motion: keep content fully visible (global kill-switch disables the animation) */
@media (prefers-reduced-motion: reduce) {
    .grid .stat, .grid .card, .dash-cols .card { opacity: 1; transform: none; }
}

/* ---------- Grille de suivi des paiements ---------- */
.pay-grid { overflow-x: auto; }
.pay-table th, .pay-table td { white-space: nowrap; }
.pay-cell { text-align: center; padding: 6px 8px; }
.cell-select {
    padding: 4px 6px; border-radius: 7px; border: 1px solid var(--border);
    font-size: 12px; font-weight: 600; cursor: pointer; background: var(--surface); color: var(--text);
    min-width: 96px;
    transition: filter .15s;
}
.cell-select:hover { filter: brightness(1.03); }
.cell-select.st-paye { background: var(--success-bg); color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.cell-select.st-part { background: var(--warning-bg); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 40%, transparent); }
.cell-select.st-non  { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.cell-select:disabled { opacity: .6; cursor: wait; }
.cell-empty { color: var(--muted); }
.recu-link { margin-left: 4px; text-decoration: none; font-size: 14px; display: inline-block; transition: transform .12s ease; }
@media (hover: hover) and (pointer: fine) {
    .recu-link:hover { transform: scale(1.12); }
}

/* Avatar dans la grille des paiements */
.payment-avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; display: block; box-shadow: 0 0 0 2px var(--surface), 0 1px 4px rgba(15, 23, 42, .12); }
.payment-avatar-placeholder {
    width: 42px; height: 42px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; background: var(--hover); color: var(--muted);
    font-size: 14px; text-transform: uppercase;
    box-shadow: 0 0 0 2px var(--surface), 0 1px 4px rgba(15, 23, 42, .12);
}

/* ---------- Menu mobile ---------- */
.menu-toggle {
    display: none; background: var(--surface); border: 1px solid var(--border);
    border-radius: 9px; padding: 7px 11px; font-size: 18px; cursor: pointer; line-height: 1; color: var(--text);
}
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(2, 8, 23, .5); z-index: 19; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); z-index: 20; transition: transform .2s ease; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .main { margin-left: 0; }
    .menu-toggle { display: inline-flex; }
    .content { padding: 18px 16px; }

    /* ---------- Navbar mobile compacte (≤768px) ---------- */
    .topbar {
        height: 60px; padding: 0 12px; gap: 10px; z-index: 30;
        -webkit-backdrop-filter: blur(14px) saturate(150%);
        backdrop-filter: blur(14px) saturate(150%);
    }
    /* La sidebar s'ouvre SOUS la navbar (qui reste visible au-dessus). */
    .sidebar { padding-top: 72px; }
    .menu-toggle { padding: 6px 9px; font-size: 17px; border-radius: 9px; }

    /* Centre : titre sur une seule ligne, tronqué si trop long. */
    .topbar .topbar-title {
        text-align: center; font-size: 16px; font-weight: 700;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }

    .topbar .user { gap: 8px; }
    .theme-toggle { width: 34px; height: 34px; font-size: 15px; }

    /* Masque identifiant/email/rôle, affiche Nom puis Prénom (2 lignes). */
    .topbar .user .who { display: none; }
    .who-mobile {
        display: flex; flex-direction: column; justify-content: center;
        line-height: 1.12; max-width: 80px;
    }
    .who-mobile span {
        font-size: 11px; white-space: nowrap; overflow: hidden;
        text-overflow: ellipsis; max-width: 80px;
    }
    .who-mobile .wm-nom { font-weight: 700; color: var(--text); }
    .who-mobile .wm-prenom { color: var(--muted); }

    /* Photo de profil : cercle 36px. */
    .topbar .thumb, .topbar .avatar { width: 36px; height: 36px; font-size: 13px; }

    /* Déconnexion = icône rouge uniquement (logique de logout inchangée). */
    .logout-text { display: none; }
    .logout-btn.btn.btn-light {
        display: inline-flex; align-items: center; justify-content: center;
        width: 34px; height: 34px; padding: 0; border-radius: 50%;
        color: var(--danger); border: 1px solid var(--danger);
        background: var(--danger-bg);
    }
    .logout-icon { display: block; }

    /* Filet de sécurité : toute table large défile horizontalement au lieu de
       déformer la page (Mes cours, Mes notes, EDT…). */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* --------- Tables Stagiaire transformées en cartes (.data-cards) --------- */
    .table-wrap--cards {
        background: transparent; border: 0; box-shadow: none;
        border-radius: 0; overflow: visible;
    }
    .data-cards { font-size: 14px; }
    .data-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .data-cards, .data-cards tbody { display: block; width: 100%; }
    .data-cards tr {
        display: block;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 14px;
        box-shadow: var(--shadow);
        padding: 4px 14px;
        margin-bottom: 12px;
    }
    .data-cards td {
        display: flex; align-items: center; justify-content: space-between;
        gap: 14px; padding: 10px 0; border: 0;
        border-bottom: 1px solid var(--border);
        text-align: right;
    }
    .data-cards tr td:last-child { border-bottom: 0; }
    .data-cards td::before {
        content: attr(data-label);
        font-weight: 600; color: var(--muted);
        text-transform: none; letter-spacing: 0;
        text-align: left; flex: 0 0 auto;
    }
    /* 1ʳᵉ cellule = en-tête de carte (mois / date) */
    .data-cards td:first-child {
        justify-content: flex-start;
        font-size: 16px; font-weight: 700;
        padding: 12px 0 10px; border-bottom: 2px solid var(--border);
    }
    .data-cards td:first-child::before { content: ''; }
    /* Message « aucune donnée » */
    .data-cards td.empty {
        display: block; text-align: center; color: var(--muted);
        border: 1px solid var(--border); border-radius: 14px;
        background: var(--surface); padding: 18px;
    }
    .data-cards td.empty::before { content: ''; }
}

/* =====================================================================
   Login IPFPS — thème CLAIR (page autonome, layout auth)
   Toujours en clair, indépendant du dark mode de l'application.
   ===================================================================== */
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: stretch;
    position: relative;
    overflow: hidden;
    color: #1e293b;
    font-family: 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
    background:
        radial-gradient(900px 600px at 12% 8%, rgba(37, 99, 235, .10), transparent 55%),
        radial-gradient(820px 560px at 92% 96%, rgba(22, 163, 74, .10), transparent 55%),
        #ffffff;
}
/* Accents flous bleu / vert (légers, dérive douce) */
.login-page::before, .login-page::after {
    content: ""; position: absolute; border-radius: 50%;
    filter: blur(60px); pointer-events: none; z-index: 0;
}
.login-page::before {
    width: 360px; height: 360px; left: -90px; top: -70px;
    background: radial-gradient(circle, rgba(37, 99, 235, .22), transparent 70%);
    animation: loginFloat 9s ease-in-out infinite;
}
.login-page::after {
    width: 320px; height: 320px; right: -80px; bottom: -80px;
    background: radial-gradient(circle, rgba(22, 163, 74, .20), transparent 70%);
    animation: loginFloat 11s ease-in-out infinite reverse;
}
@keyframes loginFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(22px); } }

/* ----- Panneau de marque ----- */
.login-brand {
    flex: 1 1 50%;
    display: flex; align-items: center; justify-content: center;
    padding: 48px 44px; position: relative; z-index: 2;
}
.login-brand-inner { max-width: 420px; text-align: center; animation: loginUp .6s ease both; }
/* Scène 3D : la perspective vit sur le conteneur pour donner de la profondeur. */
.login-logo {
    perspective: 1100px;
    perspective-origin: 50% 45%;
    display: inline-block;
}
.login-logo img {
    width: min(210px, 50vw);
    /* Rotation 3D lente autour de l'axe Y → objet qui tourne dans l'espace, pas un spin plat. */
    animation: logoSpin3d 14s cubic-bezier(0.45, 0, 0.55, 1) infinite;
    transform-style: preserve-3d;
    transform-origin: center center;
    backface-visibility: visible;
    will-change: transform, filter;
}
/* L'ombre suit la rotation (plus profonde de profil, douce de face) → sensation de volume. */
@keyframes logoSpin3d {
    0%   { transform: rotateY(0deg)   translateZ(0); filter: drop-shadow(0 12px 22px rgba(37, 99, 235, .18)); }
    25%  { transform: rotateY(90deg)  translateZ(14px); filter: drop-shadow(14px 16px 30px rgba(37, 99, 235, .26)); }
    50%  { transform: rotateY(180deg) translateZ(0); filter: drop-shadow(0 12px 22px rgba(22, 163, 74, .18)); }
    75%  { transform: rotateY(270deg) translateZ(14px); filter: drop-shadow(-14px 16px 30px rgba(37, 99, 235, .26)); }
    100% { transform: rotateY(360deg) translateZ(0); filter: drop-shadow(0 12px 22px rgba(37, 99, 235, .18)); }
}
/* Respect du kill-switch global ; on neutralise aussi explicitement la rotation 3D. */
@media (prefers-reduced-motion: reduce) {
    .login-logo img {
        animation: none;
        transform: none;
        filter: drop-shadow(0 12px 24px rgba(37, 99, 235, .18));
    }
}
.login-brand-title {
    font-size: clamp(28px, 3.4vw, 42px);
    letter-spacing: .14em; font-weight: 800; margin-top: 14px;
    background: linear-gradient(90deg, #2563eb, #16a34a);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.login-brand-sub { margin: 10px auto 0; max-width: 340px; color: #64748b; font-size: 14px; line-height: 1.55; }
.login-points {
    list-style: none; margin: 26px 0 0; padding: 0;
    display: inline-flex; flex-direction: column; gap: 12px; text-align: left;
}
.login-points li { display: flex; align-items: center; gap: 10px; color: #334155; font-size: 14px; font-weight: 500; }
.login-points svg { width: 20px; height: 20px; flex: 0 0 auto; color: #16a34a; }

/* ----- Côté formulaire ----- */
.login-form-side {
    flex: 1 1 50%;
    display: flex; align-items: center; justify-content: center;
    padding: 40px; position: relative; z-index: 2;
}
.login-card {
    width: min(420px, 100%);
    background: rgba(255, 255, 255, .80);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    backdrop-filter: blur(14px) saturate(140%);
    border: 1px solid rgba(37, 99, 235, .14);
    border-radius: 22px;
    padding: 38px 32px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .12), 0 2px 6px rgba(15, 23, 42, .05);
    animation: loginUp .5s ease both;
}
.login-card-head { text-align: center; margin-bottom: 24px; }
.login-card-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 54px; height: 54px; border-radius: 16px; margin-bottom: 12px;
    color: #fff; background: linear-gradient(135deg, #2563eb, #16a34a);
    box-shadow: 0 10px 24px rgba(37, 99, 235, .28);
}
.login-card-badge svg { width: 26px; height: 26px; }
.login-title { font-size: clamp(22px, 3vw, 28px); font-weight: 800; color: #0f172a; margin: 0; }
.login-sub { color: #64748b; font-size: 14px; margin: 6px 0 0; }

.login-field { margin-bottom: 16px; }
.login-label { display: block; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 7px; }

.login-input-group {
    display: flex; align-items: center; gap: 10px;
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 13px;
    padding: 0 14px;
    transition: border-color .2s, box-shadow .2s, background .2s;
}
.login-input-group:focus-within {
    background: #fff; border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .14);
}
.login-input-group .ic { width: 20px; height: 20px; color: #2563eb; flex: 0 0 auto; }
.login-input-group input {
    flex: 1 1 auto; min-width: 0;
    background: transparent; border: none; outline: none;
    color: #0f172a; font-size: 15px; padding: 13px 0;
}
.login-input-group input::placeholder { color: #94a3b8; }
.login-input-group input:-webkit-autofill {
    -webkit-text-fill-color: #0f172a;
    -webkit-box-shadow: 0 0 0 1000px #fff inset;
    transition: background-color 9999s ease-out 0s;
}
.password-toggle {
    background: none; border: none; cursor: pointer; color: #94a3b8;
    display: inline-flex; align-items: center; padding: 6px; flex: 0 0 auto;
    transition: color .15s;
}
.password-toggle:hover { color: #2563eb; }
.password-toggle .eye, .password-toggle .eye-off { width: 20px; height: 20px; }
.password-toggle .eye-off { display: none; }
.password-toggle.is-on .eye { display: none; }
.password-toggle.is-on .eye-off { display: inline; }

.login-btn-gradient {
    width: 100%; margin-top: 22px;
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    border: none; border-radius: 13px; padding: 14px;
    font-size: 15px; font-weight: 700; letter-spacing: .02em; color: #fff;
    cursor: pointer;
    background: linear-gradient(90deg, #2563eb 0%, #1aa3d8 50%, #16a34a 100%);
    background-size: 180% 100%;
    box-shadow: 0 12px 26px rgba(37, 99, 235, .26);
    transition: background-position .35s ease, transform .12s ease, box-shadow .2s ease;
}
.login-btn-gradient svg { width: 18px; height: 18px; }
.login-btn-gradient:hover { background-position: 100% 0; transform: translateY(-1px); box-shadow: 0 16px 32px rgba(22, 163, 74, .28); }
.login-btn-gradient:active { transform: translateY(0); }

.login-foot { text-align: center; color: #94a3b8; font-size: 12px; margin: 18px 0 0; }

/* Alerts dans la carte claire */
.login-card .alert { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.login-card .alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }

@keyframes loginUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* ----- Responsive : empilé sur mobile ----- */
@media (max-width: 860px) {
    .login-page { flex-direction: column; }
    .login-brand { flex: 0 0 auto; padding: 40px 24px 8px; }
    .login-logo img { width: 130px; }
    .login-points { display: none; }
    .login-form-side { flex: 1 1 auto; padding: 14px 18px 40px; }
}
@media (max-width: 480px) {
    .login-card { padding: 28px 20px; border-radius: 18px; }
    .login-brand { padding: 30px 20px 4px; }
}

/* ----- Mobile + petite hauteur (SE portrait, paysage) : compacter le vertical
   uniquement (padding haut/bas, marges, taille logo) — horizontal/largeurs inchangés ----- */
@media (max-width: 860px) and (max-height: 720px) {
    .login-brand { padding-top: 22px; padding-bottom: 4px; }
    .login-logo img { width: 88px; }
    .login-brand-title { margin-top: 8px; }
    .login-brand-sub { margin-top: 6px; }
    .login-card { padding-top: 22px; padding-bottom: 22px; }
    .login-card-head { margin-bottom: 16px; }
    .login-card-badge { width: 46px; height: 46px; margin-bottom: 8px; }
    .login-field { margin-bottom: 12px; }
    .login-btn-gradient { margin-top: 16px; }
    .login-foot { margin-top: 12px; }
}
@media (max-width: 860px) and (max-height: 560px) {
    .login-brand { padding-top: 14px; padding-bottom: 2px; }
    .login-logo img { width: 64px; }
    .login-card { padding-top: 16px; padding-bottom: 16px; }
    .login-card-head { margin-bottom: 12px; }
    .login-field { margin-bottom: 10px; }
}

/* ----- Bascule de thème (coin haut-droit) — réutilise .theme-toggle/#themeIcon ----- */
.login-theme-toggle { position: absolute; top: 16px; right: 16px; z-index: 3; }

/* ----- Login en mode sombre : suit le thème global (tokens) ; accents bleu/vert conservés ----- */
[data-theme="dark"] .login-page {
    color: var(--text);
    background:
        radial-gradient(900px 600px at 12% 8%, rgba(37, 99, 235, .16), transparent 55%),
        radial-gradient(820px 560px at 92% 96%, rgba(22, 163, 74, .14), transparent 55%),
        linear-gradient(135deg, #0c1730 0%, #122544 100%);
}
[data-theme="dark"] .login-card {
    background: var(--surface); border-color: var(--border);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
}
[data-theme="dark"] .login-title { color: var(--text); }
[data-theme="dark"] .login-sub,
[data-theme="dark"] .login-brand-sub,
[data-theme="dark"] .login-foot { color: var(--muted); }
[data-theme="dark"] .login-points li { color: var(--text); }
[data-theme="dark"] .login-label { color: var(--text); }
[data-theme="dark"] .login-input-group { background: var(--hover); border-color: var(--border); }
[data-theme="dark"] .login-input-group input { color: var(--text); }
[data-theme="dark"] .login-input-group input::placeholder { color: var(--muted); }
[data-theme="dark"] .login-input-group input:-webkit-autofill {
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
}
[data-theme="dark"] .login-input-group:focus-within {
    background: var(--surface); border-color: var(--primary-blue);
}

/* ===================== Ma classe (Stagiaire) : cartes membres ===================== */
.members {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
}
.member-card {
    display: flex; align-items: center; gap: 12px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow);
    transition: transform .18s cubic-bezier(0.23, 1, 0.32, 1), box-shadow .18s ease;
}
@media (hover: hover) and (pointer: fine) {
    .member-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
}
.member-avatar {
    width: 48px; height: 48px; border-radius: 50%; object-fit: cover;
    flex: 0 0 48px; background: var(--primary-light);
    box-shadow: 0 0 0 2px var(--surface), 0 1px 4px rgba(15, 23, 42, .12);
}
.member-avatar--initials {
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 16px;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-green));
}
.member-name { font-weight: 600; font-size: 14px; line-height: 1.25; min-width: 0; }
@media (max-width: 768px) {
    .members { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
}

/* ===================== Pièce jointe : viewer intégré (message) ===================== */
.att-block { margin-top: 18px; }
.att-viewer { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.att-toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.att-stage {
    position: relative; width: 100%; height: 70vh;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}
.att-scroll {
    width: 100%; height: 100%; overflow: auto; padding: 12px;
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    background: #525659;
}
.att-canvas { background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.35); max-width: 100%; }
.att-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.att-msg { padding: 28px; text-align: center; color: var(--muted); }
.att-msg p { margin: 0; font-size: 15px; }

/* Plein écran : tout le viewer (barre + scène) → boutons restent visibles. */
.att-viewer:fullscreen, .att-viewer:-webkit-full-screen {
    width: 100vw; height: 100vh; box-sizing: border-box;
    padding: 12px 16px; background: var(--bg);
}
.att-viewer:fullscreen .att-stage,
.att-viewer:-webkit-full-screen .att-stage { flex: 1 1 auto; height: auto; min-height: 0; }

@media (max-width: 768px) { .att-stage { height: 58vh; } }

/* ===================== Boîte de réception : liste compacte mobile ===================== */
/* Desktop : la liste mobile est masquée (le tableau reste). */
.mobile-inbox-list { display: none; }

@media (max-width: 768px) {
    .inbox-desktop { display: none; }            /* masque le tableau sur mobile */
    .mobile-inbox-list {
        display: block;
        background: var(--surface); border: 1px solid var(--border);
        border-radius: 14px; overflow: hidden; box-shadow: var(--shadow);
    }
    .mobile-inbox-empty { padding: 24px; text-align: center; color: var(--muted); }

    .mobile-inbox-item {
        display: flex; align-items: center; gap: 12px;
        padding: 12px 14px; min-height: 72px;
        border-bottom: 1px solid var(--border);
        color: var(--text); text-decoration: none;
    }
    .mobile-inbox-item:last-child { border-bottom: 0; }
    .mobile-inbox-item:hover, .mobile-inbox-item:active { background: var(--hover); }

    .inbox-avatar {
        width: 40px; height: 40px; border-radius: 50%; flex: 0 0 40px;
        display: flex; align-items: center; justify-content: center;
        font-weight: 700; color: #fff; font-size: 15px;
        background: linear-gradient(135deg, var(--primary-blue), var(--primary-green));
    }
    .inbox-content { flex: 1 1 auto; min-width: 0; }
    .inbox-subject {
        font-size: 14px; line-height: 1.25; color: var(--text);
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .inbox-item-unread .inbox-subject { font-weight: 700; }
    .inbox-meta {
        margin-top: 2px; font-size: 12px; color: var(--muted);
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .inbox-side {
        flex: 0 0 auto; display: flex; flex-direction: column;
        align-items: flex-end; gap: 5px;
    }
    .inbox-date { font-size: 11px; color: var(--muted); white-space: nowrap; }
    .badge-status { font-size: 10px; padding: 2px 8px; }
    .inbox-chevron { flex: 0 0 auto; color: var(--muted); }
}

/* ===================== Emploi du temps hebdomadaire (grille) ===================== */
.edt-week-wrap { overflow-x: auto; }
.edt-week { width: 100%; border-collapse: collapse; min-width: 720px; table-layout: fixed; }
.edt-week th, .edt-week td {
    border: 1px solid var(--border); padding: 6px; text-align: center; vertical-align: top;
}
.edt-week thead th {
    background: var(--th-bg); color: var(--muted); font-size: 12px;
    text-transform: uppercase; letter-spacing: .03em; padding: 10px 6px;
}
.edt-week .edt-day {
    background: var(--th-bg); color: var(--text); font-weight: 700;
    width: 110px; text-align: left; padding-left: 12px;
}
.edt-cell { height: 78px; }
.edt-cell.edt-editable { cursor: pointer; transition: background .12s; }
.edt-cell.edt-editable:hover { background: var(--hover); }
.edt-add { color: var(--muted); font-size: 22px; font-weight: 300; line-height: 78px; display: block; }

/* Saisie directe : deux selects empilés par cellule */
.edt-cell-edit { padding: 6px; vertical-align: middle; }
.edt-cell-edit select.form-control {
    width: 100%; font-size: 12px; padding: 6px 7px; margin: 0 0 5px;
}
.edt-cell-edit select.form-control:last-child { margin-bottom: 0; }
.edt-week-edit td, .edt-week-edit th { vertical-align: middle; }

.seance {
    display: flex; flex-direction: column; gap: 2px; text-align: left;
    border-radius: 8px; padding: 7px 9px; border-left: 4px solid var(--muted);
    background: var(--hover); height: 100%; box-sizing: border-box;
}
.seance-module { font-weight: 700; font-size: 13px; color: var(--text); }
.seance-form { font-size: 12px; color: var(--text); }
.seance-type { font-size: 11px; color: var(--muted); }
.seance-cours  { background: rgba(37, 99, 235, .12);  border-left-color: var(--primary-blue); }
.seance-stage  { background: rgba(22, 163, 74, .14);  border-left-color: var(--primary-green); }
.seance-examen { background: rgba(220, 38, 38, .12);  border-left-color: #dc2626; }
.seance-autre  { background: var(--hover);            border-left-color: var(--muted); }

/* Modale d'édition de cellule */
.edt-modal-overlay {
    position: fixed; inset: 0; z-index: 40; display: flex;
    align-items: center; justify-content: center; padding: 16px;
    background: rgba(2, 8, 23, .55); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.edt-modal {
    width: 100%; max-width: 460px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 16px;
    box-shadow: var(--shadow-hover); padding: 22px;
}
.edt-modal h3 { margin: 0 0 14px; }
.edt-modal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

@media (max-width: 768px) {
    .edt-week .edt-day { width: 84px; padding-left: 8px; font-size: 13px; }
}

/* Respect des préférences de mouvement réduit */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ===================== Lecteur de cours (PDF / image / vidéo) ===================== */
.reader { display: flex; flex-direction: column; gap: 14px; }
.reader-bar {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
}
.reader-head h1 { margin: 0 0 4px; }
.reader-head p { margin: 0; color: var(--muted); font-size: 14px; }
.reader-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.reader-group { display: inline-flex; gap: 6px; align-items: center; }
.reader-pageinfo { font-size: 14px; color: var(--muted); min-width: 56px; text-align: center; }
.reader-desc { margin: 0; }

.reader-stage {
    position: relative;
    width: 100%;
    height: 80vh;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Zone de défilement du rendu PDF (canvas PDF.js) */
.pdf-scroll {
    width: 100%; height: 100%;
    overflow: auto;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 12px;
    background: #525659;
}
#pdfCanvas { background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.35); max-width: 100%; }
.reader-loading {
    position: absolute; inset: 0; display: flex; gap: 10px;
    align-items: center; justify-content: center;
    color: var(--muted); font-size: 14px; background: var(--surface);
}
.reader-loading .spinner {
    width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid var(--border); border-top-color: var(--primary);
    display: inline-block; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.reader-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.reader-video { width: 100%; height: 100%; background: #000; }

/* Boutons à icône (expand/compress…) */
.btn-icon { display: inline-flex; align-items: center; gap: 6px; }
.btn-icon svg { display: block; }

/* Plein écran : c'est TOUT le lecteur (.reader) qui passe en plein écran afin que
   la barre d'outils — donc les boutons, dont « Quitter le plein écran » — reste
   visible AU-DESSUS du PDF. */
.reader:fullscreen,
.reader:-webkit-full-screen {
    width: 100vw; height: 100vh; box-sizing: border-box;
    padding: 12px 16px; gap: 10px;
    background: var(--bg);
}
.reader:fullscreen .reader-bar,
.reader:-webkit-full-screen .reader-bar { flex: 0 0 auto; }
.reader:fullscreen .reader-stage,
.reader:-webkit-full-screen .reader-stage { flex: 1 1 auto; height: auto; min-height: 0; }
.reader:fullscreen .reader-desc,
.reader:-webkit-full-screen .reader-desc,
.reader:fullscreen .hint,
.reader:-webkit-full-screen .hint { display: none; }

.reader-fallback {
    padding: 28px; text-align: center; color: var(--muted);
    max-width: 460px;
}
.reader-fallback p { margin: 0; font-size: 15px; }

@media (max-width: 640px) {
    .reader-stage { height: 68vh; }
}

/* =====================================================================
   Phase 1 — Fondation & shell (polish global, additif)
   Aucune classe existante n'est renommée/supprimée ; seules des propriétés
   sont affinées et de nouveaux utilitaires ajoutés.
   ===================================================================== */

/* Accessibilité : focus clavier visible (ne change aucun comportement) */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.form-control:focus-visible { outline: none; } /* l'anneau box-shadow suffit */
.sidebar nav a:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }

/* Lien d'évitement (skip-link) pour la navigation clavier */
.skip-link {
    position: absolute; left: -9999px; top: 0; z-index: 100;
    background: var(--primary); color: #fff; padding: 10px 16px;
    border-radius: 0 0 10px 0; font-weight: 600; box-shadow: var(--shadow);
}
.skip-link:focus { left: 0; }

/* Barres de défilement premium (discrètes) */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
    background: var(--border); border-radius: 8px;
    border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }

/* Canevas de contenu : largeur de lecture confortable + accents très légers
   bleu/vert UNIQUEMENT en mode clair (le dark mode reste inchangé). */
.content { max-width: var(--content-max); margin-inline: auto; width: 100%; }
html:not([data-theme="dark"]) .main {
    background:
        radial-gradient(720px 380px at 100% 0%, rgba(22, 163, 74, .045), transparent 60%),
        radial-gradient(640px 360px at 0% 100%, rgba(37, 99, 235, .05), transparent 60%);
}

/* Hiérarchie : titres de page plus affirmés */
.page-head h1 { font-weight: 800; letter-spacing: -.01em; }

/* Topbar : liseré bas net + cohérence verre */
.topbar { box-shadow: 0 1px 0 var(--border); }

/* Cartes : légère élévation au survol (les cartes cliquables/interactives) */
.card { transition: background .25s, border-color .25s, box-shadow .2s, transform .12s; }

/* Tables : dernière ligne sans liseré (conteneur déjà arrondi) */
table.data tbody tr:last-child td { border-bottom: 0; }

@media (max-width: 768px) {
    .content { padding: 18px 14px; }
}
@media (max-width: 480px) {
    .content { padding: 16px 12px; }
}
