/* Point de vente Tunisie Telecom
   Nuit profonde, verre dépoli, bleu et cyan lumineux.
   Palette approchée de la charte TT : ajustez les variables --bleu / --cyan si besoin. */
:root {
  --nuit: #050b1f;
  --nuit-2: #0a1733;
  --bleu: #0066b3;
  --bleu-fonce: #003a75;
  --cyan: #00b2e3;
  --glace: #eaf4ff;
  --brume: #93a9c9;
  --verre: rgba(148, 196, 255, 0.06);
  --verre-fort: rgba(148, 196, 255, 0.1);
  --ligne: rgba(147, 169, 201, 0.22);
  --ok: #2bd9a0;
  --erreur: #ff5a6e;
  --halo: 0 0 0 1px rgba(0, 178, 227, 0.35), 0 8px 32px rgba(0, 120, 220, 0.35);
  --grad: linear-gradient(135deg, var(--cyan) 0%, var(--bleu) 70%);
  --font: "Sora", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --r-s: 12px;
  --r-l: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--nuit); }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--glace);
  background: var(--nuit);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* Fond : halos + trame fine, fixe même sur iOS */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60vmax 45vmax at 10% -10%, rgba(0, 102, 179, 0.45), transparent 60%),
    radial-gradient(50vmax 40vmax at 110% 30%, rgba(0, 178, 227, 0.18), transparent 60%),
    var(--nuit);
}
.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(147, 169, 201, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(147, 169, 201, 0.06) 1px, transparent 1px);
  background-size: 32px 32px;
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 70%);
  mask-image: linear-gradient(to bottom, #000, transparent 70%);
}

a { color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
code { font-size: .88em; background: var(--verre-fort); padding: 1px 6px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Barre du haut ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: var(--safe-top);
  background: rgba(5, 11, 31, 0.72);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
}
.topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  /* filet aux couleurs du logo Tunisie Telecom */
  background: linear-gradient(90deg, #2956a0, #40a6dd, #32b099, #89bd54, #ffea00, #f9bc0b, #e85f32, #de161f, #e42175, #772680);
  opacity: .75;
}
.topbar__inner {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 18px;
  min-height: 60px;
}
.topbar__back {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-left: -8px;
  border-radius: 50%;
  color: var(--glace);
}
.topbar__out {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--brume);
  text-decoration: none;
  padding: 8px 12px;
  border: 1px solid var(--ligne);
  border-radius: 999px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; }
.brand__mark {
  flex: none;
  width: 22px;
  height: 28px;
  background: var(--grad);
  clip-path: polygon(0 0, 65% 0, 100% 27%, 100% 100%, 0 100%);
  filter: drop-shadow(0 0 8px rgba(0, 178, 227, 0.7));
}
.brand__logo { flex: none; height: 32px; width: auto; display: block; }
.brand__text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand__text strong { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.brand__text small { font-size: 12.5px; color: var(--brume); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Page ---------- */

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 18px calc(48px + var(--safe-bottom));
}
.page__title {
  font-size: clamp(30px, 8vw, 48px);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.035em;
  margin: 0 0 26px;
}

.notice {
  padding: 14px 16px;
  margin: 0 0 20px;
  border-radius: var(--r-s);
  background: var(--verre);
  border: 1px solid var(--ligne);
  font-size: 15px;
}
.notice--error { border-color: rgba(255, 90, 110, 0.5); background: rgba(255, 90, 110, 0.08); }
.notice ul { margin: 6px 0 0; padding-left: 20px; }

.hint { font-size: 14px; color: var(--brume); margin: 10px 0 0; }
.optional { font-weight: 400; color: var(--brume); font-size: 13px; }

/* ---------- Tuiles d'accueil ---------- */

.tiles { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 780px) { .tiles { grid-template-columns: 1.35fr 1fr 1fr; } }

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  min-height: 184px;
  padding: 24px;
  border-radius: var(--r-l);
  text-decoration: none;
  overflow: hidden;
}
@media (min-width: 780px) { .tile { min-height: 320px; } }
.tile__body { position: relative; display: flex; flex-direction: column; gap: 6px; }
.tile__title { font-size: 25px; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }
.tile__meta { font-size: 14.5px; color: var(--brume); }

/* SIM : la pièce maîtresse, carte au coin coupé et puce lumineuse */
.tile--sim {
  color: #fff;
  border-radius: var(--r-l);
  background:
    radial-gradient(120% 80% at 85% 0%, rgba(255, 255, 255, 0.22), transparent 55%),
    linear-gradient(160deg, #00b2e3 0%, #0066b3 55%, #003a75 100%);
  -webkit-mask-image: linear-gradient(225deg, transparent 36px, #000 36.5px);
  mask-image: linear-gradient(225deg, transparent 36px, #000 36.5px);
}
.tile--sim .tile__meta { color: rgba(234, 244, 255, 0.85); }
.tile--sim::before { /* trame de circuit */
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(200deg, #000 10%, transparent 60%);
  mask-image: linear-gradient(200deg, #000 10%, transparent 60%);
}
.tile--sim::after { /* reflet au toucher */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, 0.28) 50%, transparent 65%);
  transform: translateX(-120%);
  transition: transform .7s ease;
}
.tile--sim:hover::after, .tile--sim:focus-visible::after, .tile--sim:active::after { transform: translateX(120%); }
.tile--sim:focus-visible { outline: none; }
.tile--sim:focus-visible .tile__title { text-decoration: underline; text-underline-offset: 6px; }
.tile__chip {
  position: relative;
  width: 70px;
  height: 52px;
  color: #fff;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.55));
}
@media (min-width: 780px) { .tile__chip { width: 92px; height: 68px; } }

/* Recharge : ticket en verre à encoches */
.tile--voucher {
  background: var(--verre);
  border: 1px solid var(--ligne);
  -webkit-mask:
    radial-gradient(circle 13px at 0 50%, transparent 98%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle 13px at 100% 50%, transparent 98%, #000) right / 51% 100% no-repeat;
  mask:
    radial-gradient(circle 13px at 0 50%, transparent 98%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle 13px at 100% 50%, transparent 98%, #000) right / 51% 100% no-repeat;
}
.tile--voucher::after {
  content: "";
  position: absolute;
  left: 26px; right: 26px; top: 50%;
  border-top: 1.5px dashed rgba(147, 169, 201, 0.35);
}

/* Autres ventes */
.tile--other {
  background: linear-gradient(var(--nuit-2), var(--nuit-2)) padding-box,
              linear-gradient(160deg, rgba(0, 178, 227, 0.5), rgba(147, 169, 201, 0.12)) border-box;
  border: 1px solid transparent;
}

.tile[aria-disabled="true"] { cursor: not-allowed; }
.tile[aria-disabled="true"] .tile__title { color: rgba(234, 244, 255, 0.55); }
.tile__soon {
  position: relative;
  align-self: flex-start;
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 11px;
  color: var(--cyan);
  border: 1px solid rgba(0, 178, 227, 0.5);
  border-radius: 999px;
  background: rgba(0, 178, 227, 0.08);
}

/* ---------- Formulaire par étapes ---------- */

.steps { max-width: 780px; }

.step {
  position: relative;
  padding: 22px 18px 24px;
  margin: 0 0 16px;
  border-radius: var(--r-l);
  background: var(--verre);
  border: 1px solid var(--ligne);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
@media (min-width: 600px) { .step { padding: 26px 26px 28px; } }
.step__title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 18px;
}
.step__num {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  color: var(--cyan);
  border: 1.5px solid var(--cyan);
  box-shadow: 0 0 12px rgba(0, 178, 227, 0.45), inset 0 0 8px rgba(0, 178, 227, 0.25);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border-radius: 14px;
  background: rgba(5, 11, 31, 0.6);
  border: 1px solid var(--ligne);
}
.segmented__opt { position: relative; }
.segmented__opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented__opt span {
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 6px 8px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  line-height: 1.15;
  color: var(--brume);
  border-radius: 10px;
  transition: background .2s, color .2s;
}
.segmented__opt input:checked + span { background: var(--grad); color: #fff; box-shadow: 0 4px 16px rgba(0, 120, 220, 0.4); }
.segmented__opt input:focus-visible + span { outline: 2px solid var(--glace); outline-offset: 2px; }

.scan { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .scan { grid-template-columns: 1fr 1fr; } }

.scan__previews { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.scan__previews:empty { display: none; }

/* Aperçu dans un cadre de visée */
.preview { position: relative; margin: 0; width: 158px; padding: 8px; }
.preview::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(var(--cyan), var(--cyan)) top left / 16px 2px,
    linear-gradient(var(--cyan), var(--cyan)) top left / 2px 16px,
    linear-gradient(var(--cyan), var(--cyan)) top right / 16px 2px,
    linear-gradient(var(--cyan), var(--cyan)) top right / 2px 16px,
    linear-gradient(var(--cyan), var(--cyan)) bottom left / 16px 2px,
    linear-gradient(var(--cyan), var(--cyan)) bottom left / 2px 16px,
    linear-gradient(var(--cyan), var(--cyan)) bottom right / 16px 2px,
    linear-gradient(var(--cyan), var(--cyan)) bottom right / 2px 16px;
  background-repeat: no-repeat;
}
.preview img { display: block; width: 100%; height: auto; border-radius: 6px; }
.preview figcaption { font-size: 12.5px; color: var(--brume); margin-top: 6px; }
.preview__beam { display: none; }
.preview.is-scanning .preview__beam {
  display: block;
  position: absolute;
  left: 8px; right: 8px; top: 8px;
  height: 3px;
  border-radius: 3px;
  background: var(--cyan);
  box-shadow: 0 0 14px 3px rgba(0, 178, 227, 0.8);
  animation: balayage 1.6s ease-in-out infinite alternate;
}
@keyframes balayage { to { top: calc(100% - 34px); } }

.scan__status { margin-top: 16px; }
.scan__status p { margin: 10px 0 0; font-size: 14.5px; }
.scan__status.is-error p { color: var(--erreur); }
.progress { height: 4px; border-radius: 4px; background: rgba(147, 169, 201, 0.16); overflow: hidden; }
.progress__bar {
  height: 100%;
  width: 0;
  background: var(--grad);
  box-shadow: 0 0 12px rgba(0, 178, 227, 0.8);
  transition: width .25s ease;
}
.scan__status.is-error .progress__bar { background: var(--erreur); box-shadow: none; }

/* ---------- Champs ---------- */

.grid { display: grid; gap: 14px 16px; grid-template-columns: 1fr; }
@media (min-width: 600px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .field--wide { grid-column: 1 / -1; }
}
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 4px; }
.field[hidden] { display: none; }
.field label { font-size: 13.5px; font-weight: 600; color: var(--brume); }

input, select, button { font: inherit; }

.field input, .field select {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  font-size: 17px; /* ≥ 16 px : pas de zoom automatique sur iOS */
  color: var(--glace);
  background: rgba(5, 11, 31, 0.55);
  border: 1px solid var(--ligne);
  border-radius: var(--r-s);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input::placeholder { color: rgba(147, 169, 201, 0.55); }
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%2300B2E3' stroke-width='2.2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 44px;
}
.field select option { background: var(--nuit-2); color: var(--glace); }
.field input[type="date"] { display: block; min-width: 0; }
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 178, 227, 0.22), 0 0 18px rgba(0, 178, 227, 0.25);
}
.field input:user-invalid { border-color: var(--erreur); }

/* Valeur lue par le scan : à vérifier */
.field input.is-auto, .field select.is-auto {
  border-color: rgba(0, 178, 227, 0.7);
  background: rgba(0, 178, 227, 0.1);
  box-shadow: inset 4px 0 0 var(--cyan);
}

/* ---------- Boutons ---------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 12px 22px;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  text-decoration: none;
  text-align: center;
  border: 1px solid transparent;
  border-radius: 16px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .2s, opacity .2s;
}
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--grad); color: #fff; box-shadow: var(--halo); }
.btn--primary:disabled { background: var(--verre-fort); color: var(--brume); box-shadow: none; cursor: progress; }
.btn--dark { background: var(--grad); color: #fff; box-shadow: var(--halo); }
.btn--outline { background: rgba(5, 11, 31, 0.4); color: var(--glace); border-color: rgba(0, 178, 227, 0.5); }
.btn--scan { width: 100%; }
.btn[hidden] { display: none; }

.submitbar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding: 14px 0 calc(14px + var(--safe-bottom));
  background: linear-gradient(to top, var(--nuit) 70%, rgba(5, 11, 31, 0));
}
.submitbar .btn { width: 100%; }
@media (min-width: 600px) { .submitbar .btn { width: auto; min-width: 300px; } }

/* ---------- Confirmation ---------- */

.done { max-width: 580px; }
.done__status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ok);
}
.done__status::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(43, 217, 160, 0.18), 0 0 14px rgba(43, 217, 160, 0.9);
}
.done__msisdn {
  margin: 10px 0 26px;
  font-size: clamp(38px, 11.5vw, 60px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 28px rgba(0, 178, 227, 0.55);
}
.done__facts {
  margin: 0 0 24px;
  padding: 4px 18px;
  border-radius: var(--r-l);
  background: var(--verre);
  border: 1px solid var(--ligne);
}
.done__facts div { display: flex; justify-content: space-between; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--ligne); }
.done__facts div:last-child { border-bottom: 0; }
.done__facts dt { color: var(--brume); font-size: 14.5px; }
.done__facts dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.done__actions { display: grid; gap: 10px; }

/* ---------- Code d'accès ---------- */

.gate { display: grid; place-items: center; min-height: 62vh; }
.gate__card {
  width: 100%;
  max-width: 400px;
  padding: 30px 24px;
  border-radius: 26px;
  text-align: center;
  background: var(--verre);
  border: 1px solid var(--ligne);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 30px 80px rgba(0, 40, 100, 0.45);
}
.gate__icon {
  display: inline-grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  color: var(--cyan);
  border: 1.5px solid rgba(0, 178, 227, 0.6);
  box-shadow: 0 0 24px rgba(0, 178, 227, 0.4);
}
.gate__logo { display: block; width: 120px; height: auto; margin: 0 auto 6px; filter: drop-shadow(0 8px 24px rgba(0, 102, 179, 0.45)); }
.gate__title { font-size: 26px; letter-spacing: -0.02em; margin: 16px 0 6px; }
.gate__text { color: var(--brume); font-size: 14.5px; margin: 0 0 20px; }
.gate__form { display: grid; gap: 12px; }
.gate__input {
  width: 100%;
  min-height: 58px;
  padding: 12px;
  font-size: 22px;
  letter-spacing: 0.3em;
  text-align: center;
  color: var(--glace);
  background: rgba(5, 11, 31, 0.6);
  border: 1px solid var(--ligne);
  border-radius: 16px;
}
.gate__input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(0, 178, 227, 0.22); }
.gate .notice { text-align: left; }

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