/*
 * WIIO WMS — feuille de style.
 *
 * Le vocabulaire visuel vient de l'entrepot lui-meme : le gris beton du sol,
 * l'asphalte des allees, et surtout L'ETIQUETTE D'EMPLACEMENT JAUNE des
 * racks. Ce que l'operateur doit trouver ou scanner (emplacement, chevalet,
 * palette) est affiche comme cette etiquette : c'est le seul element appuye
 * de la page, tout le reste est calme et lisible a bout de bras.
 */

:root {
  --beton: #e6e9ec;
  --asphalte: #1e2a33;
  --encre: #16212a;
  --gris: #5b6874;
  --trait: #c9d0d6;
  --blanc: #ffffff;
  --jaune: #f4c21a;
  --jaune-fonce: #c99a00;
  --vert: #1f8a57;
  --vert-clair: #e2f3ea;
  --rouge: #c4382b;
  --rouge-clair: #fbe7e4;

  --police: "Bahnschrift", "DIN Alternate", "Barlow", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --r: 10px;
  --largeur: 560px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--beton);
  color: var(--encre);
  font-family: var(--police);
  font-size: 17px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

button, input { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--jaune); outline-offset: 2px; }

/* --- La barre du haut ------------------------------------------------------- */

.barre {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px max(14px, env(safe-area-inset-left)) 10px max(14px, env(safe-area-inset-right));
  background: var(--asphalte);
  color: var(--blanc);
}

.barre-titres { flex: 1; min-width: 0; }
.barre h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barre p { margin: 0; font-size: 14px; color: #a9b6c1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barre p:empty { display: none; }

.retour {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--blanc);
  cursor: pointer;
}
.retour svg { width: 26px; height: 26px; }
.retour:hover { background: #2c3b47; }

.operateur {
  border: 1px solid #3d4e5b;
  border-radius: 999px;
  background: transparent;
  color: #d4dde4;
  padding: 6px 12px;
  font-size: 15px;
  cursor: pointer;
}

/* La progression d'une mission : un segment par ligne. */
.progression {
  display: flex;
  gap: 3px;
  padding: 0 14px 8px;
  background: var(--asphalte);
}
.progression span { flex: 1; height: 5px; border-radius: 3px; background: #3d4e5b; }
.progression span.fait { background: var(--vert); }
.progression span.rupture { background: var(--rouge); }
.progression span.courant { background: var(--jaune); }

/* --- L'ecran ---------------------------------------------------------------------- */

main {
  flex: 1;
  width: 100%;
  max-width: var(--largeur);
  margin: 0 auto;
  padding: 18px 16px 120px;
}

.chargement { color: var(--gris); }

.consigne {
  margin: 4px 0 14px;
  font-size: 23px;
  font-weight: 600;
  line-height: 1.2;
}

.texte { margin: 0 0 12px; color: var(--gris); }

/* L'etiquette d'emplacement : ce qu'il faut trouver ou scanner. */
.etiquette {
  display: flex;
  align-items: stretch;
  margin: 0 0 16px;
  border: 3px solid var(--encre);
  border-radius: 6px;
  background: var(--jaune);
  color: var(--encre);
  overflow: hidden;
}
.etiquette-nom {
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: var(--encre);
  color: var(--jaune);
  font-size: 14px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}
.etiquette-valeur {
  flex: 1;
  padding: 10px 14px;
  font-size: clamp(30px, 9vw, 44px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.02em;
  word-break: break-all;
}
.etiquette-valeur small { display: block; font-size: 16px; font-weight: 500; letter-spacing: 0; margin-top: 4px; }
.etiquette.geante .etiquette-valeur { font-size: clamp(64px, 26vw, 120px); text-align: center; }

/* Les informations : libelle a gauche, valeur a droite. */
.infos {
  margin: 0 0 16px;
  border-top: 1px solid var(--trait);
}
.infos div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--trait);
}
.infos dt { color: var(--gris); }
.infos dd { margin: 0; font-weight: 600; text-align: right; }

/* --- La saisie ------------------------------------------------------------------- */

.saisie { margin: 0 0 12px; }
.saisie label { display: block; margin-bottom: 6px; color: var(--gris); font-size: 15px; }
.saisie-ligne { display: flex; gap: 8px; }
.saisie input {
  flex: 1;
  min-width: 0;
  height: 56px;
  padding: 0 14px;
  border: 2px solid var(--trait);
  border-radius: var(--r);
  background: var(--blanc);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.saisie input:focus { outline: none; border-color: var(--jaune-fonce); box-shadow: 0 0 0 3px rgba(244, 194, 26, 0.45); }
.saisie button {
  height: 56px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--r);
  background: var(--asphalte);
  color: var(--blanc);
  font-weight: 600;
  cursor: pointer;
}

/* Le compte rendu du dernier scan. */
.retour-scan {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: var(--r);
  font-weight: 600;
}
.retour-scan.ok { background: var(--vert-clair); color: #145c3a; border-left: 5px solid var(--vert); }
.retour-scan.ko { background: var(--rouge-clair); color: #8e2219; border-left: 5px solid var(--rouge); animation: secousse 0.25s 1; }
.retour-scan.info { background: var(--blanc); color: var(--encre); border-left: 5px solid var(--asphalte); }
@keyframes secousse { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(-5px); } 70% { transform: translateX(5px); } }

/* --- Les listes de choix (menus, supports, anomalies) -------------------------------- */

.choix { list-style: none; margin: 0 0 16px; padding: 0; }
.choix li + li { margin-top: 8px; }
.choix button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 60px;
  padding: 10px 14px;
  border: 1px solid var(--trait);
  border-radius: var(--r);
  background: var(--blanc);
  text-align: left;
  cursor: pointer;
}
.choix button:hover:not(:disabled) { border-color: var(--asphalte); }
.choix button:disabled { cursor: default; opacity: 0.55; }
.choix .pastille {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--asphalte);
  color: var(--jaune);
  font-weight: 700;
  font-size: 18px;
}
.choix .libelle { flex: 1; }
.choix .libelle strong { display: block; font-size: 18px; font-weight: 600; }
.choix .libelle span { display: block; color: var(--gris); font-size: 14px; }
.choix .marque { font-size: 13px; color: var(--gris); }
.choix button.choisi { border: 2px solid var(--jaune-fonce); background: #fff8dc; }

/* --- Les actions (touches de fonction) ------------------------------------------------- */

.actions {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 3;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px max(12px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom));
  background: var(--blanc);
  border-top: 1px solid var(--trait);
}
.actions:empty { display: none; }
.actions button {
  flex: 1;
  max-width: 200px;
  min-height: 52px;
  padding: 6px 8px;
  border: 1px solid var(--trait);
  border-radius: var(--r);
  background: var(--beton);
  font-weight: 600;
  font-size: 15px;
  line-height: 1.15;
  cursor: pointer;
}
.actions button.principal { background: var(--asphalte); border-color: var(--asphalte); color: var(--blanc); }
.actions button.danger { color: var(--rouge); }
.actions kbd { display: block; font-family: inherit; font-size: 12px; font-weight: 500; color: var(--gris); }
.actions button.principal kbd { color: #a9b6c1; }

/* --- Accueil -------------------------------------------------------------------------- */

.accueil-tete { margin: 4px 0 18px; }
.accueil-tete h2 { margin: 0; font-size: 28px; font-weight: 600; }
.accueil-tete p { margin: 2px 0 0; color: var(--gris); }

/* --- Planche de codes-barres ------------------------------------------------------------- */

.filtres { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.filtres button {
  padding: 8px 12px;
  border: 1px solid var(--trait);
  border-radius: 999px;
  background: var(--blanc);
  cursor: pointer;
}
.filtres button[aria-pressed="true"] { background: var(--asphalte); color: var(--blanc); border-color: var(--asphalte); }

.planche h3 { margin: 22px 0 8px; font-size: 19px; }
.planche-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.code {
  padding: 10px 12px 8px;
  border: 1px solid var(--trait);
  border-radius: 8px;
  background: var(--blanc);
  break-inside: avoid;
}
.code p { margin: 0 0 6px; font-size: 14px; color: var(--gris); }
.code svg { display: block; width: 100%; height: 58px; }
.code strong { display: block; margin-top: 4px; font-size: 16px; text-align: center; letter-spacing: 0.04em; }

main.large { max-width: 1100px; }

@media print {
  @page { margin: 10mm; }
  body { background: #fff; }
  .barre, .progression, .actions, .filtres, .pas-imprime { display: none !important; }
  main, main.large { max-width: none; padding: 0; }
  .planche-grille { grid-template-columns: repeat(3, 1fr); gap: 6mm; }
  .code { border: 1px solid #999; }
  .planche h3 { break-after: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  .retour-scan.ko { animation: none; }
}

@media (min-width: 700px) {
  main { padding-top: 28px; }
  .consigne { font-size: 26px; }
}

[hidden] { display: none !important; }

/* --- Lanceur de l'APK ------------------------------------------------------------------ */

.lanceur { display: grid; gap: 12px; margin: 6px 0 26px; }
.tuile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 118px;
  padding: 18px 20px;
  border: 0;
  border-radius: var(--r);
  background: var(--asphalte);
  color: var(--blanc);
  text-align: left;
  cursor: pointer;
}
.tuile-titre { font-size: 30px; font-weight: 700; letter-spacing: 0.01em; color: var(--jaune); }
.tuile-texte { font-size: 15px; color: #c3ced7; }
.tuile-bridge { background: var(--blanc); color: var(--encre); border: 2px solid var(--asphalte); }
.tuile-bridge .tuile-titre { color: var(--encre); }
.tuile-bridge .tuile-texte { color: var(--gris); }
.tuile-config { min-height: 86px; background: transparent; color: var(--encre); border: 2px dashed var(--gris); }
.tuile-config .tuile-titre { font-size: 22px; color: var(--encre); }
.tuile-config .tuile-texte { color: var(--gris); }
.tuile:active { transform: translateY(1px); }

.serveurs { padding-top: 2px; }
.serveurs h2 { margin: 12px 0 10px; font-size: 17px; font-weight: 600; color: var(--gris); }
.serveur { margin: 0 0 14px; }
.serveur h3 { margin: 0 0 4px; font-size: 18px; }
.serveur h3 span { margin-left: 6px; font-size: 14px; font-weight: 500; color: var(--gris); }
.serveur .infos { margin: 0; }
.serveur .infos div { flex-direction: column; gap: 1px; padding: 7px 0; }
.serveur .infos dt { font-size: 14px; }
.serveur .infos dd { text-align: left; font-size: 18px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.serveurs-note { margin: 6px 0 0; font-size: 14px; color: var(--gris); }

@media (min-width: 640px) { .lanceur { grid-template-columns: 1fr 1fr; } .tuile-config { grid-column: 1 / -1; } }
