/* heyRinger admin UI. Plain CSS, colour tokens on :root, phone first. No inline styles anywhere (the CSP forbids them). */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --text: #1d1f22;
  --muted: #5f646b;
  --border: #dedbd2;
  --brand: #0b6e4f;
  --brand-strong: #08583f;
  --brand-soft: #e3f2ec;
  --accent: #e0662f;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --warning: #8a5a00;
  --warning-soft: #fdf2d8;
  --ok: #1b7a3d;
  --ok-soft: #e4f4e8;
  --focus: #2a62d4;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 2px 8px rgb(0 0 0 / 4%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1f2226;
    --surface-2: #2a2e33;
    --text: #eceae4;
    --muted: #a3a8ae;
    --border: #3a3f45;
    --brand: #3fb489;
    --brand-strong: #5fd0a5;
    --brand-soft: #1d3a30;
    --danger: #f28b82;
    --danger-soft: #3d1f1d;
    --warning: #f0c060;
    --warning-soft: #3a2f16;
    --ok: #7fd49a;
    --ok-soft: #1c3424;
    --focus: #8ab4f8;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.6rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--brand); }
a:hover { color: var(--brand-strong); }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 0.05rem 0.3rem; border-radius: 4px; }
blockquote { margin: 0.4rem 0; padding: 0.5rem 0.8rem; border-left: 3px solid var(--brand); background: var(--surface-2); border-radius: 0 6px 6px 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.lead { font-size: 1.05rem; }
.hint { color: var(--muted); font-size: 0.9rem; margin-top: 0.25rem; }
.wrap { overflow-wrap: anywhere; word-break: break-word; }

/* Top bar and navigation */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem;
  padding: 0.6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 1.2rem; text-decoration: none; color: var(--text); }
.brand span { color: var(--brand); }
.nav-toggle { margin-left: auto; }
.main-nav { display: none; width: 100%; }
.main-nav.is-open { display: block; }
.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.main-nav a, .main-nav .link { display: block; padding: 0.5rem 0.25rem; text-decoration: none; color: var(--text); }
.main-nav a[aria-current="page"] { color: var(--brand); font-weight: 600; }
.main-nav .secondary { border-top: 1px solid var(--border); margin-top: 0.3rem; padding-top: 0.3rem; }
.guest-bar .language { margin-left: auto; }

@media (min-width: 960px) {
  .nav-toggle { display: none; }
  .main-nav { display: flex; width: auto; flex: 1; justify-content: space-between; }
  .main-nav ul { flex-direction: row; gap: 0.25rem 0.9rem; align-items: center; }
  .main-nav .secondary { border-top: 0; margin: 0; padding: 0; font-size: 0.92rem; }
}

main.page { max-width: 1200px; margin: 0 auto; padding: 1rem; }
main.narrow { max-width: 480px; margin: 2rem auto; padding: 1rem; }

/* Cards and layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card.highlight { border-color: var(--brand); background: var(--brand-soft); }
.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 760px) {
  .grid.two { grid-template-columns: 1fr 1fr; }
  .grid.three { grid-template-columns: repeat(3, 1fr); }
}
.row { display: grid; gap: 0.75rem; grid-template-columns: 1fr; }
@media (min-width: 560px) { .row { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); } }
.bordered { border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem; margin-bottom: 0.75rem; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain > li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 0.25rem 0.6rem; align-items: center; }
ul.plain > li:last-child { border-bottom: 0; }
dl.pairs { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; margin: 0 0 1rem; }
dl.pairs dt { color: var(--muted); }
dl.pairs dd { margin: 0; }

/* Forms */
form.stack { display: flex; flex-direction: column; gap: 0.35rem; }
form.stack > button, form.stack > .actions { margin-top: 0.6rem; align-self: flex-start; }
form.inline { display: inline; }
.row-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.row-form input[type="text"], .row-form input[type="tel"] { flex: 1 1 12rem; }
label { font-weight: 600; font-size: 0.95rem; }
label.check { font-weight: 400; display: flex; gap: 0.5rem; align-items: baseline; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 7px;
  padding: 0.5rem 0.6rem; width: 100%; max-width: 100%; min-height: 2.5rem;
}
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }
input:disabled, select:disabled, textarea:disabled { opacity: 0.75; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.8rem; margin: 0.4rem 0; }
legend { font-weight: 600; padding: 0 0.3rem; }
fieldset.choice { display: flex; flex-wrap: wrap; gap: 0.5rem 1.2rem; }
fieldset.choice label { font-weight: 400; display: flex; gap: 0.4rem; align-items: center; }
.field-error { color: var(--danger); font-size: 0.9rem; margin: 0.2rem 0 0.4rem; }
.has-error > input, .has-error > select, .has-error > textarea, input.has-error { border-color: var(--danger); }
progress { width: 100%; height: 0.7rem; accent-color: var(--brand); }

button, .button {
  font: inherit; font-weight: 600; display: inline-block; text-decoration: none; cursor: pointer; text-align: center;
  background: var(--brand); color: #fff; border: 1px solid var(--brand); border-radius: 7px; padding: 0.5rem 1rem; min-height: 2.5rem;
}
button:hover, .button:hover { background: var(--brand-strong); color: #fff; }
button.secondary, .button.secondary { background: var(--surface); color: var(--brand); border-color: var(--brand); }
button.secondary:hover, .button.secondary:hover { background: var(--brand-soft); color: var(--brand-strong); }
button.danger { background: var(--danger); border-color: var(--danger); }
button.link { background: none; border: 0; color: var(--brand); padding: 0.25rem; min-height: 0; font-weight: 400; text-decoration: underline; }
button.small, .button.small { padding: 0.25rem 0.6rem; min-height: 2rem; font-size: 0.9rem; }

/* Messages */
.flash { padding: 0.7rem 0.9rem; border-radius: 8px; margin-bottom: 1rem; background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.error-box { padding: 0.7rem 0.9rem; border-radius: 8px; margin: 0 0 1rem; background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }
.error-box p:last-child, .error-box ul { margin-bottom: 0; }
.notice { padding: 0.6rem 0.8rem; border-radius: 8px; background: var(--warning-soft); color: var(--warning); }
.secret-box { padding: 0.8rem 1rem; border-radius: 8px; background: var(--brand-soft); border: 1px solid var(--brand); margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.4rem; align-items: flex-start; }
.error-list { padding-left: 1.2rem; margin: 0; }
.error-list .ok { color: var(--ok); list-style: none; margin-left: -1.2rem; }
.status-box { border-radius: 8px; padding: 0.8rem; margin-bottom: 1rem; background: var(--surface-2); }
.status-approved { background: var(--ok-soft); }
.status-rejected { background: var(--danger-soft); }
.status-submitted { background: var(--warning-soft); }

/* Badges */
.badge { display: inline-block; font-size: 0.8rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge-active, .badge-answered { background: var(--ok-soft); color: var(--ok); }
.badge-pending, .badge-in_progress, .badge-voicemail { background: var(--warning-soft); color: var(--warning); }
.badge-missed, .badge-failed, .badge-abandoned, .badge-released { background: var(--danger-soft); color: var(--danger); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.9rem; }
.filters { display: grid; gap: 0.6rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
.filter-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: 1rem; }
.tabs { display: flex; gap: 1rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: 0.5rem 0; text-decoration: none; color: var(--muted); white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--brand); border-bottom: 2px solid var(--brand); font-weight: 600; }

/* Wizard */
.steps { list-style: none; display: flex; flex-wrap: wrap; gap: 0.3rem; padding: 0; margin: 0 0 1rem; counter-reset: step; }
.steps li { counter-increment: step; }
.steps a { display: block; padding: 0.3rem 0.7rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.steps a::before { content: counter(step) ". "; }
.steps .is-done a { background: var(--ok-soft); color: var(--ok); }
.steps .is-current a { background: var(--brand); color: #fff; }
.choice-card {
  display: flex; flex-direction: column; gap: 0.4rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); text-decoration: none; color: var(--text); font-weight: 400;
}
.choice-card:hover, .choice-card:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice-card.recommended { border-color: var(--brand); }
.choice-card .tag { align-self: flex-start; font-size: 0.75rem; font-weight: 700; color: var(--brand); text-transform: uppercase; }
.guide { padding-left: 1.2rem; }
.number-list { display: flex; flex-direction: column; gap: 0.3rem; }
.number-option { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; font-weight: 400; padding: 0.4rem; border-radius: 6px; }
.number-option:hover { background: var(--surface-2); }
.code-pair { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; margin: 1rem 0; }
.code { font-family: var(--mono); font-size: 1.6rem; font-weight: 700; letter-spacing: 0.05em; margin: 0; }
.checklist { padding-left: 1.2rem; }
.target-row { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.code-form input { width: 6rem; }
.status-line { color: var(--muted); }
.status-line[data-kind="error"] { color: var(--danger); }
.status-line[data-kind="ok"] { color: var(--ok); }
.status-line[data-kind="dirty"] { color: var(--warning); }
.flow-outline { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.flow-outline li { display: flex; gap: 0.6rem; align-items: center; padding: 0.5rem 0.7rem; border: 1px solid var(--border); border-radius: 8px; transition: background 0.3s; }
.flow-outline li.is-visited { background: var(--brand-soft); border-color: var(--brand); }
.flow-outline li.is-last { box-shadow: 0 0 0 3px var(--brand); }
.trail { padding-left: 1.4rem; }
.trail li { margin: 0.2rem 0; }

/* Schedules */
.week { display: flex; flex-direction: column; gap: 0.4rem; }
.week-day { display: grid; grid-template-columns: 1fr; gap: 0.3rem; padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
@media (min-width: 640px) { .week-day { grid-template-columns: 8rem 1fr; } }
.day-name { font-weight: 600; margin: 0.4rem 0 0; }
.intervals { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; }
.interval { display: flex; gap: 0.3rem; align-items: center; flex-wrap: wrap; }
.interval input { width: 7rem; }

/* Prompts */
.prompt-list audio { max-width: 100%; height: 2.2rem; }

/* Builder */
.builder-head { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; align-items: baseline; }
.builder-toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; position: sticky; top: 3.4rem; z-index: 5; background: var(--bg); padding: 0.5rem 0; }
.builder-main { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 1024px) { .builder-main { grid-template-columns: minmax(0, 1fr) 340px; } }
.builder-tree { min-width: 0; }
.entry-row { display: flex; gap: 0.6rem; align-items: center; margin-bottom: 0.5rem; }
.entry-row select { width: auto; }
.node-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--brand); border-radius: var(--radius); padding: 0.7rem 0.8rem; margin: 0.3rem 0; box-shadow: var(--shadow); }
.node-card.node-hours { border-left-color: #6a4fbf; }
.node-card.node-menu { border-left-color: #2a62d4; }
.node-card.node-ring { border-left-color: var(--accent); }
.node-card.node-voicemail { border-left-color: #a0408c; }
.node-card.node-hangup, .node-card.node-goto { border-left-color: var(--muted); }
.node-card.has-error { border-color: var(--danger); }
.node-card.is-focus { box-shadow: 0 0 0 3px var(--focus); }
.node-card.sim-visited { background: var(--brand-soft); }
.node-head { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.4rem; }
.node-head .node-id { width: auto; flex: 0 1 12rem; font-family: var(--mono); min-height: 2rem; padding: 0.2rem 0.4rem; }
.node-type { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.node-fields { display: flex; flex-direction: column; gap: 0.4rem; }
.node-fields .field { display: flex; flex-direction: column; gap: 0.2rem; }
.node-fields audio { max-width: 100%; height: 2.2rem; }
.subfields { border-top: 1px dashed var(--border); padding-top: 0.4rem; display: flex; flex-direction: column; gap: 0.4rem; }
.subtitle { font-weight: 600; margin: 0; }
.target { margin-bottom: 0.3rem; }
.node-end { color: var(--muted); font-size: 0.9rem; margin: 0.4rem 0 0; }
.lanes { margin-top: 0.6rem; display: flex; flex-direction: column; gap: 0.5rem; }
.lane { border-left: 2px dashed var(--border); padding-left: 0.6rem; }
.lane.has-error { border-left-color: var(--danger); }
.lane-head { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.lane-head select { width: auto; max-width: 14rem; min-height: 2rem; padding: 0.2rem 0.4rem; }
.lane-label { font-weight: 600; font-size: 0.9rem; background: var(--surface-2); border-radius: 999px; padding: 0.1rem 0.6rem; }
.lane-body { padding-top: 0.2rem; }
.lane-add { display: flex; gap: 0.4rem; }
.lane-add select { width: auto; }
.insert { margin: 0.2rem 0; }
.insert-select { width: auto; min-height: 1.9rem; padding: 0.1rem 0.4rem; font-size: 0.85rem; border-style: dashed; color: var(--brand); }
.node-link { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); font-family: var(--mono); font-weight: 400; min-height: 2rem; padding: 0.2rem 0.6rem; }
.loose-title { margin-top: 1.5rem; color: var(--muted); }
.builder-side .card h2 { font-size: 1.05rem; }
.sim-inputs { padding-left: 1.2rem; margin: 0.2rem 0; }
.versions li { gap: 0.4rem; }

/* Modal */
dialog.modal { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; max-width: min(420px, 92vw); background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgb(0 0 0 / 25%); }
dialog.modal::backdrop { background: rgb(0 0 0 / 40%); }
dialog .actions { display: flex; gap: 0.6rem; justify-content: flex-end; }
