/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #22263a;
  --border:    #2e3250;
  --accent-a:  #4f9cf9;   /* customer — blue */
  --accent-b:  #50d9a0;   /* support  — green */
  --text:      #e2e8f0;
  --text-muted:#8892a4;
  --danger:    #f87171;
  --success:   #4ade80;
  --warning:   #fbbf24;
  --radius:    10px;
  --radius-sm: 6px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

html { font-size: 14px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.brand {
  color: var(--accent-b);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-decoration: none;
}
.brand:hover { text-decoration: underline; }

/* ── Main Layout ── */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 1.5rem 2rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ── Agents Grid ── */
.agents-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

/* ── Agent Panel ── */
.agent-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: border-color 0.2s;
}

.agent-panel.speaking {
  border-color: var(--accent-a);
  box-shadow: 0 0 0 1px var(--accent-a)22;
}

#panel-b.speaking {
  border-color: var(--accent-b);
  box-shadow: 0 0 0 1px var(--accent-b)22;
}

.agent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.agent-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 100px;
}

.agent-label.customer {
  background: #4f9cf922;
  color: var(--accent-a);
  border: 1px solid #4f9cf944;
}

.agent-label.support {
  background: #50d9a022;
  color: var(--accent-b);
  border: 1px solid #50d9a044;
}

.agent-status {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Config Rows ── */
.agent-config {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.config-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 0.5rem;
}

.config-row label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.select-model,
.select-voice,
.input-key {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.8rem;
  padding: 5px 8px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

.select-model:focus,
.select-voice:focus,
.input-key:focus {
  border-color: #4f9cf9;
}

.key-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.key-row .input-key { flex: 1; }

.key-status {
  font-size: 0.9rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.key-status.valid::after   { content: '✓'; color: var(--success); }
.key-status.invalid::after { content: '✗'; color: var(--danger); }
.key-status.checking::after { content: '…'; color: var(--text-muted); }

/* ── Prompt ── */
.section-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
  margin-bottom: 0.4rem;
}

.prompt-section { display: flex; flex-direction: column; }

.prompt-textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.6;
  padding: 0.6rem 0.75rem;
  resize: vertical;
  min-height: 130px;
  max-height: 260px;
  outline: none;
  transition: border-color 0.15s;
}

.prompt-textarea:focus { border-color: #4f9cf9; }

/* ── Visualizer Row ── */
.visualizer-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.mute-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 4px 8px;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.mute-btn:hover    { background: var(--border); }
.mute-btn.muted    { color: var(--danger); border-color: var(--danger); }

.visualizer {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  height: 40px;
  display: block;
}

/* ── Transcript Box ── */
.transcript-section { display: flex; flex-direction: column; flex: 1; }

.transcript-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.7;
  padding: 0.6rem 0.75rem;
  min-height: 100px;
  max-height: 180px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.transcript-placeholder {
  color: var(--text-muted);
  font-style: italic;
}

/* ── Controls Bar ── */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.controls-left  { display: flex; gap: 0.6rem; }
.controls-center { flex: 1; display: flex; justify-content: center; }
.controls-right { display: flex; align-items: center; gap: 0.6rem; }

/* ── Buttons ── */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 18px;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-start  { background: #22c55e; color: #fff; }
.btn-start:not(:disabled):hover { background: #16a34a; }

.btn-stop   { background: var(--danger); color: #fff; }
.btn-stop:not(:disabled):hover  { background: #dc2626; }

.btn-export {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 4px 12px;
}
.btn-export:not(:disabled) { color: var(--text); }
.btn-export:not(:disabled):hover { border-color: var(--accent-a); color: var(--accent-a); }

/* ── Status Indicator ── */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot.idle     { background: var(--text-muted); }
.dot.active   { background: var(--success); animation: pulse 1.2s infinite; }
.dot.error    { background: var(--danger); }

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

/* ── Controls Right ── */
.inline-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.input-small {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.8rem;
  padding: 4px 8px;
  width: 60px;
  text-align: center;
  outline: none;
}

.turn-counter,
.timer {
  font-size: 0.78rem;
  font-family: var(--mono);
  color: var(--text-muted);
  min-width: 56px;
}

/* ── Timeline ── */
.timeline-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.timeline-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.8;
  padding: 0.75rem 1rem;
  min-height: 140px;
  max-height: 280px;
  overflow-y: auto;
}

.timeline-entry {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.tl-time  { color: var(--text-muted); flex-shrink: 0; }
.tl-name  { font-weight: 600; flex-shrink: 0; min-width: 60px; }
.tl-name.customer { color: var(--accent-a); }
.tl-name.support  { color: var(--accent-b); }
.tl-text  { color: var(--text); }

/* ── Agent Stats ── */
.agent-stats {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.4rem 0.1rem 0;
}

.stats-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
}

.stats-label {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.stats-value {
  font-family: var(--mono);
  color: var(--text);
  font-weight: 600;
}

.stats-cost { color: var(--warning); }

/* ── Footer ── */
footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 0.6rem 2rem;
  text-align: center;
}

/* ── Warning Bar ── */
.warning-bar {
  background: #78350f22;
  border-top: 1px solid #92400e55;
  color: var(--warning);
  font-size: 0.72rem;
  padding: 0.5rem 2rem;
  text-align: center;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .agents-grid { grid-template-columns: 1fr; }
  .controls-bar { flex-direction: column; align-items: flex-start; }
  .controls-center { justify-content: flex-start; }
}
