/* Конструктор голосовых агентов. Три колонки: список, форма, звонок. */

:root {
  --bg: #eef1f6;
  --panel: #fff;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e2e8f0;
  --accent: #16a34a;
  --accent-soft: #dcfce7;
  --warn: #f59e0b;
  --call: #ef4444;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --radius: 13px;
}

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

body {
  font: 15px/1.45 -apple-system, "Segoe UI", Inter, system-ui, sans-serif;
  color: var(--ink); background: var(--bg);
  height: 100vh; display: flex; flex-direction: column; overflow: hidden;
}
.hidden { display: none !important; }

/* ── Шапка ──────────────────────────────────────────────────────────── */

.top {
  display: flex; align-items: center; gap: 24px;
  padding: 11px 20px; background: #0f172a; color: #fff; flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 26px; }
.brand-title { font-size: 16px; font-weight: 650; }
.brand-sub { font-size: 12.5px; color: #94a3b8; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }

.btn {
  border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08);
  color: #fff; padding: 9px 15px; border-radius: 10px;
  font: inherit; font-weight: 560; cursor: pointer; transition: .15s;
}
.btn:hover:not(:disabled) { background: rgba(255,255,255,.16); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: #15803d; }
.btn-call { background: #2563eb; border-color: #2563eb; }
.btn-call:hover:not(:disabled) { background: #1d4ed8; }

.btn-sm {
  padding: 7px 11px; font-size: 13px; border-radius: 8px;
  border: 1px solid var(--line); background: #f8fafc; color: var(--ink);
}
.btn-sm:hover:not(:disabled) { background: #eef2f7; }
.btn-danger { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }

/* ── Сетка ──────────────────────────────────────────────────────────── */

.grid {
  flex: 1 1 auto; display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 420px;
  gap: 12px; padding: 12px; min-height: 0;
}
.col { display: flex; flex-direction: column; gap: 12px; min-height: 0; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 15px;
  display: flex; flex-direction: column; min-height: 0;
}
.card.grow { flex: 1 1 auto; overflow: hidden; }
.card.scroll { overflow-y: auto; gap: 14px; }
/* В скроллящейся колонке дочерние блоки не должны ужиматься: иначе нижние
   карточки налезают друг на друга вместо того, чтобы уехать под скролл. */
.card.scroll > * { flex: 0 0 auto; }
.card.sub { border-color: #e8edf3; background: #fbfcfe; padding: 12px 13px; gap: 11px; }

.card-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 9px; }
.card-head h2 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2); }
.src { margin-left: auto; font: 11.5px/1 var(--mono); color: var(--ink-3); }
.src.ok { color: var(--accent); }
.src.bad { color: var(--call); }
.empty { color: var(--ink-3); font-size: 13.5px; padding: 8px 0; }

/* ── Список агентов ─────────────────────────────────────────────────── */

.agents { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.agent {
  text-align: left; font: inherit; font-size: 13.5px; cursor: pointer;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; color: var(--ink);
}
.agent:hover { border-color: var(--accent); }
.agent.on { background: var(--accent-soft); border-color: #86efac; font-weight: 600; }
.agent small { display: block; color: var(--ink-3); font-weight: 400; font-size: 11.5px; }

/* ── Форма ──────────────────────────────────────────────────────────── */

.f { display: flex; flex-direction: column; gap: 5px; }
.f-label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.f-label i { font-weight: 400; font-style: normal; color: var(--ink-3); }
.f-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.f-inline { display: flex; gap: 8px; }
.f-inline input, .f-inline select { flex: 1 1 auto; }

input, select, textarea {
  font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; background: #fff; width: 100%;
}
textarea { font: 13.5px/1.55 var(--mono); resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.tools-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.tool-chip {
  display: flex; align-items: center; gap: 6px;
  font: 12.5px var(--mono); background: #fff;
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px 4px 8px;
  cursor: pointer;
}
.tool-chip.on { background: var(--accent-soft); border-color: #86efac; }
.tool-chip input { width: auto; }

.form-foot { display: flex; padding: 4px 0 2px; }

/* ── Звонок ─────────────────────────────────────────────────────────── */

.wave { display: flex; align-items: flex-end; justify-content: center; gap: 4px; height: 30px; }
.wave i { width: 4px; height: 5px; border-radius: 2px; background: #cbd5e1; }
body.agent-speaking .wave i { background: var(--accent); animation: bounce .9s infinite ease-in-out; }
.wave i:nth-child(2){animation-delay:.08s} .wave i:nth-child(3){animation-delay:.16s}
.wave i:nth-child(4){animation-delay:.24s} .wave i:nth-child(5){animation-delay:.32s}
.wave i:nth-child(6){animation-delay:.40s} .wave i:nth-child(7){animation-delay:.48s}
.wave i:nth-child(8){animation-delay:.56s} .wave i:nth-child(9){animation-delay:.64s}
@keyframes bounce { 0%,100%{height:5px} 50%{height:24px} }

.callbar { display: flex; align-items: center; gap: 9px; margin-top: 10px; font-size: 12.5px; color: var(--ink-2); }
.mic-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); }
.mic-dot.on { background: var(--accent); }
.meter { width: 90px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
#meterFill { height: 100%; width: 0; background: var(--accent); transition: width .08s; }
.lat { margin-left: auto; font: 12px var(--mono); color: var(--accent); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 14px; font-size: 13px; }
.stat { display: flex; gap: 8px; }
.stat b { margin-left: auto; font-variant-numeric: tabular-nums; }
.stat.warn b { color: var(--call); }

.transcript { overflow-y: auto; display: flex; flex-direction: column; gap: 7px; }
.line { display: flex; gap: 8px; font-size: 13.5px; }
.line .who { flex: 0 0 62px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding-top: 3px; }
.line .txt { background: #f8fafc; border-radius: 9px; padding: 6px 10px; }
.line.agent .txt { background: var(--accent-soft); }
.line.filler .txt { background: #fef3c7; color: #92400e; font-style: italic; }
.line.sys .txt { background: transparent; color: var(--ink-3); font-size: 12.5px; padding-left: 0; }

.tools { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.tool { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
.tool.pending { border-color: var(--warn); background: #fffbeb; }
.tool.done { border-color: #bbf7d0; }
.tool-head { display: flex; align-items: center; gap: 8px; }
.tool-name { font: 600 13px var(--mono); }
.tool-ms { margin-left: auto; font: 12px var(--mono); color: var(--accent); }
.tool pre {
  font: 11.5px/1.4 var(--mono); background: #f8fafc; border-radius: 7px;
  padding: 6px 8px; margin-top: 6px; white-space: pre-wrap; word-break: break-word;
  max-height: 150px; overflow: auto; color: #334155;
}

/* ── Тост ───────────────────────────────────────────────────────────── */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 13.5px; z-index: 40; box-shadow: 0 10px 30px rgba(15,23,42,.3);
}
.toast.bad { background: #b91c1c; }
