/* HikeCare design tokens — docs/design/STYLE_GUIDE.md (proposed). */
:root {
    --hc-ink: #14283F;
    --hc-primary: #0F6D67;
    --hc-bg: #F5F7FA;
    --hc-panel: #FFFFFF;
    --hc-line: #DCE5ED;
    --hc-text-secondary: #526478;
    --hc-ok: #1E6B3A;     --hc-ok-bg: #E6F4EA;
    --hc-warn: #8A5300;   --hc-warn-bg: #FFF4E5;
    --hc-error: #A61B1B;  --hc-error-bg: #FDECEC;
    --hc-radius: 8px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --hc-ink: #E6EDF5;
        --hc-primary: #2BA59B;
        --hc-bg: #0F1720;
        --hc-panel: #17212C;
        --hc-line: #2A3846;
        --hc-text-secondary: #A3B3C4;
        --hc-ok: #7FD39A;     --hc-ok-bg: #16301F;
        --hc-warn: #F2B866;   --hc-warn-bg: #33270F;
        --hc-error: #F29191;  --hc-error-bg: #3A1717;
    }
}

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

html, body {
    margin: 0;
    background: var(--hc-bg);
    color: var(--hc-ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Tamil", "Noto Sans Malayalam", sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

a { color: var(--hc-primary); }

:focus-visible {
    outline: 3px solid var(--hc-primary);
    outline-offset: 2px;
}

h1:focus { outline: none; }

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

.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid var(--hc-error); }
.validation-message { color: var(--hc-error); }

.blazor-error-boundary {
    background: var(--hc-error-bg);
    color: var(--hc-error);
    padding: 1rem;
    border-radius: var(--hc-radius);
}

    .blazor-error-boundary::after { content: "Something went wrong while showing this section."; }

/* ── Shared UI (Stage 5a): text, cards, forms, buttons, alerts, badges, tables ─────────── */
.muted { color: var(--hc-text-secondary); }
.small { font-size: 0.875rem; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.9em; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.card {
    background: var(--hc-panel);
    border: 1px solid var(--hc-line);
    border-radius: 12px;
    padding: 24px;
    margin: 0 0 24px;
}
.card h1 { margin-top: 0; font-size: 1.5rem; }
.card h2 { margin-top: 0; font-size: 1.125rem; }
.card-narrow { max-width: 420px; margin: 16px auto 24px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 1.5rem; }

.form { display: grid; gap: 16px; }
.form-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: start; }
.form-grid .alert, .form-grid .actions, .form-grid .check { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; }
.hint { font-size: 0.8125rem; color: var(--hc-text-secondary); }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.check input { width: 20px; height: 20px; }

.input {
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    font: inherit;
    color: var(--hc-ink);
    background: var(--hc-panel);
    border: 1px solid var(--hc-line);
    border-radius: var(--hc-radius);
}
.input:focus { outline: 2px solid var(--hc-primary); outline-offset: 1px; border-color: var(--hc-primary); }
.input-code { text-transform: uppercase; letter-spacing: 0.05em; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 44px; padding: 8px 18px;
    font: inherit; font-weight: 600; text-decoration: none;
    border: 1px solid transparent; border-radius: var(--hc-radius);
    cursor: pointer;
}
.btn:focus-visible { outline: 2px solid var(--hc-primary); outline-offset: 2px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--hc-primary); color: #fff; }
.btn-secondary { background: var(--hc-panel); color: var(--hc-ink); border-color: var(--hc-line); }
.btn-quiet { background: transparent; color: var(--hc-primary); padding: 8px 10px; }
.btn-quiet:hover { background: var(--hc-bg); }
.btn-block { width: 100%; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }

.alert { margin: 0 0 16px; padding: 12px 14px; border-radius: var(--hc-radius); }
.form .alert { margin: 0; }
.alert-error { background: var(--hc-error-bg); color: var(--hc-error); }
.alert-warn { background: var(--hc-warn-bg); color: var(--hc-warn); }
.alert-ok { background: var(--hc-ok-bg); color: var(--hc-ok); }

.badge {
    display: inline-block; padding: 2px 8px; margin: 2px 4px 2px 0;
    font-size: 0.8125rem; font-weight: 600; border-radius: 999px;
    background: var(--hc-bg); color: var(--hc-text-secondary); border: 1px solid var(--hc-line);
}
.badge-ok { background: var(--hc-ok-bg); color: var(--hc-ok); border-color: transparent; }
.badge-warn { background: var(--hc-warn-bg); color: var(--hc-warn); border-color: transparent; }
.badge-error { background: var(--hc-error-bg); color: var(--hc-error); border-color: transparent; }

.table-wrap { background: var(--hc-panel); border: 1px solid var(--hc-line); border-radius: 12px; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--hc-line); vertical-align: middle; }
.table th { font-size: 0.8125rem; color: var(--hc-text-secondary); font-weight: 600; background: var(--hc-bg); }
.table tbody tr:last-child td { border-bottom: 0; }
.row-inactive td { color: var(--hc-text-secondary); }
.row-actions { text-align: right; white-space: nowrap; }

/* Phones: each table row becomes a stacked card with its column label. */
@media (max-width: 640px) {
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr { padding: 8px 0; border-bottom: 1px solid var(--hc-line); }
    .table td { border: 0; padding: 4px 12px; }
    .table td[data-label]::before { content: attr(data-label); display: block; font-size: 0.75rem; color: var(--hc-text-secondary); }
    .row-actions { text-align: left; white-space: normal; }
}

/* ── Reception and queue (Stage 5b/5c) ──────────────────────────────────────────────── */
.field-wide { grid-column: 1 / -1; }
.choice { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.choice legend { font-weight: 600; margin-bottom: 6px; padding: 0; width: 100%; }
.pill {
    display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 14px;
    border: 1px solid var(--hc-line); border-radius: 999px; background: var(--hc-panel); cursor: pointer;
}
.pill:has(input:checked) { border-color: var(--hc-primary); box-shadow: inset 0 0 0 1px var(--hc-primary); }
.pill input { width: 18px; height: 18px; }
.notice { padding: 12px 14px; border-radius: var(--hc-radius); background: var(--hc-warn-bg); color: var(--hc-ink); }
.plain-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 6px; }

.search { display: flex; gap: 8px; flex-wrap: wrap; }
.search .input { flex: 1 1 240px; font-size: 1.125rem; }
.results { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.result {
    width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
    padding: 12px 14px; text-align: left; font: inherit; color: var(--hc-ink);
    background: var(--hc-panel); border: 1px solid var(--hc-line); border-radius: var(--hc-radius); cursor: pointer;
}
.result:hover, .result:focus-visible { border-color: var(--hc-primary); outline: none; }
.result-selected { border-color: var(--hc-primary); box-shadow: inset 0 0 0 1px var(--hc-primary); }
.result-name { font-weight: 700; }
.result-meta { grid-column: 1; color: var(--hc-text-secondary); font-size: 0.9375rem; }
.result .badge { grid-row: 1 / span 2; grid-column: 2; }

.patient-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.patient-head h2 { margin: 0 0 4px; font-size: 1.375rem; }
.patient-head p { margin: 0; }
.uhid {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 1.25rem; font-weight: 700;
    padding: 6px 12px; border-radius: var(--hc-radius); background: var(--hc-bg); border: 1px solid var(--hc-line);
}
.facts { display: grid; gap: 0; margin: 16px 0; }
.facts div { display: grid; grid-template-columns: 140px 1fr; gap: 12px; padding: 8px 0; border-top: 1px solid var(--hc-line); }
.facts dt { color: var(--hc-text-secondary); }
.facts dd { margin: 0; }
.visit-form { padding: 16px; margin: 8px 0 16px; border-radius: var(--hc-radius); background: var(--hc-bg); }
.visit-form h3, .patient h3 { margin: 0; font-size: 1rem; }
.patient h3 { margin-top: 16px; }
.visits li { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.token-box {
    display: grid; justify-items: start; gap: 6px; padding: 16px; margin: 8px 0 16px;
    border-radius: var(--hc-radius); background: var(--hc-ok-bg); color: var(--hc-ink);
}
.token-label { font-weight: 600; color: var(--hc-ok); }
.token { font-size: 2.25rem; font-weight: 800; line-height: 1.1; }
.token-small {
    display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 6px;
    font-size: 1.125rem; font-weight: 800; border-radius: var(--hc-radius); background: var(--hc-bg); border: 1px solid var(--hc-line);
}

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.chip {
    display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 12px;
    font: inherit; color: var(--hc-ink); background: var(--hc-panel);
    border: 1px solid var(--hc-line); border-radius: 999px; cursor: pointer;
}
.chip-on { border-color: var(--hc-primary); background: var(--hc-primary); color: #fff; }
.chip-count { font-weight: 700; }

@media (max-width: 640px) {
    .facts div { grid-template-columns: 1fr; gap: 2px; }
    .search .btn { flex: 1 1 auto; }
}
