/* ═══════════════════════════════════════════════════════════════
   Porte — design system sombre
   Palette : fond bleu nuit profond, accents bleu signal / vert porte
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg: #0A0F1A;
  --bg-2: #0D1420;
  --surface: #121B2A;
  --surface-2: #182338;
  --border: rgba(148, 180, 255, 0.10);
  --border-strong: rgba(148, 180, 255, 0.24);
  --text: #E7EDF7;
  --text-dim: #8FA0BA;
  --text-faint: #5A6B85;
  --accent: #3B82F6;
  --accent-2: #60A5FA;
  --ok: #34D399;
  --warn: #FBBF24;
  --danger: #F87171;
  --radius: 16px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter",
    "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  background-image: radial-gradient(1200px 600px at 50% -10%, rgba(59, 130, 246, 0.08), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.45;
}

button { font: inherit; color: inherit; }
input { font: inherit; color: inherit; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }

/* ── Coquille ─────────────────────────────────────────────────── */

.app-shell {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 12px) 16px
           calc(env(safe-area-inset-bottom) + 84px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 10px rgba(96, 165, 250, 0.8);
}

.pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12.5px;
  white-space: nowrap;
}

.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.pill.ok { color: var(--ok); border-color: rgba(52, 211, 153, 0.3); }
.pill.ok .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.pill.warn { color: var(--warn); border-color: rgba(251, 191, 36, 0.3); }
.pill.warn .dot { background: var(--warn); box-shadow: 0 0 8px var(--warn); }

/* ── Accueil ──────────────────────────────────────────────────── */

.hero {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 34px 20px 26px;
  border-radius: 20px;
  background: linear-gradient(180deg, #131E33, #0D1524);
  border: 1px solid var(--border);
}

.ring {
  position: absolute;
  left: 50%;
  top: 38%;
  width: 230px;
  height: 230px;
  margin: -115px 0 0 -115px;
  border-radius: 50%;
  border: 1px solid rgba(96, 165, 250, 0.28);
  animation: pulse 3.4s ease-out infinite;
  pointer-events: none;
}

.ring.r2 { animation-delay: 1.7s; }

@keyframes pulse {
  0%   { transform: scale(0.34); opacity: 0.9; }
  100% { transform: scale(1.18); opacity: 0; }
}

.hero-icon {
  position: relative;
  width: 68px;
  height: 68px;
  margin: 0 auto;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-2);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  box-shadow: 0 0 34px rgba(59, 130, 246, 0.25), inset 0 0 18px rgba(59, 130, 246, 0.10);
}

.hero-icon svg { width: 30px; height: 30px; }

.hero h1 {
  position: relative;
  margin-top: 16px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero .sub { position: relative; margin-top: 4px; color: var(--text-dim); font-size: 14px; }

.door-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.08);
  border: 1px solid rgba(52, 211, 153, 0.28);
  color: var(--ok);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.4s ease, border-color 0.4s ease, color 0.4s ease;
}

.door-chip svg { width: 15px; height: 15px; }

.door-chip.open {
  background: rgba(251, 191, 36, 0.10);
  border-color: rgba(251, 191, 36, 0.35);
  color: var(--warn);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease;
}

.action-btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.action-btn:active { transform: scale(0.97); }
.action-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.action-btn svg { width: 22px; height: 22px; color: var(--accent-2); }
.action-btn .label { font-size: 14.5px; font-weight: 600; }
.action-btn .hint { font-size: 12px; color: var(--text-faint); }

/* ── Cartes info ──────────────────────────────────────────────── */

.info-card {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 16px;
}

.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

.info-row:last-child { border-bottom: none; }
.info-row .k { color: var(--text-faint); }
.info-row .v { color: var(--text); text-align: right; word-break: break-all; }

/* ── Historique ───────────────────────────────────────────────── */

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 2px 10px;
}

.section-head h2, .section-title { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }

.section-title { margin: 22px 2px 10px; }
.section-title:first-child { margin-top: 2px; }

.btn-ghost {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 10px;
}

.btn-ghost:hover { color: var(--danger); background: rgba(248, 113, 113, 0.08); }

.history-list { list-style: none; }

.h-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
}

.h-item:last-child { border-bottom: none; }

.h-icon {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--accent-2);
}

.h-icon svg { width: 20px; height: 20px; }

.h-main { flex: 1; min-width: 0; }

.h-title { font-weight: 600; font-size: 14.5px; }

.h-sub {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-faint);
}

.badge {
  flex: none;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.badge.repondu { color: var(--accent-2); background: rgba(59, 130, 246, 0.10); border-color: rgba(59, 130, 246, 0.28); }
.badge.manque   { color: var(--danger);  background: rgba(248, 113, 113, 0.10); border-color: rgba(248, 113, 113, 0.28); }
.badge.refuse   { color: var(--text-dim); background: rgba(143, 160, 186, 0.10); border-color: rgba(143, 160, 186, 0.25); }
.badge.termine  { color: var(--text-dim); background: rgba(143, 160, 186, 0.10); border-color: rgba(143, 160, 186, 0.25); }
.badge.porte    { color: var(--ok);      background: rgba(52, 211, 153, 0.10); border-color: rgba(52, 211, 153, 0.28); }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 20px;
  color: var(--text-faint);
  font-size: 14px;
}

.empty svg { width: 34px; height: 34px; }

/* ── Réglages ─────────────────────────────────────────────────── */

.field { margin-bottom: 15px; }

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  margin: 0 2px 7px;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

.field-hint { margin: 7px 2px 0; font-size: 12px; color: var(--text-faint); }

.pass-wrap { position: relative; }

.pass-wrap input { padding-right: 48px; }

.pass-wrap button {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 10px;
  color: var(--text-faint);
  cursor: pointer;
}

.pass-wrap button:hover { color: var(--text-dim); background: var(--surface); }
.pass-wrap button svg { width: 19px; height: 19px; }

.btn-row { display: flex; gap: 10px; margin-top: 18px; }

.btn {
  flex: 1;
  height: 46px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.08s ease, filter 0.15s ease;
}

.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }

.btn.outline {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--accent-2);
}

.btn.outline:hover { background: rgba(59, 130, 246, 0.08); }
.btn.full { width: 100%; margin-top: 14px; }

.note {
  margin-top: 16px;
  padding: 13px 15px;
  border-radius: 12px;
  background: rgba(251, 191, 36, 0.07);
  border: 1px solid rgba(251, 191, 36, 0.22);
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.5;
}

.note strong { color: var(--warn); }

.ios-hint {
  margin-top: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
}

/* ── Barre d'onglets ──────────────────────────────────────────── */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  display: flex;
  background: rgba(10, 15, 26, 0.93);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 40;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0 8px;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 11.5px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--accent-2); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ── Overlay d'appel ──────────────────────────────────────────── */

#call-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 20px) 18px
           calc(env(safe-area-inset-bottom) + 20px);
  background: linear-gradient(180deg, #0C1322, #070B12);
  animation: fadeIn 0.22s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.hidden { display: none !important; }

.call-head { text-align: center; }

.source-chip {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
}

.call-head h2 { margin-top: 12px; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.call-head p { margin-top: 4px; font-size: 14px; color: var(--text-dim); }

.video-wrap {
  position: relative;
  margin-top: 22px;
  aspect-ratio: 16 / 9;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  box-shadow: var(--shadow);
}

.video-wrap canvas { width: 100%; height: 100%; display: block; }

.video-chip {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 9px;
  border-radius: 6px;
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: var(--warn);
}

.video-clock {
  position: absolute;
  bottom: 10px;
  left: 10px;
  font-size: 11px;
  color: rgba(231, 237, 247, 0.75);
  font-variant-numeric: tabular-nums;
}

.scanline {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(96, 165, 250, 0.10), transparent);
  animation: scan 2.6s linear infinite;
  pointer-events: none;
}

@keyframes scan {
  0%   { top: -4%; }
  100% { top: 104%; }
}

.call-status { margin: 20px 0 6px; text-align: center; min-height: 44px; }

#call-state { font-size: 15px; color: var(--text-dim); }
#call-timer { margin-top: 3px; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }

.call-controls {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding-bottom: 8px;
}

.ctrl-col { display: flex; flex-direction: column; align-items: center; gap: 7px; }

.ctrl {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  font-size: 10px;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}

.ctrl:active { transform: scale(0.93); }
.ctrl:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.ctrl svg { width: 23px; height: 23px; }

.ctrl.open {
  width: 84px;
  height: 84px;
  background: linear-gradient(180deg, #34D399, #0EA47C);
  border: none;
  color: #04291E;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(52, 211, 153, 0.35);
}

.ctrl.open svg { width: 28px; height: 28px; }

.ctrl.danger {
  background: #C93A45;
  border: none;
  color: #fff;
  box-shadow: 0 8px 24px rgba(201, 58, 69, 0.30);
}

.ctrl.muted {
  background: rgba(248, 113, 113, 0.14);
  border-color: rgba(248, 113, 113, 0.4);
  color: var(--danger);
}

/* ── Toast ────────────────────────────────────────────────────── */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 90px);
  transform: translateX(-50%) translateY(14px);
  z-index: 80;
  max-width: calc(100vw - 40px);
  padding: 11px 17px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13.5px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Vues / petites animations ────────────────────────────────── */

.view { animation: fadeIn 0.25s ease; }

@media (prefers-reduced-motion: reduce) {
  .ring, .scanline { animation: none; }
  .view, #call-overlay { animation: none; }
}

/* ── Écran large ──────────────────────────────────────────────── */

@media (min-width: 560px) {
  .app-shell { padding-top: calc(env(safe-area-inset-top) + 22px); }
  .hero { padding: 40px 24px 30px; }
  .hero h1 { font-size: 30px; }
}
