/* style.css — Portail Marchand Geeb
   Couleurs alignées sur geebservices.com (extraites du site en production,
   pas seulement du logo) : rouge #E9092B, indigo de marque #231E46 (chrome
   sombre — sidebar), vert #45A041 en accent secondaire, fond blanc/gris
   très clair dominant (le site vitrine Geeb est clair, pas sombre).
   Thème clair par défaut ; thème sombre disponible via le sélecteur en
   bas de la sidebar (data-theme sur <html>, voir app.js) ou la préférence
   système si l'utilisateur n'a rien choisi explicitement.
   Typo système (aucune police externe : surface CSP minimale, zéro
   dépendance réseau — voir security.py, style-src/font-src 'self'). */

:root {
  /* Marque */
  --brand-red: #e9092b;
  --brand-red-600: #c10723;
  --brand-red-100: #fce4e8;
  --brand-green: #2e8b32;
  --brand-green-100: #e7f5e8;
  --brand-ink: #231e46;
  --brand-ink-hover: #322a5e;

  /* Neutres (mêmes tons que geebservices.com) */
  --ink-950: #1d2127;
  --ink-800: #383f48;
  --ink-600: #62666c;
  --ink-400: #999999;
  --ink-300: #cccccc;

  --paper-0: #ffffff;
  --paper-50: #f4f4f4;
  --paper-100: #f3f5f9;
  --border: #e6e6e6;

  /* Sémantique */
  --accent: var(--brand-red);
  --accent-ink: var(--brand-red-600);
  --good: var(--brand-green);
  --good-bg: var(--brand-green-100);
  --warn: #b9791a;
  --warn-bg: #fbf0dc;
  --bad: var(--brand-red-600);
  --bad-bg: var(--brand-red-100);

  --shadow-sm: 0 1px 2px rgba(29, 33, 39, 0.05);
  --shadow: 0 1px 2px rgba(29, 33, 39, 0.05), 0 8px 24px rgba(29, 33, 39, 0.07);
  --shadow-lg: 0 24px 64px rgba(29, 33, 39, 0.22);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
}

/* Thème sombre : suit le système tant que l'utilisateur n'a rien choisi
   explicitement (pas de data-theme="light" posé). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand-red: #ff4d6d;
    --brand-red-600: #ff7086;
    --brand-red-100: #3a1620;
    --brand-green: #59c95e;
    --brand-green-100: #123322;
    --brand-ink: #14122a;
    --brand-ink-hover: #1f1c3d;

    --ink-950: #f2f1ef;
    --ink-800: #d8d6d2;
    --ink-600: #a5a9ac;
    --ink-400: #767b7f;
    --ink-300: #4a4e51;

    --paper-0: #1c1e20;
    --paper-50: #131415;
    --paper-100: #26282a;
    --border: #34373a;

    --warn-bg: #3a2c10;
    --bad-bg: #3a1620;
  }
}

/* Thème sombre forcé via le sélecteur, quel que soit le système. */
:root[data-theme="dark"] {
  --brand-red: #ff4d6d;
  --brand-red-600: #ff7086;
  --brand-red-100: #3a1620;
  --brand-green: #59c95e;
  --brand-green-100: #123322;
  --brand-ink: #14122a;
  --brand-ink-hover: #1f1c3d;

  --ink-950: #f2f1ef;
  --ink-800: #d8d6d2;
  --ink-600: #a5a9ac;
  --ink-400: #767b7f;
  --ink-300: #4a4e51;

  --paper-0: #1c1e20;
  --paper-50: #131415;
  --paper-100: #26282a;
  --border: #34373a;

  --warn-bg: #3a2c10;
  --bad-bg: #3a1620;
}

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

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper-50);
  color: var(--ink-950);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-ink); }

h1, h2, h3 { font-weight: 700; letter-spacing: -0.015em; line-height: 1.2; color: var(--ink-950); margin: 0; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.2rem; margin-bottom: 12px; }
h3 { font-size: 0.75rem; color: var(--ink-600); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }

/* ── Layout applicatif ─────────────────────────────────────────── */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--brand-ink);
  color: #f1f0f7;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}

.sidebar .brand img {
  height: 22px;
  width: auto;
  display: block;
  background: #fff;
  border-radius: 5px;
  padding: 3px 6px;
}

.sidebar .brand span.wordmark {
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b7b2d6;
}

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar nav a {
  color: #c6c2e0;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 550;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar nav a:hover { background: rgba(255,255,255,0.08); color: #ffffff; }
.sidebar nav a.active { background: var(--brand-red); color: #ffffff; }

.sidebar .theme-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
}

.sidebar .theme-toggle span { font-size: 0.78rem; color: #c6c2e0; font-weight: 600; }

.sidebar .theme-toggle button {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #ffffff;
  width: 30px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.sidebar .theme-toggle button:hover { background: rgba(255,255,255,0.18); }
.sidebar .theme-toggle svg { width: 15px; height: 15px; }
.sidebar .theme-toggle .icon-sun,
html[data-theme="dark"] .sidebar .theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .sidebar .theme-toggle .icon-sun { display: block; }

.sidebar .user-box {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.12);
  padding-top: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar .user-box .avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.sidebar .user-box .who { min-width: 0; flex: 1; }
.sidebar .user-box .name { color: #ffffff; font-weight: 600; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .user-box .role { color: #b7b2d6; text-transform: capitalize; font-size: 0.76rem; }

.sidebar form.logout-form { margin-top: 4px; }

.sidebar form.logout-form button {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: #ffffff;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 0.8rem;
  cursor: pointer;
  width: 100%;
  transition: border-color 0.15s ease;
}

.sidebar form.logout-form button:hover { border-color: var(--brand-red); }

.main {
  flex: 1;
  padding: 32px 40px 60px;
  max-width: 1120px;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header p { color: var(--ink-600); margin: 5px 0 0; }

/* ── Composants ─────────────────────────────────────────────────── */

.card {
  background: var(--paper-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: 16px; }

.card-narrow { max-width: 440px; }

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.grid-stats .card { position: relative; overflow: hidden; padding-top: 22px; }
.grid-stats .card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--brand-red);
}
.grid-stats .card:nth-child(2)::before { background: var(--brand-green); }
.grid-stats .card:nth-child(3n)::before { background: var(--brand-ink); }

.stat-value { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--ink-600); font-size: 0.82rem; margin-top: 4px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--paper-0); }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }

th, td {
  text-align: left;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th { color: var(--ink-600); font-weight: 700; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; background: var(--paper-50); }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background-color 0.12s ease; }
tbody tr:hover { background: var(--paper-50); }

.pill {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 650;
}

.pill-good { background: var(--good-bg); color: var(--good); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-neutral { background: var(--paper-100); color: var(--ink-600); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: end; }
.pagination-bar { margin-top: 16px; align-items: center; }

.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-stack .field { margin: 0; }
.form-stack input { width: 100%; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 0.78rem; color: var(--ink-600); font-weight: 600; }

input, select, button {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  background: var(--paper-0);
  color: var(--ink-950);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, button:focus, a:focus {
  outline: none;
  border-color: var(--brand-red);
  box-shadow: 0 0 0 3px var(--brand-red-100);
}

button { cursor: pointer; }

button.primary, .btn-primary {
  background: var(--brand-red);
  border-color: var(--brand-red);
  color: #ffffff;
  font-weight: 650;
}

button.primary:hover { background: var(--brand-red-600); border-color: var(--brand-red-600); }
button.primary:focus { box-shadow: 0 0 0 3px var(--brand-red-100); }

.error-banner {
  background: var(--bad-bg);
  color: var(--bad);
  border: 1px solid var(--bad);
  border-radius: var(--radius-sm);
  padding: 11px 15px;
  margin-bottom: 18px;
  font-size: 0.88rem;
  font-weight: 550;
}

.empty-state { color: var(--ink-600); padding: 34px 0; text-align: center; }

/* ── Page de connexion ─────────────────────────────────────────── */

.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  background:
    radial-gradient(560px circle at 12% 10%, rgba(233,9,43,0.14), transparent 60%),
    radial-gradient(480px circle at 88% 92%, rgba(46,139,50,0.12), transparent 60%),
    var(--brand-ink);
  padding: 32px 20px;
  position: relative;
}

.auth-theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
}

.auth-theme-toggle button {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.16);
  color: #ffffff;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.auth-theme-toggle button:hover { background: rgba(255,255,255,0.18); }
.auth-theme-toggle svg { width: 16px; height: 16px; }
.auth-theme-toggle .icon-sun,
html[data-theme="dark"] .auth-theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .auth-theme-toggle .icon-sun { display: block; }

.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.auth-brand img { height: 40px; width: auto; background: #fff; border-radius: 8px; padding: 6px 10px; }
.auth-brand span { color: #b7b2d6; font-size: 0.76rem; font-weight: 650; letter-spacing: 0.1em; text-transform: uppercase; }

.auth-card {
  background: var(--paper-0);
  border-radius: var(--radius-lg);
  padding: 38px 34px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}

.auth-card h1 { font-size: 1.2rem; margin-bottom: 4px; }
.auth-card .subtitle { color: var(--ink-600); font-size: 0.86rem; margin-bottom: 22px; }

.auth-card .field { margin-bottom: 14px; }
.auth-card input { width: 100%; padding: 10px 12px; }
.auth-card button { width: 100%; padding: 10px; margin-top: 6px; }

.auth-footnote { color: #b7b2d6; font-size: 0.78rem; margin-top: 20px; text-align: center; }
