/* voicebot-admin — v0.6 UI: light surface, emerald primary, soft tech feel. */

:root {
  /* ── canvas / surfaces ──────────────────────────────────────────── */
  --bg-page:        #f6f8fa;
  --bg-card:        #ffffff;
  --bg-input:       #f8fafc;
  --bg-muted:       #f1f5f9;
  --bg-tint:        #ecfdf5;        /* emerald-50 — soft accent wash */
  --bg-darken:      #eef2f7;        /* alt row, table head */

  /* ── ink ────────────────────────────────────────────────────────── */
  --fg:             #0f172a;        /* slate-900 — body */
  --fg-strong:      #020617;        /* slate-950 — headlines */
  --fg-dim:         #475569;        /* slate-600 — secondary */
  --fg-muted:       #94a3b8;        /* slate-400 — disabled / placeholder */

  /* ── primary: emerald ───────────────────────────────────────────── */
  --accent:         #059669;        /* emerald-600 */
  --accent-hover:   #047857;        /* emerald-700 */
  --accent-strong:  #064e3b;        /* emerald-800 — for text on light */
  --accent-soft:    #d1fae5;        /* emerald-100 — chip / tag bg */
  --accent-tint:    #ecfdf5;        /* emerald-50 — panel wash */
  --accent-glow:    rgba(5,150,105,0.18);

  /* ── status colours ─────────────────────────────────────────────── */
  --ok:             #059669;
  --ok-soft:        #d1fae5;
  --warn:           #d97706;        /* amber-600 */
  --warn-soft:      #fef3c7;
  --err:            #dc2626;        /* red-600 */
  --err-soft:       #fee2e2;
  --info:           #0284c7;        /* sky-600 */
  --info-soft:      #e0f2fe;

  /* ── lines ──────────────────────────────────────────────────────── */
  --border:         #e2e8f0;        /* slate-200 */
  --border-strong:  #cbd5e1;        /* slate-300 */
  --border-accent:  rgba(5,150,105,0.32);

  /* ── elevation ──────────────────────────────────────────────────── */
  --shadow-sm:  0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow:     0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.06);
  --shadow-md:  0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg:  0 10px 18px -3px rgba(15, 23, 42, 0.10), 0 4px 8px -4px rgba(15, 23, 42, 0.06);
  --ring:       0 0 0 3px var(--accent-glow);

  /* ── type ───────────────────────────────────────────────────────── */
  --font:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius:    8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--fg);
  background-color: var(--bg-page);
  /* Subtle dot grid — adds quiet "tech surface" texture without noise. */
  background-image: radial-gradient(circle at 1px 1px, rgba(15, 23, 42, 0.04) 1px, transparent 0);
  background-size: 22px 22px;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { color: var(--fg-strong); letter-spacing: -0.012em; }
h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 10px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }

code, .mono { font-family: var(--mono); font-size: 12.5px; }
code {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12.5px;
}

/* ── Topbar ──────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand a {
  color: var(--fg-strong);
  font-weight: 700;
  letter-spacing: -0.015em;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand a::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar nav a { color: var(--fg-dim); font-weight: 500; font-size: 13px; }
.topbar nav a:hover { color: var(--accent); text-decoration: none; }
.topbar nav .who { color: var(--fg-dim); font-size: 12.5px; }
.topbar nav .role {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--border);
  background: var(--bg-tint);
  color: var(--accent-strong);
  border-radius: 4px;
  margin-left: 6px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

main { max-width: 1100px; margin: 32px auto; padding: 0 28px; }

/* ── Generic text helpers ────────────────────────────────────────── */
.dim    { color: var(--fg-dim); }
.muted  { color: var(--fg-muted); font-style: italic; }
.row    { display: flex; gap: 12px; align-items: center; }
.row.spread { justify-content: space-between; margin-top: 18px; }
.inline { display: inline; }
.narrow { max-width: 580px; }

/* ── Alerts ──────────────────────────────────────────────────────── */
.ok, .error {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin: 12px 0;
  border-width: 1px;
  border-style: solid;
}
.ok    { background: var(--ok-soft);  color: var(--accent-strong); border-color: var(--border-accent); }
.error { background: var(--err-soft); color: #991b1b;              border-color: rgba(220,38,38,0.25); }

.log {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
  overflow-x: auto;
  color: var(--fg);
}

/* ── Cards / panels ──────────────────────────────────────────────── */
.card, .panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 440px; margin: 64px auto; }
.panel        { margin-top: 20px; }
.panel-header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.panel-header h2 { margin: 0; }
.cards {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  margin-top: 20px;
}

/* ── Tables ──────────────────────────────────────────────────────── */
table.grid {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
table.grid th, table.grid td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
table.grid th {
  background: var(--bg-darken);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-dim);
}
table.grid tr:last-child td { border-bottom: 0; }
table.grid tr:hover td { background: var(--bg-tint); }
table.kv input { width: 100%; }

/* ── Forms ───────────────────────────────────────────────────────── */
form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--fg-dim);
  font-weight: 500;
}
form input, form select, form textarea {
  background: var(--bg-card);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
form textarea {
  font-family: var(--mono);
  font-size: 12.5px;
  resize: vertical;
  min-height: 140px;
}
form input::placeholder, form textarea::placeholder { color: var(--fg-muted); }
form input:focus, form select:focus, form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

/* ── Buttons ─────────────────────────────────────────────────────── */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-card);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.12s ease;
}
button:hover, .button:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
  text-decoration: none;
}
button.primary, .button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: var(--shadow-sm);
}
button.primary:hover, .button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: white;
  box-shadow: var(--shadow);
}
button.ghost, .button.ghost {
  background: transparent;
  border-color: var(--border);
}
button.ghost:hover, .button.ghost:hover { background: var(--bg-tint); }
button:disabled, .button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
button.link {
  background: transparent;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font: inherit;
  font-size: 12.5px;
}
button.link:hover { color: var(--accent-hover); text-decoration: underline; }

/* ── Status pills ────────────────────────────────────────────────── */
.state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 14px;
  font-size: 11.5px;
  font-family: var(--mono);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}
.state::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.state-active, .state-online, .state-answered, .state-running {
  background: var(--ok-soft); color: var(--accent-strong); border-color: var(--border-accent);
}
.state-online::before { animation: pulse 2.4s ease-in-out infinite; }
.state-stale, .state-paused, .state-pending, .state-voicemail, .state-activating, .state-deactivating {
  background: var(--warn-soft); color: #92400e; border-color: rgba(217,119,6,0.25);
}
.state-inactive, .state-failed, .state-unknown, .state-offline, .state-no_answer {
  background: var(--err-soft); color: #991b1b; border-color: rgba(220,38,38,0.22);
}
.state-calling {
  background: var(--info-soft); color: #075985; border-color: rgba(2,132,199,0.25);
}
.state-draft, .state-done {
  background: var(--bg-muted); color: var(--fg-dim); border-color: var(--border);
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* ── Chips / tags ────────────────────────────────────────────────── */
.chip {
  display: inline-block;
  padding: 1px 8px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  color: var(--fg-dim);
  border-radius: 4px;
  margin-right: 4px;
  font-size: 11.5px;
  font-family: var(--mono);
}

details > summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 500; }
details[open]     { margin-top: 8px; padding: 12px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; }
details[open] > summary { margin-bottom: 8px; }


/* ════════════════════════════════════════════════════════════════════
   Bot grid — card-based picker on the home page
   ════════════════════════════════════════════════════════════════════ */
.bot-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  margin-top: 22px;
}
.bot-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  color: var(--fg);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.bot-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #34d399);
  opacity: 0;
  transition: opacity 0.18s;
}
.bot-card:hover {
  text-decoration: none;
  border-color: var(--border-accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.bot-card:hover::before { opacity: 1; }

.bot-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.bot-avatar {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  box-shadow: var(--shadow-sm);
  text-transform: uppercase;
}
.bot-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--fg-strong);
  margin: 0;
  letter-spacing: -0.01em;
}
.bot-role {
  color: var(--accent-hover);
  font-size: 12.5px;
  font-weight: 600;
  margin: 3px 0 0;
  letter-spacing: 0.005em;
}
.bot-company {
  color: var(--fg-dim);
  font-size: 13px;
  margin: 2px 0 0;
}
.bot-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0 0;
}
.bot-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-tint);
  color: var(--accent-strong);
  border: 1px solid var(--border-accent);
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.bot-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px dashed var(--border);
  color: var(--fg-muted);
  font-size: 11px;
  font-family: var(--mono);
}

/* ── Bot detail — keep .cards grid alive but in new theme ───────── */
.card h2 { margin-top: 0; }
.card p.dim { font-size: 12.5px; }

/* ════════════════════════════════════════════════════════════════════
   Voice picker — accent tabs + per-voice cards
   ════════════════════════════════════════════════════════════════════ */
.accent-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 8px 0 18px;
  flex-wrap: wrap;
}
.accent-tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 8px 16px;
  color: var(--fg-dim);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.12s, border-color 0.12s;
}
.accent-tab:hover { color: var(--fg-strong); }
.accent-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.accent-tab.find-more {
  margin-left: auto;
  padding: 4px 12px;
  align-self: center;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-card);
  color: var(--fg-dim);
  text-decoration: none;
  font-size: 12px;
}
.accent-tab.find-more:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--bg-tint);
}

.voice-cards {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.voice-cards.hidden { display: none; }
.voice-card-form { margin: 0; padding: 0; }
.voice-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  font-size: 13px;
  transition: border-color 0.1s, background 0.1s;
}
.voice-card:hover { border-color: var(--accent); background: var(--bg-tint); }
.voice-card.is-selected {
  border-color: var(--accent);
  background: var(--bg-tint);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.voice-radio {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--accent);
}
.voice-card.is-selected .voice-radio {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}
.voice-avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
}
.voice-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}
.voice-meta strong { font-size: 13px; color: var(--fg-strong); }
.voice-meta .dim { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voice-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent);
  flex: 0 0 30px;
  text-decoration: none;
  font-size: 14px;
}
.voice-play:hover { background: var(--accent-soft); color: var(--accent-hover); }
.voice-play.inline { margin-left: 8px; width: 24px; height: 24px; font-size: 12px; vertical-align: middle; }
.voice-table tr.is-current { background: var(--bg-tint); }
.voice-table audio        { vertical-align: middle; }

.lang-voice-form select {
  min-width: 280px;
  max-width: 100%;
  background: var(--bg-card);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 13px;
}

/* ── Voice recorder + scripts ────────────────────────────────────── */
.recorder-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 22px;
  margin-top: 12px;
}
.script-box {
  background: var(--bg-tint);
  border: 1px solid var(--border-accent);
  border-radius: 8px;
  padding: 16px 20px;
  margin-top: 12px;
  line-height: 1.7;
}
.script-box p { margin: 0 0 10px; }
.script-box q { quotes: "“" "”"; color: var(--accent-hover); font-style: italic; }
.script-box q::before { content: open-quote; }
.script-box q::after  { content: close-quote; }
.script-lang-btn { padding: 4px 12px; font-size: 12px; }
.rec-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}
#rec-status { font-size: 13px; }
#rec-btn, #rec-stop { min-width: 160px; }

/* ── Library card on /voice/library ──────────────────────────────── */
.library-card { transition: border-color 0.12s; background: var(--bg-card); }
.library-card:hover { border-color: var(--accent); }
.library-card input[type="text"] {
  background: var(--bg-input);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 9px;
  font-size: 12.5px;
}
