/* Personal Callmaker — single accent, system fonts, light theme. */

:root {
  --accent: #2563eb;
  --accent-soft: #e8effd;
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e2e5ea;
  --text: #1c2330;
  --muted: #6b7382;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

.hidden { display: none !important; }

/* ---------------------------------------------------------------- header */

.app-header {
  max-width: 1040px;
  margin: 0 auto;
  padding: 22px 20px 6px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.app-header h1 { margin: 0; font-size: 21px; font-weight: 700; }

.subtitle { margin: 0; color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- layout */

.layout {
  max-width: 1040px;
  margin: 0 auto;
  padding: 12px 20px 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.card h2 { margin: 0 0 14px; font-size: 16px; }

/* ---------------------------------------------------------------- error banner */

.error-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fdecec;
  color: #8f1d1d;
  border-bottom: 1px solid #f3c2c2;
  padding: 10px 20px;
  font-size: 14px;
}

.error-banner span { flex: 1; }

.error-banner button {
  background: none;
  border: none;
  color: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

/* ---------------------------------------------------------------- forms */

.form { display: flex; flex-direction: column; gap: 12px; }

.field { display: flex; flex-direction: column; gap: 4px; }

.field-label { font-size: 13px; font-weight: 600; }

.field-label em { font-weight: 400; color: var(--muted); font-style: normal; }

input[type="tel"],
input[type="text"],
textarea,
select {
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  width: 100%;
}

textarea { resize: vertical; }

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text);
}

.checkbox-field input { margin-top: 3px; accent-color: var(--accent); }

.form-actions { margin-top: 4px; }

/* ---------------------------------------------------------------- buttons */

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 8px 16px;
  cursor: pointer;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:not(:disabled):hover { background: #1d4fc4; }

.btn-secondary {
  background: #fff;
  color: var(--accent);
  border-color: var(--accent);
}
.btn-secondary:not(:disabled):hover { background: var(--accent-soft); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:not(:disabled):hover { background: #b91c1c; }

.btn-active { background: var(--accent); color: #fff; }
.btn-active:not(:disabled):hover { background: var(--accent); }

.recording-row { margin-top: 12px; }
.recording-audio { width: 100%; margin-top: 8px; }

/* ---------------------------------------------------------------- call panel */

.call-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.call-number { font-weight: 700; font-size: 16px; }

.call-timer {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 600;
  margin-left: auto;
}

.call-head .btn { margin-left: 8px; }

.call-objective {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

.reconnect-note {
  margin: 10px 0 0;
  padding: 6px 10px;
  border-radius: 6px;
  background: #fef6e7;
  border: 1px solid #f2dfb8;
  color: #8a5a06;
  font-size: 13px;
}

/* status badges */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #e7e9ee;
  color: #454d5c;
}

.badge-small { padding: 1px 8px; font-size: 10.5px; }

.badge-queued      { background: #e7e9ee; color: #454d5c; }
.badge-dialing     { background: var(--accent-soft); color: var(--accent); }
.badge-ringing     { background: #fdf0dc; color: var(--warn); }
.badge-in_progress { background: #e3f5e9; color: var(--ok); }
.badge-ended       { background: #dde3ec; color: #33404f; }
.badge-failed      { background: #fde4e4; color: var(--danger); }
.badge-unknown     { background: #e7e9ee; color: var(--muted); }

/* ---------------------------------------------------------------- outcome */

.outcome {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: #fafbfd;
}

.outcome h3 { margin: 0 0 8px; font-size: 14px; }

.outcome-grid {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 4px 12px;
  margin: 0;
  font-size: 13.5px;
}

.outcome-grid dt { color: var(--muted); font-weight: 600; }
.outcome-grid dd { margin: 0; white-space: pre-wrap; }

/* ---------------------------------------------------------------- transcript */

.transcript {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafafb;
  height: 380px;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.entry {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.entry-role {
  flex: 0 0 86px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: right;
}

.entry-text { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: break-word; }

.entry-t {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.entry-them .entry-role { color: #33404f; }
.entry-them .entry-text { font-weight: 500; }

.entry-ai .entry-role { color: var(--accent); }
.entry-ai .entry-text { color: #223a6e; }

.entry-supervisor { opacity: 0.85; }
.entry-supervisor .entry-role { color: #7c3aed; }
.entry-supervisor .entry-text { font-style: italic; font-size: 13.5px; color: #4c4560; }

.entry-system { opacity: 0.8; }
.entry-system .entry-role { color: var(--muted); }
.entry-system .entry-text { color: var(--muted); font-size: 12.5px; }

/* ---------------------------------------------------------------- controls */

.controls {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-row { display: flex; gap: 8px; }

.control-row input { flex: 1; }

.control-row .btn { flex: 0 0 auto; min-width: 70px; }

.control-row-end { justify-content: flex-end; margin-top: 2px; }

/* ---------------------------------------------------------------- history */

.sidebar h2 { margin-bottom: 10px; }

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 70vh;
  overflow-y: auto;
}

.history-empty { color: var(--muted); font-size: 13.5px; }

.history-item {
  width: 100%;
  text-align: left;
  font: inherit;
  background: #fafbfd;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.history-item:hover { border-color: var(--accent); background: var(--accent-soft); }

.history-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.history-number { font-weight: 600; color: var(--text); }

.history-objective { font-size: 13px; }

.history-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-outcome { font-size: 12px; color: var(--muted); }
