/* Developer console layout. Tokens and components come from theme.css. */

.small { font-size: var(--fs-xs); }
.row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.row.between { justify-content: space-between; }

/* ---- ON AIR indicator: lights while a call is live --------------------------------- */

.on-air {
  padding: 3px var(--sp-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font: 600 var(--fs-2xs) / 1.4 var(--font-sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.on-air.live { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* ---- shell: rail + views ------------------------------------------------------------ */

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: calc(100vh - 57px);
}

.rail {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--sp-8);
  padding: var(--sp-6) 0 var(--sp-6);
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.rail ul { list-style: none; margin: 0; padding: 0; }
.rail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 40px;
  padding: 0 var(--sp-4) 0 var(--sp-6);
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font: 500 var(--fs-base) / 1 var(--font-sans);
  text-align: left;
  cursor: pointer;
}
.rail-item:hover { color: var(--text); background: var(--sunken); }
.rail-item[aria-current="page"] { color: var(--text); border-left-color: var(--accent); background: var(--surface); }
.rail-item[aria-current="page"] kbd { border-color: var(--accent); color: var(--accent); }
.rail-foot { display: grid; gap: var(--sp-2); padding: 0 var(--sp-6); font-size: var(--fs-xs); }
.rail-foot .label + * { margin-bottom: var(--sp-3); }
.rail-tenant { font-weight: 500; overflow-wrap: anywhere; }

.views { min-width: 0; }
.views > .notice { margin: var(--sp-4) var(--sp-8) 0; }
.view { min-width: 0; }

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}
.view-head h1 { font-size: var(--fs-2xl); letter-spacing: -0.02em; line-height: 1.05; margin-top: var(--sp-1); }

/* ---- test call ---------------------------------------------------------------------- */

.view-call {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--inspector-w);
  min-height: calc(100vh - 57px);
}
.call-main {
  display: grid;
  grid-template-rows: auto auto auto minmax(280px, 1fr) auto;
  gap: var(--sp-4);
  padding: var(--sp-8) var(--sp-8) var(--sp-6);
  min-width: 0;
}

.call-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-6); flex-wrap: wrap; }
.call-agent { display: grid; gap: var(--sp-2); min-width: 0; flex: 1 1 320px; }
.agent-select { max-width: 420px; font-weight: 600; font-size: var(--fs-md); min-height: 40px; }
.agent-line { font-size: var(--fs-xs); overflow-wrap: anywhere; }
.call-clock { display: grid; justify-items: end; gap: var(--sp-1); }
/* The dominant element of the screen: the call clock */
.timer { font-size: var(--fs-3xl); font-weight: 500; line-height: 1; letter-spacing: -0.03em; color: var(--muted); }
.timer.live { color: var(--text); }

.call-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border);
}
.btn-call { min-width: 168px; }
.btn-call.hangup { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn-call.hangup:hover { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.call-controls .check { margin-left: auto; font-size: var(--fs-xs); color: var(--muted); }

.meters {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 104px;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
}
.meter { height: 4px; background: var(--sunken); overflow: hidden; }
.meter > div { width: 0; height: 100%; background: var(--text); transition: width 80ms linear; }
.meter.agent > div { background: var(--accent); }
.meter-state { font-size: var(--fs-2xs); font-weight: 600; color: var(--muted); text-align: right; text-transform: uppercase; letter-spacing: 0.07em; }
.meter-state.on { color: var(--text); }
.meter-state.agent-on { color: var(--accent); }

/* Transcript as a timestamped log, the way a call monitor prints it */
.log-wrap { min-height: 0; border: 1px solid var(--border); background: var(--surface); overflow-y: auto; }
.log { list-style: none; margin: 0; padding: var(--sp-2) 0; }
.log-empty { display: grid; gap: var(--sp-2); max-width: 60ch; padding: var(--sp-6) var(--sp-4); }
.log-line {
  display: grid;
  grid-template-columns: 52px 64px minmax(0, 1fr);
  gap: var(--sp-3);
  padding: 6px var(--sp-4);
  line-height: 1.55;
}
.log-line + .log-line { border-top: 1px solid var(--sunken); }
.log-line .t { font: 400 var(--fs-xs) / 1.9 var(--font-mono); color: var(--muted); }
.log-line .who { font: 600 var(--fs-2xs) / 2.1 var(--font-sans); letter-spacing: 0.07em; text-transform: uppercase; }
.log-line.caller .who { color: var(--text); }
.log-line.agent .who { color: var(--accent); }
.log-line .said { max-width: 72ch; overflow-wrap: anywhere; }
.log-line.live .said { color: var(--muted); }
.log-line.live .said::after { content: "▍"; font-style: normal; color: var(--accent); margin-left: 2px; }
.log-line .tag {
  margin-left: var(--sp-2);
  padding: 0 4px;
  border: 1px solid var(--border-strong);
  font: 600 var(--fs-2xs) / 1.5 var(--font-sans);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.log-line.note { grid-template-columns: 52px minmax(0, 1fr); }
.log-line.note .said { font-size: var(--fs-xs); line-height: 1.8; color: var(--muted); }
.log-line.note.danger .said { color: var(--danger); }

.composer { display: flex; gap: var(--sp-2); }
.composer .input { flex: 1; min-width: 0; }

/* ---- inspector ---------------------------------------------------------------------- */

.inspector {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--surface);
  min-width: 0;
}
.insp { padding: var(--sp-4) var(--sp-4) var(--sp-6); border-bottom: 1px solid var(--border); }
.insp.grow { flex: 1; min-height: 160px; }
.insp h2 { margin-bottom: var(--sp-3); }
.figures-list { margin: 0; display: grid; }
.figures-list > div { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 6px 0; border-bottom: 1px solid var(--sunken); }
.figures-list > div:last-child { border-bottom: 0; }
.figures-list dt { color: var(--muted); font-size: var(--fs-xs); }
.figures-list dd { margin: 0; font-size: var(--fs-base); font-weight: 500; }
.figures-list dd.fresh { color: var(--accent); }

.rag { display: grid; gap: var(--sp-3); max-height: 320px; overflow-y: auto; }
.rag-turn { display: grid; gap: var(--sp-1); }
.rag-query { font-size: var(--fs-xs); color: var(--muted); overflow-wrap: anywhere; }
.rag-query b { color: var(--text); font-weight: 500; }
.rag-hit { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--sp-2); font-size: var(--fs-xs); }
.rag-hit summary { display: contents; cursor: pointer; list-style: none; }
.rag-hit summary::-webkit-details-marker { display: none; }
.rag-hit .score { font-family: var(--font-mono); text-align: right; color: var(--ok); }
.rag-hit .score.low { color: var(--muted); }
.rag-hit .src { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rag-hit summary:hover .src { text-decoration: underline; }
.rag-hit p { grid-column: 2; padding: var(--sp-2); background: var(--sunken); color: var(--text); white-space: pre-wrap; }

.events { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); font-size: var(--fs-xs); max-height: 340px; overflow-y: auto; }
.events li { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: var(--sp-2); }
.events li.muted { display: block; }
.events .t { font-family: var(--font-mono); color: var(--muted); }
.events .what { overflow-wrap: anywhere; }
.events .what code { font-size: var(--fs-2xs); }
.events .danger { color: var(--danger); }
.tool-form { grid-column: 2; display: grid; gap: var(--sp-2); padding: var(--sp-2); border: 1px dashed var(--accent); }

.sim { padding-bottom: var(--sp-4); }
.sim summary { cursor: pointer; }
.sim[open] summary { margin-bottom: var(--sp-3); }
.sim .field { margin-top: var(--sp-3); font-size: var(--fs-xs); }
.sim .field > span { font-weight: 400; color: var(--muted); }

/* ---- split views: agents, call history ---------------------------------------------- */

.view-split {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: var(--sp-8);
  padding: var(--sp-8);
  align-items: start;
}
.split-list { display: grid; gap: var(--sp-6); min-width: 0; }
.split-detail { min-width: 0; position: sticky; top: var(--sp-4); }
.split-list .table td { height: 52px; }
.agent-cell b { font-weight: 600; }

.id-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-4); background: var(--sunken); border-bottom: 1px solid var(--border); min-width: 0; }
.id-row code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: var(--fs-xs); user-select: all; }

.placeholder {
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-12) var(--sp-6);
  border: 1px dashed var(--border-strong);
  color: var(--muted);
  max-width: 56ch;
}

.editor { display: grid; }
.editor-section { margin: 0; padding: var(--sp-4) var(--sp-4) var(--sp-6); border: 0; border-bottom: 1px solid var(--border); display: grid; gap: var(--sp-4); min-width: 0; }
.editor-section legend { float: left; width: 100%; padding: 0; margin-bottom: var(--sp-1); font-weight: 600; }
.editor-section legend .label { margin-right: var(--sp-2); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3) var(--sp-4); }
.kb-picks { display: grid; gap: 0; border: 1px solid var(--border); }
.kb-picks .check { padding: 0 var(--sp-3); border-bottom: 1px solid var(--sunken); }
.kb-picks .check:last-child { border-bottom: 0; }
.kb-picks .check small { margin-left: auto; font-family: var(--font-mono); color: var(--muted); }
.editor-actions { display: flex; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-4); }

.log.static { max-height: 70vh; overflow-y: auto; }

/* ---- knowledge ---------------------------------------------------------------------- */

.view-knowledge { display: grid; gap: var(--sp-6); padding: var(--sp-8); align-content: start; max-width: 1280px; }
.kb-select { min-width: 280px; }
.kb-summary { font-size: var(--fs-xs); margin-top: calc(var(--sp-4) * -1); }
.doc-name { font-weight: 500; overflow-wrap: anywhere; }
.dropzone {
  display: grid;
  gap: var(--sp-1);
  padding: var(--sp-4);
  border-top: 1px dashed var(--border-strong);
  cursor: pointer;
}
.dropzone:hover, .dropzone.over { background: var(--accent-soft); }
.dropzone:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; }
.retrieval { display: grid; gap: var(--sp-3); margin-top: var(--sp-8); }
.retrieval h2 { font-size: var(--fs-lg); letter-spacing: -0.01em; }
.passage { max-width: 80ch; font-size: var(--fs-xs); color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.score-cell { color: var(--ok); }
.score-cell.low { color: var(--muted); }

/* ---- responsive --------------------------------------------------------------------- */

@media (max-width: 1180px) {
  .view-call { grid-template-columns: minmax(0, 1fr); }
  .inspector { border-left: 0; border-top: 1px solid var(--border); }
  .view-split { grid-template-columns: minmax(0, 1fr); }
  .split-detail { position: static; }
}

@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { flex-direction: row; padding: 0; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .rail ul { display: flex; }
  .rail-item { padding: 0 var(--sp-4); border-left: 0; border-bottom: 3px solid transparent; white-space: nowrap; min-height: 44px; }
  .rail-item[aria-current="page"] { border-bottom-color: var(--accent); }
  .rail-item kbd, .rail-foot { display: none; }
  .call-main, .view-split, .view-knowledge { padding: var(--sp-6) var(--sp-4); }
  .views > .notice { margin: var(--sp-4) var(--sp-4) 0; }
  .timer { font-size: var(--fs-2xl); }
  .call-controls .check { margin-left: 0; }
  .btn kbd { display: none; }
  .meters { grid-template-columns: 48px minmax(0, 1fr) 84px; }
  .log-line { grid-template-columns: 44px minmax(0, 1fr); }
  .log-line .who { grid-column: 2; line-height: 1.2; }
  .log-line .said { grid-column: 2; }
  .log-line .t { grid-row: 1 / span 2; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .kb-select { min-width: 0; flex: 1; }
  .view-head h1 { font-size: var(--fs-xl); }
}

/* Let tables scroll inside their panel instead of widening the page */
.view-knowledge > *, .split-list > *, .split-detail > *, .retrieval > * { min-width: 0; }
.nowrap { white-space: nowrap; }
.view-head .row { flex-wrap: nowrap; }
.view-head .kb-select { min-width: 240px; max-width: 360px; }
.rail-foot a { display: block; line-height: 1.8; }
.rail-foot .label { margin-top: var(--sp-3); }
.rail-foot .label:first-child { margin-top: 0; }
.rail-foot .label + * { margin-bottom: 0; }
@media (max-width: 760px) {
  .view-head .row { flex-wrap: wrap; width: 100%; }
  .view-head .kb-select { min-width: 0; max-width: none; flex: 1 1 100%; }
}
