/**
 * Charte Nexora Media — la même que le studio.
 *
 * Les jetons et les composants sont repris à l'identique de
 * `fidelite-studio/public/assets/{app,brand}.css` pour que passer d'un
 * outil à l'autre ne donne pas l'impression de changer de produit.
 *
 * Les classes restent celles de cette application (`.card`, `.stat`,
 * `.option`…) : c'est l'apparence qui est alignée, pas le balisage. Cela
 * évite de réécrire huit pages pour un changement de peinture.
 *
 * Exception assumée : les pages vues par les CLIENTS d'un commerçant
 * (enseigne, carte) reçoivent par-dessus les couleurs de l'enseigne —
 * c'est le produit qu'on lui vend, pas notre marque.
 */

:root {
  --bg: #0d0d0d;
  --surface: #161616;
  --accent: #3b82f6;
  --cream: #ffffff;

  --bg-deep: #000000;
  --line: rgba(255, 255, 255, 0.12);
  --muted: rgba(255, 255, 255, 0.64);
  --faint: rgba(255, 255, 255, 0.38);
  --on-accent: #ffffff;
  --danger: #f16a4b;
  --success: #3b82f6;
  --radius: 14px;
  --shadow: 0 24px 60px -22px rgba(0, 0, 0, 0.9);

  /* Deux surfaces, deux couleurs de texte.
     Un commerçant peut choisir une page sombre avec des cartes claires —
     c'est même le réglage par défaut. Confondre les deux rend le texte des
     cartes invisible, ce qui est exactement arrivé. `applyTheme()` calcule
     les deux jeux à partir de la luminance de chaque fond. */
  --page-ink: var(--cream);
  --field-bg: rgba(0, 0, 0, 0.22);
  --placeholder: rgba(255, 255, 255, 0.26);

  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --display: "Montserrat", "Inter", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

/* Plusieurs composants imposent display:flex ; sans !important l'attribut
   hidden serait ignoré et les éléments masqués resteraient visibles. */
[hidden] { display: none !important; }

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

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--page-ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Le halo bleu du studio, franc et unique. */
body::before {
  content: "";
  position: fixed;
  inset: -20% -20% auto -20%;
  height: 70vh;
  background: radial-gradient(52% 46% at 50% 0%, rgba(59, 130, 246, 0.14), transparent 72%);
  pointer-events: none;
  z-index: 0;
}

h1, h2, h3, legend {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.12;
  margin-bottom: 0.4em;
}
h1 { font-size: 1.7rem; }
h2 { font-size: 1.18rem; }
h3 { font-size: 1rem; }
p { margin-bottom: 1em; }
a { color: var(--accent); }

ul { margin: 0 0 1em 18px; }

.wrap {
  position: relative;
  z-index: 1;
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 26px 20px 64px;
}
.narrow { width: min(520px, 100%); }
.mid { width: min(760px, 100%); }

/* ── Barre supérieure ─────────────────────────────────────────────── */

header.top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-deep);
}

/* La signature Nexora, posée en image de fond : aucune page à modifier,
   et `img-src data:` la couvre déjà côté CSP. */
header.top .brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--cream);
}
header.top .brand::before {
  content: "";
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 9px;
  background: #000 center / 21px 21px no-repeat
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"><path d="M4 20V5l11 12" stroke="%23fff" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M9 19l9-11m0 0h-5.4M18 8v5.4" stroke="%233b82f6" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"/></svg>');
  border: 1px solid var(--line);
}
header.top .brand span { color: var(--accent); }

/* Les pages d'une enseigne portent SON logo : la signature Nexora n'a rien
   à faire à côté, c'est la marque du commerçant que le client doit voir. */
header.top .brand#enseigne::before { display: none; }
header.top .who { margin-left: auto; font-size: 0.85rem; color: var(--muted); }
header.top select {
  width: auto;
  min-height: 38px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
  color: var(--cream);
}

/* ── Panneaux ─────────────────────────────────────────────────────── */

.card {
  /* Le contenu d'une carte suit la couleur lisible SUR la carte, qui n'est
     pas forcément celle du fond de page. */
  color: var(--cream);
  padding: 22px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card h2 { font-size: 1.15rem; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spread { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }

/* ── Statistiques ─────────────────────────────────────────────────── */

.stat {
  color: var(--cream);
  padding: 16px 12px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.stat .value {
  display: block;
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--accent);
}
.stat .label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ── Formulaires ──────────────────────────────────────────────────── */

label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}
label .hint { font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--faint); }

/* Un libellé court se met en capitales ; une phrase, non. Le consentement
   RGPD s'affichait entièrement en majuscules, ce qui le rendait pénible à
   lire au moment précis où le client doit le comprendre. */
label.small {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-size: 13px;
  color: var(--muted);
}

input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--field-bg);
  color: var(--cream);
  font: inherit;
  font-size: 16px; /* en dessous, iOS zoome tout seul */
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
textarea { min-height: 96px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input[type="color"] { padding: 4px; min-height: 46px; cursor: pointer; }
input[type="checkbox"] { width: auto; min-height: 0; }
input[readonly] { color: var(--muted); }

.field { margin-bottom: 15px; }
fieldset { border: 0; margin-bottom: 26px; }
legend { font-size: 1.05rem; margin-bottom: 4px; }

/* ── Boutons ──────────────────────────────────────────────────────── */

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 11px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--cream);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.2s ease, background 0.2s ease;
}
button:hover:not(:disabled), .btn:hover { background: rgba(255, 255, 255, 0.07); }
button:active:not(:disabled) { transform: scale(0.985); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}
button.primary:hover:not(:disabled) { filter: brightness(1.09); background: var(--accent); }

button.ghost { border-color: transparent; color: var(--muted); }
button.danger { border-color: rgba(241, 106, 75, 0.5); color: var(--danger); }
button.danger:hover:not(:disabled) { background: rgba(241, 106, 75, 0.12); }
button.small, .btn.small { min-height: 38px; padding: 8px 16px; font-size: 13px; }

/* ── Tableaux ─────────────────────────────────────────────────────── */

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  font-weight: 600;
}
td.num, th.num { text-align: right; font-family: var(--mono); }
.scroll { overflow-x: auto; }

/* ── Pastilles et messages ────────────────────────────────────────── */

.pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 99px;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.08);
  color: var(--faint);
}
.pill.active { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.pill.pending { background: rgba(241, 106, 75, 0.16); color: #f6c2b0; }
.pill.suspended, .pill.failed, .pill.revoked, .pill.churned {
  background: rgba(241, 106, 75, 0.14);
  color: var(--danger);
}

.notice {
  margin-bottom: 16px;
  padding: 13px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
}
.notice.error { background: rgba(241, 106, 75, 0.14); border: 1px solid rgba(241, 106, 75, 0.34); color: #f6c2b0; }
.notice.ok {
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
  color: var(--accent);
}
.notice.info { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: var(--mono); }
.code {
  display: inline-block;
  font-family: var(--mono);
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  user-select: all;
}

/* ── Onglets ──────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--faint);
  font-size: 14px;
  min-height: 0;
  padding: 10px 14px;
}
.tabs button:hover { background: none; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--cream); border-bottom-color: var(--accent); }

/* ── Lignes cliquables et options ─────────────────────────────────── */

.option {
  color: var(--cream);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  margin-bottom: 10px;
}
.option .qty { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.option .qty input { width: 70px; min-height: 42px; text-align: center; font-family: var(--mono); }
.option .price { font-family: var(--mono); font-weight: 700; color: var(--accent); }
.option label { margin-bottom: 4px; }

/* ── Tampons et progression ───────────────────────────────────────── */

.stamps { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.stamps i {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px dashed var(--line);
  display: grid; place-items: center;
  font-style: normal; font-size: 0.82rem; color: var(--faint);
}
.stamps i.on {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.bar { height: 7px; background: rgba(255, 255, 255, 0.1); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width 0.4s ease; }

/* ── Aperçu ───────────────────────────────────────────────────────── */

.preview { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
@media (max-width: 860px) { .preview { grid-template-columns: 1fr; } }
.phone {
  width: 340px; max-width: 100%; height: 640px;
  border-radius: 30px; overflow: hidden;
  border: 9px solid #101010; background: #000;
  box-shadow: var(--shadow);
}
.phone iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ── Visuels de l'enseigne ────────────────────────────────────────── */

.upload { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.upload .thumb {
  width: 62px; height: 62px; flex: 0 0 auto;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  object-fit: cover;
}
.upload .thumb.wide { width: 124px; height: 40px; }
.upload .meta { flex: 1; min-width: 140px; font-size: 12.5px; color: var(--faint); line-height: 1.45; }

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

@media (max-width: 640px) {
  .wrap { padding: 18px 14px 48px; }
  h1 { font-size: 1.35rem; }
}
