/* Hadale — « station abyssale », néons 80s et fosse océanique.
   Les couleurs qui portent l'information (barres, statuts) sont validées pour le
   mode sombre : bande de luminosité, écart perceptif y compris en vision
   daltonienne, contraste ≥ 3:1 sur la surface des panneaux. Les néons vifs ne
   servent qu'au décor : halos, bordures, titres. */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@500;700&family=Chakra+Petch:wght@400;500;600&display=swap');

:root {
  color-scheme: dark;

  /* Profondeurs */
  --abyss: #02060c;
  --plane: #060d1a;
  --surface: #0a1424;
  --surface-2: #0e1b2f;
  --line: rgba(120, 200, 255, 0.16);
  --line-strong: rgba(120, 200, 255, 0.34);

  /* Encre */
  --ink: #e6f4ff;
  --ink-2: #a3bcd6;
  --muted: #6e88a3;

  /* Néons (décor) */
  --neon-cyan: #35e6ff;
  --neon-magenta: #ff4fd8;
  --neon-violet: #b79bff;

  /* Données (validées) */
  --series-think: #0f9cbb;
  --series-act: #8a5cf0;
  --ok: #12a970;
  --warning: #bf8420;
  --ko: #e0415a;
  --grid: rgba(120, 200, 255, 0.12);
  --axis: rgba(120, 200, 255, 0.28);

  /* Halos de texte pour les états */
  --ok-ink: #3fe3a4;
  --warning-ink: #f5c25a;
  --ko-ink: #ff7189;

  --radius: 4px;
  --font-display: 'Orbitron', system-ui, sans-serif;
  --font-ui: 'Chakra Petch', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(255, 79, 216, 0.12), transparent 60%),
    radial-gradient(90% 50% at 50% 0%, rgba(53, 230, 255, 0.10), transparent 70%),
    linear-gradient(180deg, var(--plane) 0%, var(--abyss) 70%);
  background-attachment: fixed;
  color: var(--ink);
  font: 15px/1.55 var(--font-ui);
  letter-spacing: 0.01em;
}

/* Grille en perspective : l'horizon synthwave, vu depuis la fosse. */
body::before {
  content: "";
  position: fixed;
  inset: 45% -20% -20%;
  z-index: -2;
  background:
    repeating-linear-gradient(90deg, transparent 0 78px, rgba(53, 230, 255, 0.30) 78px 80px),
    repeating-linear-gradient(0deg, transparent 0 78px, rgba(255, 79, 216, 0.22) 78px 80px);
  transform: perspective(300px) rotateX(74deg);
  transform-origin: top center;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 70%);
  mask-image: linear-gradient(to bottom, #000 0%, transparent 70%);
  opacity: 0.5;
  pointer-events: none;
  animation: derive 22s linear infinite;
}

/* Balayage de vieux moniteur, très léger pour ne pas gêner la lecture. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.30) 0 1px, transparent 1px 3px);
  opacity: 0.30;
  pointer-events: none;
}

@keyframes derive { to { background-position: 0 80px, 0 80px; } }
@keyframes pulsation { 50% { opacity: 0.35; } }
@keyframes sonar { 0% { opacity: 0.25; } 50% { opacity: 1; } 100% { opacity: 0.25; } }

@media (prefers-reduced-motion: reduce) {
  *, body::before { animation: none !important; transition: none !important; }
}

a { color: var(--neon-cyan); text-decoration: none; }
a:hover { text-shadow: 0 0 10px rgba(53, 230, 255, 0.6); }

h1 { font-family: var(--font-display); font-size: 19px; font-weight: 700; margin: 0 0 6px; letter-spacing: 0.04em; }
h2 {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  margin: 0 0 16px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--neon-cyan);
  text-shadow: 0 0 14px rgba(53, 230, 255, 0.35);
}
h2 .muted { color: var(--muted); text-shadow: none; letter-spacing: 0.08em; }

.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.empty { color: var(--muted); margin: 10px 0; font-style: italic; }

/* ---- Connexion : sas de plongée ---- */
.page-login { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card {
  position: relative;
  width: min(380px, 94vw);
  padding: 34px 30px;
  background: linear-gradient(160deg, rgba(14, 27, 47, 0.95), rgba(6, 13, 26, 0.95));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 0 60px rgba(53, 230, 255, 0.12), inset 0 0 40px rgba(53, 230, 255, 0.05);
  text-align: center;
}
.login-card h1 {
  font-size: 34px;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  background: linear-gradient(180deg, #ffffff 10%, var(--neon-cyan) 55%, var(--neon-magenta) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(53, 230, 255, 0.45));
}
.login-card .muted { font-size: 12px; text-transform: uppercase; letter-spacing: 0.18em; }
.login-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 26px; text-align: left; }
.login-card label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.18em; color: var(--ink-2); }
.login-card .error { color: var(--ko-ink); font-size: 13px; margin: 0; }
.login-card button {
  margin-top: 6px;
  background: linear-gradient(180deg, rgba(53, 230, 255, 0.22), rgba(255, 79, 216, 0.18));
  border-color: var(--neon-cyan);
  color: var(--ink);
  text-shadow: 0 0 12px rgba(53, 230, 255, 0.55);
}
.login-card button:hover { box-shadow: 0 0 24px rgba(53, 230, 255, 0.35); }

input, select, button, textarea { font: inherit; color: inherit; }
input, select {
  width: 100%;
  padding: 10px 12px;
  background: rgba(2, 6, 12, 0.6);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 1px rgba(53, 230, 255, 0.35), 0 0 18px rgba(53, 230, 255, 0.18);
}
button, .chip {
  display: inline-block;
  padding: 7px 14px;
  background: rgba(53, 230, 255, 0.07);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
button:hover, .chip:hover {
  color: var(--ink);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 18px rgba(53, 230, 255, 0.22);
  text-decoration: none;
}
.chip.actif, button[aria-pressed="true"] {
  color: var(--abyss);
  background: linear-gradient(180deg, var(--neon-cyan), #14b8d8);
  border-color: transparent;
  box-shadow: 0 0 22px rgba(53, 230, 255, 0.45);
}

/* ---- Structure ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px 24px;
  background: linear-gradient(180deg, rgba(10, 20, 36, 0.92), rgba(6, 13, 26, 0.75));
  border-bottom: 1px solid var(--line-strong);
  box-shadow: 0 1px 30px rgba(53, 230, 255, 0.10);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(6px);
}
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  background: linear-gradient(180deg, #ffffff, var(--neon-cyan) 60%, var(--neon-magenta));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 12px rgba(53, 230, 255, 0.4));
}
.brand a { color: inherit; }
.depth {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  border-left: 1px solid var(--line);
  padding-left: 14px;
}
.depth b { color: var(--neon-cyan); font-weight: 600; }
.periods { display: flex; gap: 6px; flex-wrap: wrap; }
.topbar-right { margin-left: auto; display: flex; gap: 6px; }

.wrap { max-width: 1140px; margin: 0 auto; padding: 24px 20px 60px; display: flex; flex-direction: column; gap: 18px; }

.card {
  position: relative;
  padding: 20px 22px;
  background: linear-gradient(170deg, rgba(14, 27, 47, 0.82), rgba(8, 16, 28, 0.88));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(120, 200, 255, 0.06), 0 12px 40px rgba(2, 6, 12, 0.5);
}
/* Équerres de visée, dans l'esprit des interfaces de l'époque. */
.card::before, .card::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1px solid var(--neon-cyan);
  opacity: 0.5;
  pointer-events: none;
}
.card::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.card::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.card-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; justify-content: space-between; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 920px) { .two-columns { grid-template-columns: 1fr; } }

/* ---- Chiffres clés ---- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
@media (max-width: 920px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile {
  position: relative;
  padding: 16px 18px;
  background: linear-gradient(170deg, rgba(14, 27, 47, 0.8), rgba(8, 16, 28, 0.9));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.tile::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--neon-cyan), transparent);
  opacity: 0.6;
}
.tile-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.2em; color: var(--muted); }
.tile-value {
  display: block;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
  margin: 6px 0 2px;
  text-shadow: 0 0 22px rgba(53, 230, 255, 0.35);
}
.tile-value.bon { color: var(--ok-ink); text-shadow: 0 0 22px rgba(18, 169, 112, 0.5); }
.tile-value.moyen { color: var(--warning-ink); text-shadow: 0 0 22px rgba(191, 132, 32, 0.45); }
.tile-value.mauvais { color: var(--ko-ink); text-shadow: 0 0 22px rgba(224, 65, 90, 0.45); }
.tile-sub { font-size: 12px; color: var(--muted); }

/* ---- Tableaux ---- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--neon-cyan);
  padding: 8px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
td { padding: 10px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.15s, box-shadow 0.15s; }
.runs tbody tr { cursor: pointer; }
.runs tbody tr:hover, .steps tbody tr:hover {
  background: linear-gradient(90deg, rgba(53, 230, 255, 0.10), transparent 70%);
  box-shadow: inset 2px 0 0 var(--neon-cyan);
}
.ligne-ko { background: linear-gradient(90deg, rgba(224, 65, 90, 0.12), transparent 70%); }
.ko-text { color: var(--ko-ink); }
.warn { color: var(--warning-ink); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.badge.ok { color: var(--ok-ink); background: rgba(18, 169, 112, 0.14); box-shadow: 0 0 14px rgba(18, 169, 112, 0.22); }
.badge.ko { color: var(--ko-ink); background: rgba(224, 65, 90, 0.14); box-shadow: 0 0 14px rgba(224, 65, 90, 0.22); }
.badge.moyen { color: var(--warning-ink); background: rgba(191, 132, 32, 0.14); box-shadow: 0 0 14px rgba(191, 132, 32, 0.20); }
.badge.neutre { color: var(--ink-2); background: rgba(120, 200, 255, 0.07); border-color: var(--line-strong); }
.badge.type-explorateur { color: #6fd9f0; background: rgba(15, 156, 187, 0.16); box-shadow: 0 0 14px rgba(15, 156, 187, 0.25); }
.badge.type-ouvrier { color: var(--neon-violet); background: rgba(138, 92, 240, 0.16); box-shadow: 0 0 14px rgba(138, 92, 240, 0.25); }

.meter {
  display: inline-block;
  width: 92px;
  height: 7px;
  background: rgba(2, 6, 12, 0.8);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  vertical-align: middle;
}
.meter span { display: block; height: 100%; background: var(--series-think); }
.meter span.bon { background: linear-gradient(90deg, var(--ok), var(--ok-ink)); box-shadow: 0 0 12px rgba(18, 169, 112, 0.6); }
.meter span.moyen { background: linear-gradient(90deg, var(--warning), var(--warning-ink)); box-shadow: 0 0 12px rgba(191, 132, 32, 0.5); }
.meter span.mauvais { background: linear-gradient(90deg, var(--ko), var(--ko-ink)); box-shadow: 0 0 12px rgba(224, 65, 90, 0.5); }
.meter-value { font-size: 12px; color: var(--ink-2); margin-left: 8px; font-variant-numeric: tabular-nums; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input[type="search"] { width: auto; min-width: 140px; font-size: 12px; padding: 7px 10px; }
.pagination { display: flex; align-items: center; gap: 14px; justify-content: center; margin-top: 18px; font-size: 12px; }

/* ---- Graphiques ---- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick, .chart .row-label, .chart .row-value {
  fill: var(--muted);
  font-size: 10px;
  font-family: var(--font-ui);
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}
.chart .row-label { fill: var(--ink-2); text-transform: uppercase; }
.chart .row-value.ko { fill: var(--ko-ink); }
.chart .bar, .chart .span { transition: filter 0.15s, opacity 0.15s; }
.chart .bar.ok { fill: var(--ok); filter: drop-shadow(0 0 5px rgba(18, 169, 112, 0.55)); }
.chart .bar.ko { fill: var(--ko); filter: drop-shadow(0 0 5px rgba(224, 65, 90, 0.5)); }
.chart .bar.neutre { fill: var(--muted); }
.chart .bar.vide { fill: rgba(120, 200, 255, 0.18); }
.chart .span.think { fill: var(--series-think); filter: drop-shadow(0 0 5px rgba(15, 156, 187, 0.6)); }
.chart .span.act { fill: var(--series-act); filter: drop-shadow(0 0 5px rgba(138, 92, 240, 0.6)); }
.chart .bar:hover, .chart .span:hover { opacity: 0.8; filter: drop-shadow(0 0 10px currentColor); }

.legend {
  list-style: none;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin: 14px 0 0;
  padding: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-2);
}
.legend li { display: flex; align-items: center; gap: 7px; }
.key { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.key.ok { background: var(--ok); box-shadow: 0 0 8px rgba(18, 169, 112, 0.8); }
.key.ko { background: var(--ko); box-shadow: 0 0 8px rgba(224, 65, 90, 0.8); }
.key.neutre { background: var(--muted); }
.key.think { background: var(--series-think); box-shadow: 0 0 8px rgba(15, 156, 187, 0.9); }
.key.act { background: var(--series-act); box-shadow: 0 0 8px rgba(138, 92, 240, 0.9); }

/* Historique d'une mission : bande sonar */
.history {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: rgba(2, 6, 12, 0.5);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.history .dot { width: 16px; height: 16px; border-radius: 2px; display: block; }
.history .dot.ok { background: var(--ok); box-shadow: 0 0 10px rgba(18, 169, 112, 0.7); }
.history .dot.ko { background: var(--ko); box-shadow: 0 0 10px rgba(224, 65, 90, 0.7); }
.history .dot.neutre { background: var(--muted); }
.history .dot.courant { outline: 1px solid var(--neon-cyan); outline-offset: 3px; animation: sonar 2.4s ease-in-out infinite; }

/* ---- Détail d'une exécution ---- */
.run-head h1 { font-size: 20px; }
.tags { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 14px 0 0; font-size: 12px; }
.pages { margin: 0; padding-left: 22px; font-size: 13px; display: flex; flex-direction: column; gap: 6px; color: var(--ink-2); }
.pages::marker, .pages li::marker { color: var(--neon-cyan); }
.hosts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px 24px; font-size: 13px; }
.hosts li { display: flex; gap: 8px; align-items: baseline; }
.host { font-weight: 600; color: var(--neon-cyan); letter-spacing: 0.04em; }
.url { color: var(--ink-2); word-break: break-all; }
.resultat { margin: 0; white-space: pre-line; color: var(--ink); }

/* ---- Infobulles ---- */
#tip {
  position: fixed;
  z-index: 20;
  padding: 8px 11px;
  background: rgba(2, 6, 12, 0.96);
  border: 1px solid var(--neon-cyan);
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 12px;
  letter-spacing: 0.02em;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  max-width: 300px;
  box-shadow: 0 0 24px rgba(53, 230, 255, 0.28);
}
#tip.visible { opacity: 1; }

/* Témoin du suivi direct : éteint au repos, il bat quand la veille est active. */
.dot-live {
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
  background: var(--muted);
  opacity: 0.6;
}
button[aria-pressed="true"] .dot-live {
  background: var(--abyss);
  opacity: 1;
  animation: pulsation 2s ease-in-out infinite;
}
