/* ==========================================================================
   NevSpot — Design System v2 (« Obsidian Signal »)
   Feuille de marque partagée : portail captif (+ socle de tokens de l'admin).
   Aucune ressource externe : tout est local, le portail doit s'afficher
   avant même l'authentification du client (walled garden).

   Tokens
   --nev-bg / --nev-bg-soft   : nuit profonde (fond, dégradés)
   --nev-surface / -raised    : panneaux et cartes
   --nev-line / --nev-line-2  : liserés (repos / survol)
   --nev-text / --nev-muted / --nev-faint : échelle de texte
   --nev-blue / --nev-cyan    : signal de marque (dégradé primaire)
   --nev-ok / --nev-warn / --nev-danger   : tons sémantiques
   --nev-s1..s6               : échelle d'espacement (4 pt)
   --nev-r-sm / -md / -lg     : rayons
   --nev-shadow / --nev-glow  : profondeur et halo d'accent
   ========================================================================== */

:root {
  --nev-bg: #030610;
  --nev-bg-soft: #071227;
  --nev-surface: rgba(9, 18, 38, 0.78);
  --nev-surface-raised: rgba(14, 27, 54, 0.88);
  --nev-line: #16294e;
  --nev-line-2: #24457c;
  --nev-text: #eaf2ff;
  --nev-muted: #93a9cc;
  --nev-faint: #5f759c;
  --nev-blue: #1ea8ff;
  --nev-blue-soft: #30a1e9;
  --nev-cyan: #3ae2ff;
  --nev-ok: #38d39f;
  --nev-warn: #ffb224;
  --nev-danger: #ff5d6c;
  --nev-s1: 4px;
  --nev-s2: 8px;
  --nev-s3: 12px;
  --nev-s4: 16px;
  --nev-s5: 24px;
  --nev-s6: 32px;
  --nev-r-sm: 10px;
  --nev-r-md: 14px;
  --nev-r-lg: 20px;
  --nev-shadow: 0 24px 64px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35);
  --nev-glow: 0 10px 32px rgba(30, 168, 255, 0.28);
  --nev-ease: cubic-bezier(0.22, 0.9, 0.28, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

::selection { background: rgba(30, 168, 255, 0.35); color: #fff; }

/* ---- Scène -------------------------------------------------------------- */

body.nev-body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 24px;
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
  padding-top: max(24px, env(safe-area-inset-top, 0px));
  padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
  -webkit-tap-highlight-color: rgba(30, 168, 255, .18);
  color: var(--nev-text);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(90% 55% at 50% -10%, rgba(30, 168, 255, 0.16) 0%, transparent 60%),
    radial-gradient(70% 50% at 85% 110%, rgba(58, 226, 255, 0.07) 0%, transparent 55%),
    radial-gradient(120% 90% at 50% 0%, var(--nev-bg-soft) 0%, var(--nev-bg) 62%);
  background-attachment: fixed;
}

/* ---- Aurore de fond : l'unique moment signature (halo vivant, GPU).
   Doctrine : une seule séquence de chargement (carte + aurore), le reste
   ne bouge qu'en réponse à une action (survol, onglet). Pas d'ambiant
   superflu. ---- */

body.nev-body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(34% 30% at 22% 16%, rgba(30, 168, 255, 0.13), transparent 70%),
    radial-gradient(30% 28% at 80% 80%, rgba(58, 226, 255, 0.09), transparent 70%);
  animation: nev-aurora 26s ease-in-out infinite alternate;
}

@keyframes nev-aurora {
  from { transform: translate3d(-3%, -2%, 0) scale(1); }
  to { transform: translate3d(3%, 2%, 0) scale(1.06); }
}

@keyframes nev-fade { from { opacity: 0; } to { opacity: 1; } }

/* ---- Carte -------------------------------------------------------------- */

.nev-card {
  width: 100%;
  max-width: 26rem;
  position: relative;
  z-index: 1;
  background: linear-gradient(180deg, var(--nev-surface-raised), var(--nev-surface));
  border: 1px solid var(--nev-line);
  border-radius: var(--nev-r-lg);
  padding: 40px 32px 32px;
  text-align: center;
  box-shadow: var(--nev-shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: nev-rise 0.45s var(--nev-ease) both;
  overflow-wrap: anywhere;
}

/* Liseré lumineux supérieur */
.nev-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  border-radius: var(--nev-r-lg) var(--nev-r-lg) 0 0;
  background: linear-gradient(90deg, transparent, rgba(58, 226, 255, 0.55), transparent);
}

.nev-card--portal { max-width: 30rem; padding: 32px 28px 24px; }

@keyframes nev-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.nev-logo {
  width: 132px;
  height: auto;
  margin: 0 auto 20px;
  display: block;
  filter: drop-shadow(0 8px 24px rgba(30, 168, 255, 0.35));
}

.nev-logo--sm { width: 104px; margin-bottom: 14px; }

.nev-title {
  margin: 0 0 8px;
  font-size: clamp(1.15rem, 4.6vw + 0.6rem, 1.38rem);
  font-weight: 680;
  letter-spacing: -0.01em;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.nev-sub {
  margin: 0;
  color: var(--nev-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.nev-badge {
  display: inline-block;
  margin-top: 20px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(30, 168, 255, 0.35);
  background: rgba(30, 168, 255, 0.09);
  color: var(--nev-blue);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  animation: nev-fade 0.5s var(--nev-ease) 0.12s both;
}

/* ---- Onglets segmentés ---------------------------------------------------- */

.nev-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  margin: 18px 0 20px;
  border: 1px solid var(--nev-line);
  border-radius: 12px;
  background: rgba(3, 6, 16, 0.55);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.nev-tabs::-webkit-scrollbar { display: none; }

.nev-tab {
  flex: 1 0 auto;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--nev-muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 550;
  cursor: pointer;
  transition: color 0.16s var(--nev-ease), background 0.16s var(--nev-ease), box-shadow 0.16s var(--nev-ease);
  white-space: nowrap;
}

.nev-tab:hover { color: var(--nev-text); }

.nev-tab.is-active {
  background: linear-gradient(180deg, rgba(30, 168, 255, 0.22), rgba(30, 168, 255, 0.12));
  color: var(--nev-text);
  box-shadow: inset 0 0 0 1px rgba(30, 168, 255, 0.4);
}

/* Onglet activé : le panneau révélé fond en place (sans JS). */
[data-panel]:not([hidden]) { animation: nev-fade 0.28s var(--nev-ease); }

.nev-btn, .nev-tab, .nev-links a, .nev-list-item { touch-action: manipulation; }

.nev-tab:focus-visible,
.nev-btn:focus-visible,
.nev-field input:focus-visible,
.nev-field select:focus-visible,
.nev-links a:focus-visible {
  outline: 2px solid var(--nev-cyan);
  outline-offset: 2px;
}

/* ---- Formulaires ---------------------------------------------------------- */

.nev-form { display: grid; gap: 14px; text-align: left; margin: 0; }

.nev-form--inline { display: flex; justify-content: center; margin-top: 18px; }

.nev-field { display: grid; gap: 7px; }

.nev-field > span {
  font-size: 0.8rem;
  font-weight: 550;
  color: var(--nev-muted);
  letter-spacing: 0.02em;
}

.nev-field input,
.nev-field select {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border-radius: var(--nev-r-sm);
  border: 1px solid var(--nev-line);
  background: rgba(3, 6, 16, 0.65);
  color: var(--nev-text);
  font: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.16s var(--nev-ease), box-shadow 0.16s var(--nev-ease), background 0.16s var(--nev-ease);
}

.nev-field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image: linear-gradient(45deg, transparent 50%, var(--nev-muted) 50%), linear-gradient(135deg, var(--nev-muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.nev-field input::placeholder { color: var(--nev-faint); }

.nev-field input:hover, .nev-field select:hover { border-color: var(--nev-line-2); }

.nev-field input:focus, .nev-field select:focus {
  border-color: var(--nev-blue);
  box-shadow: 0 0 0 3px rgba(30, 168, 255, 0.2);
  background: rgba(3, 6, 16, 0.85);
}

/* Texte d'aide sous un champ (pattern Form shadcn : label + contrôle + aide). */
.nev-hint {
  font-size: 0.78rem;
  color: var(--nev-faint);
  line-height: 1.45;
}

/* Champ « code prépayé » : saisie large, centrée, monospace (lot portail). */
.nev-field--code input {
  text-align: center;
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
  font-size: clamp(1.05rem, 5vw + 0.5rem, 1.3rem);
  font-weight: 650;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

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

.nev-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 48px;
  padding: 11px 20px;
  border-radius: var(--nev-r-sm);
  border: 1px solid transparent;
  background: linear-gradient(180deg, #37baff 0%, #0f8ce6 100%);
  box-shadow: var(--nev-glow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  color: #02101f;
  font: inherit;
  font-weight: 680;
  font-size: 0.97rem;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.16s var(--nev-ease), transform 0.1s var(--nev-ease), box-shadow 0.16s var(--nev-ease);
  position: relative;
  overflow: hidden;
}

.nev-btn:not(.nev-btn--ghost)::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 45%;
  pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: translateX(-160%) skewX(-18deg);
}

.nev-btn:not(.nev-btn--ghost):hover::after { animation: nev-sheen 0.7s var(--nev-ease); }

@keyframes nev-sheen {
  from { transform: translateX(-160%) skewX(-18deg); }
  to { transform: translateX(340%) skewX(-18deg); }
}

.nev-btn:hover { filter: brightness(1.07); }

.nev-btn:active { transform: translateY(1px); box-shadow: 0 4px 14px rgba(30, 168, 255, 0.22); }

.nev-btn:disabled,
.nev-btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; box-shadow: none; }

.nev-btn--block { width: 100%; }

.nev-btn--ghost {
  background: rgba(30, 168, 255, 0.05);
  border-color: var(--nev-line);
  color: var(--nev-muted);
  font-weight: 550;
  box-shadow: none;
}

.nev-btn--ghost:hover { color: var(--nev-text); border-color: var(--nev-line-2); filter: none; }

.nev-btn--danger {
  background: linear-gradient(180deg, #ff7482 0%, #e23c4e 100%);
  box-shadow: 0 10px 28px rgba(255, 93, 108, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  color: #1f0207;
}

.nev-btn--sm { min-height: 38px; padding: 7px 13px; font-size: 0.86rem; border-radius: 9px; }

/* ---- Alertes ------------------------------------------------------------------ */

.nev-alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 18px;
  padding: 11px 13px;
  border-radius: var(--nev-r-sm);
  font-size: 0.89rem;
  line-height: 1.45;
  text-align: left;
  animation: nev-rise 0.35s var(--nev-ease) both;
}

.nev-alert::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: currentColor;
}

.nev-alert--error {
  border: 1px solid rgba(255, 93, 108, 0.38);
  background: rgba(255, 93, 108, 0.1);
  color: #ffb9c0;
}

.nev-alert--ok {
  border: 1px solid rgba(56, 211, 159, 0.38);
  background: rgba(56, 211, 159, 0.1);
  color: #a5eccd;
}

/* ---- Métriques de session ------------------------------------------------------- */

.nev-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: 10px;
  margin: 22px 0 8px;
}

.nev-metric {
  position: relative;
  padding: 14px 12px 12px;
  border: 1px solid var(--nev-line);
  border-radius: 12px;
  background: rgba(3, 6, 16, 0.55);
  display: grid;
  gap: 5px;
  overflow: hidden;
  animation: nev-rise 0.45s var(--nev-ease) 0.08s both;
}

.nev-metric::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--nev-blue), transparent 75%);
  opacity: 0.65;
}

.nev-metric-label { font-size: 0.74rem; color: var(--nev-muted); letter-spacing: 0.06em; text-transform: uppercase; }

.nev-metric-value { font-size: 1.28rem; font-weight: 650; font-variant-numeric: tabular-nums; }

/* Jauge linéaire (temps / volume restant) — largeur via style="--p:62%". */
.nev-progress {
  height: 8px;
  border-radius: 999px;
  background: rgba(30, 168, 255, 0.14);
  overflow: hidden;
  margin: 14px 0 4px;
}

.nev-progress > i {
  display: block;
  height: 100%;
  width: var(--p, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--nev-blue), var(--nev-cyan));
  transition: width 0.6s var(--nev-ease);
}

/* Anneau de progression (écran compteur) — part via style="--p:62". */
.nev-ring {
  --p: 0;
  width: 148px;
  height: 148px;
  margin: 18px auto 6px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--nev-blue) calc(var(--p) * 1%), rgba(30, 168, 255, 0.13) 0);
  animation: nev-fade 0.5s var(--nev-ease) 0.1s both;
}

.nev-ring > .nev-ring-in {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: #060d1f;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 10px;
}

/* ---- Listes / forfaits ------------------------------------------------------------- */

.nev-list { display: grid; gap: 10px; margin: 18px 0; }

.nev-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid var(--nev-line);
  border-radius: 12px;
  background: rgba(3, 6, 16, 0.55);
  text-align: left;
  margin: 0;
  transition: border-color 0.16s var(--nev-ease), background 0.16s var(--nev-ease), transform 0.16s var(--nev-ease);
}

a.nev-list-item:hover,
button.nev-list-item:hover {
  border-color: var(--nev-line-2);
  background: rgba(10, 22, 46, 0.75);
  transform: translateY(-1px);
}

/* Forfait mis en avant (offre recommandée). */
.nev-list-item.nev-plan--featured {
  border-color: rgba(30, 168, 255, 0.55);
  background: linear-gradient(180deg, rgba(30, 168, 255, 0.13), rgba(30, 168, 255, 0.05));
  box-shadow: 0 10px 30px rgba(30, 168, 255, 0.14);
}

.nev-list-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.nev-list-text strong { font-size: 0.97rem; font-weight: 640; overflow-wrap: anywhere; }
.nev-list-text .nev-muted { font-size: 0.81rem; overflow-wrap: anywhere; }
.nev-muted { color: var(--nev-muted); }
.nev-price { font-variant-numeric: tabular-nums; color: var(--nev-blue); font-weight: 680; font-size: 1.02rem; white-space: nowrap; }

/* ---- Liens et pied ------------------------------------------------------------------- */

.nev-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  justify-content: center;
  margin-top: 22px;
  font-size: 0.86rem;
  animation: nev-fade 0.5s var(--nev-ease) 0.22s both;
}

.nev-links a {
  color: var(--nev-blue);
  text-decoration: none;
  transition: color 0.16s var(--nev-ease);
}

.nev-links a:hover { color: var(--nev-cyan); text-decoration: underline; }

.nev-footer {
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--nev-line);
  color: var(--nev-faint);
  font-size: 0.78rem;
}

.nev-footer-dot { margin: 0 7px; }
.nev-footer-brand { color: var(--nev-blue); font-weight: 600; }

/* ---- Mouvement et petits écrans ---------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .nev-card { animation: none; }
  .nev-btn, .nev-tab, .nev-field input, .nev-list-item, .nev-progress > i { transition: none; }
  body.nev-body::before, .nev-logo, .nev-alert, .nev-badge, .nev-metric,
  .nev-form > *, .nev-list > *, .nev-links, [data-panel] { animation: none !important; }
}

/* Tablette / grand mobile : carte plus large, air préservé. */
@media (max-width: 560px) {
  body.nev-body { padding: 18px; padding-left: max(18px, env(safe-area-inset-left, 0px)); padding-right: max(18px, env(safe-area-inset-right, 0px)); }
  .nev-card { padding: 32px 24px 24px; }
  .nev-card--portal { padding: 28px 22px 20px; }
  .nev-logo { width: 112px; }
  .nev-ring { width: 132px; height: 132px; }
  .nev-ring > .nev-ring-in { width: 104px; height: 104px; }
}

@media (max-width: 420px) {
  body.nev-body { padding: 14px; padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); }
  .nev-card { padding: 28px 20px 20px; border-radius: var(--nev-r-md); }
  .nev-card--portal { padding: 24px 16px 18px; border-radius: var(--nev-r-md); }
  .nev-metrics { grid-template-columns: 1fr 1fr; }
  .nev-btn { width: 100%; min-height: 48px; }
  .nev-form--inline .nev-btn { width: auto; }
  .nev-logo { width: 96px; margin-bottom: 14px; }
  .nev-field input, .nev-field select { font-size: 16px; }
  .nev-field--code input { letter-spacing: 0.14em; text-indent: 0.14em; }
  .nev-list-item { padding: 12px; gap: 10px; }
  .nev-list-text strong { font-size: 0.9rem; }
  .nev-price { font-size: 0.95rem; }
  .nev-ring { width: 120px; height: 120px; }
  .nev-ring > .nev-ring-in { width: 94px; height: 94px; }
  .nev-tabs { margin: 14px 0 16px; }
  .nev-tab { font-size: 0.82rem; padding: 10px; }
}

@media (max-width: 340px) {
  body.nev-body { padding: 10px; }
  .nev-card, .nev-card--portal { padding: 22px 14px 16px; }
  .nev-metrics { grid-template-columns: 1fr 1fr; gap: 8px; }
  .nev-metric { padding: 10px 8px; }
  .nev-metric-value { font-size: 1.05rem; }
  .nev-field--code input { letter-spacing: 0.08em; text-indent: 0.08em; }
  .nev-links { font-size: 0.8rem; gap: 6px 12px; }
}

/* Paysage bas : carte scrollable, logo compact, pas de débordement. */
@media (max-height: 500px) and (orientation: landscape) {
  body.nev-body { align-content: start; padding: 12px; }
  .nev-card, .nev-card--portal { padding: 20px 18px 16px; max-height: calc(100dvh - 24px); overflow-y: auto; }
  .nev-logo { width: 72px; margin-bottom: 10px; }
  .nev-logo--sm { width: 64px; margin-bottom: 8px; }
  .nev-ring { width: 104px; height: 104px; margin: 10px auto 4px; }
  .nev-ring > .nev-ring-in { width: 82px; height: 82px; }
  .nev-metrics { margin: 14px 0 6px; }
  .nev-footer { margin-top: 16px; padding-top: 12px; }
}

/* Offline banner shown by portal.js after repeated polling failures. */
.poll-offline {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  max-width: 18rem;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #8c1d18;
  color: #fff;
  font: 500 13px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}
