/* --- Polices (hébergées localement, licence SIL OFL) --- */
@font-face {
    font-family: "Inter";
    src: url("../fonts/inter-latin-Gz7AlRl.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Plus Jakarta Sans";
    src: url("../fonts/plus-jakarta-sans-latin-ZHdaFJ8.woff2") format("woff2");
    font-weight: 200 800;
    font-style: normal;
    font-display: swap;
}

:root {
    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-heading: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #cbd5e1;
    --error: #b91c1c;
    --error-bg: #fef2f2;
    --success: #15803d;
    --success-bg: #f0fdf4;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 16px/1.55 var(--font-sans);
    font-feature-settings: "cv11", "ss01";
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

a { color: var(--primary); text-underline-offset: .15em; }

h1, h2, h3, .auth-brand, .stat-value {
    font-family: var(--font-heading);
    letter-spacing: -.02em;
}
h1 { font-size: 1.75rem; font-weight: 800; line-height: 1.2; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; font-weight: 700; line-height: 1.3; margin: 0 0 .75rem; }
strong, b { font-weight: 600; }
.table, .details, .stat-value, .code, .timer strong { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* --- Messages --- */
.flash, .alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}
.flash { max-width: 960px; margin: 1rem auto 0; }
.flash-success { background: var(--success-bg); color: var(--success); }
.alert-error, .flash-error { background: var(--error-bg); color: var(--error); }

/* --- Pages d'authentification --- */
body.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem 1rem;
    background: linear-gradient(135deg, #dbeafe, #f1f5f9);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .08);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 800;
    font-size: 1.25rem;
}
.auth-logo { font-size: 1.6rem; }
.auth-tagline { color: var(--muted); margin: .25rem 0 1.5rem; }

.auth-form { display: grid; gap: 1rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }

.field label { display: block; font-weight: 600; margin-bottom: .35rem; }
.field input {
    width: 100%;
    padding: .65rem .8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
}
.field input:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
    border-color: transparent;
}
.field .help-text, .field small { color: var(--muted); font-size: .85rem; }

.checkbox { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.checkbox label { font-weight: normal; }

/* Erreurs de formulaire Symfony */
.auth-form ul { list-style: none; margin: .35rem 0 0; padding: 0; color: var(--error); font-size: .9rem; }
.checkbox ul { flex-basis: 100%; }

.auth-switch { text-align: center; margin: 1.5rem 0 0; color: var(--muted); }

/* --- Boutons --- */
.btn {
    display: inline-block;
    padding: .7rem 1.1rem;
    border-radius: 8px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { border-color: var(--border); color: var(--text); background: var(--surface); padding: .45rem .9rem; }
.btn-ghost:hover { background: var(--bg); }

/* --- Dashboard --- */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .9rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar-user { display: flex; align-items: center; gap: 1rem; }

.page { max-width: 960px; margin: 0 auto; padding: 2rem 1rem; }

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
}

.details { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.5rem; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }

/* --- Espace enseignant : navigation --- */
.topbar-left { display: flex; align-items: center; gap: 2rem; flex-wrap: wrap; }
.topbar .auth-brand { color: var(--text); text-decoration: none; }
.nav { display: flex; gap: .25rem; }
.nav a {
    padding: .4rem .8rem;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
}
.nav a:hover { background: var(--bg); color: var(--text); }
.nav a.active { background: #dbeafe; color: var(--primary); }
@media (max-width: 640px) {
    .topbar { flex-wrap: wrap; padding: .75rem 1rem; }
    .topbar-left { gap: .75rem; }
    .topbar-name { display: none; }
}

/* --- En-têtes de page --- */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}
.page-head h1 { margin-bottom: .35rem; }
.head-actions { display: flex; gap: .5rem; align-items: center; }
.breadcrumb { margin: 0 0 .75rem; }
.breadcrumb a { text-decoration: none; color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }

/* --- Boutons supplémentaires --- */
.btn-inline { width: auto; }
.btn-sm { padding: .3rem .7rem; font-size: .9rem; }
.btn-danger { background: var(--surface); color: var(--error); border-color: #fecaca; }
.btn-danger:hover { background: var(--error-bg); }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; }

/* --- Formulaires de l'espace --- */
.form-card { max-width: 720px; }
.field select, .field textarea {
    width: 100%;
    padding: .65rem .8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: var(--surface);
}
.field textarea { resize: vertical; }
.field select:focus, .field textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
    border-color: transparent;
}
.danger-zone { max-width: 720px; border: 1px solid #fecaca; }

/* --- Statistiques --- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
@media (max-width: 560px) { .stats { grid-template-columns: 1fr; } }
.stat {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
}
.stat:hover { box-shadow: 0 4px 12px rgba(15, 23, 42, .1); }
.stat-value { font-size: 2rem; font-weight: 800; line-height: 1.15; }
.stat-label { color: var(--muted); }

/* --- Listes et tableaux --- */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .65rem 0;
    border-top: 1px solid var(--bg);
    flex-wrap: wrap;
}
.list li:first-child { border-top: 0; }

.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0 0; }
.filters a {
    padding: .35rem .85rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    font-size: .92rem;
}
.filters a.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .8rem 1rem; text-align: left; border-bottom: 1px solid var(--bg); }
.table th { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }
.table a { font-weight: 600; text-decoration: none; }
.actions-col { text-align: right; white-space: nowrap; }

.empty { text-align: center; padding: 2.5rem 1.5rem; }

/* --- Badges de statut --- */
.badge {
    display: inline-block;
    padding: .15rem .6rem;
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 600;
}
.badge-planifiee { background: #dbeafe; color: #1e40af; }
.badge-realisee { background: var(--success-bg); color: var(--success); }
.badge-annulee { background: #f1f5f9; color: var(--muted); }

.prewrap { white-space: pre-wrap; margin: 0; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

/* --- Élèves --- */
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }
.toolbar input[type=search], .toolbar select {
    padding: .5rem .75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: var(--surface);
}
.toolbar input[type=search] { flex: 1 1 220px; }

/* --- Envoi des codes --- */
.selection-bar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.selection-count { margin-left: auto; }
.eleve-choices {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: .5rem;
    margin-bottom: 1.25rem;
}
.eleve-choice {
    display: flex;
    gap: .6rem;
    align-items: flex-start;
    padding: .65rem .8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}
.eleve-choice:has(input:checked) { border-color: var(--primary); background: #eff6ff; }
.eleve-choice input { margin-top: .25rem; }
.eleve-choice span { display: flex; flex-direction: column; min-width: 0; }
.eleve-choice small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: .08em;
    background: #eff6ff;
    color: #1e40af;
    padding: .2rem .5rem;
    border-radius: 6px;
}
.badge-erreur { background: var(--error-bg); color: var(--error); }

/* --- Espace élève --- */
.auth-card-wide { max-width: 640px; }
.code-input {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 1.4rem !important;
    letter-spacing: .15em;
    text-transform: uppercase;
}
.timer {
    background: #fff7ed;
    color: #9a3412;
    padding: .6rem .9rem;
    border-radius: 8px;
    margin: 1rem 0 1.25rem;
}
.mt { margin-top: 1.5rem; }

/* --- Réponses --- */
.reponse-box {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}
.reponse-statut { color: var(--success); background: var(--success-bg); padding: .6rem .8rem; border-radius: 8px; font-size: .92rem; }
.timer-urgent { background: var(--error-bg); color: var(--error); }
.timer-fini { background: #f1f5f9; color: var(--muted); }
.reponses { display: grid; gap: .75rem; }
.reponse-item {
    border: 1px solid var(--bg);
    border-left: 3px solid var(--primary);
    border-radius: 8px;
    padding: .8rem 1rem;
}
.reponse-item header { display: flex; flex-wrap: wrap; gap: .25rem; align-items: baseline; margin-bottom: .4rem; }
.reponse-date { margin-left: auto; font-size: .88rem; }

/* --- Correction des réponses --- */
.correction-resume { display: flex; gap: .4rem; flex-wrap: wrap; margin: 0; }
.badge-valide { background: var(--success-bg); color: var(--success); }
.badge-fausse { background: var(--error-bg); color: var(--error); }
.badge-a-corriger { background: #fff7ed; color: #9a3412; }
.reponse-item.reponse-valide { border-left-color: var(--success); }
.reponse-item.reponse-fausse { border-left-color: var(--error); }
.reponse-item.reponse-a-corriger { border-left-color: #f59e0b; }
.correction-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-top: .75rem; }
.btn-valide { background: var(--surface); color: var(--success); border-color: #bbf7d0; }
.btn-valide:hover, .btn-valide.is-active { background: var(--success); color: #fff; border-color: var(--success); }
.btn-fausse { background: var(--surface); color: var(--error); border-color: #fecaca; }
.btn-fausse:hover, .btn-fausse.is-active { background: var(--error); color: #fff; border-color: var(--error); }

/* --- Envoi des corrections --- */
.envoi-groupe {
    display: flex;
    gap: .75rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
    background: #eff6ff;
    border-radius: 8px;
    padding: .6rem .8rem;
    margin-bottom: 1rem;
}
.correction-envoi {
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: .6rem;
    padding-top: .6rem;
    border-top: 1px dashed var(--border);
    font-size: .9rem;
}
.envoi-ok { color: var(--success); }
.envoi-attente { color: #9a3412; }
.btn-link { background: none; border: 0; color: var(--primary); padding: .2rem .4rem; text-decoration: underline; }

/* --- Questions --- */
.small { font-size: .88rem; }
.questions { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.question-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: .75rem;
    align-items: start;
    padding: .75rem;
    border: 1px solid var(--bg);
    border-radius: 8px;
}
@media (max-width: 640px) { .question-item { grid-template-columns: auto 1fr; } .question-actions { grid-column: 1 / -1; } }
.question-num {
    display: inline-grid;
    place-items: center;
    min-width: 1.8rem;
    height: 1.8rem;
    border-radius: 999px;
    background: #dbeafe;
    color: var(--primary);
    font-weight: 700;
    font-size: .9rem;
}
.question-num.small { min-width: 1.4rem; height: 1.4rem; font-size: .78rem; }
.question-enonce { margin: 0 0 .35rem; font-weight: 600; }
.reponse-attendue { margin: 0; font-size: .92rem; }
.reponse-attendue span { color: var(--muted); }
.question-actions { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }

/* --- Réponses par élève --- */
.eleves-reponses { display: grid; gap: 1rem; }
.eleve-reponses { border: 1px solid var(--border); border-radius: 10px; padding: 1rem; }
.eleve-reponses-head { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .75rem; }
.eleve-reponses .reponse-item { margin-top: .6rem; }
.reponse-item.reponse-vide { border-left-color: var(--border); }
.reponse-question { margin: 0 0 .5rem; font-weight: 600; display: flex; gap: .5rem; align-items: baseline; }
.reponse-comparaison { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.reponse-comparaison > div:only-child { grid-column: 1 / -1; }
@media (max-width: 640px) { .reponse-comparaison { grid-template-columns: 1fr; } }
.reponse-comparaison .label { display: block; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: .2rem; }
.reponse-comparaison .attendue { background: #f8fafc; border-radius: 6px; padding: .4rem .6rem; }

/* --- Questions côté élève --- */
.question-eleve { display: grid; gap: .4rem; }
.question-eleve-enonce { display: flex; gap: .6rem; align-items: baseline; font-weight: 600; }
.question-eleve textarea {
    width: 100%;
    padding: .65rem .8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    resize: vertical;
}
.question-eleve textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }
.reponse-statut-mini { color: var(--success); }
