/* Voice Panel — design system : fond noir, accent menthe, Plus Jakarta Sans. */
:root {
  --bg: #0A0A0A;
  --surface: #141414;
  --surface-2: #1d1d1d;
  --border: #2a2a2a;
  --accent: #4BDEBB;
  --accent-dim: rgba(75, 222, 187, 0.15);
  --text: #F2F2F2;
  --text-dim: #9a9a9a;
  --danger: #ff5c5c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 800; letter-spacing: -0.02em; font-size: 20px; }
.topbar .brand span { color: var(--accent); }
.topbar nav a { margin-left: 20px; color: var(--text-dim); font-weight: 600; }
.topbar nav a:hover { color: var(--accent); }

.container { max-width: 920px; margin: 0 auto; padding: 32px 24px 64px; }
.wide { max-width: 1200px; }

h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 6px; }
h2 { font-size: 18px; font-weight: 700; margin: 0 0 14px; }
.muted { color: var(--text-dim); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
}

.stimulus-img {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.stimulus-video {
  width: 100%;
  max-height: 420px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #000;
  display: block;
}
.stimulus-desc { font-size: 16px; margin-top: 16px; }

label { display: block; font-size: 13px; color: var(--text-dim); margin: 14px 0 6px; font-weight: 600; }
input[type=text], select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 13px;
  font-family: inherit;
  font-size: 14px;
}
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > div { flex: 1 1 160px; }

button {
  background: var(--accent);
  color: #04130f;
  border: none;
  border-radius: 999px;
  padding: 13px 24px;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.05s;
}
button:hover { opacity: 0.9; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button.recording { background: var(--danger); color: #fff; }

.record-row { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.record-row .record-area { flex: 1 1 240px; }
.webcam-box { flex: 0 0 auto; text-align: center; }
#webcam {
  width: 240px; height: 180px; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--border); background: #000;
  transform: scaleX(-1); /* effet miroir */
}
.webcam-box .hint { max-width: 240px; margin-top: 8px; }
.record-area { text-align: center; padding: 8px 0; }
.timer { font-size: 38px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 10px 0; }
.hint { font-size: 13px; color: var(--text-dim); }
audio { width: 100%; margin-top: 14px; }

.thanks { text-align: center; padding: 40px 0; }
.thanks .check {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--accent-dim); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 34px; margin-bottom: 12px;
}

/* Dashboard */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.stat .value { font-size: 26px; font-weight: 800; color: var(--accent); }
.stat .label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 4px; }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 760px) { .charts { grid-template-columns: 1fr; } }
canvas { max-width: 100%; height: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-dim); font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: 0.04em; }
td.num { font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--accent-dim); color: var(--accent); font-weight: 700; font-size: 12px; }
.tag-null { color: #5a5a5a; }
.status-pending { color: var(--accent); font-weight: 600; font-size: 12px; }
.cred-badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  border: 1px solid currentColor; font-weight: 700; font-size: 12px;
  cursor: help; white-space: nowrap;
}

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* Sous-tableau des métriques faciales détaillées (Action Units). */
.facial-detail td { background: var(--surface-2); padding: 14px 16px; }
.facial-au-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; }
.facial-au-grid h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); }
.aurow { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 12px; }
.aulabel { width: 66px; color: var(--text-dim); flex: none; }
.auval { width: 52px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); flex: none; }
.aubar { flex: 1; height: 7px; border-radius: 999px; background: var(--border); overflow: hidden; }
.aubar span { display: block; height: 100%; border-radius: 999px; }
.duchenne { margin-top: 8px; font-size: 12px; font-weight: 700; color: var(--text-dim); }
.duchenne.ok { color: var(--accent); }

/* ============================ Responsive mobile-first ============================ */
/* Desktop : layout actuel (stimulus à gauche, webcam à droite) conservé tel quel.    */
/* Mobile (<768px) : empilement vertical + cibles tactiles, tableau -> cartes.        */
@media (max-width: 767px) {
  .topbar { padding: 14px 16px; }
  .topbar nav a { margin-left: 14px; }
  .container { padding: 20px 16px 48px; }
  h1 { font-size: 23px; }
  .card { padding: 18px; border-radius: 14px; }

  /* Page contributeur : stimulus en haut, webcam dessous, en pleine largeur. */
  .record-row { flex-direction: column; align-items: stretch; }
  .record-row .record-area,
  .webcam-box { width: 100%; flex: 1 1 auto; }
  #webcam {
    width: 100%; height: auto; aspect-ratio: 4 / 3; max-width: 100%;
  }
  .webcam-box .hint { max-width: none; }

  /* Timer bien visible + bouton d'enregistrement large et facile à toucher. */
  .timer { font-size: 44px; }
  #recBtn { width: 100%; min-height: 52px; font-size: 16px; }
  #submitBtn { width: 100%; min-height: 50px; }
  button { min-height: 48px; }

  /* Champs de formulaire en pleine largeur (la rangée s'empile). */
  .row { flex-direction: column; gap: 0; }
  .row > div { flex: 1 1 auto; }

  /* Dashboard : barre d'outils empilée, export accessible. */
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar #stimulusSelect { width: 100%; }
  .toolbar button { width: 100%; min-height: 48px; }

  /* Tableau des réactions -> cartes empilées (une carte par réaction). */
  #reactionsTable thead { display: none; }
  #reactionsTable,
  #reactionsTable tbody,
  #reactionsTable tr,
  #reactionsTable td { display: block; width: 100%; }
  #reactionsTable tr {
    border: 1px solid var(--border); border-radius: 12px;
    margin-bottom: 12px; padding: 6px 10px; background: var(--surface);
  }
  #reactionsTable td {
    border: none; padding: 6px 2px;
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
  }
  #reactionsTable td::before {
    content: attr(data-label);
    color: var(--text-dim); font-weight: 700;
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
    flex: none;
  }
  /* La ligne de détail facial occupe toute la largeur, sans préfixe de label. */
  #reactionsTable tr.facial-detail { padding: 0; }
  #reactionsTable tr.facial-detail td { display: block; padding: 12px; }
  #reactionsTable tr.facial-detail td::before { content: ""; }
}
