/* ========================================================
   Voice Agent · console
   Direction : observability dark, accents néon sobres,
   typo monospace pour les données techniques + serif italique
   pour les titres. Style "tail -f" propre.
   ======================================================== */

:root {
  --bg: #0a0d0f;
  --bg-2: #10141a;
  --bg-3: #161b22;
  --line: #232a33;
  --line-soft: #1a2028;
  --text: #d6dde6;
  --text-mute: #6b7785;
  --text-dim: #4a5562;

  --accent: #5eead4;       /* mint cyan */
  --accent-2: #fbbf24;     /* ambre   */
  --accent-3: #f472b6;     /* rose tools */
  --accent-user: #93c5fd;  /* user */
  --accent-bot: #86efac;   /* assistant */
  --error: #fb7185;

  --radius: 4px;
  --gap: 14px;
  --pad: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 13px;
  line-height: 1.55;
  overflow: hidden;
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(94, 234, 212, 0.05), transparent 60%),
    radial-gradient(800px 500px at 110% 110%, rgba(244, 114, 182, 0.04), transparent 60%),
    var(--bg);
}

.mono { font-family: 'JetBrains Mono', monospace; }

/* ---------- topbar ---------- */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  color: var(--accent);
  font-size: 14px;
  text-shadow: 0 0 12px rgba(94, 234, 212, 0.6);
}
.brand-title {
  font-family: 'Instrument Serif', serif;
  font-size: 22px;
  letter-spacing: 0.2px;
  font-style: italic;
}
.brand-title i { font-style: italic; color: var(--text); }
.brand-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.04em;
  font-style: normal;
}

.status {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--text-mute);
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim);
  box-shadow: 0 0 0 0 currentColor;
}
.dot.connected { background: var(--accent); box-shadow: 0 0 12px var(--accent); animation: pulse 2s ease-in-out infinite; }
.dot.error { background: var(--error); box-shadow: 0 0 12px var(--error); }

@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.controls { display: flex; justify-content: flex-end; gap: 10px; }

.btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 16px;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.05em;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(94, 234, 212, 0.06);
}
.btn-primary:hover:not(:disabled) { background: rgba(94, 234, 212, 0.14); }

/* ---------- main grid ---------- */
.grid {
  display: grid;
  grid-template-columns: 1.1fr 1.4fr 1fr;
  gap: var(--gap);
  padding: var(--gap);
  overflow: hidden;
  min-height: 0;
}

.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
}
.card-head.sub { background: var(--bg-3); }

.card-title {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: 16px;
  color: var(--text);
}
.card-sub {
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- conversation ---------- */
.conv {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.bubble {
  max-width: 92%;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--line-soft);
  background: var(--bg-3);
  position: relative;
}
.bubble.user {
  align-self: flex-start;
  border-left: 2px solid var(--accent-user);
  color: var(--text);
}
.bubble.assistant {
  align-self: flex-end;
  border-left: 2px solid var(--accent-bot);
  color: var(--text);
  background: rgba(134, 239, 172, 0.04);
}
.bubble.interim {
  align-self: flex-start;
  color: var(--text-mute);
  font-style: italic;
  background: transparent;
  border-color: transparent;
  border-left: 2px dashed var(--text-dim);
}
.bubble-role {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 4px;
  font-family: 'JetBrains Mono', monospace;
}

/* ---------- pipeline column ---------- */
.pipeline-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line-soft);
}

.vad-box {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: radial-gradient(circle at center, var(--bg-3), var(--bg-2));
  transition: all 0.2s ease;
}
.vad-box.active {
  border-color: var(--accent);
  background: radial-gradient(circle at center, rgba(94, 234, 212, 0.18), var(--bg-2));
}
.vad-ring {
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 1px dashed var(--line);
  transition: all 0.2s ease;
}
.vad-box.active .vad-ring {
  border-color: var(--accent);
  border-style: solid;
  animation: ring 1s ease-in-out infinite;
}
@keyframes ring {
  0%,100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.06); opacity: 1; }
}
.vad-label {
  position: absolute;
  top: 10px; left: 12px;
  font-size: 9px; color: var(--text-mute);
  letter-spacing: 0.1em;
}
.vad-state {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: 22px;
  color: var(--text-mute);
  z-index: 1;
}
.vad-box.active .vad-state { color: var(--accent); }

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-content: start;
}
.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--bg-3);
}
.metric-label {
  display: block;
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.metric-value {
  font-size: 18px;
  color: var(--accent);
  font-weight: 500;
}
.metric-value.warn { color: var(--accent-2); }
.metric-value.bad  { color: var(--error); }

/* ---------- LLM stream ---------- */
.llm-stream {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  background:
    repeating-linear-gradient(
      transparent 0,
      transparent 23px,
      rgba(255,255,255,0.015) 23px,
      rgba(255,255,255,0.015) 24px
    ),
    var(--bg-2);
}
.llm-stream .tok {
  animation: tok-in 80ms ease-out;
}
.llm-stream .tok.fresh {
  background: rgba(94, 234, 212, 0.18);
  border-radius: 2px;
}
@keyframes tok-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- slots ---------- */
.slots {
  display: grid;
  grid-template-columns: 90px 1fr;
  row-gap: 8px;
  column-gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line-soft);
}
.slots dt {
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  align-self: center;
}
.slots dd {
  font-size: 13px;
  color: var(--text-dim);
  border-bottom: 1px dashed var(--line);
  padding-bottom: 4px;
  transition: color 0.3s ease, border-color 0.3s ease;
}
.slots dd.filled {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---------- tool timeline ---------- */
.timeline {
  flex: 1;
  list-style: none;
  overflow-y: auto;
  padding: 12px 16px;
}
.timeline li {
  position: relative;
  padding: 8px 0 12px 18px;
  border-left: 1px dashed var(--line);
  margin-left: 4px;
  font-size: 11.5px;
}
.timeline li:before {
  content: '';
  position: absolute;
  left: -5px; top: 12px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent-3);
  box-shadow: 0 0 0 3px var(--bg-2);
}
.timeline li.success:before { background: var(--accent); }
.timeline li.error:before   { background: var(--error); }

.tool-name {
  color: var(--accent-3);
  font-weight: 500;
  font-size: 12px;
}
.tool-args {
  color: var(--text-mute);
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-all;
  margin-top: 3px;
}
.tool-result {
  color: var(--accent);
  font-size: 11px;
  margin-top: 3px;
}
.tool-result.err { color: var(--error); }

/* ---------- bottom event log ---------- */
.bottom {
  border-top: 1px solid var(--line);
  padding: 7px 22px;
  font-size: 11px;
  color: var(--text-mute);
  background: var(--bg-2);
}

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
  border: 2px solid var(--bg-2);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr 1fr; }
}
