/* ==========================================================================
   CyberRange Lab — feuille de style unique.
   Objectif : lisible, sobre, lisible sur téléphone. Pas de dépendance
   externe (aucune police ni script téléchargé depuis Internet).
   ========================================================================== */

:root {
  --bg:        #070b12;
  --bg-soft:   #0d1420;
  --bg-card:   #111a28;
  --line:      #1e2a3d;
  --line-soft: #172234;
  --text:      #e6edf6;
  --muted:     #8a9bb5;
  --accent:    #4dd4ac;
  --accent-2:  #4b9dff;
  --warn:      #ffb347;
  --bad:       #ff6b6b;
  --ok:        #4dd4ac;
  --radius:    12px;
  --shadow:    0 8px 24px rgba(0,0,0,.35);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); font-size: .92em; }
code {
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: .1em .4em;
}
pre {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6rem; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .9rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.inline { display: inline; }
.accent { color: var(--accent); }

/* --- Barre supérieure ---------------------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap;
  padding: .7rem 1.2rem;
  background: rgba(13,20,32,.92);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04121a; font-weight: 800; font-size: .85rem;
}
.nav { display: flex; gap: .2rem; flex-wrap: wrap; }
.nav a {
  color: var(--muted); padding: .35rem .7rem; border-radius: 8px; font-size: .93rem;
}
.nav a:hover { color: var(--text); background: var(--bg-card); text-decoration: none; }
.nav a.on { color: var(--text); background: var(--bg-card); }
.nav a.admin-link { color: var(--warn); }
.userbox { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.userlink { color: var(--text); font-size: .93rem; }

/* --- Structure ----------------------------------------------------------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 1.6rem 1.2rem 3rem; }
.narrow { max-width: 620px; margin: 0 auto; }
.center-block { text-align: center; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.3rem;
}
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.grid { display: grid; gap: 1rem; margin-bottom: 1.2rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: .8rem; }

/* --- Cartes -------------------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1.2rem;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: .7rem; flex-wrap: wrap;
}
.card.note-card { border-color: #2a3550; background: linear-gradient(180deg, #101a2b, #0d1420); }

/* --- Boutons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem .95rem; border-radius: 9px; border: 1px solid transparent;
  font-size: .93rem; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: transform .06s ease, background .15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); color: #04121a; }
.btn-primary:hover { background: #5fe0b8; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--bg-soft); }
.btn-danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: rgba(255,107,107,.12); }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; }
.btn-lg { padding: .7rem 1.3rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: .4rem; flex-wrap: wrap; }

/* --- Formulaires --------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: .3rem; }
.field > span { font-size: .88rem; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], select, textarea {
  width: 100%; padding: .6rem .75rem;
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  font-family: inherit; font-size: .95rem;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(75,157,255,.35); border-color: var(--accent-2);
}
.otp-input { font-family: var(--mono); font-size: 1.5rem; letter-spacing: .35em; text-align: center; }
textarea { min-height: 110px; resize: vertical; }

/* --- Badges -------------------------------------------------------------- */
.badge {
  display: inline-block; padding: .15rem .5rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--muted);
}
.badge-running { color: #04121a; background: var(--ok); border-color: transparent; }
.badge-creating { color: #04121a; background: var(--accent-2); border-color: transparent; }
.badge-stopped { color: var(--muted); }
.badge-expired, .badge-destroyed { color: var(--muted); }
.badge-error { color: #fff; background: var(--bad); border-color: transparent; }
.badge-warning { color: #2a1a00; background: var(--warn); border-color: transparent; }
.badge-points { color: var(--accent); border-color: rgba(77,212,172,.35); }
.badge-debutant { color: var(--accent); border-color: rgba(77,212,172,.35); }
.badge-intermediaire { color: var(--warn); border-color: rgba(255,179,71,.35); }
.badge-avance { color: var(--bad); border-color: rgba(255,107,107,.35); }

/* --- Tableaux ------------------------------------------------------------ */
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th {
  text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--line); padding: .5rem .6rem;
}
.table td { padding: .6rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table-compact td, .table-compact th { padding: .35rem .5rem; }

/* --- Messages flash ------------------------------------------------------ */
.flashes { max-width: 1120px; margin: 1rem auto -0.4rem; padding: 0 1.2rem; display: flex; flex-direction: column; gap: .5rem; }
.flash {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .9rem; border-radius: 10px; font-size: .93rem;
  background: var(--bg-card); border: 1px solid var(--line);
}
.flash-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); flex: none; }
.flash-success { border-color: rgba(77,212,172,.4); }
.flash-success .flash-dot { background: var(--ok); }
.flash-warning { border-color: rgba(255,179,71,.4); }
.flash-warning .flash-dot { background: var(--warn); }
.flash-error { border-color: rgba(255,107,107,.4); }
.flash-error .flash-dot { background: var(--bad); }

/* --- Statistiques -------------------------------------------------------- */
.stat { display: flex; flex-direction: column; gap: .35rem; }
.stat-label { font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-value small { font-size: 1rem; color: var(--muted); font-weight: 400; }
.bar { height: 7px; background: var(--bg-soft); border-radius: 99px; overflow: hidden; border: 1px solid var(--line-soft); }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.numbers div { display: flex; flex-direction: column; }
.numbers strong { font-size: 1.8rem; }

/* --- Listes -------------------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  padding: .5rem 0; border-bottom: 1px solid var(--line-soft);
}
.list li:last-child { border-bottom: none; }
.ticks { list-style: none; padding: 0; margin: 0; }
.ticks li { padding: .3rem 0 .3rem 1.5rem; position: relative; }
.ticks li::before {
  content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 700;
}
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; align-items: center; gap: .7rem; padding: .35rem 0; font-size: .9rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); }
.dot.ko { background: var(--bad); }

/* --- Accueil ------------------------------------------------------------- */
.hero { padding: 2.5rem 0 1.5rem; }
.hero h1 { font-size: 2.4rem; max-width: 20ch; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 60ch; margin-bottom: 1.4rem; }

/* --- Authentification ---------------------------------------------------- */
.auth-shell {
  display: grid; grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 1.2rem; align-items: start; max-width: 900px; margin: 1rem auto;
}
@media (max-width: 760px) { .auth-shell { grid-template-columns: 1fr; } }
.auth-card { margin-bottom: 0; }
.auth-aside { margin-bottom: 0; }
.qr-card { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.qr-card svg { width: 168px; height: 168px; background: #fff; border-radius: 8px; padding: 6px; }
.qr-side { flex: 1; min-width: 200px; }
.secret { display: block; word-break: break-all; padding: .5rem; background: var(--bg-soft); border-radius: 8px; }

/* --- Terminal ------------------------------------------------------------ */
.terminal {
  background: #04070c; border: 1px solid var(--line); border-radius: var(--radius);
  height: 60vh; min-height: 380px; padding: .6rem; overflow: hidden;
}
.terminal-status { font-size: .85rem; color: var(--muted); margin: .4rem 0; display: flex; gap: .8rem; align-items: center; }

/* --- Divers -------------------------------------------------------------- */
.big-code { font-size: 3.5rem; font-weight: 800; color: var(--accent-2); line-height: 1; }
.footer {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 1.2rem; border-top: 1px solid var(--line); font-size: .85rem; color: var(--muted);
}
.hint { border-left: 3px solid var(--warn); padding-left: .8rem; margin: .6rem 0; }
.lesson-body { max-width: 72ch; }
.lesson-body h2 { margin-top: 1.6rem; }
.lesson-body ul { padding-left: 1.3rem; }
.lesson-body table { width: 100%; border-collapse: collapse; margin: .8rem 0; }
.lesson-body th, .lesson-body td { border: 1px solid var(--line); padding: .45rem .6rem; text-align: left; }
.copyable { display: flex; gap: .5rem; align-items: center; }
.danger-zone { border-color: rgba(255,107,107,.35); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem .9rem; font-size: .93rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); }


/* ==========================================================================
   Compléments : fiches de machines, cours, administration.
   Ajoutés après la première version — mêmes variables, même logique.
   ========================================================================== */

.breadcrumb { color: var(--muted); font-size: .85rem; margin-bottom: .8rem; }
.section-title {
  font-size: 1.05rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 1.8rem 0 .8rem;
}

/* --- Fiche machine --- */
.machine { display: flex; flex-direction: column; gap: .6rem; }
.machine-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.machine-head h3 { margin: 0; }
.machine-meta { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.machine-meta li { display: flex; justify-content: space-between; gap: 1rem; font-size: .88rem; }
.machine-meta .k { color: var(--muted); }
.machine-actions { display: flex; gap: .5rem; align-items: center; margin-top: auto; padding-top: .5rem; }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* --- Texte long (cours, descriptions) --- */
.prose { line-height: 1.7; }
.prose h2 { margin-top: 1.6rem; font-size: 1.15rem; }
.prose h3 { margin-top: 1.3rem; font-size: 1rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin-bottom: .35rem; }
.prose table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: .9rem; }
.prose th, .prose td { border: 1px solid var(--line); padding: .45rem .6rem; text-align: left; }
.prose th { background: var(--bg-soft); }
.prose blockquote {
  margin: 1rem 0; padding: .6rem 1rem; border-left: 3px solid var(--accent-2);
  background: var(--bg-soft); border-radius: 0 8px 8px 0;
}
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.6rem 0; }

/* --- Bandeaux d'avertissement --- */
.banner {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .8rem 1rem; border-radius: var(--radius);
  background: var(--bg-card); border: 1px solid var(--line);
  margin-bottom: 1.2rem;
}
.banner-warn { border-left: 3px solid var(--warn); }
.banner-ok { border-left: 3px solid var(--ok); }

.badge-ok { background: rgba(77,212,172,.16); color: var(--ok); border-color: rgba(77,212,172,.35); }
.badge-outils, .badge-api { background: rgba(75,157,255,.14); color: var(--accent-2); border-color: rgba(75,157,255,.3); }
.ok-text { color: var(--ok); }

/* --- Terminal --- */
.term-shell {
  background: #05080e; border: 1px solid var(--line); border-radius: var(--radius);
  padding: .5rem; height: 70vh; min-height: 380px;
}
.term-shell .xterm { height: 100%; }
.term-toolbar {
  display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .8rem;
}


/* --- Listes de leçons, discussion, terminal large --- */
.wrap-wide { max-width: 1400px; }

.bar-lg { height: 10px; }

.list li.done a { color: var(--muted); }
.list-lessons li { align-items: flex-start; }
.lesson-line { display: flex; flex-direction: column; flex: 1; }
.lesson-line span { margin-top: .1rem; }
.tick {
  font-family: var(--mono); color: var(--ok); width: 1.2rem; flex: 0 0 1.2rem;
  text-align: center; padding-top: .1rem;
}
.lesson-nav {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  margin: 2rem 0 3rem; flex-wrap: wrap;
}

.table tr.done { opacity: .72; }
tr.me { background: rgba(77,212,172,.07); }

/* --- Discussion avec l'assistant --- */
.chat-layout { align-items: start; }
.side-list { position: sticky; top: 1rem; }
.side-list .list li.on a { color: var(--accent); font-weight: 600; }
.list-suggestions li { display: block; line-height: 1.4; }
.chat { display: flex; flex-direction: column; min-height: 60vh; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.chat-body { flex: 1; display: flex; flex-direction: column; gap: .8rem; margin: 1rem 0; }
.bubble {
  padding: .7rem 1rem; border-radius: 14px; max-width: 88%;
  border: 1px solid var(--line);
}
.bubble p:last-child { margin-bottom: 0; }
.bubble-user {
  align-self: flex-end; background: rgba(75,157,255,.13);
  border-color: rgba(75,157,255,.35); white-space: pre-wrap;
}
.bubble-ai { align-self: flex-start; background: var(--bg-soft); }
.chat-form { display: flex; flex-direction: column; gap: .6rem; }
.chat-form textarea {
  width: 100%; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .7rem .9rem; font-family: inherit; font-size: 1rem; resize: vertical;
}
.chat-form textarea:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; }


/* --- Administration --- */
.admin-nav {
  display: flex; gap: .4rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); margin-bottom: 1.4rem; padding-bottom: .6rem;
}
.admin-nav a {
  padding: .35rem .75rem; border-radius: 8px; color: var(--muted); font-size: .92rem;
}
.admin-nav a:hover { background: var(--bg-soft); text-decoration: none; }
.admin-nav a.on { background: var(--bg-card); color: var(--text); border: 1px solid var(--line); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem; }
.field-wide { grid-column: 1 / -1; }
.form-grid textarea, .form-grid input, .form-grid select {
  width: 100%; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem;
  font-family: inherit; font-size: .95rem;
}
.form-grid textarea { resize: vertical; font-family: var(--mono); font-size: .88rem; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field > span { color: var(--muted); font-size: .85rem; }
