/* Callfort design system: tokens, base type, layout primitives and the
   shared component set. Loaded on every page (landing, auth, control panel).
   See app.css for the app-shell-only layout (rail, mobile drawer, tabs). */
@import url("/static/fonts.css");

:root {
  /* Colour */
  --plaster: #F1F3F1;
  --surface: #FFFFFF;
  --slate: #1C2A2E;
  --muted: #5B6B6F;
  --line: #0E6B5C;
  --line-tint: #E3F0EC;
  --needs: #9A5B00;
  --needs-tint: #FFF1D6;
  --danger: #B3261E;
  --danger-tint: #FBE9E7;
  --rule: #D9DFDC;

  /* Type */
  --font-display: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Shape */
  --radius-control: 8px;
  --radius-surface: 12px;

  /* Spacing */
  --space-1: 4px;
  --gutter: 32px;
  --section-gap: 40px;
  --content-max: 1120px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; }
body {
  margin: 0;
  background: var(--plaster);
  color: var(--slate);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  font-variant-numeric: normal;
}
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
  color: var(--slate);
}
h1 { font-size: 32px; }
h2 { font-size: 24px; }
h3 { font-size: 19px; }
p { margin: 0 0 16px; max-width: 72ch; }
a { color: var(--line); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .small { font-size: 13px; }
.muted { color: var(--muted); }
.tnum { font-variant-numeric: tabular-nums; }

.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 20; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid rgba(14, 107, 92, 0.4); outline-offset: 2px; border-radius: 4px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(14, 107, 92, 0.4);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  h1 { font-size: 28px; }
}

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 18px; border-radius: var(--radius-control);
  font-weight: 700; text-decoration: none; border: 1px solid transparent; cursor: pointer;
  font-family: inherit; font-size: 15px; line-height: 1.2;
}
.btn-primary { background: var(--line); color: #fff; }
.btn-primary:hover { background: #0a5348; }
.btn-secondary { background: var(--surface); color: var(--slate); border-color: var(--rule); }
.btn-secondary:hover { background: var(--plaster); }
.btn-quiet { background: transparent; color: var(--line); border-color: transparent; padding-left: 4px; padding-right: 4px; }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn-danger.btn-danger-filled { background: var(--danger); color: #fff; }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.inline-form { display: inline; }

@media (max-width: 640px) {
  .btn { min-height: 44px; }
}

/* ---------------------------------------------------------------------
   Google button + example call card (auth/landing shared)
   --------------------------------------------------------------------- */
.btn-google {
  background: #fff; color: #3c4043; border: 1px solid var(--rule);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
}
.btn-google img { width: 18px; height: 18px; }

.example-call { border-radius: var(--radius-surface); padding: 24px; }
.example-call .sample-label { font-size: 13px; color: inherit; opacity: 0.7; margin-bottom: 12px; }
.example-call .bubble { padding: 10px 14px; border-radius: 14px; max-width: 92%; margin-bottom: 8px; }

/* ---------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field.full { grid-column: 1 / -1; }
.field label, label { font-weight: 700; font-size: 15px; color: var(--slate); }
.field .hint, .hint { color: var(--muted); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; align-items: start; }
input[type=text], input[type=tel], input[type=email], input[type=number], input[type=date],
input[type=time], input[type=datetime-local], input[type=url], input[type=search], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--rule); border-radius: var(--radius-control);
  font: inherit; background: var(--surface); color: var(--slate);
}
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--line); }
textarea { min-height: 120px; resize: vertical; }
.field-error, .error-text { color: var(--danger); font-size: 13px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.form-grid > .form-actions { margin-top: 24px; }
.danger-zone { border: 1px solid var(--danger); border-radius: var(--radius-surface); padding: 20px; margin-top: var(--section-gap); background: var(--surface); }
.danger-zone h2 { color: var(--danger); }
.card form + form { margin-top: var(--section-gap); padding-top: var(--section-gap); border-top: 1px solid var(--rule); }

@media (max-width: 640px) {
  input, select, textarea { min-height: 44px; }
}

/* ---------------------------------------------------------------------
   Chips
   --------------------------------------------------------------------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px; font-size: 13px; font-weight: 600; background: #eef2ef; color: var(--slate); text-transform: none; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.chip-handled { background: var(--line-tint); color: #0a5348; }
.chip-needs { background: var(--needs-tint); color: var(--needs); }
.chip-problem { background: var(--danger-tint); color: var(--danger); }
.chip-neutral { background: #eef2ef; color: var(--muted); }

/* Back-compat alias: existing template code emits `badge badge-*`. */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: #eef2ef; color: var(--slate); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-ok { background: var(--line-tint); color: #0a5348; }
.badge-info { background: var(--line-tint); color: var(--line); }
.badge-warn { background: var(--needs-tint); color: var(--needs); }
.badge-danger { background: var(--danger-tint); color: var(--danger); }
.badge-muted { background: #eef2ef; color: var(--muted); }

/* ---------------------------------------------------------------------
   Surfaces / page primitives
   --------------------------------------------------------------------- */
.surface { background: var(--surface); border-radius: var(--radius-surface); padding: 24px; }
.card { background: var(--surface); border-radius: var(--radius-surface); padding: 24px; margin-bottom: var(--section-gap); }
.card h2 { font-size: 19px; margin-bottom: 12px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.narrow { max-width: 720px; }
.card-flush { padding: 0; }
.card-flush .checklist { padding: 4px 24px; }
.card-flush-heading { padding: 24px 24px 0; }
.card-flush-pad { padding: 0 24px 24px; }
.needs-dot { background: var(--needs); }

/* Section header row: heading + a right-aligned link (e.g. "All calls"). */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.section-head h2 { margin-bottom: 0; }

/* Needs-you list: slate text rows with a small amber marker, whole row a link. */
.needs-you-list { display: flex; flex-direction: column; }
.needs-you-row {
  display: flex; align-items: baseline; gap: 10px; padding: 10px 4px; color: var(--slate);
  border-bottom: 1px solid var(--rule); text-decoration: none;
}
.needs-you-row:hover { background: var(--plaster); text-decoration: none; }
.needs-you-row:last-child { border-bottom: none; }
.needs-you-marker { width: 7px; height: 7px; border-radius: 50%; background: var(--needs); flex-shrink: 0; margin-top: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.section-gap { margin-bottom: var(--section-gap); }
.stat { font-family: var(--font-display); font-size: 32px; font-weight: 700; }
.stat-line { color: var(--muted); font-size: 15px; }

/* Page header */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: var(--section-gap); }
.page-head h1 { margin-bottom: 4px; }
.page-head .context { color: var(--muted); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-head .actions .btn-danger { margin-left: auto; }
@media (max-width: 640px) {
  .page-head { flex-direction: column; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { width: 100%; }
  .page-head .actions .btn-danger { margin-left: 0; }
}

/* Banners */
.alert, .banner { padding: 12px 16px; border-radius: var(--radius-control); margin-bottom: 16px; max-width: var(--content-max); }
.alert-error, .banner-danger { background: var(--danger-tint); color: var(--danger); }
.alert-warning, .banner-warning, .banner-amber { background: var(--needs-tint); color: var(--needs); }
.alert-ok, .alert-success { background: var(--line-tint); color: #0a5348; }
.alert-debug, .alert-info { background: var(--line-tint); color: var(--line); }
.alert code { font-size: 1.2em; letter-spacing: 0.1em; font-weight: 700; }

/* Key-value list */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dt { margin-top: 10px; }
}

/* Empty state */
.empty { padding: 16px 0; color: var(--muted); text-align: left; }
.empty h3 { color: var(--slate); margin-bottom: 4px; font-size: 16px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 15px; background: var(--surface); border-radius: var(--radius-surface); }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; white-space: nowrap; }
table.data td.wrap { white-space: normal; }
table.data th { color: var(--muted); font-weight: 600; font-size: 13px; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr:hover td { background: var(--plaster); }
table.data a { text-decoration: none; }

/* Checklist */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.checklist li:last-child { border-bottom: 0; }
.check { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; flex-shrink: 0; border: 2px solid var(--rule); color: transparent; }
.check.done { background: var(--line); border-color: var(--line); color: #fff; }

/* Transcript (call detail) */
.transcript { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.transcript li { padding: 10px 14px; border-radius: 12px; max-width: 85%; }
.transcript li .speaker { font-size: 13px; color: var(--muted); display: block; margin-bottom: 2px; }
.transcript li.customer { background: var(--plaster); }
.transcript li.assistant { background: var(--surface); margin-left: auto; border: 1px solid var(--rule); border-right: 3px solid var(--line); }
.transcript li.system { background: transparent; color: var(--muted); font-size: 13px; text-align: center; max-width: 100%; }
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 24px; }
pre.preview { white-space: pre-wrap; background: var(--plaster); padding: 12px; border-radius: var(--radius-control); max-height: 400px; overflow: auto; font-size: 13px; }

.htmx-request .htmx-indicator { display: inline; }
.htmx-indicator { display: none; }

/* Filters bar */
.filters-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters-bar .search { position: relative; flex: 1 1 220px; min-width: 180px; }
.filters-bar .search input { padding-left: 34px; }
.filters-bar .search::before { content: ""; position: absolute; left: 11px; top: 50%; width: 14px; height: 14px; margin-top: -7px; border: 2px solid var(--muted); border-radius: 50%; box-sizing: border-box; pointer-events: none; }
.filters-bar .field { margin-bottom: 0; }
.segmented { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--radius-control); overflow: hidden; height: 40px; }
.segmented a, .segmented button { display: inline-flex; align-items: center; padding: 0 14px; font-size: 14px; color: var(--slate); text-decoration: none; background: var(--surface); border: 0; border-right: 1px solid var(--rule); cursor: pointer; font: inherit; }
.segmented a:last-child, .segmented button:last-child { border-right: 0; }
.segmented a[aria-current="page"], .segmented .active { background: var(--line); color: #fff; }
.quick-ranges { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-ranges a { display: inline-flex; align-items: center; height: 40px; padding: 0 12px; border: 1px solid var(--rule); border-radius: 999px; text-decoration: none; color: var(--slate); font-size: 14px; }
.quick-ranges a[aria-current="page"] { background: var(--line); color: #fff; border-color: var(--line); }
.filters-more { margin-bottom: 16px; }
.filters-more summary { cursor: pointer; color: var(--line); font-weight: 600; font-size: 14px; padding: 8px 0; }
.filters-more .form-grid { margin-top: 8px; }

/* Call row: fixed ~64px, two lines in the "who" column (name, then either
   the summary or a masked-number fallback), 4px gap between them. */
.call-list { display: flex; flex-direction: column; container-type: inline-size; container-name: call-list; }
.call-day-heading { font-size: 13px; color: var(--muted); font-weight: 700; margin: 24px 0 8px; }
.call-day-heading:first-child { margin-top: 0; }
.call-row { display: grid; grid-template-columns: 56px 16px 1fr 80px auto; align-items: center; gap: 12px;
  padding: 10px 16px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--rule); background: var(--surface); position: relative; min-height: 64px; }
.call-row:hover { text-decoration: none; background: var(--plaster); }
.call-row:first-child { border-top-left-radius: var(--radius-surface); border-top-right-radius: var(--radius-surface); }
.call-row:last-child { border-bottom: none; border-bottom-left-radius: var(--radius-surface); border-bottom-right-radius: var(--radius-surface); }
.call-row.needs-you { border-left: 3px solid var(--needs); padding-left: 13px; }
.call-row .time { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--slate); }
.call-row .dir { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.call-row .who { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.call-row .who .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.2; }
.call-row .who .row-detail { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.2; }
.call-row .who .row-detail.masked { font-variant-numeric: tabular-nums; }
.call-row .duration { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; text-align: right; }
.call-row .outcome { justify-self: end; }
.chip-live::before { animation: chip-pulse 1.6s ease-in-out infinite; }
@keyframes chip-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (max-width: 640px) {
  .call-row {
    grid-template-columns: auto 1fr auto auto;
    grid-template-areas: "time . duration outcome" "who who who who";
    column-gap: 10px; row-gap: 4px; min-height: 56px;
  }
  .call-row .time { grid-area: time; }
  .call-row .dir { display: none; }
  .call-row .who { grid-area: who; }
  .call-row .duration { grid-area: duration; text-align: right; }
  .call-row .outcome { grid-area: outcome; justify-self: end; }
}
/* Same compact layout when the row's container is narrow, regardless of
   viewport (e.g. a call-row list inside a 320px detail-page side column) —
   a container query rather than a media query, since this is about the
   available column width, not the screen. */
@container call-list (max-width: 480px) {
  .call-row {
    grid-template-columns: auto 1fr auto auto;
    grid-template-areas: "time . duration outcome" "who who who who";
    column-gap: 10px; row-gap: 4px; min-height: 56px;
  }
  .call-row .time { grid-area: time; }
  .call-row .dir { display: none; }
  .call-row .who { grid-area: who; }
  .call-row .duration { grid-area: duration; text-align: right; }
  .call-row .outcome { grid-area: outcome; justify-self: end; }
}

/* Daily minutes bar chart (usage page), pure CSS, no chart library. */
.bar-chart { display: flex; align-items: flex-end; gap: 2px; height: 120px; }
.bar-chart-col { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.bar-chart-bar { width: 100%; min-height: 2px; background: var(--line); border-radius: 2px 2px 0 0; }

/* Step indicator (tasks) */
.steps-indicator { display: flex; list-style: none; padding: 0; margin: 0 0 var(--section-gap); gap: 4px; }
.steps-indicator li { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.steps-indicator li .bar { height: 4px; border-radius: 2px; background: var(--rule); }
.steps-indicator li.done .bar, .steps-indicator li.current .bar { background: var(--line); }
.steps-indicator li.current { color: var(--slate); font-weight: 700; }
.steps-indicator li.done { color: var(--slate); }
.steps-indicator li.problem .bar { background: var(--danger); }
.steps-indicator li.problem { color: var(--danger); font-weight: 700; }

/* Drawer (mobile nav) */
.drawer-scrim { display: none; }
.drawer-scrim.open { display: block; position: fixed; inset: 0; background: rgba(28, 42, 46, 0.4); z-index: 30; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------------
   Auth layout (signin, verify, setup, mfa, security)
   --------------------------------------------------------------------- */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 45% 1fr; }
.auth-aside { background: var(--slate); color: #fff; position: relative; padding: 32px; display: flex; align-items: center; justify-content: center; }
.auth-aside .wordmark { position: absolute; top: 32px; left: 32px; color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 22px; text-decoration: none; }
.auth-aside .example-call { background: rgba(255, 255, 255, 0.06); color: #fff; max-width: 420px; width: 100%; }
.auth-aside .example-call .bubble.customer { background: rgba(255, 255, 255, 0.12); }
.auth-aside .example-call .bubble.assistant { background: var(--line); color: #fff; margin-left: auto; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px; }
.auth-form { width: 100%; max-width: 400px; }
.auth-form .wordmark { display: none; }
.auth-form h1 { margin-bottom: 8px; }
.auth-form p { color: var(--muted); }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 20px 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.code-input { font-family: var(--font-display); font-size: 24px; letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; }
.code-block { background: var(--surface-tint, #f4f6f4); border: 1px solid var(--rule); border-radius: var(--radius-surface); padding: 16px; margin: 12px 0; line-height: 1.8; font-size: 15px; }

@media (max-width: 960px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-form .wordmark { display: inline-block; margin-bottom: 24px; }
}

/* ---------------------------------------------------------------------
   Landing page (shares tokens with the app; a few marketing-only bits)
   --------------------------------------------------------------------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px var(--gutter); background: var(--surface); border-bottom: 1px solid var(--rule);
}
.site-header nav { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.site-header nav a { color: var(--slate); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.wordmark { font-family: var(--font-display); font-weight: 700; font-size: 22px; color: var(--slate); text-decoration: none; }

main.landing { padding: 0 var(--gutter); max-width: 1280px; margin: 0 auto; }
.landing section { padding: var(--section-gap) 0; border-bottom: 1px solid var(--rule); }
.landing .closing { text-align: center; border-bottom: 0; }

.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: center; }
.hero-copy p { font-size: 18px; color: var(--muted); max-width: 34rem; }
.cta-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.fineprint { font-size: 14px; color: var(--muted); }
.hero-demo { margin: 0; }

.steps ol { list-style: none; counter-reset: step; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin: 0; }
.steps li { counter-increment: step; background: var(--surface); border-radius: var(--radius-surface); padding: 24px; }
.steps li::before { content: counter(step); display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--line); color: #fff; font-weight: 700; margin-bottom: 12px; font-family: var(--font-display); }
.feature-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.feature-grid article { background: var(--surface); border-radius: var(--radius-surface); padding: 24px; }
.faq dt { font-weight: 700; margin-top: 16px; }
.faq dd { margin: 4px 0 0; color: var(--muted); }
.site-footer { padding: 24px var(--gutter); color: var(--muted); font-size: 14px; max-width: 1280px; margin: 0 auto; }

@media (max-width: 900px) {
  .hero, .steps ol, .feature-grid { grid-template-columns: 1fr; }
}

.status { text-transform: capitalize; }
