/* FIDEL — design system
   encre / papier / outremer / or (le tampon) */

:root {
  --ink: #20243a;
  --ink-2: #5a5f78;
  --paper: #f4f4f1;
  --card: #ffffff;
  --line: #e4e4de;
  --brand: #3b47d6;
  --brand-deep: #2a34ad;
  --brand-soft: #eceefc;
  --gold: #f0b429;
  --gold-ink: #6b4e0a;
  --ok: #1e7a46;
  --ok-bg: #e8f4ec;
  --err: #c0362c;
  --err-bg: #fbecea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(32, 36, 58, 0.06), 0 8px 24px rgba(32, 36, 58, 0.07);
  --font-display: "Bricolage Grotesque", "Avenir Next", -apple-system, sans-serif;
  --font-body: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .wordmark { font-family: var(--font-display); }
h1 { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.025em; margin: 0 0 0.35rem; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 0.75rem; }
.lead { color: var(--ink-2); margin: 0 0 1.6rem; font-size: 0.97rem; line-height: 1.5; }

::selection { background: var(--gold); color: var(--gold-ink); }

/* ---- Barre du commerçant ---- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.wordmark {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark::after {
  content: "";
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--gold);
  margin-left: 3px;
}
.topbar nav { display: flex; gap: 0.25rem; }
.topbar nav a {
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
}
.topbar nav a:hover { color: var(--ink); background: var(--paper); }
.topbar nav a.current { color: var(--brand-deep); background: var(--brand-soft); }

/* Icônes de navigation (affichées dans le panneau latéral desktop) */
.topbar nav a::before {
  content: "";
  display: none;
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.topbar nav a[href="/scan.html"] { --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'><path d='M3 7V5a2 2 0 0 1 2-2h2M17 3h2a2 2 0 0 1 2 2v2M21 17v2a2 2 0 0 1-2 2h-2M7 21H5a2 2 0 0 1-2-2v-2M7 12h10'/></svg>"); }
.topbar nav a[href="/clients.html"] { --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'><circle cx='9' cy='8' r='3.5'/><path d='M3 20c0-3 2.5-5 6-5s6 2 6 5'/><circle cx='17' cy='9' r='2.5'/><path d='M17 15c2.6.3 4 2 4 4.5'/></svg>"); }
.topbar nav a[href="/prestations.html"] { --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'><path d='M20 12l-8 8-8.5-8.5V4h7.5L20 12z'/><circle cx='8' cy='8' r='1.4'/></svg>"); }
.topbar nav a[href="/customize.html"] { --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'><rect x='3' y='5' width='18' height='14' rx='3'/><path d='M3 10h18'/></svg>"); }
.topbar nav a[href="/poster.html"] { --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'><rect x='4' y='4' width='6' height='6'/><rect x='14' y='4' width='6' height='6'/><rect x='4' y='14' width='6' height='6'/><path d='M14 14h3v3h3v3h-6z'/></svg>"); }
.topbar nav a[href="/stats.html"] { --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'><path d='M5 20v-7M11 20V5M17 20v-10M2 20h20'/></svg>"); }
.topbar nav a[href="/notifs.html"] { --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M18 9a6 6 0 1 0-12 0c0 5-2 6-2 6h16s-2-1-2-6M10.5 20a1.8 1.8 0 0 0 3 0'/></svg>"); }
.topbar nav a[href="/nouveau.html"], .topbar nav a[href="/"] { --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'><circle cx='12' cy='12' r='9'/><path d='M12 8v8M8 12h8'/></svg>"); }
.topbar nav a[href="/logout"] { --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9'/></svg>"); opacity: 0.75; }

/* Stats = offre Pro, signalée en or */
.pro-pill {
  background: var(--gold);
  color: var(--gold-ink);
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.14rem 0.42rem;
  border-radius: 999px;
  line-height: 1;
}
.topbar nav a[href="/stats.html"] { color: var(--gold-ink); background: rgba(240, 180, 41, 0.14); }
.topbar nav a[href="/stats.html"]:hover { color: var(--gold-ink); background: rgba(240, 180, 41, 0.26); }
.topbar nav a.current[href="/stats.html"] { color: var(--gold-ink); background: rgba(240, 180, 41, 0.38); }

main { max-width: 560px; margin: 0 auto; padding: 2.2rem 1.25rem 4rem; }
main.wide { max-width: 960px; }

/* ---- Panneau latéral (desktop) ---- */
@media (min-width: 900px) {
  body:has(> .topbar) { padding-left: 232px; }
  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 232px;
    height: auto;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 1.8rem;
    background: var(--ink);
    border-bottom: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    padding: 1.5rem 1rem;
  }
  .topbar .wordmark { color: #fff; font-size: 1.5rem; padding: 0 0.75rem; }
  .topbar nav { flex-direction: column; gap: 0.15rem; }
  .topbar nav a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.95rem;
    padding: 0.62rem 0.75rem;
    border-radius: 9px;
    position: relative;
  }
  .topbar nav a::before { display: inline-block; }
  .topbar nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
  .topbar nav a.current { color: #fff; background: rgba(255, 255, 255, 0.1); }
  .topbar nav a[href="/stats.html"] { color: var(--gold); background: rgba(240, 180, 41, 0.1); }
  .topbar nav a[href="/stats.html"]:hover { color: var(--gold); background: rgba(240, 180, 41, 0.18); }
  .topbar nav a.current[href="/stats.html"] { color: var(--gold); background: rgba(240, 180, 41, 0.16); }
  .topbar nav a.current::after {
    content: "";
    position: absolute;
    left: -1rem;
    top: 22%;
    bottom: 22%;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background: var(--gold);
  }
  main { padding-top: 2.8rem; }
}

@media print {
  body:has(> .topbar) { padding-left: 0; }
  .topbar { display: none; }
}

/* ---- Cartes / formulaires ---- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}
input, select {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 1rem;
  font-family: var(--font-body);
  background: var(--card);
  color: var(--ink);
  margin-bottom: 1rem;
}
input:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-color: var(--brand);
}
.hint { color: var(--ink-2); font-size: 0.8rem; margin: -0.6rem 0 1rem; }
.muted { color: var(--ink-2); font-size: 0.85rem; }

button {
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(42, 52, 173, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: background 0.15s, transform 0.08s;
}
button:hover { background: var(--brand-deep); }
button:active { transform: scale(0.985); }
button.secondary, button.ghost { box-shadow: none; }
button:disabled { opacity: 0.55; cursor: default; }
button.secondary {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
}
button.secondary:hover { background: var(--paper); }
button.ghost {
  background: none;
  color: var(--brand-deep);
  width: auto;
  padding: 0.4rem 0.6rem;
}
button.ghost:hover { background: var(--brand-soft); }

.row { display: flex; gap: 0.75rem; }
.row > div { flex: 1; }

/* ---- Messages : toasts flottants ---- */
.error, .success {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  max-width: min(92vw, 460px);
  width: max-content;
  border-radius: 11px;
  padding: 0.8rem 1.1rem 0.8rem 0.95rem;
  font-size: 0.92rem;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  box-shadow: 0 8px 30px rgba(32, 36, 58, 0.25);
  animation: toast-in 0.3s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.error::before, .success::before {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.05rem;
}
.error { background: var(--err-bg); color: var(--err); border: 1px solid rgba(192, 54, 44, 0.25); }
.error::before { content: "!"; background: var(--err); }
.success { background: var(--ok-bg); color: var(--ok); border: 1px solid rgba(30, 122, 70, 0.25); }
.success::before { content: "✓"; background: var(--ok); }
@media (min-width: 900px) {
  .error, .success { left: auto; right: 1.5rem; transform: none; bottom: 1.5rem; }
  @keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
  }
}
.hidden { display: none !important; }

/* ---- États vides ---- */
.empty {
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  color: var(--ink-2);
  padding: 1.5rem 1rem;
  font-size: 0.92rem;
}

/* ---- La carte Wallet (motif central) ---- */
.pass {
  --pass-bg: #1e40af;
  background: var(--pass-bg);
  color: #fff;
  border-radius: 16px;
  padding: 1.1rem 1.25rem 1.3rem;
  box-shadow: 0 14px 34px rgba(32, 36, 58, 0.22);
  transition: background 0.25s;
}
.pass .top { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.pass .logo { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.pass .f-label {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.75;
  font-weight: 600;
}
.pass .f-value { font-size: 1rem; font-weight: 500; }
.pass .primary { margin: 1.2rem 0 1rem; }
.pass .primary .f-value {
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-display);
}
.pass .qrbox {
  background: #fff;
  border-radius: 10px;
  width: 96px;
  height: 96px;
  margin: 1rem auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font-size: 0.6rem;
  text-align: center;
  overflow: hidden;
}
.pass .qrbox img { width: 100%; height: 100%; }

/* ---- Le tampon (signature) ---- */
.stamp {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--gold-ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.stamp::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 2px dashed rgba(107, 78, 10, 0.45);
  border-radius: 50%;
}
.stamp .n {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.9rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stamp .u {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---- QR ---- */
.qr-frame {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  display: inline-block;
}
.qr-frame img { display: block; width: 220px; height: 220px; }

/* ---- Puces points rapides ---- */
.chips { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.chips button {
  width: auto;
  flex: 1;
  min-width: 64px;
  background: var(--card);
  color: var(--ink);
  border: 1.5px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.chips button.on {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-deep);
}

/* ---- Prestations ---- */
.presta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-bottom: 0.4rem; }
.presta-grid button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  background: var(--card);
  color: var(--ink);
  border: 1.5px solid var(--line);
  padding: 0.7rem 0.85rem;
  text-align: left;
}
.presta-grid button:hover { border-color: var(--brand); background: var(--brand-soft); }
.badge-gold {
  background: var(--gold);
  color: var(--gold-ink);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.presta-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}
.presta-row:last-child { border-bottom: 0; }
.presta-row .name { flex: 1; font-weight: 500; }
.presta-row .del {
  width: auto;
  background: none;
  border: 0;
  color: var(--ink-2);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  border-radius: 7px;
}
.presta-row .del:hover { color: var(--err); background: var(--err-bg); }

/* ---- Caméra ---- */
video { width: 100%; border-radius: var(--radius); background: #000; display: block; }

/* ---- Pastilles couleur (personnalisation) ---- */
.swatches { display: flex; gap: 0.6rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.swatches label {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  margin: 0;
  position: relative;
  border: 0;
}
.swatches input { position: absolute; opacity: 0; }
.swatches label.selected::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
}
.swatches label.selected { outline: 2px solid var(--ink); outline-offset: 2px; }

details { margin-bottom: 1rem; }
summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.25rem 0;
}

/* ---- Étapes (vraie séquence) ---- */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li {
  counter-increment: step;
  display: flex;
  gap: 0.85rem;
  align-items: baseline;
  padding: 0.5rem 0;
}
.steps li::before {
  content: counter(step);
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
}

/* ---- Bord perforé (affiche & page client) ---- */
.perforated {
  position: relative;
  padding-top: 1.6rem;
}
.perforated::before {
  content: "";
  position: absolute;
  top: 0.7rem;
  left: 1.4rem;
  right: 1.4rem;
  border-top: 2px dashed var(--line);
}

/* ---- Animations ---- */
.reveal { animation: reveal 0.45s ease both; }
@keyframes reveal {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---- Mobile : barre d'onglets en bas, comme une app ---- */
@media (max-width: 719px) {
  .topbar { height: 50px; justify-content: center; }
  .topbar nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 30;
    background: var(--ink);
    padding: 0.45rem 0.3rem calc(0.45rem + env(safe-area-inset-bottom));
    justify-content: space-around;
    gap: 0;
    box-shadow: 0 -6px 24px rgba(32, 36, 58, 0.28);
  }
  .topbar nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.28rem;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    padding: 0.3rem 0.2rem;
    border-radius: 8px;
  }
  .topbar nav a::before { display: inline-block; width: 21px; height: 21px; }
  .topbar nav a:hover { background: none; color: #fff; }
  .topbar nav a.current { color: #fff; background: none; }
  /* Stats en or = fonctionnalité Pro (la pastille est masquée, l'or suffit) */
  .topbar nav a[href="/stats.html"] { color: var(--gold); background: none; }
  .topbar nav a[href="/stats.html"] .pro-pill { display: none; }
  /* Déconnexion réservée au desktop : la barre d'onglets reste respirable */
  .topbar nav a[href="/logout"] { display: none; }
  main { padding: 1.4rem 1rem calc(6rem + env(safe-area-inset-bottom)); }
  .error, .success { bottom: calc(4.8rem + env(safe-area-inset-bottom)); }
}
