/* ── VoiceForge dashboard ─────────────────────────────────────────────── */

:root {
  --bg: #0b0e14;
  --bg-2: #11151f;
  --bg-3: #171c29;
  --border: #232a3b;
  --text: #e8ecf4;
  --text-dim: #8b93a7;
  --accent: #6c8cff;
  --accent-2: #9b6cff;
  --green: #3ecf8e;
  --red: #ff5d6c;
  --amber: #ffb454;
  --radius: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #1a2140 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

#app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.brand-mark { font-size: 26px; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: 0.2px; }
.brand-tag {
  font-size: 10px; color: var(--text-dim); border: 1px solid var(--border);
  padding: 2px 6px; border-radius: 999px;
}
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; color: var(--text-dim);
  font-size: 14px; font-weight: 500; padding: 10px 12px;
  border-radius: 10px; cursor: pointer; text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item.active { background: linear-gradient(90deg, rgba(108,140,255,0.18), rgba(155,108,255,0.10)); color: var(--text); }
.nav-ico { font-size: 16px; }
.sidebar-foot { margin-top: auto; padding-top: 16px; }
.key-status { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.key-chip {
  font-size: 10.5px; padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-dim);
}
.key-chip.ok { color: var(--green); border-color: rgba(62,207,142,0.35); }
.key-chip.miss { color: var(--amber); border-color: rgba(255,180,84,0.3); }
.foot-note { font-size: 11px; color: var(--text-dim); line-height: 1.5; }

/* ── Main ── */
.main { flex: 1; padding: 24px 32px 48px; max-width: 1200px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.topbar h1 { font-size: 22px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--amber); display: inline-block; }
.conn-dot.on { background: var(--green); box-shadow: 0 0 8px rgba(62,207,142,0.7); }

/* ── Buttons ── */
.btn {
  border: none; border-radius: 10px; padding: 9px 16px;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: transform 0.1s, filter 0.15s, background 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: var(--bg-3); color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: #1e2435; }
.btn.danger { background: rgba(255,93,108,0.15); color: var(--red); border: 1px solid rgba(255,93,108,0.35); }
.btn.danger:hover { background: rgba(255,93,108,0.25); }
.btn.icon { padding: 6px 10px; font-size: 13px; }
.btn.sm { padding: 6px 12px; font-size: 12.5px; }

/* ── Views ── */
.view { display: none; }
.view.active { display: block; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* ── Agent cards ── */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.agent-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.agent-card:hover { border-color: rgba(108,140,255,0.45); transform: translateY(-2px); box-shadow: var(--shadow); }
.agent-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.agent-name { font-size: 16px; font-weight: 700; }
.agent-desc { font-size: 12.5px; color: var(--text-dim); line-height: 1.45; }
.agent-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  font-size: 10.5px; padding: 3px 8px; border-radius: 999px;
  background: var(--bg-3); border: 1px solid var(--border); color: var(--text-dim);
}
.badge.llm { color: var(--accent); border-color: rgba(108,140,255,0.35); }
.badge.voice { color: var(--accent-2); border-color: rgba(155,108,255,0.35); }
.badge.demo { color: var(--amber); border-color: rgba(255,180,84,0.3); }
.agent-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.agent-call-count { font-size: 11.5px; color: var(--text-dim); }
.agent-actions { display: flex; gap: 6px; }

/* ── Calls table ── */
.calls-table { width: 100%; border-collapse: collapse; background: var(--bg-2); border-radius: var(--radius); overflow: hidden; }
.calls-table th, .calls-table td { padding: 11px 14px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--border); }
.calls-table th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); background: var(--bg-3); }
.calls-table tr:hover td { background: rgba(255,255,255,0.02); }
.calls-table .row-actions { text-align: right; }
.empty-state { text-align: center; padding: 70px 0; color: var(--text-dim); }
.empty-ico { font-size: 44px; margin-bottom: 12px; }

/* ── Modal ── */
.modal {
  position: fixed; inset: 0; background: rgba(5,7,12,0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  animation: fade 0.2s ease;
}
.modal.hidden, .hidden { display: none !important; }
.modal-card {
  width: 560px; max-width: 94vw; max-height: 88vh; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); padding: 22px;
}
.modal-card.wide { width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h2 { font-size: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ── Forms ── */
.agent-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.field .hint { font-weight: 400; color: #5d6579; }
.field input[type="text"], .field input[type="number"], .field textarea, .field select {
  background: var(--bg-3); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font-size: 13.5px; font-family: inherit;
  outline: none; transition: border-color 0.15s;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 80px; }
.field input[type="range"] { accent-color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.advanced { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.advanced summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.advanced-body { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; }

/* ── Call overlay ── */
.call-overlay {
  position: fixed; inset: 0; background: rgba(5,7,12,0.82); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  animation: fade 0.25s ease;
}
.call-card {
  width: 640px; max-width: 94vw; max-height: 88vh;
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow);
  padding: 24px; display: flex; flex-direction: column; gap: 18px;
}
.call-head { display: flex; align-items: center; justify-content: space-between; }
.call-agent { display: flex; align-items: center; gap: 14px; }
.call-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center; font-size: 24px;
  box-shadow: 0 0 24px rgba(108,140,255,0.45);
}
.call-avatar.pulse { animation: pulse 1.6s ease infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 18px rgba(108,140,255,0.4); }
  50% { box-shadow: 0 0 34px rgba(108,140,255,0.85); }
}
.call-name { font-size: 17px; font-weight: 700; }
.call-sub { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.state-badge {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
  padding: 3px 10px; border-radius: 999px;
  background: var(--bg-3); color: var(--text-dim); border: 1px solid var(--border);
}
.state-badge.listening { color: var(--green); border-color: rgba(62,207,142,0.4); }
.state-badge.thinking { color: var(--amber); border-color: rgba(255,180,84,0.4); }
.state-badge.speaking { color: var(--accent); border-color: rgba(108,140,255,0.5); }
.call-timer { font-size: 12.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.waveform-wrap { background: var(--bg-3); border: 1px solid var(--border); border-radius: 12px; padding: 8px; }
#waveform { width: 100%; height: 90px; display: block; }

.call-transcript {
  flex: 1; min-height: 220px; max-height: 46vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px; padding: 4px 2px;
}
.bubble { max-width: 80%; padding: 10px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; word-wrap: break-word; }
.bubble.user { align-self: flex-end; background: linear-gradient(135deg, rgba(108,140,255,0.28), rgba(155,108,255,0.22)); border: 1px solid rgba(108,140,255,0.35); }
.bubble.assistant { align-self: flex-start; background: var(--bg-3); border: 1px solid var(--border); }
.bubble .who { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-dim); margin-bottom: 4px; }
.bubble.user .who { color: var(--accent); }
.bubble.assistant .who { color: var(--accent-2); }
.bubble.greeting { border-style: dashed; opacity: 0.9; }

.call-foot { display: flex; justify-content: space-between; align-items: center; min-height: 18px; }
.call-error { color: var(--red); font-size: 12px; }

/* ── Call detail ── */
.detail-body { display: flex; flex-direction: column; gap: 8px; }
.detail-row { font-size: 13px; color: var(--text-dim); }
.detail-row b { color: var(--text); font-weight: 600; }
.detail-transcript { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; max-height: 50vh; overflow-y: auto; }

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #2a3145; border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }
