/* =========================================================
   SPACE MANAGEMENT UI — CRT BRUT / PIXEL ORANGE HUD
   ========================================================= */

/* ---------- Thème & tokens ---------- */
:root {
  --bg-deep: #000000;          /* fond noir profond */
  --bg-panel: #0a0a0a;         /* panneaux */
  --ink: #ffb347;              /* texte principal orange chaud */
  --ink-mid: #ff9933;          /* secondaire plus sombre */
  --ink-dim: #cc7a29;          /* tertiaire */
  --line: #662b00;             /* séparateurs rouille */
  --line-strong: #ff6600;      /* séparateurs intenses */
  --accent: #ff8c00;           /* orange vif HUD */
  --accent-2: #ffaa33;         /* accent clair */
  --danger: #ff3300;           /* rouge alerte */
  --ok: #66ff66;               /* vert statuts */

  --radius: 4px;
}

/* ---------- Reset & base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
[hidden] { display: none !important; } /* utilitaire global */

body.pageBody {
  margin: 0;
  font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--bg-deep);
  color: var(--ink);
  text-rendering: optimizeSpeed;
  image-rendering: pixelated; /* grain brut */
  position: relative;
  overflow-x: hidden;
 animation: flicker 2s infinite both;
  /* léger zoom + bombé CRT */
  filter: url(#crt); /* nécessite le <svg> filtre dans le HTML */
}

/* ---------- Fond grille vectorielle animée ---------- */
.hudGrid {
  position: fixed;
  inset: 0;
  background:repeating-linear-gradient(
      to right,
      rgba(255,140,0,0.18) 0px,
      rgba(255,140,0,0.18) 6px,
      transparent 6px,
      transparent 40px
    ),
    repeating-linear-gradient(
      to top,
      rgba(255,140,0,0.18) 0px,
      rgba(255,140,0,0.18) 6px,
      transparent 6px,
      transparent 40px
    );
  background-size: 60px 60px;
  z-index: 0;
  animation: gridScroll 10s linear infinite;
  opacity: 0.25;
}
@keyframes gridScroll {
  0% { background-position: 0 0, 0 0; }
  25%  { background-position: 40px 40px, 40px 40px; }
  50% {background-position: 70px 20px, 70px 20px;}
  75% {background-position: 50px -30px, 50px -30px;}
  100% {background-position: 0 0, 0 0;}
}

/* ---------- Overlays CRT : scanlines + blink ---------- */
body.pageBody::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255,140,0,0.10) 0px,
      rgba(0,0,0,0.22) 3px
    ),
    repeating-linear-gradient(
      to right,
      rgba(255,140,0,0.06) 0px,
      rgba(0,0,0,0.18) 3px
    );
  mix-blend-mode: screen;
  z-index: 1;
}
body.pageBody::after {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(255,140,0,0.03);
  animation: crtBlink 0.6s infinite;
  animation: hudPulse .6s infinite;
  pointer-events: none;
  z-index: 2;
}

/* ---------- Structure ---------- */
.siteHeader, .siteFooter {
  position: relative;
  z-index: 3; /* au-dessus de la grille */
  padding: .6rem 1rem;
  border-bottom: 2px solid var(--line-strong);
  background: #0a0a0a;
}
.siteFooter {
  border-top: 2px solid var(--line-strong);
  border-bottom: none;
  color: var(--ink-dim);
}

.siteTitle {
  margin: 0;
  font-size: 1.25rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--accent);
  text-shadow: 0 0 6px var(--accent), 0 0 12px var(--accent);
}
.siteSubtitle, .footerNote {
  margin: .25rem 0 0;
  color: var(--ink-mid);
  font-size: .9rem;
}

/* Top nav + boutons dédiés */
.topNav {
  display: flex;
  gap: .5rem;
  align-items: center;
}
.buttonPrimary, .buttonSecondary, .buttonGhost, .buttonDanger, .buttonLink,
.buttonDashboard, .buttonLogout {
  position: relative;
  z-index: 3;
  padding: .42rem .8rem;
  border-radius: var(--radius);
  border: 2px solid var(--line-strong);
  background: #111;
  color: var(--ink);
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: .1em;
  cursor: pointer;
  image-rendering: pixelated;
}
.buttonPrimary { color: var(--accent); text-shadow: 0 0 6px var(--accent); }
.buttonSecondary { color: var(--accent-2); }
.buttonGhost { color: var(--ink-mid); border-color: var(--line); }
.buttonDanger { color: var(--danger); text-shadow: 0 0 6px var(--danger); }
.buttonLink { border: none; padding: 0 .25rem; text-decoration: underline; }

/* Boutons spécifiques */
.buttonDashboard {
  border-color: var(--accent-2);
  color: var(--accent-2);
  text-shadow: 0 0 6px var(--accent-2);
}
.buttonDashboard::before {
  content: "⌂ ";
  filter: drop-shadow(0 0 4px var(--accent-2));
}
.buttonLogout {
  border-color: var(--danger);
  color: var(--danger);
  text-shadow: 0 0 6px var(--danger);
}
.buttonLogout::before {
  content: "⎋ ";
  filter: drop-shadow(0 0 4px var(--danger));
}

.buttonPrimary:hover,
.buttonSecondary:hover,
.buttonGhost:hover,
.buttonDanger:hover,
.buttonDashboard:hover,
.buttonLogout:hover {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  text-shadow: none;
}
.buttonDanger:hover,
.buttonLogout:hover {
  background: var(--danger);
  border-color: var(--danger);
}
.buttonGhost:hover { background: #222; color: var(--ink); border-color: var(--line-strong); }

/* ---------- Grille principale ---------- */
.mainContent {
  position: relative;
  z-index: 3;
  padding: 1rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr 1fr; /* 2 colonnes desktop */
}

/* Panneaux */
.authSection, .recordSection, .historySection {
  border: 2px solid var(--line-strong);
  padding: .75rem;
  background: #111;
  box-shadow: inset 0 0 10px rgba(255,140,0,0.3);
   animation: bloom 2s infinite both;
}

/* Titres de section */
.sectionTitle {
  margin: 0 0 .5rem;
  font-size: 1rem;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: .15em;
  border-bottom: 2px dashed var(--line);
  padding-bottom: .25rem;
}

/* Historique */
.historyList {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: .3rem;
}
.historyItem {
  font-size: .8rem;
  color: var(--ink-dim);
  border-bottom: 1px dotted var(--line);
  padding: .2rem 0 .25rem 0;
  position: relative;
  padding-left: 1rem;
}
.historyItem::before {
  content: "►";
  position: absolute; left: 0; top: .1rem;
  color: var(--accent-2);
}

/* ---------- Formulaires ---------- */
.formBox { display: block; }
.formFieldset {
  border: 2px dashed var(--line-strong);
  padding: .6rem;
  border-radius: var(--radius);
  background: #0a0a0a;
}
.formLegend { color: var(--ink-dim); text-transform: uppercase; letter-spacing: .08em; }

.formRow { display: grid; gap: .25rem; margin-bottom: .7rem; }
.formRowInline { display: inline-flex; align-items: center; gap: .5rem; margin-right: .75rem; }

.formLabel { font-size: .85rem; color: var(--ink-mid); text-transform: uppercase; letter-spacing: .08em; }

.inputText, .inputNumber, .selectInput, .jsonOutput {
  width: 100%;
  padding: .4rem .5rem;
  background: #000;
  color: var(--ink);
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  font-weight: 700;
}
.inputNumber { max-width: 8rem; }
.selectInput { min-width: 14rem; }
.inputText:focus, .inputNumber:focus, .selectInput:focus, .jsonOutput:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 0 10px rgba(255,140,0,0.3);
   animation: bloom 2s infinite both;
}

/* ---------- Layout de jeu ---------- */
.gameLayout {
  position: relative; z-index: 3;
  display: grid;
  grid-template-rows: 3fr 1fr;
  height: calc(100vh - 72px);
  gap: .5rem;
  padding: .5rem;
}
.upperArea {
  display: grid;
  grid-template-columns: 4fr 1fr;
  gap: .5rem;
}
.commandsPanel, .percentagesPanel, .jsonArea {
  border: 2px solid var(--line-strong);
  background: rgba(10,10,10,0.6);
  padding: .5rem;
  box-shadow: inset 0 0 10px rgba(255,140,0,0.3);
   animation: bloom 2s infinite both;
  border-radius: var(--radius);
}
.commandBlock { border-top: 2px dashed var(--line); padding-top: .6rem; margin-top: .6rem; }
.commandTitle {
  margin: 0 0 .4rem;
  font-size: .95rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--accent-2);
}
.jsonArea { display: flex; flex-direction: column; }
.monoArea {
  flex: 1; resize: none; min-height: 8rem;
  background: #000;
  color: var(--accent-2);
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  padding: .5rem;
}

/* ---------- Barres de progression ---------- */
.stationList { width: 100%; display: grid; gap: .5rem; }
.stationCard {
  width: 100%;
  border: 2px dashed var(--line-strong);
  padding: .5rem;
  border-radius: var(--radius);
  background: #111;
}
.stationName {
  font-weight: 900;
  margin: 0 0 .25rem;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: .08em;
  text-shadow: 0 0 10px rgba(255,140,0,.25);
}
.percentageRow { display: grid; grid-template-columns: 1fr 4fr; gap: .5rem; align-items: center; }
.percentageLabel { font-size: .78rem; color: var(--ink-dim); white-space: nowrap; }

.progressTrack {
  height: 10px;
  background: #000;
  border: 2px solid var(--line-strong);
}
.progressFill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
   animation: bloom 2s infinite both;
  transition: width .3s steps(5, end);
}
.progressFill.importFill { background: var(--danger); box-shadow: inset 0 0 10px var(--danger); animation: bloom 2s infinite both;}
.progressFill.exportFill { background: var(--ok); box-shadow: inset 0 0 10px var(--ok); }

/* ---------- Modal Game Over ---------- */
.gameOverModal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex; justify-content: center; align-items: center;
  z-index: 9999; /* au-dessus de tout */
}
.gameOverModal[hidden] { display: none !important; } /* cache proprement la modal */

.modalContent {
  border: 2px solid var(--line-strong);
  background: #111;
  padding: 1rem;
  color: var(--ink);
  text-align: center;
  text-shadow: 0 0 6px var(--accent);
  max-width: 520px;
  border-radius: var(--radius);
}
.modalContent .sectionTitle {
  border: none;
  color: var(--accent);
  text-shadow: 0 0 12px var(--accent);
}

/* ---------- États & accessibilité ---------- */
.statusMessage[hidden] { display: none !important; }
.textFeedback { margin-top: .6rem; color: var(--ok); text-shadow: 0 0 6px var(--ok); }
.monoMini { font-size: .85rem; color: var(--ink-dim); }
.inlineActions { display: flex; gap: .5rem; flex-wrap: wrap; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
[disabled], .is-disabled { opacity: .55; filter: grayscale(.2); cursor: not-allowed !important; }

/* ---------- Animations ---------- */
@keyframes crtBlink {
  0%,100% { opacity: 1; }
  50% { opacity: 0.7; }
}
@keyframes hudPulse {
  0%,100% { text-shadow: 0 0 3px var(--accent), 0 0 6px var(--accent); }
  50% { text-shadow: 0 0 12px var(--accent), 0 0 24px var(--accent); }
}
@keyframes bloom {
  0% { box-shadow: inset 0 0 10px;}
  50% { box-shadow: inset 0 0 5px;}
  100% { box-shadow: inset 0 0 10px;}
} 


/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .mainContent { grid-template-columns: 1fr; } /* stack en colonne */
  .gameLayout { display: block; height: auto; }
  .upperArea, .commandsPanel, .percentagesPanel, .jsonArea {
    display: block; width: 100%; margin-bottom: .5rem; min-height: auto;
  }
  .percentageRow { grid-template-columns: 1fr 3fr; }
  .jsonArea { min-height: 12rem; }
  .stationList { grid-template-columns: 1fr; }
}
