/* Audena test/production UI. Light + dark via prefers-color-scheme.
   No framework — all styles live here. Keep under ~300 lines. */

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --border: #e5e7eb;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warn: #d97706;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #111827;
    --surface-2: #1f2937;
    --border: #1f2937;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

#app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav { display: flex; gap: 20px; align-items: center; }
.nav a { color: var(--text-muted); font-weight: 500; }
.nav a.brand { color: var(--text); font-weight: 700; margin-right: 12px; }
.nav a:hover { color: var(--text); text-decoration: none; }
.nav-right { display: flex; align-items: center; gap: 12px; }

main { padding: 24px; max-width: 1200px; margin: 0 auto; }

.page-title {
  margin: 0 0 16px 0;
  font-size: 20px;
  font-weight: 600;
}

.page-subtitle {
  color: var(--text-muted);
  margin: -8px 0 24px 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card-title { margin: 0 0 12px 0; font-size: 15px; font-weight: 600; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 24px; font-weight: 700; margin-top: 4px; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 12px; }
#register-form [data-step] { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: flex; flex-direction: column; gap: 4px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.script-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  background: var(--surface);
}
.kb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-weight: normal;
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
  color: var(--text);
}
.kb-row .pill { margin-left: auto; font-size: 11px; }
.preview {
  white-space: pre-wrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  max-height: 480px;
  overflow: auto;
}
.form-row label { font-weight: 500; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
fieldset.form-row { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; }
fieldset.form-row legend { padding: 0 6px; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
fieldset.form-row label { display: flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], textarea, select {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); }
textarea { min-height: 80px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Buttons */
.btn, .btn-primary, .btn-ghost, .btn-danger {
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { background: var(--text-muted); border-color: var(--text-muted); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: rgba(220, 38, 38, 0.08); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
tr:last-child td { border-bottom: none; }
tr.clickable:hover { background: var(--surface-2); cursor: pointer; }

/* Pills / badges */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.pill-success { background: rgba(22, 163, 74, 0.12); color: var(--success); }
.pill-danger { background: rgba(220, 38, 38, 0.12); color: var(--danger); }
.pill-warn { background: rgba(217, 119, 6, 0.12); color: var(--warn); }

/* Toasts */
#toast-tray {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}
.toast {
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease;
  max-width: 360px;
}
.toast-error { border-color: var(--danger); color: var(--danger); }
.toast-success { border-color: var(--success); color: var(--success); }
.toast-out { opacity: 0; transform: translateY(10px); transition: all 0.2s; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Auth page — centered card */
.auth-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 24px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}
.auth-tabs { display: flex; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.auth-tabs button {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.auth-tabs button.active { color: var(--text); border-bottom-color: var(--primary); }
.auth-title { margin: 0 0 4px 0; font-size: 22px; }
.auth-actions { display: flex; gap: 8px; margin-top: 8px; }

/* Drawer (call detail) */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 50;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(600px, 90vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 51;
  padding: 24px;
  overflow-y: auto;
  box-shadow: -8px 0 20px rgba(0,0,0,0.15);
}
.drawer-close { float: right; }

.transcript {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
}
.turn { padding: 4px 0; }
.turn-role { font-weight: 600; color: var(--primary); }

.user { color: var(--text-muted); font-size: 13px; }
.muted { color: var(--text-muted); }
.hint { color: var(--text-muted); font-size: 12px; }
.error { color: var(--danger); font-size: 13px; margin-top: 4px; }
.empty { padding: 32px; text-align: center; color: var(--text-muted); }
