/* Correcteur NSI — feuille de style principale */
:root {
  --navy: #17324f; --navy-2: #22476f; --blue: #2563c9; --blue-soft: #e8f0fc;
  --bg: #f3f5f8; --card: #ffffff; --line: #d9e0e8; --line-2: #e9edf2;
  --text: #18222e; --muted: #5d6b7b; --ok: #17803d; --ok-soft: #e3f4e8;
  --warn: #a15c00; --warn-soft: #fff3dc; --err: #b42318; --err-soft: #fdeceb;
  --violet: #6b3fb5; --violet-soft: #f0eafb;
  --radius: 10px; --shadow: 0 1px 3px rgba(16, 32, 56, .07);
  --mono: "JetBrains Mono", "Fira Code", Consolas, "DejaVu Sans Mono", monospace;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-size: 15px; line-height: 1.45; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .7rem; }
h3 { font-size: 1rem; margin: .8rem 0 .4rem; }
code, pre, .mono { font-family: var(--mono); font-size: .88em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* En-tête */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 1.2rem; padding: 0 1.2rem;
  height: 52px; position: sticky; top: 0; z-index: 50; }
.topbar .brand { color: #fff; font-weight: 700; font-size: 1.05rem; letter-spacing: .2px; white-space: nowrap; }
.topbar nav { display: flex; gap: .2rem; flex: 1; }
.topbar nav a, .topbar .user a { color: #d7e3f2; padding: .4rem .7rem; border-radius: 6px; font-size: .93rem; }
.topbar nav a:hover, .topbar nav a.active { background: var(--navy-2); color: #fff; text-decoration: none; }
.topbar .user { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: #c8d6e8; }
.topbar .user form { margin: 0; }
.topbar .ai-pill { font-size: .75rem; padding: .15rem .5rem; border-radius: 99px; background: #0f2338; color: #9fd3a8; }
.topbar .ai-pill.off { color: #f0a39b; }

main.container { max-width: 1280px; margin: 1.4rem auto 3rem; padding: 0 1.2rem; }
main.wide { max-width: none; margin: 0; padding: .6rem .8rem 1rem; }

/* Cartes, grilles */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow); margin-bottom: 1rem; }
.card.tight { padding: .7rem .9rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.stack > * + * { margin-top: .6rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.page-head h1 { margin-bottom: .2rem; }
.breadcrumb { font-size: .88rem; color: var(--muted); margin-bottom: .3rem; }

/* Statistiques */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.stat .v { font-size: 1.6rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .85rem; }

/* Formulaires */
label { display: block; font-weight: 600; font-size: .88rem; margin: .5rem 0 .2rem; }
label.inline { display: inline-flex; align-items: center; gap: .35rem; font-weight: 500; margin: 0; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=email], input[type=file],
select, textarea {
  width: 100%; padding: .48rem .6rem; border: 1px solid #c4ced9; border-radius: 7px; font: inherit; background: #fff; color: inherit; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cbcf0; border-color: var(--blue); }
input[type=checkbox], input[type=radio] { width: 1.05rem; height: 1.05rem; accent-color: var(--blue); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 1rem; }
.help { font-size: .82rem; color: var(--muted); margin: .15rem 0 0; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .9rem; margin: .6rem 0; }
legend { font-weight: 600; font-size: .9rem; padding: 0 .3rem; }

/* Boutons */
.btn, button { display: inline-flex; align-items: center; gap: .35rem; padding: .48rem .9rem; border-radius: 7px; border: 1px solid var(--blue);
  background: var(--blue); color: #fff; font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover, button:hover { filter: brightness(1.07); text-decoration: none; }
.btn:disabled, button:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary, button.secondary { background: #fff; color: var(--blue); }
.btn.ghost, button.ghost { background: transparent; border-color: transparent; color: var(--blue); padding: .35rem .5rem; }
.btn.ok, button.ok { background: var(--ok); border-color: var(--ok); }
.btn.danger, button.danger { background: var(--err); border-color: var(--err); }
.btn.danger.secondary, button.danger.secondary { background: #fff; color: var(--err); }
.btn.warn, button.warn { background: var(--warn); border-color: var(--warn); }
.btn.ai, button.ai { background: var(--violet); border-color: var(--violet); }
.btn.ai.secondary, button.ai.secondary { background: #fff; color: var(--violet); }
.btn.sm, button.sm { padding: .28rem .55rem; font-size: .82rem; }
.btn.lg, button.lg { padding: .65rem 1.2rem; font-size: 1rem; }
.topbar button { background: transparent; border: 1px solid #3a5f88; color: #d7e3f2; padding: .3rem .6rem; }

/* Messages */
.flash { padding: .65rem .9rem; border-radius: 8px; margin-bottom: .7rem; border: 1px solid; }
.flash.success { background: var(--ok-soft); border-color: #b5dfc1; color: #11592b; }
.flash.error { background: var(--err-soft); border-color: #f2c0bb; color: #8a1c12; }
.flash.warning { background: var(--warn-soft); border-color: #f1d49c; color: #7a4600; }
.flash.info, .flash.message { background: var(--blue-soft); border-color: #c5d7f4; color: #1c457f; }
#toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 200; display: flex; flex-direction: column; gap: .4rem; max-width: 420px; }
.toast { padding: .6rem .9rem; border-radius: 8px; background: #1d2b3c; color: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.2); font-size: .9rem; }
.toast.error { background: var(--err); }
.toast.success { background: var(--ok); }

/* Tableaux */
table.data { width: 100%; border-collapse: collapse; background: #fff; }
table.data th, table.data td { padding: .45rem .55rem; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: middle; }
table.data th { font-size: .8rem; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); background: #f7f9fb; position: sticky; top: 0; }
table.data tr:hover td { background: #fafcff; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }

/* Badges */
.badge { display: inline-block; padding: .12rem .5rem; border-radius: 99px; font-size: .75rem; font-weight: 600; background: #eef1f5; color: #44505e; white-space: nowrap; }
.badge.ok, .badge.correction_validee { background: var(--ok-soft); color: var(--ok); }
.badge.warn, .badge.transcription_a_verifier, .badge.a_revoir { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.info, .badge.transcrite_auto, .badge.transcription_validee { background: var(--blue-soft); color: #1c4f9c; }
.badge.ai, .badge.correction_proposee { background: var(--violet-soft); color: var(--violet); }
.badge.preparation { background: #eef1f5; }
.badge.correction { background: var(--blue-soft); color: #1c4f9c; }
.badge.terminee { background: var(--ok-soft); color: var(--ok); }

/* Progression */
.progress { height: 8px; background: #e3e8ee; border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--blue); width: 0; transition: width .3s; }
.progress.ok > span { background: var(--ok); }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .6rem; }
.step { border: 1px solid var(--line); border-radius: 9px; padding: .7rem .8rem; background: #fff; }
.step .n { font-size: .75rem; font-weight: 700; color: var(--muted); }
.step.done { border-color: #b5dfc1; background: #f6fcf8; }
.step.todo { border-style: dashed; }

/* Tableau de bord */
.eval-card { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; background: #fff; }
.eval-card h3 { margin: 0 0 .25rem; }
.eval-card .meta { font-size: .85rem; color: var(--muted); }
.kpis { display: flex; gap: 1rem; font-size: .82rem; color: var(--muted); margin: .45rem 0; flex-wrap: wrap; }
.kpis b { color: var(--text); }

/* Éditeur de zones */
.zones-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 1rem; align-items: start; }
.zones-side { position: sticky; top: 64px; max-height: calc(100vh - 76px); overflow: auto; }
.q-list { list-style: none; margin: 0; padding: 0; }
.q-list li { display: flex; align-items: center; gap: .4rem; padding: .38rem .5rem; border-radius: 7px; cursor: pointer; border: 1px solid transparent; }
.q-list li:hover { background: #f3f7fd; }
.q-list li.active { background: var(--blue-soft); border-color: #bcd2f3; }
.q-list li .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.q-list li.dirty .qn::after { content: " •"; color: var(--warn); }
.tools { display: flex; gap: .3rem; flex-wrap: wrap; }
.tools button.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.pages { display: flex; flex-direction: column; gap: 1.2rem; align-items: center; }
.page-wrap { position: relative; box-shadow: 0 2px 10px rgba(0,0,0,.12); background: #fff; user-select: none; }
.page-wrap img { display: block; width: 100%; height: auto; pointer-events: none; }
.page-wrap .page-label { position: absolute; left: -2.2rem; top: 0; font-size: .8rem; color: var(--muted); }
.overlay { position: absolute; inset: 0; cursor: crosshair; }
.rect { position: absolute; border: 2px solid; background: rgba(37, 99, 201, .1); cursor: move; }
.rect .lab { position: absolute; left: 0; top: -1.25rem; font-size: .72rem; font-weight: 700; padding: 0 .3rem; border-radius: 3px; color: #fff; white-space: nowrap; pointer-events: none; }
.rect.inactive { opacity: .35; }
.rect.selected { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #111; }
.rect .handle { position: absolute; width: 10px; height: 10px; background: #fff; border: 2px solid #111; right: -6px; bottom: -6px; cursor: nwse-resize; }
.rect.kind-option { border-style: solid; background: rgba(0, 150, 80, .12); }
.rect.kind-blank { border-style: dashed; background: rgba(160, 90, 0, .1); }
.rect.kind-text { border-style: dotted; background: rgba(120, 120, 120, .08); }
.drawing { position: absolute; border: 2px dashed #111; background: rgba(0,0,0,.06); pointer-events: none; }
.zoom-bar { position: sticky; top: 58px; z-index: 5; background: rgba(243,245,248,.95); padding: .3rem; border-radius: 8px; }

/* Préparation */
.prep-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 1rem; align-items: start; }
.crit-table input, .crit-table textarea { font-size: .88rem; padding: .3rem .4rem; }
.crit-table textarea { min-height: 38px; }
.crit-row { border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; margin-bottom: .5rem; background: #fff; }
.crit-row.unvalidated { border-color: #cbb5ef; background: var(--violet-soft); }
.crit-row.auto { background: #f6f8fa; }
.crit-row .head { display: grid; grid-template-columns: 90px minmax(0,1fr) 90px auto; gap: .5rem; align-items: end; }
.check-line { padding: .4rem .7rem; border-radius: 7px; font-weight: 600; font-size: .88rem; }
.check-line.ok { background: var(--ok-soft); color: var(--ok); }
.check-line.bad { background: var(--err-soft); color: var(--err); }

/* Correction : 4 colonnes */
body.correction { overflow: hidden; }
.corr-bar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: .45rem .7rem; margin-bottom: .5rem; }
.corr-bar select { width: auto; max-width: 320px; padding: .32rem .45rem; }
.corr-bar .prog { min-width: 160px; }
.corr-wrap { position: relative; padding: 0 2.8rem; }
.corr-grid { display: grid; grid-template-columns: var(--c1, 1fr) 6px var(--c2, 1fr) 6px var(--c3, 1fr) 6px var(--c4, .8fr); height: calc(100vh - 128px); min-height: 480px; }
.corr-col { background: #fff; border: 1px solid var(--line); border-radius: 9px; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.corr-col > header { padding: .5rem .75rem; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; background: #fafbfc; }
.corr-col > header h2 { font-size: .95rem; margin: 0; flex: 1; }
.corr-col .body { padding: .7rem .75rem; overflow: auto; flex: 1; }
.corr-col > footer { padding: .5rem .75rem; border-top: 1px solid var(--line-2); display: flex; gap: .4rem; flex-wrap: wrap; background: #fafbfc; }
.gutter { cursor: col-resize; display: flex; align-items: center; justify-content: center; }
.gutter::after { content: ""; width: 2px; height: 40px; border-radius: 2px; background: #c3ccd7; }
.gutter:hover::after { background: var(--blue); }
.nav-arrow { position: fixed; top: 50%; transform: translateY(-50%); width: 2.4rem; height: 6rem; display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; background: var(--navy); color: #fff; border-radius: 10px; z-index: 30; box-shadow: 0 3px 12px rgba(0,0,0,.2); }
.nav-arrow:hover { background: var(--blue); text-decoration: none; }
.nav-arrow.left { left: .3rem; } .nav-arrow.right { right: .3rem; }
.nav-arrow.disabled { background: #b7c1cc; pointer-events: none; }
.img-viewer { position: relative; overflow: auto; background: #eef1f4; border-radius: 6px; height: 100%; }
.img-viewer img { display: block; transform-origin: 0 0; max-width: none; }
.img-tools { display: flex; gap: .25rem; align-items: center; }
.img-tools button { padding: .2rem .5rem; }
.fullpage { position: relative; }
.fullpage img { width: 100%; display: block; }
.fullpage .hl { position: absolute; border: 2px solid #e0362c; background: rgba(224,54,44,.08); }
.fullpage .hl.editable { cursor: move; }
.fullpage .hl .handle { position: absolute; right: -6px; bottom: -6px; width: 11px; height: 11px; background: #fff; border: 2px solid #e0362c; cursor: nwse-resize; }
.notice { padding: .5rem .65rem; border-radius: 7px; font-size: .86rem; margin-bottom: .5rem; }
.notice.warn { background: var(--warn-soft); color: #7a4600; }
.notice.info { background: var(--blue-soft); color: #1c457f; }
.notice.ok { background: var(--ok-soft); color: #11592b; }
.notice.err { background: var(--err-soft); color: #8a1c12; }
.notice.ai { background: var(--violet-soft); color: #4b2a86; }
.spinner { width: 18px; height: 18px; border: 3px solid #c7d4e6; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-box { display: flex; align-items: center; gap: .6rem; padding: 1rem; color: var(--muted); }
.qcm-opt { display: flex; align-items: center; gap: .55rem; padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 8px; margin-bottom: .35rem; }
.qcm-opt input { width: 1.3rem; height: 1.3rem; }
.qcm-opt.ambiguous { border-color: #f1c46b; background: var(--warn-soft); }
.qcm-opt.correct-ref { border-color: #a6d9b6; background: var(--ok-soft); }
.qcm-opt .score { margin-left: auto; font-size: .75rem; color: var(--muted); }
.blank-row { display: grid; grid-template-columns: 80px minmax(0, 1fr) auto; gap: .4rem; align-items: center; margin-bottom: .35rem; }
.blank-row input[type=text] { font-family: var(--mono); }
.crit { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; margin-bottom: .45rem; }
.crit.validated { border-color: #b5dfc1; background: #f7fcf8; }
.crit .top { display: flex; gap: .5rem; align-items: flex-start; }
.crit .top .title { flex: 1; font-weight: 600; font-size: .9rem; }
.crit .pts { display: flex; align-items: center; gap: .3rem; }
.crit .pts input { width: 4.6rem; text-align: right; padding: .3rem .4rem; }
.crit .ai-just { font-size: .82rem; color: #4b2a86; background: var(--violet-soft); border-radius: 6px; padding: .3rem .45rem; margin-top: .3rem; }
.crit .desc { font-size: .8rem; color: var(--muted); }
.total-box { display: flex; align-items: baseline; gap: .4rem; font-size: 1.05rem; padding: .4rem 0; }
.total-box b { font-size: 1.5rem; }
.expected pre, pre.code-view { background: #f6f8fa; border: 1px solid var(--line-2); border-radius: 7px; padding: .55rem .65rem; overflow: auto; white-space: pre; margin: .3rem 0; }
.history-item { border-top: 1px solid var(--line-2); padding: .35rem 0; font-size: .82rem; }
.history-item pre { max-height: 120px; overflow: auto; font-size: .78rem; }
@media (max-width: 1250px) {
  body.correction { overflow: auto; }
  .corr-grid { grid-template-columns: 1fr 1fr !important; height: auto; gap: .6rem; }
  .corr-grid .gutter { display: none; }
  .corr-col { min-height: 420px; }
}
@media (max-width: 760px) {
  .corr-grid { grid-template-columns: 1fr !important; }
  .corr-wrap { padding: 0; }
  .nav-arrow { top: auto; bottom: .5rem; transform: none; height: 3rem; }
}

/* Éditeur de code (coloration syntaxique) */
.code-editor { position: relative; font-family: var(--mono); font-size: 13.5px; line-height: 1.5; border: 1px solid #c4ced9; border-radius: 7px; background: #fbfcfd; }
.code-editor textarea, .code-editor pre { margin: 0; padding: .55rem .65rem; font: inherit; white-space: pre; overflow: auto; tab-size: 4; border: 0; min-height: 220px; }
.code-editor pre { position: absolute; inset: 0; pointer-events: none; color: #1d2733; background: transparent; }
.code-editor textarea { position: relative; color: transparent; background: transparent; caret-color: #111; resize: vertical; width: 100%; outline: none; display: block; }
.code-editor textarea::selection { background: rgba(37, 99, 201, .25); color: transparent; }
.tok-kw { color: #8b2fc9; font-weight: 600; } .tok-str { color: #0f7a3b; } .tok-com { color: #7b8794; font-style: italic; }
.tok-num { color: #b35c00; } .tok-fn { color: #1f5fbf; } .tok-op { color: #a3243b; } .tok-ill { background: #ffe1de; color: #b42318; }

/* Résultats */
.results-table td.cell { text-align: center; font-variant-numeric: tabular-nums; }
.results-table td.cell a { display: block; color: inherit; }
.results-table td.cell.validated { background: #f3fbf5; }
.results-table td.cell.proposed { color: var(--violet); font-style: italic; }
.results-table td.cell.stale { outline: 2px solid #f1c46b; outline-offset: -2px; }
.hist { display: flex; align-items: flex-end; gap: .6rem; height: 140px; padding-top: .5rem; }
.hist .bar { flex: 1; background: var(--blue); border-radius: 5px 5px 0 0; position: relative; min-height: 2px; }
.hist .bar span { position: absolute; top: -1.3rem; left: 0; right: 0; text-align: center; font-size: .8rem; font-weight: 600; }
.hist-labels { display: flex; gap: .6rem; } .hist-labels div { flex: 1; text-align: center; font-size: .8rem; color: var(--muted); }
.rate { display: grid; grid-template-columns: 140px minmax(0,1fr) 60px; gap: .5rem; align-items: center; margin: .25rem 0; font-size: .88rem; }

/* Connexion */
.login-box { max-width: 380px; margin: 9vh auto; }
.login-box h1 { text-align: center; }

/* Vignettes */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .6rem; }
.thumbs figure { margin: 0; border: 1px solid var(--line); border-radius: 7px; padding: .3rem; background: #fff; text-align: center; font-size: .8rem; }
.thumbs img { width: 100%; height: auto; display: block; }
img.thumb-mini { height: 54px; border: 1px solid var(--line); border-radius: 4px; }

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 1.2rem; max-width: 640px; width: 92vw; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(16, 28, 44, .45); }
kbd { font-family: var(--mono); font-size: .78rem; background: #eef1f5; border: 1px solid #d0d7e0; border-bottom-width: 2px; border-radius: 4px; padding: 0 .3rem; }
