/*
  Système visuel de WasteWizz.

  Parti pris : l'outil doit se lire comme un pupitre d'instrument et un
  document contrôlé, pas comme un tableau de bord générique. Trois
  conséquences tenues partout dans la feuille :

  1. La couleur porte du sens, jamais de la décoration. Le fond, le texte et
     les séparateurs sont neutres ; les trois couleurs de signal (attente,
     validé, refusé) sont réservées aux états de workflow et aux verdicts des
     modules. Une couleur vue à l'écran veut donc toujours dire quelque chose.
  2. Toute donnée chimique est en chasse fixe à chiffres tabulaires : numéros
     CAS, symboles d'éléments, teneurs, températures, numéros de fiche. Des
     colonnes de pourcentages qui ne s'alignent pas se relisent mal — et la
     somme des teneurs doit faire 100 %.
  3. Le « rail de processus » est l'élément signature. La position d'une fiche
     dans le circuit réglementaire est le fait le plus important à son sujet :
     il est représenté explicitement, à trois échelles (détail, ligne de
     liste, agrégat du tableau de bord).
*/

:root {
  /* -- Encre et papier ------------------------------------------------- */
  --ww-ink: #0f1a1e;              /* noir teinté bleu-vert, jamais #000 */
  --ww-ink-soft: #46595f;
  --ww-ink-faint: #7d8f94;
  --ww-paper: #f3f6f6;            /* stratifié de paillasse, légèrement froid */
  --ww-surface: #ffffff;
  --ww-surface-sunken: #eaefef;
  --ww-rule: #d7e0e0;
  --ww-rule-strong: #b9c7c7;

  /* -- Primaire : pétrole ---------------------------------------------- */
  --ww-petrol: #0b6e6e;
  --ww-petrol-deep: #075252;
  --ww-petrol-tint: #e2f0ef;

  /* -- Signaux : réservés aux états et verdicts ------------------------ */
  --ww-wait: #b0771a;             /* en attente d'une action */
  --ww-wait-tint: #fbf1de;
  --ww-pass: #1f7a4d;             /* validé */
  --ww-pass-tint: #e3f2ea;
  --ww-stop: #a32b2b;             /* refusé, bloquant */
  --ww-stop-tint: #f8e6e6;

  /* -- Type ------------------------------------------------------------ */
  --ww-font-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --ww-font-body: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  --ww-font-mono: 'IBM Plex Mono', 'Cascadia Mono', 'Consolas', monospace;

  /* -- Rythme ---------------------------------------------------------- */
  --ww-radius: 6px;
  --ww-radius-sm: 4px;
  --ww-shadow: 0 1px 2px rgba(15, 26, 30, 0.06), 0 4px 12px rgba(15, 26, 30, 0.04);
  --ww-shadow-lift: 0 2px 6px rgba(15, 26, 30, 0.08), 0 12px 28px rgba(15, 26, 30, 0.08);
}

html, body {
  font-family: var(--ww-font-body);
  background: var(--ww-paper);
  color: var(--ww-ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.ww-display {
  font-family: var(--ww-font-display);
  letter-spacing: -0.015em;
}

/* Chiffres tabulaires partout où une colonne doit s'aligner. */
.ww-mono,
.ww-data table td.ww-num,
.ww-data table th.ww-num {
  font-family: var(--ww-font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

.ww-num { text-align: right; }

/* Étiquette de section : petite capitale espacée, jamais un titre déguisé. */
.ww-eyebrow {
  font-family: var(--ww-font-display);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ww-ink-faint);
}

/* ---------------------------------------------------------------------- */
/* Rail de processus — élément signature                                   */
/* ---------------------------------------------------------------------- */

.ww-rail {
  display: flex;
  align-items: stretch;
  gap: 2px;
  width: 100%;
}

.ww-rail__segment {
  flex: 1 1 0;
  min-width: 0;
  padding: 0.5rem 0.75rem 0.6rem;
  background: var(--ww-surface-sunken);
  border-top: 3px solid var(--ww-rule-strong);
  color: var(--ww-ink-faint);
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.ww-rail__segment:first-child { border-top-left-radius: var(--ww-radius-sm); }
.ww-rail__segment:last-child { border-top-right-radius: var(--ww-radius-sm); }

/* Phase déjà franchie : acquise, donc discrète. */
.ww-rail__segment--done {
  background: var(--ww-petrol-tint);
  border-top-color: var(--ww-petrol);
  color: var(--ww-petrol-deep);
}

/* Phase courante : le seul segment qui appelle l'œil. */
.ww-rail__segment--current {
  background: var(--ww-petrol);
  border-top-color: var(--ww-petrol-deep);
  color: #ffffff;
}

.ww-rail__segment--terminal-pass {
  background: var(--ww-pass);
  border-top-color: var(--ww-pass);
  color: #ffffff;
}

.ww-rail__segment--terminal-stop {
  background: var(--ww-stop);
  border-top-color: var(--ww-stop);
  color: #ffffff;
}

.ww-rail__phase {
  display: block;
  font-family: var(--ww-font-display);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ww-rail__state {
  display: block;
  font-size: 0.6875rem;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Rail compact : une ligne de liste n'a pas la place des libellés. */
.ww-rail--compact { gap: 1.5px; height: 6px; }

.ww-rail--compact .ww-rail__segment {
  padding: 0;
  border-top: none;
  border-radius: 1px;
  background: var(--ww-rule);
}

.ww-rail--compact .ww-rail__segment--done { background: var(--ww-petrol-tint); }
.ww-rail--compact .ww-rail__segment--current { background: var(--ww-petrol); }
.ww-rail--compact .ww-rail__segment--terminal-pass { background: var(--ww-pass); }
.ww-rail--compact .ww-rail__segment--terminal-stop { background: var(--ww-stop); }

/* ---------------------------------------------------------------------- */
/* Sections de fiche : verrouillage lisible d'un coup d'œil                */
/* ---------------------------------------------------------------------- */

.ww-section {
  background: var(--ww-surface);
  border: 1px solid var(--ww-rule);
  border-radius: var(--ww-radius);
  overflow: hidden;
}

.ww-section__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--ww-rule);
  background: var(--ww-surface);
}

.ww-section__title {
  font-family: var(--ww-font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0;
}

.ww-section__body { padding: 1rem; }

/*
  Section verrouillée : hachure diagonale très légère et rappel du rôle qui
  la détient. L'information utile n'est pas « c'est grisé » mais « ce n'est
  pas à vous de la remplir, elle appartient à HSSEQ à cette étape ».
*/
.ww-section--locked .ww-section__body {
  background-image: repeating-linear-gradient(
    135deg,
    transparent, transparent 7px,
    rgba(125, 143, 148, 0.07) 7px, rgba(125, 143, 148, 0.07) 8px);
}

.ww-section--locked .ww-section__header { color: var(--ww-ink-soft); }

.ww-lock-owner {
  font-family: var(--ww-font-display);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ww-ink-faint);
  white-space: nowrap;
}

/* ---------------------------------------------------------------------- */
/* Jetons d'état et de verdict                                             */
/* ---------------------------------------------------------------------- */

.ww-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-family: var(--ww-font-display);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.ww-badge--neutral { background: var(--ww-surface-sunken); color: var(--ww-ink-soft); }
.ww-badge--active { background: var(--ww-petrol-tint); color: var(--ww-petrol-deep); }
.ww-badge--wait { background: var(--ww-wait-tint); color: var(--ww-wait); }
.ww-badge--pass { background: var(--ww-pass-tint); color: var(--ww-pass); }
.ww-badge--stop { background: var(--ww-stop-tint); color: var(--ww-stop); }

/* ---------------------------------------------------------------------- */
/* Indicateurs du tableau de bord                                          */
/* ---------------------------------------------------------------------- */

.ww-metric {
  background: var(--ww-surface);
  border: 1px solid var(--ww-rule);
  border-radius: var(--ww-radius);
  padding: 1rem 1.1rem;
  height: 100%;
}

.ww-metric__value {
  font-family: var(--ww-font-display);
  font-variant-numeric: tabular-nums;
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.05;
  color: var(--ww-ink);
}

.ww-metric__value--wait { color: var(--ww-wait); }
.ww-metric__value--stop { color: var(--ww-stop); }

.ww-metric__label { margin-top: 0.25rem; color: var(--ww-ink-soft); font-size: 0.875rem; }

/* ---------------------------------------------------------------------- */
/* Écran de connexion                                                      */
/* ---------------------------------------------------------------------- */

.ww-auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  background: var(--ww-paper);
}

.ww-auth__aside {
  background: var(--ww-ink);
  color: #ffffff;
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  /* Trame de paillasse : quadrillage très faible, comme un papier millimétré. */
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
}

.ww-auth__form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
}

.ww-auth__panel { width: 100%; max-width: 24rem; }

@media (max-width: 900px) {
  .ww-auth { grid-template-columns: 1fr; }
  .ww-auth__aside { padding: 2rem; }
}

/* ---------------------------------------------------------------------- */
/* Divers                                                                  */
/* ---------------------------------------------------------------------- */

.ww-page-title {
  font-family: var(--ww-font-display);
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
}

.ww-empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--ww-ink-faint);
}

.ww-nav-brand {
  font-family: var(--ww-font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Focus clavier toujours visible : l'outil se pilote aussi au clavier. */
:focus-visible {
  outline: 2px solid var(--ww-petrol);
  outline-offset: 2px;
}

/*
  Le routeur donne le focus au titre à chaque navigation, pour les lecteurs
  d'écran. C'est un focus programmatique, pas une intention de l'utilisateur :
  on le laisse silencieux à l'œil sans rien retirer à l'assistance.
*/
h1:focus { outline: none; }

/*
  Barre d'actions du formulaire de fiche, fixée au bas de la fenêtre pendant
  toute la saisie : sur un formulaire aussi long, annuler/enregistrer ne
  doivent jamais demander de remonter en tête d'écran, ni disparaître tant
  qu'on n'a pas encore atteint le bas de la page. Propre à l'écran d'édition —
  n'affecte pas les actions du gabarit d'en-tête partagé (PageHeader) utilisé
  par les autres pages.
*/
.ww-edit-actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  background: var(--ww-surface);
  border-top: 1px solid var(--ww-rule);
  box-shadow: var(--ww-shadow-lift);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
