@import url("https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,600..800&family=Instrument+Sans:wght@400;500;600&display=swap");

:root {
  --nuit: #101b5c;
  --nuit-2: #1a2a85;
  --or: #f4b63f;
  --fond: #f3f5fb;
  --blanc: #ffffff;
  --encre: #0f1430;
  --gris: #565d80;
  --ligne: #d6dbee;
  --ok: #157a52;
  --ko: #c0352b;
  --attention: #a85f00;
  --titre: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --texte: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font: 400 1rem/1.5 var(--texte);
}
h1, h2, h3 { font-family: var(--titre); line-height: 1.1; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; font-weight: 700; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--nuit-2); outline-offset: 2px; }

.page { max-width: 640px; margin: 0 auto; padding: 16px 16px 128px; }
.page.large { max-width: 980px; }
.discret { color: var(--gris); font-size: 0.9rem; }
.pile > * + * { margin-top: 20px; }

/* ---------- Le billet : élément visuel central ---------- */
.billet {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  color: #fff;
  background:
    repeating-radial-gradient(circle at 108% -12%, transparent 0 30px, rgba(255, 255, 255, 0.07) 30px 32px),
    linear-gradient(160deg, var(--nuit-2), var(--nuit) 70%);
}
.billet-haut { padding: 32px 24px 28px; }
.billet h1 { font-size: clamp(2.6rem, 12vw, 4.2rem); font-weight: 800; letter-spacing: -0.03em; }
.billet .sous-titre { margin-top: 10px; max-width: 26ch; font-size: 1.05rem; color: #dfe4ff; }
.talon {
  position: relative;
  display: flex; flex-wrap: wrap; gap: 8px 32px;
  padding: 20px 24px 22px;
  border-top: 2px dashed rgba(255, 255, 255, 0.4);
}
.talon::before, .talon::after {
  content: ""; position: absolute; top: -15px; width: 28px; height: 28px;
  border-radius: 50%; background: var(--fond);
}
.talon::before { left: -14px; }
.talon::after { right: -14px; }
.talon .petit { display: block; font-size: 0.85rem; color: #b9c2f5; }
.talon strong { font-weight: 600; font-size: 1.05rem; }

/* Billet individuel (page des billets) */
.billet.carte .billet-haut { padding: 22px 22px 18px; }
.billet.carte h2 { font-size: 1.7rem; font-weight: 800; }
.billet.carte .talon { align-items: center; gap: 16px 24px; }
.billet .qr { background: #fff; padding: 10px; border-radius: 12px; line-height: 0; }
.billet .qr svg { width: 176px; height: 176px; display: block; }
.billet .code { font-family: var(--titre); font-size: 1.6rem; font-weight: 700; letter-spacing: 0.06em; }
.billet.utilise, .billet.annule { filter: grayscale(0.85); opacity: 0.8; }
.pastille { display: inline-block; padding: 2px 10px; border-radius: 99px; background: var(--or); color: var(--nuit); font-weight: 600; font-size: 0.85rem; }

/* ---------- Boutique ---------- */
.choix { background: var(--blanc); border-radius: 16px; border: 1px solid var(--ligne); }
.choix > h2 { padding: 18px 18px 6px; }
.ligne-cat { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-top: 1px solid var(--ligne); }
.ligne-cat:first-of-type { border-top: 0; }
.ligne-cat .nom { font-weight: 600; font-size: 1.1rem; }
.ligne-cat .prix { font-weight: 600; }
.ligne-cat.complet { opacity: 0.55; }
.pas { display: flex; align-items: center; gap: 4px; }
.pas button {
  width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--nuit);
  background: var(--blanc); color: var(--nuit); font-size: 1.4rem; font-weight: 600; cursor: pointer;
}
.pas button:disabled { border-color: var(--ligne); color: var(--ligne); cursor: default; }
.pas output { min-width: 36px; text-align: center; font: 700 1.25rem var(--titre); }

.formulaire { background: var(--blanc); border-radius: 16px; border: 1px solid var(--ligne); padding: 18px; }
.formulaire h2 { margin-bottom: 12px; }
label { display: block; font-weight: 500; margin-top: 14px; }
label small { font-weight: 400; color: var(--gris); }
input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="password"], input[type="search"] {
  display: block; width: 100%; min-height: 48px; margin-top: 4px; padding: 10px 12px;
  border: 1.5px solid var(--ligne); border-radius: 10px; background: #fff;
}
input:focus { border-color: var(--nuit-2); }

.barre {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: var(--blanc); border-top: 1px solid var(--ligne);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.barre > div { max-width: 640px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.barre .total { font: 700 1.25rem var(--titre); }
.barre .total small { display: block; font: 400 0.85rem var(--texte); color: var(--gris); }
.actions-paiement { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 480px) {
  .barre > div { flex-direction: column; align-items: stretch; }
  .actions-paiement { justify-content: stretch; }
  .actions-paiement .btn { flex: 1; }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--or); color: var(--nuit); font-weight: 700; font-size: 1.05rem;
}
.btn:disabled { background: var(--ligne); color: var(--gris); cursor: default; }
.btn.sombre { background: var(--nuit); color: #fff; }
.btn.clair { background: var(--blanc); color: var(--nuit); border: 1.5px solid var(--nuit); }
.btn.petit { min-height: 40px; padding: 0 14px; font-size: 0.95rem; }
.btn.danger { background: var(--ko); color: #fff; }

.message { padding: 14px 16px; border-radius: 12px; background: #fff; border: 1.5px solid var(--ligne); }
.message.erreur { border-color: var(--ko); color: var(--ko); }
.message.info { border-color: var(--nuit-2); }
.simulation { border: 2px dashed var(--attention); border-radius: 14px; padding: 16px; background: #fff8ea; }

/* ---------- Scanneur ---------- */
body.scanner { background: var(--nuit); color: #fff; }
.scanner .page { padding-bottom: 32px; }
.scanner .entetes { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.scanner .compteur { font: 800 1.6rem var(--titre); }
.onglets { display: flex; gap: 8px; margin: 12px 0; }
.onglets button { flex: 1; min-height: 44px; border-radius: 10px; border: 1.5px solid rgba(255,255,255,0.4); background: transparent; color: #fff; font-weight: 600; cursor: pointer; }
.onglets button[aria-selected="true"] { background: var(--or); color: var(--nuit); border-color: var(--or); }
.video-cadre { position: relative; border-radius: 16px; overflow: hidden; background: #000; aspect-ratio: 1; }
.video-cadre video { width: 100%; height: 100%; object-fit: cover; }
.video-cadre::after { content: ""; position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,0.85); border-radius: 18px; pointer-events: none; }
.resultat {
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 24px; text-align: center; color: #fff;
}
.resultat[hidden] { display: none; }
.resultat.ok { background: var(--ok); }
.resultat.deja { background: var(--attention); }
.resultat.refus { background: var(--ko); }
.resultat h2 { font-size: clamp(2.2rem, 11vw, 3.4rem); font-weight: 800; }
.resultat .qui { font: 700 1.7rem var(--titre); }
.resultat .btn { margin-top: 18px; background: #fff; color: var(--encre); }
.liste-recherche { list-style: none; margin: 12px 0 0; padding: 0; }
.liste-recherche li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid rgba(255,255,255,0.2); }
.liste-recherche .sous { font-size: 0.9rem; color: #c9d0f7; }
.scanner .discret { color: #c9d0f7; }
.scanner input { color: var(--encre); }

/* ---------- Administration ---------- */
.stats { display: flex; flex-wrap: wrap; gap: 8px 40px; }
.stats strong { display: block; font: 800 2rem var(--titre); }
.tableau { overflow-x: auto; background: var(--blanc); border: 1px solid var(--ligne); border-radius: 14px; }
.tableau table { width: 100%; border-collapse: collapse; min-width: 640px; }
.tableau th, .tableau td { text-align: left; padding: 10px 12px; border-top: 1px solid var(--ligne); vertical-align: middle; }
.tableau thead th { border-top: 0; font-weight: 600; color: var(--gris); font-size: 0.9rem; }
.tableau input[type="text"], .tableau input[type="number"] { margin: 0; min-height: 40px; }
.tableau input.court { width: 92px; }
.tableau input.nom { width: 140px; }
.tableau input.desc { width: 230px; }
.statut { font-weight: 600; }
.statut.paid { color: var(--ok); }
.statut.pending, .statut.refund_due { color: var(--attention); }
.statut.expired, .statut.failed, .statut.refunded { color: var(--gris); }
.rangee-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (prefers-reduced-motion: no-preference) {
  .resultat { animation: apparition 0.12s ease-out; }
  @keyframes apparition { from { opacity: 0; } to { opacity: 1; } }
}

@media print {
  body { background: #fff; }
  .no-print, .barre { display: none !important; }
  .page { padding: 0; max-width: none; }
  .billet { break-inside: avoid; margin-bottom: 16px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .talon::before, .talon::after { background: #fff; }
}
