/*
 * The demo host page's own styles. The dock and softphone bring theirs (the
 * SDK injects them); nothing here targets an SDK class except the theming
 * presets, which go through the documented --proxy-dock-* properties.
 */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --sunken: #f0f2f5;
    --ink: #16181d;
    --muted: #5d6470;
    --line: #e2e5ea;
    --accent: #2563eb;
    --accent-ink: #ffffff;
    --danger: #c2410c;
    --success: #15803d;
    --warning: #b45309;
    --code: #6d28d9;
    --radius: 10px;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1115;
        --surface: #171a20;
        --sunken: #1e222a;
        --ink: #e8eaee;
        --muted: #9aa1ad;
        --line: #2a2f39;
        --accent: #5b8cff;
        --accent-ink: #0b0d11;
        --danger: #fb923c;
        --success: #4ade80;
        --warning: #fbbf24;
        --code: #c4b5fd;
        color-scheme: dark;
    }
}

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

code, pre { font-family: var(--mono); font-size: 0.86em; }
code { color: var(--code); }
h2 { font-size: 15px; margin: 0 0 8px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
h3 { font-size: 13px; margin: 16px 0 8px; }
h2 code, h3 code { font-weight: 500; }

/* ─────────────────────────────── top bar */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.topbar__brand { display: flex; align-items: baseline; gap: 8px; font-weight: 600; }
.topbar__logo { color: var(--accent); }
.topbar__sub { font-weight: 400; color: var(--muted); font-size: 13px; }
.topbar__right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar__label { color: var(--muted); font-size: 12px; font-family: var(--mono); }

.host-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border: 1px dashed var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 12px;
}

/* Once the dock owns the slot, the dashed placeholder look goes. */
.host-pill:has(> *) { border: 0; padding: 0; }

.back { color: var(--muted); font-weight: 500; font-size: 12.5px; text-decoration: none; margin-right: 6px; }
.back:hover { color: var(--ink); }

.unavailable { max-width: 560px; margin: 40px auto; }

.banner { margin: 12px 16px 0; padding: 10px 12px; border-radius: var(--radius); background: var(--sunken); border: 1px solid var(--line); }
.banner[data-tone="error"] { border-color: var(--danger); color: var(--danger); }

/* ─────────────────────────────── layout */

.layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 16px;
    padding: 16px;
    align-items: start;
}

.stage { display: grid; gap: 16px; min-width: 0; }

/* The developer bench, folded away: its own two columns, the log beside it. */
.every__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 16px;
    align-items: start;
    margin-top: 12px;
}

@media (max-width: 1280px) {
    .every__grid { grid-template-columns: minmax(0, 1fr); }
    .log { position: static !important; max-height: 420px !important; }
}

@media (max-width: 800px) {
    .layout { grid-template-columns: minmax(0, 1fr); }
    .stage { order: -1; }
}

/* ─────────────────────────────── the short path */

.start {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 24px 28px 28px;
}

.start h1 { font-size: 22px; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 6px; text-wrap: balance; }
.start__lede { margin: 0; color: var(--muted); max-width: 62ch; }
.start__lede a { color: var(--accent); }

.steps { list-style: none; counter-reset: step; margin: 24px 0 0; padding: 0; display: grid; gap: 22px; }
.step { counter-increment: step; position: relative; padding-left: 44px; }
.step h2 { font-size: 15px; margin: 2px 0 2px; }
.step .hint { margin: 0; font-size: 13px; max-width: 62ch; }
.step .actions { margin-top: 12px; }
.step .options { margin-top: 14px; }
.step #live-credentials { margin-top: 14px; }

.step::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--sunken);
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

/* Once the phone is up, step one is done. */
.steps:has(#start-phone:disabled) .step:first-child::before {
    content: "✓";
    background: var(--success);
    border-color: var(--success);
    color: var(--surface);
}

.btn--big { padding: 9px 16px; font-size: 14px; font-weight: 600; }
#start-phone:disabled { background: var(--sunken); border-color: var(--line); color: var(--success); opacity: 1; cursor: default; }
.start__status { color: var(--muted); font-size: 13px; }

.every > summary {
    cursor: pointer;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    font-weight: 600;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    align-items: baseline;
}

.every > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.every__sub { font-weight: 400; color: var(--muted); font-size: 12.5px; }

.crm, .bench { display: grid; gap: 16px; min-width: 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    min-width: 0;
}

.tag { font-size: 11px; font-weight: 500; padding: 1px 6px; border-radius: 999px; background: var(--sunken); color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; margin: 0 0 10px; }

/* ─────────────────────────────── controls */

.btn {
    appearance: none;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    border-radius: 7px;
    padding: 6px 10px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--danger { color: var(--danger); }
.btn--ghost { background: transparent; }
.btn--small { padding: 3px 8px; font-size: 12px; font-family: var(--mono); }
.btn--block { width: 100%; text-align: left; margin-top: 8px; }

.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.actions--quiet { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; align-items: end; }

@media (max-width: 800px) {
    .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); }
}

.field { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.field--inline { display: inline-flex; align-items: center; gap: 6px; }
.field em { font-style: normal; opacity: 0.8; }

input, select, textarea {
    font: inherit;
    font-size: 13px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 6px 8px;
    min-width: 0;
}

.field--inline input[type="number"] { width: 70px; }
input[type="color"] { padding: 0; width: 36px; height: 28px; }
input[type="range"] { padding: 0; }

.check { display: flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--ink); }

.options { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 12px; margin: 12px 0 0; display: grid; gap: 6px; min-width: 0; }
.options legend { font-size: 12px; color: var(--muted); padding: 0 4px; }

.code-input { width: 100%; font-family: var(--mono); font-size: 12px; resize: vertical; }

.field--wide { grid-column: 1 / -1; }
.mint { grid-column: 1 / -1; font-size: 12.5px; }
.mint summary { cursor: pointer; color: var(--muted); }
.mint pre { background: var(--sunken); padding: 10px; border-radius: 8px; overflow-x: auto; }

.output {
    margin: 10px 0 0;
    background: var(--sunken);
    border-radius: 8px;
    padding: 10px;
    max-height: 260px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.output--small { max-height: 120px; }

/* ─────────────────────────────── facts, tables */

.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 12px; margin: 0; font-size: 12.5px; }
.facts dt { color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts dd code { color: var(--ink); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12.5px; }
.table th { text-align: left; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); padding: 4px 8px 4px 0; }
.table td { border-bottom: 1px solid var(--line); padding: 5px 8px 5px 0; vertical-align: top; }

.pill { display: inline-block; padding: 0 7px; border-radius: 999px; font-size: 11.5px; background: var(--sunken); }
.pill--good { color: var(--success); }
.pill--bad { color: var(--danger); }
.pill--warn { color: var(--warning); }


/* ─────────────────────────────── records */

.records { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

.record {
    width: 100%;
    text-align: left;
    display: grid;
    gap: 2px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    cursor: pointer;
}

.record[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.record[data-flash="true"] { animation: flash 1.2s ease-out; }
.record__name { font-weight: 600; }
.record__meta { font-size: 12px; color: var(--muted); }

@keyframes flash { from { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); } }

.current-record { margin-top: 10px; font-size: 12px; color: var(--muted); }

/* ─────────────────────────────── hosts for mounted components */

.hosts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
@media (max-width: 800px) { .hosts { grid-template-columns: minmax(0, 1fr); } }
.host-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.host-box {
    position: relative;
    min-height: 120px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 10px;
    background: var(--sunken);
    overflow: auto;
}

/* A dock drawn into a container is still position: fixed by default; keep it in the box. */
#dock-host:has(.proxy-dock) { min-height: 620px; transform: translateZ(0); }

/* ─────────────────────────────── keypad, participants */

.keypad { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; margin-top: 10px; }
.keypad .btn { padding: 6px 0; font-family: var(--mono); }
@media (max-width: 800px) { .keypad { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

.participants { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; font-size: 12.5px; }
.participants li { display: flex; justify-content: space-between; gap: 8px; align-items: center; }

/* ─────────────────────────────── log */

.log {
    position: sticky;
    top: 66px;
    max-height: calc(100vh - 82px);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    min-width: 0;
}

.log__head { padding: 12px 14px 8px; border-bottom: 1px solid var(--line); }
.log__head h2 { margin-bottom: 6px; }
.log__filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.log__list { list-style: none; margin: 0; padding: 6px 0; overflow: auto; flex: 1; font-size: 12px; }

.entry { padding: 4px 14px; border-left: 3px solid transparent; }
.entry[data-kind="code"] { border-left-color: var(--accent); }
.entry[data-kind="event"] { border-left-color: var(--success); }
.entry[data-kind="error"] { border-left-color: var(--danger); }
.entry[data-kind="http"] { border-left-color: var(--line); color: var(--muted); }
.entry__time { color: var(--muted); font-family: var(--mono); font-size: 10.5px; margin-right: 6px; }
.entry__text { font-family: var(--mono); overflow-wrap: anywhere; }
.entry[data-kind="error"] .entry__text { color: var(--danger); }
.entry details { margin-top: 2px; }
.entry summary { cursor: pointer; color: var(--muted); font-size: 11px; }
.entry pre { margin: 4px 0 0; background: var(--sunken); padding: 6px 8px; border-radius: 6px; max-height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-size: 11px; }

.log[data-hide-code] .entry[data-kind="code"],
.log[data-hide-event] .entry[data-kind="event"],
.log[data-hide-http] .entry[data-kind="http"] { display: none; }

#setup-status[data-tone="error"] { color: var(--danger); }
.setup { margin-top: 0; margin-bottom: 12px; border-color: var(--accent); }
