/* =========================================================================
   HiringTests — "Network Operations Console"
   Thème sombre, grille blueprint, typographie IBM Plex, accent fibre cyan.
   ========================================================================= */

:root {
  --ink:        #0a0f14;
  --ink-2:      #0c1218;
  --surface:    #111b24;
  --surface-2:  #16242f;
  --surface-3:  #1c2e3b;
  --border:     #213240;
  --border-br:  #2d4456;
  --text:       #dbe7f0;
  --text-dim:   #93a8ba;
  --muted:      #607585;

  --cyan:       #2fd4c4;   /* signal fibre */
  --cyan-br:    #62ece0;
  --cyan-dim:   rgba(47,212,196,.14);
  --amber:      #f2b84c;
  --red:        #ff5d57;
  --green:      #46d97f;   /* link-up */

  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;

  --radius: 5px;
  --glow: 0 0 0 1px var(--border), 0 14px 40px rgba(0,0,0,.45);
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--ink);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---- Fond blueprint global ---- */
.bg-grid {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-color: var(--ink);
  background-image:
    linear-gradient(rgba(47,212,196,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47,212,196,.045) 1px, transparent 1px),
    radial-gradient(1200px 600px at 80% -10%, rgba(47,212,196,.10), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(98,236,224,.05), transparent 55%);
  background-size: 44px 44px, 44px 44px, 100% 100%, 100% 100%;
}
.bg-grid::after {  /* grain léger */
  content: ""; position: absolute; inset: 0; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: var(--cyan); text-decoration: none; }
a:hover { color: var(--cyan-br); }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.01em; }
code, .mono { font-family: var(--mono); }
::selection { background: rgba(47,212,196,.3); }

/* Labels techniques en capitales espacées */
.eyebrow, .kpi-lbl, .q-type, .open-grid h3, .score-form label,
.replay-toolbar label, .badge {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .68rem;
}

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes sweep { from { background-position: -150% 0; } to { background-position: 250% 0; } }

/* LED d'état */
.led { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 8px var(--green); margin-right: .5rem; vertical-align: middle; }
.led.amber { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.led.red { background: var(--red); box-shadow: 0 0 8px var(--red); animation: blink 1.1s infinite; }
.led.pulse { animation: blink 1.6s infinite; }

/* =====================  Boutons / champs  ===================== */
.btn-primary {
  font-family: var(--mono); font-weight: 600; letter-spacing: .04em;
  background: var(--cyan); color: #04241f; border: 0; border-radius: var(--radius);
  padding: .8rem 1.3rem; font-size: .95rem; cursor: pointer;
  transition: transform .08s, box-shadow .2s, background .2s;
  box-shadow: 0 6px 18px rgba(47,212,196,.22);
}
.btn-primary:hover { background: var(--cyan-br); box-shadow: 0 8px 24px rgba(47,212,196,.34); }
.btn-primary:active { transform: translateY(1px); }

.btn-link {
  font-family: var(--mono); font-size: .8rem; letter-spacing: .03em;
  background: none; border: 1px solid var(--border-br); color: var(--text-dim);
  border-radius: var(--radius); padding: .4rem .7rem; cursor: pointer; transition: .15s;
}
.btn-link:hover { color: var(--cyan-br); border-color: var(--cyan); text-decoration: none; }
.btn-link.danger { color: var(--red); border-color: transparent; }
.btn-link.danger:hover { border-color: var(--red); color: var(--red); }

input, textarea, select { font-family: var(--sans); color: var(--text); }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--cyan); outline-offset: 0; border-color: transparent; }
.muted { color: var(--muted); }
.error { color: var(--red); font-weight: 600; font-family: var(--mono); font-size: .9rem; }

/* =====================  Pages centrées (home / merci)  ===================== */
.centered { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 1.5rem; }

.card {
  position: relative; width: 100%; max-width: 440px;
  background: linear-gradient(180deg, var(--surface), var(--ink-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2.6rem 2.4rem; box-shadow: var(--glow);
  animation: rise .6s cubic-bezier(.2,.7,.2,1) both;
}
/* repère d'angle (registration mark) */
.card::before, .panel::before {
  content: ""; position: absolute; top: -1px; left: -1px; width: 18px; height: 18px;
  border-top: 2px solid var(--cyan); border-left: 2px solid var(--cyan); border-top-left-radius: var(--radius);
  opacity: .8;
}
.card .eyebrow { color: var(--cyan); display: block; margin-bottom: 1.4rem; }
.card h1 { margin: 0 0 .4rem; font-size: 1.7rem; }
.card .lead { color: var(--text-dim); margin: 0 0 .4rem; }

.code-input {
  width: 100%; margin: 1.6rem 0 1rem; padding: .95rem 1rem;
  font-family: var(--mono); font-size: 1.55rem; font-weight: 600;
  letter-spacing: .42em; text-align: center; text-transform: uppercase;
  background: var(--ink); border: 1px solid var(--border-br); border-radius: var(--radius); color: var(--cyan-br);
  caret-color: var(--cyan);
}
.code-input::placeholder { color: var(--muted); letter-spacing: .42em; }

.fineprint { color: var(--muted); font-size: .76rem; margin-top: 1.6rem; padding-top: 1.2rem; border-top: 1px dashed var(--border); }
.statusline { margin-top: 1.4rem; font-family: var(--mono); font-size: .72rem; color: var(--muted); letter-spacing: .06em; }

/* =====================  Examen candidat  ===================== */
.exam-header {
  position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center;
  padding: .85rem 1.6rem; background: rgba(12,18,24,.86); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.exam-header .brand { font-family: var(--mono); font-weight: 600; letter-spacing: .04em; font-size: .95rem; }
.exam-header .brand small { color: var(--muted); font-weight: 400; }
.timer {
  font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 1.35rem; font-weight: 700;
  padding: .25rem .85rem; border-radius: var(--radius); background: var(--surface-2);
  border: 1px solid var(--border-br); color: var(--cyan-br);
}
.timer::before { content: "⏱ "; color: var(--muted); font-size: .9rem; }
.timer.warning { color: #1a1205; background: var(--amber); border-color: var(--amber); }
.timer.danger { color: #fff; background: var(--red); border-color: var(--red); animation: blink 1s infinite; }

.exam-main { max-width: 820px; margin: 0 auto; padding: 2rem 1.5rem; }
.status-banner { font-family: var(--mono); font-size: .85rem; background: rgba(242,184,76,.12);
  border: 1px solid var(--amber); color: var(--amber); padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1.2rem; }

.q-card {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--border-br); border-radius: var(--radius);
  padding: 1.5rem 1.6rem; margin-bottom: 1.3rem; animation: rise .5s ease both;
  transition: border-color .2s;
}
.q-card:focus-within { border-left-color: var(--cyan); }
.q-card .q-num { font-family: var(--mono); color: var(--cyan); font-weight: 700; letter-spacing: .08em; margin-right: .55rem; }
.q-card .q-title { font-weight: 600; }
.q-card .q-statement { margin: .7rem 0 1.1rem; color: var(--text-dim); }
.q-card .q-statement p:first-child { margin-top: 0; }
.q-card .q-statement code { background: var(--ink); padding: .1rem .35rem; border-radius: 3px; color: var(--cyan-br); }

.choice {
  display: flex; gap: .7rem; align-items: flex-start; padding: .7rem .85rem;
  border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .55rem; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.choice:hover { background: var(--surface-2); border-color: var(--border-br); }
.choice input { margin-top: .3rem; accent-color: var(--cyan); width: 1rem; height: 1rem; }
.choice.checked { border-color: var(--cyan); background: var(--cyan-dim); }
.choice strong { font-family: var(--mono); color: var(--cyan-br); }

textarea.open-answer {
  width: 100%; min-height: 150px; resize: vertical; padding: .9rem; font-family: var(--sans); font-size: .98rem;
  background: var(--ink); border: 1px solid var(--border-br); border-radius: var(--radius); color: var(--text); line-height: 1.6;
}

.exam-actions { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: 1.8rem 0 4rem; }
#save-state { font-family: var(--mono); font-size: .78rem; color: var(--muted); }

.overlay { position: fixed; inset: 0; background: rgba(6,10,14,.94); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(4px); }
/* IMPORTANT : sans cette règle, `.overlay { display:flex }` neutralise l'attribut
   [hidden] (même spécificité) et l'overlay « Test terminé » reste affiché en
   permanence par-dessus l'épreuve. */
.overlay[hidden] { display: none; }
.overlay-card { position: relative; background: var(--surface); border: 1px solid var(--border-br); border-radius: var(--radius); padding: 2.8rem; max-width: 440px; text-align: center; box-shadow: var(--glow); }
.overlay-card h2 { margin-top: 0; }

/* =====================  Admin / console  ===================== */
.admin-header {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 1rem 1.6rem; background: rgba(12,18,24,.82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.admin-header h1 { font-family: var(--mono); font-size: 1.05rem; letter-spacing: .02em; margin: 0; font-weight: 600; }
.admin-header .code { font-size: 1rem; }
.admin-main { max-width: 1020px; margin: 0 auto; padding: 1.8rem 1.5rem 4rem; }

.panel {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.4rem 1.6rem; margin-bottom: 1.3rem;
  animation: rise .5s ease both;
}
.panel > h2 { font-family: var(--mono); font-size: .82rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-dim); margin: 0 0 1rem; }
.panel:nth-child(2) { animation-delay: .05s; }
.panel:nth-child(3) { animation-delay: .1s; }
.panel:nth-child(4) { animation-delay: .15s; }

.code { font-family: var(--mono); background: var(--ink); padding: .2rem .55rem; border-radius: 4px;
  letter-spacing: .16em; color: var(--cyan-br); border: 1px solid var(--border); }

.inline-form { display: flex; gap: .7rem; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 240px; padding: .7rem .9rem; background: var(--ink);
  border: 1px solid var(--border-br); border-radius: var(--radius); }

table.sessions { width: 100%; border-collapse: collapse; }
table.sessions th { font-family: var(--mono); text-transform: uppercase; letter-spacing: .1em; font-size: .68rem;
  color: var(--muted); text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border-br); }
table.sessions td { text-align: left; padding: .7rem .6rem; border-bottom: 1px solid var(--border); font-size: .92rem; vertical-align: middle; }
table.sessions tr:hover td { background: var(--surface-2); }
.row-actions { display: flex; gap: .35rem; align-items: center; }
.row-actions form { display: inline; }

.badge { display: inline-flex; align-items: center; padding: .25rem .65rem; border-radius: 999px; font-weight: 600;
  border: 1px solid transparent; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; margin-right: .45rem; }
.badge-created { background: var(--surface-3); color: var(--text-dim); }
.badge-created::before { background: var(--muted); }
.badge-in_progress { background: rgba(47,212,196,.12); color: var(--cyan-br); border-color: rgba(47,212,196,.35); }
.badge-in_progress::before { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); animation: blink 1.4s infinite; }
.badge-finished { background: rgba(70,217,127,.12); color: var(--green); border-color: rgba(70,217,127,.3); }
.badge-finished::before { background: var(--green); box-shadow: 0 0 7px var(--green); }

.warn { background: rgba(242,184,76,.1); border: 1px solid var(--amber); border-radius: var(--radius);
  padding: .8rem 1rem; margin-bottom: 1rem; color: #f6cd84; font-size: .9rem; }
.warn ul { margin: .4rem 0 0; padding-left: 1.2rem; }

/* ---- Correction : synthèse ---- */
.summary { display: flex; gap: 1rem; flex-wrap: wrap; }
.kpi { flex: 1; min-width: 150px; background: var(--ink); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem; }
.kpi-num { display: block; font-family: var(--mono); font-size: 1.7rem; font-weight: 700; color: var(--cyan-br); }
.kpi-lbl { color: var(--muted); display: block; margin-top: .25rem; }

.anticheat .flag { display: inline-flex; align-items: center; font-family: var(--mono); font-size: .78rem;
  background: var(--ink); border: 1px solid var(--border); padding: .35rem .75rem; border-radius: 999px; margin: .25rem .35rem .25rem 0; }
.flag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); margin-right: .45rem; }
.flag-bad { background: rgba(255,93,87,.1); border-color: rgba(255,93,87,.4); color: #ff9591; }
.flag-bad::before { background: var(--red); box-shadow: 0 0 7px var(--red); }

/* ---- Correction : questions ---- */
.question .q-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .6rem; }
.q-type { padding: .25rem .55rem; border-radius: 4px; }
.q-type-qcm { background: rgba(47,212,196,.14); color: var(--cyan-br); }
.q-type-open { background: rgba(242,184,76,.16); color: var(--amber); }
.q-pts { margin-left: auto; font-family: var(--mono); font-weight: 700; color: var(--cyan-br); }
.question .q-statement { color: var(--text-dim); margin-bottom: .9rem; }

.choices-review { list-style: none; padding: 0; margin: 0; }
.choices-review li { display: flex; gap: .55rem; align-items: baseline; padding: .5rem .7rem; border-radius: var(--radius);
  margin-bottom: .35rem; border: 1px solid var(--border); }
.choices-review li.correct { background: rgba(70,217,127,.1); border-color: rgba(70,217,127,.4); }
.choices-review li.picked:not(.correct) { background: rgba(255,93,87,.1); border-color: rgba(255,93,87,.4); }
.choices-review .mark { width: 1rem; font-weight: 700; font-family: var(--mono); }
.choices-review li.correct .mark { color: var(--green); }
.choices-review li.picked:not(.correct) .mark { color: var(--red); }
.choices-review strong { font-family: var(--mono); }
.choices-review .tag { font-family: var(--mono); font-size: .66rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); margin-left: .5rem; }
.choices-review .tag-ok { color: var(--green); }

.open-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; margin-bottom: 1.1rem; }
.open-grid h3 { color: var(--muted); margin: 0 0 .5rem; }
.answer-box { background: var(--ink); border: 1px solid var(--border-br); border-radius: var(--radius);
  padding: .9rem; white-space: pre-wrap; min-height: 90px; font-size: .92rem; }
.ref-box { background: rgba(70,217,127,.05); border: 1px solid rgba(70,217,127,.25); border-radius: var(--radius); padding: .9rem; font-size: .92rem; }
.ref-box ul { margin: .4rem 0; padding-left: 1.2rem; }
.ref-box strong { color: var(--green); }

.score-form { display: flex; gap: .9rem; align-items: flex-end; flex-wrap: wrap;
  border-top: 1px dashed var(--border); padding-top: 1rem; }
.score-form label { display: flex; flex-direction: column; color: var(--muted); gap: .35rem; }
.score-form label.grow { flex: 1; min-width: 220px; }
.score-form input { padding: .6rem .75rem; background: var(--ink); border: 1px solid var(--border-br); border-radius: var(--radius); font-family: var(--mono); }
.score-form input[type=number] { width: 90px; text-align: center; font-size: 1rem; }

@media (max-width: 640px) { .open-grid { grid-template-columns: 1fr; } .exam-header, .admin-header { padding: .75rem 1rem; } }

/* =====================  Replay  ===================== */
.replay-toolbar { display: flex; gap: .9rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.1rem; }
.replay-toolbar label { display: flex; align-items: center; gap: .4rem; color: var(--muted); }
.replay-toolbar select { background: var(--ink); border: 1px solid var(--border-br); border-radius: var(--radius); color: var(--text); padding: .45rem .5rem; font-family: var(--mono); }
.scrub { flex: 1; min-width: 220px; accent-color: var(--cyan); }
.clock { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 700; color: var(--cyan-br); }
#active-q { font-family: var(--mono); font-size: .78rem; }
.replay-stage { position: relative; background:
    repeating-linear-gradient(0deg, transparent, transparent 21px, rgba(47,212,196,.05) 22px),
    repeating-linear-gradient(90deg, transparent, transparent 21px, rgba(47,212,196,.05) 22px), var(--ink);
  border: 1px solid var(--border-br); border-radius: var(--radius); overflow: hidden; }
.replay-stage canvas { display: block; width: 100%; }
.replay-cursor { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  background: var(--cyan); box-shadow: 0 0 0 5px rgba(47,212,196,.25), 0 0 14px var(--cyan); pointer-events: none; }
.event-log { margin-top: 1.1rem; max-height: 240px; overflow: auto; font-family: var(--mono); font-size: .8rem;
  border: 1px solid var(--border); border-radius: var(--radius); }
.event-log .ev { padding: .3rem .6rem; border-bottom: 1px solid var(--border); cursor: pointer; color: var(--text-dim); }
.event-log .ev:hover { background: var(--surface-2); }
.event-log .ev.bad { color: #ff9591; }
.event-log .ev.now { background: var(--cyan-dim); color: var(--cyan-br); }

/* Scrollbars discrètes */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-br); border-radius: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
