/* ─── VISIO — design tokens (docs/DESIGN.md) ──────────────────────
   Règle d'or : jamais de couleur en dur hors de ce bloc.
   Thème sombre par défaut (SPEC §18), bascule via [data-theme]. */

:root {
  --radius: 14px;
  --shadow-1: 0 1px 2px rgba(15,23,42,.04), 0 4px 12px rgba(15,23,42,.06);
  --shadow-2: 0 4px 8px rgba(15,23,42,.06), 0 10px 24px rgba(15,23,42,.10);
}

[data-theme="light"] {
  --bg: #eef2f7; --bg-deep: #e2e8f0; --card: #f5f7fa;
  --text: #1f2937; --text-dim: #6b7280; --border: #e5e7eb;
  --accent: #0066cc; --accent-strong: #0052a3; --accent-soft: #e8f1fc;
}

[data-theme="dark"] {
  --bg: #10151c; --bg-deep: #0c1117; --card: #1a212b;
  --text: #e4e9f1; --text-dim: #93a0b1; --border: #2c3542;
  --accent: #4e9cff; --accent-strong: #2f7fe0; --accent-soft: #15304e;
  --shadow-1: 0 1px 2px rgba(0,0,0,.25), 0 4px 12px rgba(0,0,0,.25);
  --shadow-2: 0 4px 8px rgba(0,0,0,.25), 0 10px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px; line-height: 1.45;
  background: var(--bg); color: var(--text);
}

/* ─── Page de login (DESIGN.md §4.15) ───────────────────────────── */

.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}

.halo { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; pointer-events: none; }
.halo-tl { top: -30vmax; left: -30vmax;  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%); }
.halo-br { bottom: -30vmax; right: -30vmax; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 13%, transparent), transparent 70%); }

.login-card {
  width: 420px; max-width: calc(100vw - 32px);
  background: var(--card); border-radius: 24px;
  box-shadow: 0 24px 60px rgba(15,23,42,.2);
  padding: 36px; text-align: center;
  position: relative; z-index: 1;
}

.logo {
  display: inline-block;
  padding: 8px 16px; border-radius: 999px;
  background: linear-gradient(90deg, #0d6ec9 0%, #005bb5 45%, #004e99 100%);
  color: #fff; font-weight: 700; letter-spacing: .04em;
}
.login-logo { max-width: 220px; height: auto; margin: 0 auto; display: block; }

.login-card h1 { font-size: 30px; font-weight: 700; margin: 18px 0 4px; }
.subtitle { color: var(--text-dim); margin: 0 0 24px; }

.login-card form { display: flex; flex-direction: column; gap: 12px; }

.login-card input {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px;
  font: inherit; color: var(--text);
}
.login-card input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-primary {
  border: none; border-radius: 999px;
  background: var(--accent); color: #fff;
  font: inherit; font-weight: 600;
  padding: 10px 16px; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn-primary:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}
.btn-primary:disabled { opacity: .5; cursor: default; }

.footnote { margin-top: 20px; font-size: 12px; color: var(--text-dim); }


/* ─── v0.2.0 — topbar, onglets, panneaux, salle de réunion ────────── */

.dim { color: var(--text-dim); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.form-error { color: var(--danger, #f87171); font-size: 13px; margin: 0; }

/* Topbar (DESIGN.md §4.1) */
.topbar {
  height: 56px; display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  background: linear-gradient(90deg, #1c2633 0%, #161d27 45%, #10151c 100%);
  box-shadow: 0 2px 12px rgba(0,79,158,.25);
  color: #fff;
}
[data-theme="light"] .topbar {
  background: linear-gradient(90deg, #0d6ec9 0%, #005bb5 45%, #004e99 100%);
}
.topbar-logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: rgba(255,255,255,.16);
  display: flex; align-items: center; justify-content: center;
}
.topbar-title { font-weight: 700; letter-spacing: .04em; }
.version-badge {
  font-family: ui-monospace, Consolas, monospace; font-size: 11px;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25);
  backdrop-filter: blur(6px);
}
.topbar-tabs { display: flex; gap: 4px; margin-left: 16px; }
.tab {
  padding: 7px 14px; border-radius: 999px; color: #fff; text-decoration: none;
  border: none; background: transparent; font: inherit; cursor: pointer;
}
.tab:hover { background: rgba(255,255,255,.14); }
.tab.active { background: var(--accent); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.context-pill {
  padding: 3px 10px; border-radius: 999px; background: rgba(255,255,255,.12); font-size: 12px;
}

/* Boutons (DESIGN.md §4.4) */
.btn-ghost {
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--card); color: var(--text);
  font: inherit; padding: 8px 14px; cursor: pointer;
  transition: transform .12s ease, background .12s ease;
}
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent); transform: translateY(-1px); }
.btn-danger {
  border: none; border-radius: 999px; background: #d9483b; color: #fff;
  font: inherit; font-weight: 600; padding: 10px 16px; cursor: pointer;
}
.btn-danger:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-rec-active { background: #d9483b !important; color: #fff; animation: rec-pulse 1.6s ease-in-out infinite; }
@keyframes rec-pulse { 50% { opacity: .55; } }
#ctl-rec { color: #d9483b; font-size: 18px; }
#ctl-rec .rec-dot { width: 14px; height: 14px; border-radius: 50%; background: #d9483b; display: inline-block; }
#ctl-rec.btn-rec-active .rec-dot { background: #fff; }
.btn-compact { padding: 6px 12px; font-size: 13px; }
.cam-select {
  max-width: 180px; padding: 8px 10px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  font: inherit; font-size: 13px; cursor: pointer;
}
.btn-icon {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 17px; cursor: pointer;
}
.btn-icon:hover { background: var(--accent-soft); }
.btn-icon.btn-off { background: rgba(217,72,59,.15); border-color: #d9483b; }

/* Page & panneaux */
.page { max-width: 1000px; margin: 0 auto; padding: 20px 16px; display: flex; flex-direction: column; gap: 20px; }
.panel {
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow-1);
  padding: 20px 22px;
}
.panel h2 { font-size: 16px; font-weight: 600; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.count-pill {
  font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}

/* Formulaires */
.create-form, .inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.create-form input, .inline-form input, .inline-form select {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; font: inherit; color: var(--text);
}
.create-form input:focus, .inline-form input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.create-form label { display: flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: 13px; }
.create-form input[type="number"] { width: 72px; }

/* Tuiles réunions (DESIGN.md §4.5) */
.tile-list { display: flex; flex-direction: column; gap: 6px; }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.tile:hover { background: var(--accent-soft); }
.tile-head { display: flex; justify-content: space-between; align-items: center; }
.tile-meta { font-size: 12px; color: var(--text-dim); margin: 4px 0 8px; }
.tile-actions { display: flex; gap: 8px; }

/* Tags (DESIGN.md §4.7) */
.tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.tag-blue { background: var(--accent-soft); color: var(--accent); }
.tag-green { background: rgba(46,160,67,.16); color: #4ade80; }
.tag-gray { background: var(--bg-deep); color: var(--text-dim); }

/* Admin (DESIGN.md §4.14) */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-dim); text-align: left; padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.admin-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.tenant-node { border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.tenant-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat-card { background: var(--bg-deep); border-radius: 14px; padding: 14px; text-align: center; }
.stat-val { font-size: 24px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--text-dim); }

/* Pré-connexion */
.prejoin-card video {
  width: 100%; border-radius: 14px; background: var(--bg-deep);
  margin-bottom: 14px; aspect-ratio: 16/10; object-fit: cover;
}
.prejoin-toggles { display: flex; gap: 8px; justify-content: center; }
.prejoin-card .cam-select { align-self: center; width: 100%; max-width: 280px; text-align: center; }

/* Salle de réunion */
.room-page { overflow: hidden; }
.room-shell { height: 100vh; display: flex; flex-direction: column; }
.room-body { flex: 1; display: flex; min-height: 0; }
.stage { flex: 1; padding: 16px; overflow: auto; }
.video-grid {
  display: grid; gap: 12px; height: 100%;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-content: center;
}
.video-tile {
  position: relative; background: var(--card); border-radius: 14px;
  box-shadow: var(--shadow-1); overflow: hidden;
  aspect-ratio: 16/10; display: flex; align-items: center; justify-content: center;
  max-height: calc(100vh - 190px);   /* ne dépasse jamais la fenêtre */
}
.video-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.video-tile.active-speaker::after {
  content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none;
  border: 3px solid var(--accent); border-radius: 14px;
}
.tile-name {
  position: absolute; left: 10px; bottom: 8px; z-index: 2;
  background: rgba(0,0,0,.45); color: #fff; font-size: 12px;
  padding: 2px 10px; border-radius: 999px;
}
.tile-mic { position: absolute; right: 10px; top: 8px; z-index: 2; }
.avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff; font-weight: 700; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }

/* Barre de contrôle */
.control-bar {
  display: flex; gap: 10px; justify-content: center; align-items: center;
  padding: 12px; background: var(--bg-deep); border-top: 1px solid var(--border);
}

/* Volet latéral (DESIGN.md §4.9) */
.side-panel {
  width: 320px; background: var(--card); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.side-panel[hidden] { display: none; }   /* hidden doit gagner sur display:flex */
.side-tabs { display: flex; gap: 6px; padding: 10px; }
.side-tabs .tab { color: var(--text); }
.side-tabs .tab:hover { background: var(--accent-soft); }
.pane { flex: 1; overflow: auto; padding: 10px; display: flex; flex-direction: column; }
.participant-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; }
.participant-row .dim { margin-left: auto; }
.participant-row.speaking .mic-state { color: var(--accent); filter: drop-shadow(0 0 4px var(--accent)); }
#chat-log { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.chat-bubble {
  background: var(--accent-soft); border-radius: 12px; padding: 7px 11px;
  max-width: 85%; align-self: flex-start;
}
.chat-me { align-self: flex-end; }
.chat-from { display: block; font-size: 11px; font-weight: 600; color: var(--accent); margin-bottom: 2px; }
#chat-form { display: flex; gap: 6px; padding-top: 8px; }
#chat-form input {
  flex: 1; background: var(--bg-deep); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 12px; font: inherit; color: var(--text);
}

/* Toasts (DESIGN.md §4.13) */
#toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--card); border: 1px solid var(--border); border-radius: 999px;
  padding: 10px 18px; box-shadow: var(--shadow-2); animation: toast-in .2s ease;
}
.toast-danger { border-color: #d9483b; color: #f87171; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Bouton « Activer le son » (autoplay bloqué par le navigateur) */
.audio-prompt {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  z-index: 60; box-shadow: var(--shadow-2);
}

/* Pré-connexion : test micro / haut-parleur */
.prejoin-test { display: flex; align-items: center; gap: 12px; }
.meter {
  flex: 1; height: 8px; border-radius: 999px;
  background: var(--bg-deep); overflow: hidden;
}
#mic-level {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), #2e9e5b);
  border-radius: 999px; transition: width .08s linear;
}
#mic-level.hot { background: linear-gradient(90deg, var(--accent), #f59e0b, #dc2626); }

/* ─── v0.2.3 — responsive mobile ──────────────────────────────────
   Objectifs : pleine hauteur réelle (100dvh), une colonne de tuiles,
   gros boutons tactiles, panneau latéral en plein écran. */

.room-shell { height: 100vh; height: 100dvh; }

@media (max-width: 768px) {
  /* Topbar compacte */
  .topbar { height: 48px; padding: 0 10px; gap: 8px; }
  .topbar .version-badge { display: none; }
  .topbar-title { font-size: 14px; }

  /* Grille : une tuile par ligne, scroll vertical */
  .stage { padding: 8px; }
  .video-grid {
    grid-template-columns: 1fr;
    align-content: start;
    gap: 8px;
  }
  .video-tile { aspect-ratio: 4/3; }

  /* Barre de contrôle : cibles tactiles ≥ 48px, safe-area iOS/Android */
  .control-bar {
    gap: 8px; padding: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .control-bar .btn-icon { min-width: 48px; min-height: 48px; font-size: 18px; }
  .control-bar .btn-danger { min-height: 48px; padding: 0 18px; }

  /* Panneau participants/chat : plein écran par-dessus la salle */
  .side-panel {
    position: fixed; inset: 0; z-index: 50;
    width: 100%; border-left: none;
  }

  /* Pré-connexion : carte pleine largeur */
  .login-card { padding: 24px; border-radius: 20px; }
  .login-card h1 { font-size: 22px; }
  #preview { max-height: 38vh; }

  /* Bouton « Activer le son » au-dessus de la barre de contrôle */
  .audio-prompt { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
}
