/* ── Design tokens ── */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --border: #e2e6ea;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --warn: #d97706;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.container { max-width: 960px; margin: 0 auto; padding: 24px 16px; }

/* ── Navbar ── */
.navbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 56px;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 20px; }
.nav-links a { color: var(--text-muted); font-size: .9rem; }
.nav-links a:hover { color: var(--text); }

/* ── Footer ── */
.footer { text-align: center; padding: 24px; color: var(--text-muted); font-size: .8rem; border-top: 1px solid var(--border); margin-top: 48px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px; border-radius: var(--radius); font-size: .875rem;
  font-weight: 500; border: none; cursor: pointer; transition: background .15s;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-full { width: 100%; }
.btn-active { background: var(--primary); color: #fff; }

/* ── Badges ── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; white-space: nowrap;
}
.badge-inbound  { background: #dbeafe; color: #1e40af; }
.badge-outbound { background: #dcfce7; color: #166534; }
.badge-unknown  { background: #f1f5f9; color: #475569; }
.badge-completed { background: #dcfce7; color: #166534; }

.badge-status-received         { background: #fef3c7; color: #92400e; }
.badge-status-transcribed      { background: #dbeafe; color: #1e40af; }
.badge-status-emailed          { background: #ede9fe; color: #5b21b6; }
.badge-status-error            { background: #fee2e2; color: #991b1b; }
.badge-status-completed        { background: #dcfce7; color: #166534; }
.badge-status-recording_deleted{ background: #f1f5f9; color: #475569; }

/* ── Alerts / Flash ── */
.alert, .flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; }
.alert-error, .flash-error { background: #fee2e2; color: #991b1b; }
.flash-info    { background: #dbeafe; color: #1e40af; }
.flash { max-width: 960px; margin: 12px auto; }

/* ── Login ── */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 56px); background: var(--bg); padding: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px; width: 100%; max-width: 380px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 1.4rem; margin-bottom: 24px; }
.login-card label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: 4px; color: var(--text-muted); }
.login-card input { display: block; width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: .95rem; margin-bottom: 16px; }
.login-card input:focus { outline: 2px solid var(--primary); border-color: transparent; }

/* ── Page header ── */
.page-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header h1 { font-size: 1.5rem; }
.stats { display: flex; gap: 8px; margin-left: auto; }
.stat { font-size: .85rem; color: var(--text-muted); }
.stat-warn { color: var(--warn); font-weight: 600; }

/* ── Filter bar ── */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.search-input { flex: 1; min-width: 200px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: .9rem; }
.filter-bar select { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: .9rem; background: var(--surface); }
.toggle-form { margin-bottom: 16px; }

/* ── Call list ── */
.call-list { display: flex; flex-direction: column; gap: 10px; }
.call-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); transition: box-shadow .15s;
}
.call-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.call-card--completed { opacity: .7; }
.call-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.call-number { font-weight: 600; font-size: .95rem; }
.call-date { color: var(--text-muted); font-size: .85rem; }
.call-dur { color: var(--text-muted); font-size: .85rem; }
.call-status { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.transcript-preview { font-size: .85rem; color: var(--text-muted); margin-bottom: 10px; font-style: italic; }
.call-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty-state { text-align: center; padding: 48px; color: var(--text-muted); }

/* ── Detail view ── */
.detail-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.detail-card h2 { font-size: 1rem; font-weight: 600; margin-bottom: 12px; }
.meta-table { width: 100%; border-collapse: collapse; }
.meta-table th { text-align: left; color: var(--text-muted); font-size: .85rem; font-weight: 500; padding: 6px 12px 6px 0; width: 130px; }
.meta-table td { padding: 6px 0; font-size: .9rem; }
.transcript-box { white-space: pre-wrap; font-size: .9rem; line-height: 1.7; background: var(--bg); border-radius: var(--radius); padding: 16px; max-height: 500px; overflow-y: auto; }
.audio-player { width: 100%; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--text-muted); font-style: italic; font-size: .9rem; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-card { background: var(--surface); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 420px; box-shadow: 0 20px 40px rgba(0,0,0,.2); }
.modal-card h2 { font-size: 1.1rem; margin-bottom: 16px; }
.modal-card label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: 4px; color: var(--text-muted); }
.modal-card input[type=email] { display: block; width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: .9rem; margin-bottom: 14px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: .9rem; margin-bottom: 20px; cursor: pointer; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .page-header { flex-direction: column; align-items: flex-start; }
  .stats { margin-left: 0; }
  .filter-bar { flex-direction: column; }
  .search-input { min-width: unset; }
}
