/* VoiceAI admin panel styles — modern SaaS look */
:root {
  --bg: #f3f5fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8f2;
  --border-strong: #cfd6e6;
  --text: #0f172a;
  --muted: #667085;
  --faint: #98a2b3;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: #eef2ff;
  --ok: #10b981;
  --ok-soft: #ecfdf5;
  --warn: #f59e0b;
  --warn-soft: #fffbeb;
  --err: #ef4444;
  --err-soft: #fef2f2;
  --snippet-bg: #0b1220;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 8px 24px -12px rgba(16, 24, 40, .12);
  --shadow-lg: 0 8px 30px -6px rgba(16, 24, 40, .18);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(1100px 480px at 12% -8%, rgba(79, 70, 229, .08), transparent 60%),
    radial-gradient(900px 420px at 105% 0%, rgba(16, 185, 129, .07), transparent 55%),
    var(--bg);
  min-height: 100vh;
}
::selection { background: rgba(79, 70, 229, .22); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #c7cedd; border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---- header ---- */
header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #fff; padding: 14px 28px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 10px 30px -18px rgba(15, 23, 42, .9);
  position: sticky; top: 0; z-index: 40;
}
header h1 {
  font-size: 16px; margin: 0; font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 10px;
}
header h1::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, #818cf8, #22d3ee);
  box-shadow: 0 0 0 4px rgba(129, 140, 248, .18);
}
header h1 span { color: #a5b4fc; font-weight: 600; }
header .user {
  font-size: 13px; font-weight: 500; color: #cbd5e1;
  background: rgba(148, 163, 184, .14); border: 1px solid rgba(148, 163, 184, .22);
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}
header button {
  background: rgba(99, 102, 241, .9); color: #fff; border: none; border-radius: 10px;
  padding: 8px 16px; cursor: pointer; font-size: 13px; font-weight: 600; font-family: inherit;
  transition: background .15s, transform .08s;
}
header button:hover { background: #6366f1; }
header button:active { transform: translateY(1px); }

/* ---- tabs ---- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 18px 28px 0; max-width: 1400px; margin: 0 auto; }
.tab {
  background: transparent; border: 1px solid transparent; border-radius: 999px;
  padding: 9px 16px; font: 600 13.5px inherit; cursor: pointer; color: #475569;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
}
.tab:hover { background: rgba(255, 255, 255, .65); color: var(--text); }
.tab.active {
  background: var(--surface); color: var(--accent); border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.tab.active::after {
  content: ""; display: block; height: 3px; border-radius: 999px; margin-top: 4px;
  background: linear-gradient(90deg, var(--accent), #22d3ee); opacity: .9;
}

/* ---- layout ---- */
main { padding: 20px 28px 40px; max-width: 1400px; margin: 0 auto; }
/* Avoid flashing the default Settings pane while the hash route is restored. */
html.va-route-pending .pane { display: none !important; }
.pane {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); margin-top: 4px;
}
.pane h2 { margin: 0 0 18px; font-size: 18px; font-weight: 700; letter-spacing: -.2px; }
.pane h3 { font-size: 14.5px; font-weight: 700; margin: 24px 0 10px; color: #1e293b; }
.pane h4 { margin: 22px 0 8px; font-size: 13.5px; font-weight: 700; color: var(--accent); }

/* ---- tables ---- */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
thead th {
  color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  background: var(--surface-2); border-bottom: 1px solid var(--border-strong);
  position: sticky; top: 0;
}
thead th:first-child { border-radius: 10px 0 0 0; }
thead th:last-child { border-radius: 0 10px 0 0; }
tbody tr:hover { background: #f7f9ff; }
tbody tr:last-child td { border-bottom: none; }
td .key { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; color: var(--accent); word-break: break-all; }
td code { background: var(--accent-soft); border: 1px solid #dde4fb; color: #3730a3; padding: 1px 5px; border-radius: 6px; font-size: 12px; font-family: ui-monospace, Menlo, monospace; }
.pane table { margin-top: 4px; }

/* ---- badges ---- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; }
.badge.ok { background: var(--ok-soft); color: #047857; }
.badge.warn { background: var(--warn-soft); color: #b45309; }
.badge.err { background: var(--err-soft); color: #b91c1c; }

/* ---- buttons ---- */
button { font-family: inherit; }
button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff; border: none; border-radius: var(--radius-sm); padding: 10px 18px; cursor: pointer;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 6px 16px -6px rgba(79, 70, 229, .55);
  transition: transform .08s, box-shadow .15s, filter .15s;
}
button.primary:hover { filter: brightness(1.06); box-shadow: 0 10px 20px -8px rgba(79, 70, 229, .6); transform: translateY(-1px); }
button.primary:active { transform: translateY(0); }
button.ghost {
  background: var(--surface); color: #334155; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 14px; cursor: pointer; font-size: 13px; font-weight: 600;
  transition: background .15s, border-color .15s, transform .08s;
}
button.ghost:hover { background: var(--surface-2); border-color: #b7c0d6; }
button.ghost:active { transform: translateY(1px); }
button.ghost.danger { background: var(--err-soft); border-color: #fecaca; color: #b91c1c; }
button.ghost.danger:hover { background: #fee2e2; }
button.danger { background: var(--err); color: #fff; border: none; border-radius: var(--radius-sm); padding: 8px 14px; cursor: pointer; font-size: 13px; font-weight: 600; transition: filter .15s; }
button.danger:hover { filter: brightness(.95); }
button:disabled { opacity: .55; cursor: not-allowed; }

/* ---- forms ---- */
form .row { margin-bottom: 16px; }
label.flabel { display: block; font-size: 12.5px; font-weight: 600; color: #344054; margin-bottom: 6px; }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; margin-top: 4px; color: var(--text); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, .18);
}
textarea { min-height: 90px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---- misc primitives ---- */
.actions { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; line-height: 1.5; }
.hint code { background: var(--accent-soft); padding: 1px 6px; border-radius: 6px; font-size: 12px; font-family: ui-monospace, Menlo, monospace; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.card {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.card .num { font-size: 30px; font-weight: 800; letter-spacing: -.6px; background: linear-gradient(135deg, var(--accent), #0891b2); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.card .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.snippet {
  background: var(--snippet-bg); color: #7dd3fc; border: 1px solid rgba(255, 255, 255, .06);
  padding: 14px; border-radius: 12px; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; overflow-x: auto;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 600; color: #344054; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.chip:hover { border-color: var(--accent); }
.chip input { margin: 0; accent-color: var(--accent); }

/* ---- modal ---- */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: none;
  align-items: center; justify-content: center; z-index: 50; padding: 16px;
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
}
.modal.open { display: flex; }
.modal .box {
  background: var(--surface); border-radius: 18px; padding: 24px; width: min(720px, 100%);
  max-height: 86vh; overflow: auto; box-shadow: var(--shadow-lg);
  animation: modal-in .18s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }

/* ---- chat (transcripts) ---- */
.chat { font-size: 14px; }
.chat .m { margin: 10px 0; padding: 11px 14px; border-radius: 12px; line-height: 1.55; }
.chat .m.user { background: var(--err-soft); border: 1px solid #fee2e2; }
.chat .m.assistant { background: var(--accent-soft); border: 1px solid #e0e7ff; }
.chat .who { font-weight: 700; margin-right: 6px; }
.chat .time { font-size: 11px; color: var(--faint); float: right; }
.chat .user .who { color: #dc2626; } .chat .assistant .who { color: var(--accent); }

/* ---- progress / spinner / empty ---- */
.progress { height: 6px; background: #e6e9f2; border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress .bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), #22d3ee); transition: width .4s; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid #d3dae8; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { color: var(--faint); text-align: center; padding: 30px 0; font-size: 13.5px; }

/* ---- in-UI API documentation (api-docs.js) ---- */
.doc-h { margin: 28px 0 10px; font-size: 15px; font-weight: 700; }
.doc-p { color: #334155; font-size: 13.5px; line-height: 1.6; margin: 8px 0; }
.doc-p b { color: #0f172a; }
.doc-p a { color: var(--accent); font-weight: 600; text-decoration: none; }
.doc-p a:hover { text-decoration: underline; }
.doc-code { background: var(--accent-soft); border: 1px solid #dde4fb; color: #3730a3; padding: 1px 6px; border-radius: 6px; font-size: 12px; font-family: ui-monospace, Menlo, monospace; }
.doc-table td { font-size: 13px; }
.doc-snip { position: relative; margin: 4px 0 14px; }
.doc-snip pre { overflow-x: auto; margin: 0; padding: 30px 14px 14px; }
.doc-copy { position: absolute; top: 8px; right: 8px; opacity: .92; z-index: 2; }
.doc-keyrow { display: flex; gap: 8px; align-items: flex-end; margin: 10px 0 4px; flex-wrap: wrap; }
.doc-keyrow .flabel { margin-bottom: 2px; }
.doc-key { width: min(520px, 100%); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.doc-keyraw { display: none; }

/* ---- toast (API docs copy feedback) ---- */
#va-toast { font-family: inherit; }

/* ---- responsive ---- */
@media (max-width: 900px) {
  header { padding: 12px 18px; }
  .tabs { padding: 14px 18px 0; }
  main { padding: 16px 18px 32px; }
  .pane { padding: 18px; border-radius: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  thead th { position: static; }
}
@media (max-width: 640px) {
  .tab { flex: 1 1 auto; text-align: center; }
}
/* voice provider rows */
.voice-row { display:grid; grid-template-columns: minmax(140px,1fr) minmax(140px,1fr) minmax(160px,1.4fr) auto; gap:8px; align-items:center; }
.voice-row select, .voice-row input { width:100%; min-width:0; }
.voice-pick { display:flex; gap:6px; min-width:0; align-items:center; }
.voice-pick select { flex:1; min-width:0; }
.voice-pick .icon { padding:9px 10px; line-height:1; }
.voice-sample-row { display:grid; grid-template-columns:minmax(120px,.55fr) minmax(220px,2fr) auto; gap:8px; align-items:center; margin-top:7px; }
.voice-sample-row select, .voice-sample-row input { width:100%; min-width:0; }
.voice-link { background:none; border:0; color:#2563eb; padding:0; margin-top:5px; font-size:12px; cursor:pointer; text-decoration:underline; }
@media (max-width: 720px) { .voice-row, .voice-sample-row { grid-template-columns:1fr; } }
.vc-card summary { list-style:revert; }

/* Password / secret reveal toggle */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 44px; width: 100%; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  margin: 0; padding: 0; border: 0; border-radius: 8px;
  background: transparent; color: #647085; cursor: pointer; box-shadow: none;
}
.pw-toggle:hover { background: var(--surface-2); color: var(--text); }
.pw-toggle .eye-closed { display: none; }
.pw-toggle.is-visible .eye-open { display: none; }
.pw-toggle.is-visible .eye-closed { display: block; }
