/* Reader-facing pages. Speaker colours are the validated categorical pair
   (blue advisor, orange caller); identity is never colour alone. */
:root {
  --surface-0: #ffffff; --surface-1: #fcfcfb; --surface-2: #f4f4f2;
  --border: #dcdcd6; --text: #0b0b0b; --muted: #76746e;
  --advisor: #2a78d6; --caller: #eb6834; --unknown: #76746e; --accent: #eda100;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --topbar: 52px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--surface-1); color: var(--text); font: 15px/1.55 var(--sans); }
a { color: var(--advisor); }
h1 { font-size: 24px; margin: 0 0 12px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 22px 0 8px; }
.muted { color: var(--muted); font-weight: 400; }
[hidden] { display: none !important; }

/* ---- top bar with the two tabs ------------------------------------- */
.topbar { height: var(--topbar); display: flex; align-items: center; gap: 24px; padding: 0 24px;
  background: var(--surface-0); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); white-space: nowrap; }
.tabs { display: flex; gap: 4px; height: 100%; }
.tabs a { display: flex; align-items: center; padding: 0 14px; text-decoration: none; color: var(--muted);
  font-weight: 600; border-bottom: 3px solid transparent; }
.tabs a.active { color: var(--text); border-bottom-color: var(--advisor); }
.topbar-context { margin-left: auto; color: var(--muted); font-family: var(--mono); font-size: 13px; }

/* ---- report tab -------------------------------------------------------- */
body.with-frame { overflow: hidden; }
.report-frame { display: block; width: 100%; height: calc(100vh - var(--topbar)); border: 0; background: #fff; }

/* ---- calls tab --------------------------------------------------------- */
.page { max-width: 1000px; margin: 0 auto; padding: 24px; }
.page.wide { max-width: 1400px; }
.calls-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.calls-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.calls-filters input, .calls-filters select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: var(--surface-0); }
.calls-filters input { min-width: 280px; }
table.calls { width: 100%; border-collapse: collapse; background: var(--surface-0); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
table.calls th, table.calls td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.calls th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--surface-2); }
table.calls td.resume { color: #3a3a37; max-width: 560px; font-size: 14px; }
table.calls .num { text-align: right; font-family: var(--mono); font-size: 13px; white-space: nowrap; }
table.calls tr:hover td { background: #f7f9fc; }
table.calls a { font-weight: 600; text-decoration: none; white-space: nowrap; }

/* ---- call page: two panes ---------------------------------------------- */
body.call-body { overflow: hidden; }
.call { height: calc(100vh - var(--topbar)); display: flex; flex-direction: column; }
.call-head { display: flex; align-items: center; gap: 20px; padding: 12px 24px; background: var(--surface-0); border-bottom: 1px solid var(--border); }
.call-head h1 { margin: 0; font-size: 18px; }
.back { text-decoration: none; font-weight: 600; white-space: nowrap; }
.pane-tabs { display: none; margin-left: auto; gap: 4px; }
.pane-tabs button { padding: 6px 14px; border: 1px solid var(--border); background: var(--surface-0); border-radius: 8px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.pane-tabs button.active { background: var(--advisor); border-color: var(--advisor); color: #fff; }
.panes { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(360px, 5fr) minmax(420px, 7fr); }
.pane { min-height: 0; overflow: auto; }
.pane-analysis { padding: 20px 24px; border-right: 1px solid var(--border); background: var(--surface-1); }
.pane-listen { display: flex; flex-direction: column; background: var(--surface-0); }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); }
.badge-type_appelant { background: #e8f0fb; border-color: #c7dbf5; color: #1d5db3; }
.badge-motif { background: #fdeee6; border-color: #f7cdb8; color: #b34a1a; }
.badge-resolution { background: #e6f6ef; border-color: #bfe6d2; color: #157a4e; }
.resume { font-size: 16px; line-height: 1.6; margin: 0 0 8px; }
.pane-analysis ul { margin: 0; padding-left: 20px; }
.pane-analysis li { margin: 4px 0; }
.moments { list-style: none; padding: 0; }
.moments li { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); align-items: baseline; }
.moments li:last-child { border-bottom: 0; }
.moment { font-family: var(--mono); font-size: 13px; font-weight: 700; text-decoration: none; min-width: 44px; }
.moment:hover { text-decoration: underline; }

/* ---- listening pane ---------------------------------------------------- */
.player-bar { position: sticky; top: 0; z-index: 2; background: var(--surface-0); border-bottom: 1px solid var(--border);
  padding: 10px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.player-bar audio { flex: 1 1 100%; }
.player-bar label { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.player-bar select, .player-bar input[type=search] { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: 13px; }
.player-bar input[type=search] { flex: 1; min-width: 160px; }
.legend { display: flex; gap: 12px; font-size: 13px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.segments { padding: 8px 16px 60px; }
.seg { display: grid; grid-template-columns: 48px 84px 1fr; gap: 10px; padding: 6px 8px; border-left: 3px solid var(--sp); border-radius: 4px; cursor: pointer; }
.seg:hover { background: var(--surface-2); }
.seg.active { background: #fff5d6; }
.seg .t { font-family: var(--mono); font-size: 12px; color: var(--muted); padding-top: 3px; }
.seg .who { font-size: 12px; font-weight: 600; color: var(--sp); padding-top: 3px; }
.seg .txt span.w.on { background: var(--accent); color: #000; border-radius: 3px; }

/* ---- narrow screens: one pane at a time, switched by tabs -------------- */
@media (max-width: 1000px) {
  .pane-tabs { display: flex; }
  .panes { display: block; }
  .pane { display: none; height: 100%; }
  .pane.active { display: flex; flex-direction: column; }
  .pane-analysis { border-right: 0; }
  .call-head h1 span { display: none; }
  .topbar-context { display: none; }
}

/* ---- login -------------------------------------------------------------- */
.login-body { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(160deg, #eef3fb, var(--surface-1) 60%); }
.login-card { width: min(400px, 92vw); background: var(--surface-0); border: 1px solid var(--border); border-radius: 14px; padding: 32px 32px 28px; box-shadow: 0 12px 40px rgba(20, 40, 80, 0.08); }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 18px; }
.login-mark { width: 12px; height: 12px; border-radius: 4px; background: linear-gradient(135deg, var(--advisor), var(--caller)); }
.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.login-card p { margin: 0 0 18px; font-size: 14px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.login-card input { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 15px; color: var(--text); }
.login-card input:focus { outline: 2px solid var(--advisor); outline-offset: 1px; border-color: var(--advisor); }
.login-card button { width: 100%; margin-top: 6px; padding: 11px; border: 0; border-radius: 8px; background: var(--advisor); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.login-card button:hover { background: #1f66bd; }
.login-error { background: #fdecec; color: #a12727; border: 1px solid #f3c4c4; border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.logout { margin-left: 16px; font-size: 13px; color: var(--muted); text-decoration: none; }
.logout:hover { color: var(--text); }
