/* ============================================================
   Créneau — identité visuelle
   Héros = un parcmètre numérique réactif : la couleur de la carte
   (vert / ambre / rouge) répond à l'état, lisible d'un coup d'œil.
   ============================================================ */

:root {
  --bg-0: #0b0e1a;
  --bg-1: #10142400;
  --surface: #171c30;
  --surface-2: #141829;
  --row: #151a2c;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);

  --text: #eaedf7;
  --text-dim: #9aa2bd;
  --text-faint: #6b7290;

  --brand: #5b7cff;
  --brand-ink: #ffffff;

  /* couleurs d'état */
  --ok: #2fcb7e;
  --soon: #fbbf3c;
  --exp: #ff5a6e;
  --none: #7b839c;

  --accent: var(--none);          /* remplacé selon l'état du parcmètre */
  --accent-tint: rgba(123, 131, 156, 0.12);
  --accent-glow: rgba(123, 131, 156, 0.0);

  --radius: 22px;
  --radius-sm: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-0);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 620px at 50% -10%, rgba(40, 54, 122, 0.38), transparent),
    linear-gradient(180deg, #121732 0%, var(--bg-0) 46%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

.app {
  max-width: 460px;
  margin: 0 auto;
  padding:
    calc(var(--safe-t) + 14px)
    18px
    calc(var(--safe-b) + 28px);
}

.hidden { display: none !important; }

/* ---------- Marque ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(145deg, #6d8bff, #4560e6);
  color: var(--brand-ink);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.5px;
  box-shadow: 0 6px 18px rgba(76, 96, 230, 0.45), inset 0 1px 0 rgba(255,255,255,.35);
}
.brand-mark--sm { width: 28px; height: 28px; font-size: 16px; border-radius: 9px; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.2px; }
.brand--big { flex-direction: column; gap: 12px; }
.brand--big .brand-mark { width: 58px; height: 58px; font-size: 33px; border-radius: 16px; }
.brand--big .brand-name { font-size: 26px; }

/* ============================================================
   Écran de saisie
   ============================================================ */
.screen--enter { min-height: 82vh; display: flex; align-items: center; }
.enter-wrap { width: 100%; }
.enter-lead {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.5;
  margin: 18px 0 26px;
}
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 16px 4px 8px;
}
.field-opt { text-transform: none; letter-spacing: 0; font-weight: 500; }

.plate-field, .text-field {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 15px 16px;
  font-size: 17px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.plate-field {
  text-align: center;
  font-weight: 800;
  font-size: 26px;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.plate-field::placeholder { color: #3f465f; letter-spacing: 3px; }
.text-field::placeholder { color: #4a5169; }
.plate-field:focus, .text-field:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(91, 124, 255, 0.18);
}

/* ============================================================
   Barre supérieure
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.plate-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px 8px 14px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  cursor: pointer;
}
.plate-chip svg { opacity: 0.6; }

/* ============================================================
   Le parcmètre (héros)
   ============================================================ */
.meter {
  position: relative;
  border-radius: var(--radius);
  padding: 26px 22px 20px;
  background:
    linear-gradient(180deg, var(--accent-tint), rgba(255,255,255,0.015)),
    var(--surface);
  border: 1px solid var(--line);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.04) inset,
    0 18px 46px -22px var(--accent-glow),
    0 10px 30px -20px rgba(0,0,0,0.8);
  overflow: hidden;
  transition: background 0.5s var(--ease), box-shadow 0.5s var(--ease);
}
.meter::before {
  /* liseré de couleur en haut, comme un afficheur */
  content: "";
  position: absolute; inset: 0 0 auto 0;
  height: 3px;
  background: var(--accent);
  opacity: 0.9;
}

.meter-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--accent);
}
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
}

.meter-time {
  font-family: ui-monospace, "SF Mono", "Roboto Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: clamp(32px, 10.5vw, 46px);
  line-height: 1;
  letter-spacing: -1px;
  margin: 14px 0 6px;
  color: var(--text);
  font-feature-settings: "tnum" 1;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.meter-time .cd-d { font-size: 0.62em; color: var(--text-dim); font-weight: 800; }
.meter-time .cd-t { font-size: 1em; }
.meter-frozen {
  display: inline-block;
  margin-top: 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--soon);
  background: rgba(251, 191, 60, 0.14);
  border: 1px solid rgba(251, 191, 60, 0.35);
  border-radius: 999px;
  padding: 4px 10px;
}
.meter-sub {
  color: var(--text-dim);
  font-size: 14.5px;
  min-height: 20px;
}

.meter-bar {
  margin-top: 18px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.meter-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.9s linear, background 0.5s var(--ease);
}

/* Variantes d'état : on ne change qu'une variable + quelques dérivées */
.meter[data-state="ok"] {
  --accent: var(--ok);
  --accent-tint: rgba(47, 203, 126, 0.14);
  --accent-glow: rgba(47, 203, 126, 0.55);
}
.meter[data-state="soon"] {
  --accent: var(--soon);
  --accent-tint: rgba(251, 191, 60, 0.16);
  --accent-glow: rgba(251, 191, 60, 0.5);
}
.meter[data-state="expired"] {
  --accent: var(--exp);
  --accent-tint: rgba(255, 90, 110, 0.16);
  --accent-glow: rgba(255, 90, 110, 0.55);
}
.meter[data-state="none"] {
  --accent: var(--none);
  --accent-tint: rgba(123, 131, 156, 0.10);
  --accent-glow: rgba(0,0,0,0);
}
.meter[data-state="soon"] .dot,
.meter[data-state="expired"] .dot {
  animation: pulse 1.4s var(--ease) infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 var(--accent); opacity: 1; }
  70%  { box-shadow: 0 0 0 8px rgba(0,0,0,0); opacity: 0.85; }
  100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); opacity: 1; }
}

/* ============================================================
   Actions
   ============================================================ */
.actions { margin-top: 16px; display: grid; gap: 10px; }

.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 700;
  padding: 15px 18px;
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.15s ease, background 0.15s ease;
  font-family: inherit;
}
.btn:active { transform: scale(0.985); }
.btn--block { width: 100%; display: block; }
.btn--primary {
  background: linear-gradient(180deg, #6a89ff, var(--brand));
  color: var(--brand-ink);
  box-shadow: 0 10px 26px -12px rgba(91,124,255,0.9);
}
.btn--primary:active { filter: brightness(0.96); }
.btn--ghost {
  background: transparent;
  color: var(--exp);
  border: 1px solid rgba(255, 90, 110, 0.4);
}
.btn--flat { background: transparent; color: var(--text-dim); box-shadow: none; }

/* ============================================================
   Lignes (notifications)
   ============================================================ */
.row {
  width: 100%;
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 13px;
  text-align: left;
  background: var(--row);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 15px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}
.row-icon {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: rgba(91,124,255,0.14);
  color: var(--brand);
  flex: none;
}
.row-icon.is-on { background: rgba(47,203,126,0.16); color: var(--ok); }
.row-text { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 15px; }
.row-sub { color: var(--text-faint); font-size: 13px; margin-top: 2px; }

.switch {
  width: 46px; height: 28px; border-radius: 999px;
  background: #333a54; flex: none; position: relative;
  transition: background 0.2s ease;
}
.switch span {
  position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; transition: transform 0.2s var(--ease);
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.switch[data-on="true"] { background: var(--ok); }
.switch[data-on="true"] span { transform: translateX(18px); }

.test-link {
  display: block;
  margin: 8px auto 0;
  background: none;
  border: none;
  color: var(--brand);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 6px 10px;
}

/* ---------- Astuce iOS ---------- */
.ios-hint {
  margin-top: 14px;
  background: rgba(91,124,255,0.10);
  border: 1px solid rgba(91,124,255,0.28);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text);
}
.ios-hint strong { display: block; margin-bottom: 8px; font-size: 14px; }
.ios-hint ol { margin: 0; padding-left: 20px; color: var(--text-dim); line-height: 1.7; }
.ios-hint b { color: var(--text); }
.ios-share {
  display: inline-block; width: 15px; height: 15px; vertical-align: -2px;
  background: currentColor;
  -webkit-mask: center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 2l4 4h-3v9h-2V6H8l4-4zM5 10h3v2H6v8h12v-8h-2v-2h3a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V11a1 1 0 0 1 1-1z'/%3E%3C/svg%3E");
  mask: center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 2l4 4h-3v9h-2V6H8l4-4zM5 10h3v2H6v8h12v-8h-2v-2h3a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V11a1 1 0 0 1 1-1z'/%3E%3C/svg%3E");
  color: var(--brand);
}

/* ============================================================
   Historique
   ============================================================ */
.log { margin-top: 26px; }
.log-head {
  font-size: 12px; font-weight: 700; letter-spacing: 0.5px;
  text-transform: uppercase; color: var(--text-faint);
  margin: 0 4px 10px;
}
.log-list { display: grid; gap: 8px; }
.log-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
}
.log-pill {
  width: 8px; height: 34px; border-radius: 4px; flex: none;
  background: var(--none);
}
.log-pill.paid { background: var(--ok); }
.log-pill.stopped { background: var(--text-faint); }
.log-main { flex: 1; min-width: 0; }
.log-line { font-size: 14px; font-weight: 600; }
.log-meta { font-size: 12.5px; color: var(--text-faint); margin-top: 1px; }
.log-empty {
  color: var(--text-faint); font-size: 14px;
  padding: 14px 4px; text-align: center;
}

.foot {
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  margin-top: 26px;
  opacity: 0.7;
}

/* ============================================================
   Feuille (paiement)
   ============================================================ */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(4, 6, 14, 0.62);
  backdrop-filter: blur(3px);
  z-index: 40;
  animation: fade 0.2s ease;
}
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  margin: 0 auto;
  max-width: 460px;
  background: var(--surface);
  border-top-left-radius: 26px;
  border-top-right-radius: 26px;
  border: 1px solid var(--line);
  border-bottom: none;
  padding: 10px 18px calc(var(--safe-b) + 20px);
  box-shadow: 0 -18px 50px -20px rgba(0,0,0,0.85);
  animation: slideUp 0.28s var(--ease);
}
.sheet-handle {
  width: 40px; height: 5px; border-radius: 999px;
  background: var(--line-strong);
  margin: 6px auto 14px;
}
.sheet-title { font-size: 19px; font-weight: 800; margin-bottom: 4px; }
.sheet-section-label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.4px;
  text-transform: uppercase; color: var(--text-faint);
  margin: 18px 2px 10px;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 15px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip--sel {
  background: #4a63e0;
  border-color: #4a63e0;
  color: #ffffff;
  font-weight: 700;
}
.reminder-note {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.4;
}
.custom-days { margin-top: 12px; }

.pin-block { margin-top: 18px; }
.pin-hint { font-size: 12.5px; color: var(--text-faint); margin-top: 6px; }

.sheet-err {
  margin-top: 14px;
  background: rgba(255, 90, 110, 0.12);
  border: 1px solid rgba(255, 90, 110, 0.4);
  color: #ffb3bd;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 14px;
}
.sheet .btn { margin-top: 14px; }
.sheet .btn--flat { margin-top: 4px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-b) + 22px);
  z-index: 60;
  background: #23293f;
  color: var(--text);
  border: 1px solid var(--line-strong);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 12px 30px -12px rgba(0,0,0,0.8);
  animation: fade 0.2s ease;
  max-width: 90%;
  text-align: center;
}

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

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

/* ============================================================
   Mode clair
   ============================================================ */
@media (prefers-color-scheme: light) {
  :root {
    --bg-0: #eef0f7;
    --surface: #ffffff;
    --surface-2: #f5f6fb;
    --row: #ffffff;
    --line: rgba(15, 20, 40, 0.09);
    --line-strong: rgba(15, 20, 40, 0.16);
    --text: #10142a;
    --text-dim: #545c78;
    --text-faint: #878ea8;
  }
  body {
    background:
      radial-gradient(1000px 560px at 50% -12%, #dfe4fb, transparent),
      linear-gradient(180deg, #e9ecf8 0%, var(--bg-0) 44%);
  }
  .brand-name { color: var(--text); }
  .meter { box-shadow: 0 18px 44px -26px var(--accent-glow), 0 8px 22px -18px rgba(20,30,60,0.35); }
  .switch { background: #c9cedd; }
  .toast { background: #ffffff; }
}
