/* ---------------------------------------------------------------------------
   NDC Self Service - tokens and shared primitives.

   Rules (pinned by StylingGuardTests):
   - Colours are defined here, in :root, and nowhere else. Everything else uses
     var(--...) or color-mix() of a token.
   - No !important, no <style> blocks, no style="" attributes.
   - Page- and component-specific rules live in that component's .razor.css.
   - Mobile first: base rules are the phone layout; wider screens add to them.
   --------------------------------------------------------------------------- */

:root {
    color-scheme: light only;

    /* NDC brand, unchanged from the WebForms site. */
    --brand: #2994ae;
    --brand-strong: #1f7a8c;
    --brand-light: #3ba8c4;
    --brand-soft: color-mix(in srgb, var(--brand) 10%, var(--surface));

    /* Status colours the site already used. */
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --danger-strong: color-mix(in srgb, var(--danger) 80%, var(--ink));
    --warning-ink: color-mix(in srgb, var(--warning) 35%, var(--ink));

    /* Neutrals (Bootstrap's, which the site was built on). */
    --ink: #212529;
    --ink-muted: #6c757d;
    --canvas: #f8f9fa;
    --surface: #ffffff;
    --border: #dee2e6;
    --on-brand: #ffffff;

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-pill: 999px;
    --shadow: 0 1px 2px color-mix(in srgb, var(--ink) 6%, transparent),
              0 8px 24px color-mix(in srgb, var(--ink) 8%, transparent);
    --focus-ring: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent);

    --gutter: 16px;
    --content-width: 1140px;
    --narrow-width: 460px;
}

/* --- base ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--ink);
    background: var(--canvas);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.5rem; }
p { margin: 0 0 0.75rem; }
img { max-width: 100%; height: auto; }

a { color: var(--brand); }
a:hover { color: var(--brand-strong); }

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 4px; }

.skip-link {
    position: absolute;
    left: var(--gutter);
    top: -3rem;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border-radius: var(--radius-sm);
    z-index: 10;
}
.skip-link:focus { top: var(--gutter); }

.site-main { flex: 1 0 auto; padding: 1.5rem 0 2rem; }

.container {
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 var(--gutter);
}
.container-narrow { max-width: 820px; }

hr.divider { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* --- icons ------------------------------------------------------------- */

.icon { width: 1em; height: 1em; flex: none; vertical-align: -0.125em; }
.icon-lg { width: 1.5em; height: 1.5em; }
.icon-xl { width: 2.5em; height: 2.5em; }

/* --- buttons: the only five --------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 44px; /* a comfortable tap target on a phone */
    padding: 0.5rem 1.25rem;
    border: 2px solid transparent;
    border-radius: var(--radius-pill);
    font: inherit;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--on-brand); }

.btn-secondary { background: var(--surface); border-color: var(--brand); color: var(--brand); }
.btn-secondary:hover { background: var(--brand-soft); color: var(--brand-strong); }

.btn-quiet { background: transparent; color: var(--brand); padding-inline: 0.75rem; }
.btn-quiet:hover { background: var(--brand-soft); color: var(--brand-strong); }

.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-brand); }
.btn-danger:hover { background: var(--danger-strong); border-color: var(--danger-strong); color: var(--on-brand); }

.btn-inverse { background: transparent; border-color: var(--on-brand); color: var(--on-brand); }
.btn-inverse:hover { background: var(--on-brand); color: var(--brand-strong); }

.btn-sm { min-height: 36px; padding: 0.3rem 0.9rem; font-size: 0.875rem; }
.btn-lg { min-height: 52px; padding: 0.7rem 1.75rem; font-size: 1.1rem; }
.btn-block { display: flex; width: 100%; }

/* --- forms ------------------------------------------------------------- */

.form { display: grid; gap: 1rem; }
.form-inline-center { display: flex; justify-content: center; margin-top: 0.75rem; }

.input {
    display: block;
    width: 100%;
    min-height: 48px;
    padding: 0.65rem 0.9rem;
    font: inherit;
    font-size: 1.05rem; /* 16px or more: phones do not zoom into the field */
    color: var(--ink);
    background: var(--canvas);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus-ring); background: var(--surface); }
.input.invalid { border-color: var(--danger); }
.input-code { font-size: 1.4rem; letter-spacing: 0.3em; text-align: center; }

.input-with-action { position: relative; }
.input-with-action .input { padding-right: 3rem; }
.input-action {
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--ink-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.input-action .when-shown { display: none; }
.input-action.is-shown .when-shown { display: inline-flex; }
.input-action.is-shown .when-hidden { display: none; }

.check { display: flex; align-items: center; gap: 0.6rem; cursor: pointer; }
.check input { width: 1.25rem; height: 1.25rem; accent-color: var(--brand); }

.validation-message { color: var(--danger); font-size: 0.875rem; margin-top: 0.25rem; }
.validation-errors { display: none; }

/* --- tables: rows become stacked cards on a phone ----------------------- */

.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th, .table td { padding: 0.65rem 0.75rem; text-align: left; vertical-align: middle; }
.table thead th { background: var(--canvas); font-weight: 600; border-bottom: 1px solid var(--border); }
.table tbody tr { border-bottom: 1px solid var(--border); }
.table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--canvas) 60%, var(--surface)); }
.table .num { text-align: right; white-space: nowrap; }

@media (max-width: 767.98px) {
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr { padding: 0.5rem 0; }
    .table-stack td { display: flex; justify-content: space-between; gap: 1rem; padding: 0.35rem 0.25rem; text-align: right; }
    .table-stack td::before { content: attr(data-label); font-weight: 600; text-align: left; color: var(--ink-muted); }
    .table-stack td.num { text-align: right; }
}

.action-row { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: flex-end; }

/* --- small shared pieces ---------------------------------------------- */

.tag {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    border-radius: var(--radius-pill);
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-size: 0.8rem;
    font-weight: 600;
}

.pill {
    display: inline-block;
    margin: 0;
    padding: 0.2rem 0.75rem;
    border-radius: var(--radius-pill);
    color: var(--on-brand);
    font-weight: 600;
    font-size: 0.875rem;
}
.pill-brand { background: var(--brand); }
.pill-brand-light { background: var(--brand-light); }
.pill-success { background: var(--success); }
.pill-danger { background: var(--danger); }

.summary-list { margin: 0; }
.summary-list > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border);
}
.summary-list > div:last-child { border-bottom: 0; }
.summary-list dt { font-weight: 500; }

.empty-state { color: var(--ink-muted); margin: 0; }

/* Content of the narrow single-column cards: sign-in, lockout, errors. */
.auth-logo { display: block; margin: 0 auto 1rem; max-height: 80px; width: auto; }
.auth-title { text-align: center; font-size: 1.6rem; margin-bottom: 1.25rem; }
.auth-symbol { display: flex; justify-content: center; margin-bottom: 1rem; color: var(--brand); }
.auth-symbol-danger { color: var(--danger); }
.auth-links { display: grid; justify-items: center; gap: 0.6rem; text-align: center; }
.section-title { font-size: 1.15rem; }

.reminder-list { margin: 0 0 0.75rem; padding-left: 1.25rem; }
.reminder-list li { margin-bottom: 0.35rem; }

/* A section that opens in place: the old pages' pop-up forms. Native <details>, no script. */
.expander { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.expander > summary {
    cursor: pointer;
    padding: 0.7rem 1rem;
    font-weight: 600;
    color: var(--brand-strong);
    list-style-position: inside;
}
.expander > summary:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
.expander[open] > summary { border-bottom: 1px solid var(--border); }
.expander > :not(summary) { margin-left: 1rem; margin-right: 1rem; }
.expander > :last-child { margin-bottom: 1rem; }

/* --- utilities ---------------------------------------------------------- */

.text-small { font-size: 0.875rem; }
.text-muted { color: var(--ink-muted); }
.text-center { text-align: center; }
.text-small .icon, .text-muted .icon { margin-right: 0.35rem; }

/* --- admin pages --------------------------------------------------------- */

/* Document Management's preview pop-up: the file fills the pop-up. */
.doc-preview {
    display: block;
    width: 100%;
    height: 70dvh;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--canvas);
}

.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem 1rem; margin-bottom: 1rem; }
.filter-bar .field { min-width: 12rem; margin: 0; }

.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1rem; flex-wrap: wrap; }

.detail-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 0.75rem 1.5rem; margin: 0 0 1rem; }
.detail-list dt { font-size: 0.85rem; color: var(--ink-muted); }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }

.status { display: inline-block; padding: 0.15rem 0.6rem; border-radius: var(--radius-pill); font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.status-pending { background: color-mix(in srgb, var(--warning) 25%, var(--surface)); color: var(--warning-ink); }
.status-approved { background: color-mix(in srgb, var(--success) 18%, var(--surface)); color: color-mix(in srgb, var(--success) 70%, var(--ink)); }
.status-rejected { background: color-mix(in srgb, var(--danger) 15%, var(--surface)); color: var(--danger-strong); }
.status-none { background: var(--canvas); color: var(--ink-muted); }

.setting-value { font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; overflow-wrap: anywhere; white-space: pre-wrap; max-width: 28rem; }
.cell-wrap { overflow-wrap: anywhere; max-width: 24rem; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1.5rem; margin-top: 1.5rem; }

.daily-chart { width: 100%; height: auto; display: block; margin-bottom: 1rem; }
.chart-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-baseline { stroke: var(--ink-muted); stroke-width: 1; }
.chart-axis { fill: var(--ink-muted); font-size: 12px; }
.chart-mark { fill: var(--brand-strong); }
.chart-hit { fill: transparent; }
.chart-bar:hover .chart-mark { fill: var(--brand); }
.chart-bar:hover .chart-hit { fill: color-mix(in srgb, var(--brand) 8%, transparent); }

.share-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.share-label { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.9rem; margin-bottom: 0.25rem; }
.share-track { display: block; width: 100%; height: 8px; }
.share-rail { fill: var(--canvas); }
.share-fill { fill: var(--brand-strong); }
