/* ==========================================================================
   BAMTHLabReports - patient laboratory report portal
   --------------------------------------------------------------------------
   Design tokens are taken from the existing Bakhtawar Amin Hospital website
   (WordPress theme "Clinico", see docs/Repository-Analysis.md):

     brand red ......... #ff2323   (theme accent, hover #ff0000)
     heading ink ....... #373737   (.widget-title, .main-menu)
     body text ......... #7c7c7c   (body)
     hairline .......... #e3e3e3   (borders, tag cloud)
     surface ........... #ffffff
     canvas ............ #f5f7f9   (light neutral page background)
     typeface .......... Lato (body 14px / line-height 21px in the theme)

   Reusable behaviours copied from the theme:
     * section titles keep the theme's 3px left accent border ( .widget-title )
     * buttons keep the theme's uppercase 14px treatment ( .cws_button )
     * containers are 1170px wide and centred ( .container in layout.css )
   ========================================================================== */

:root {
    --brand: #ff2323;
    --brand-strong: #ff0000;
    --brand-dark: #d81b1b;
    --brand-tint: #fff1f1;
    --brand-tint-strong: #ffe3e3;

    --ink: #373737;
    --ink-soft: #4a4a4a;
    --muted: #7c7c7c;
    --line: #e3e3e3;
    --line-soft: #eef1f4;

    --surface: #ffffff;
    --canvas: #f5f7f9;
    --footer: #2b2f33;

    --ok: #1f8a4c;
    --warn: #b26a00;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(20, 30, 45, .06), 0 1px 3px rgba(20, 30, 45, .04);
    --shadow: 0 10px 30px rgba(20, 30, 45, .08);
    --shadow-lg: 0 24px 60px rgba(20, 30, 45, .14);

    --font: "Lato", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --container: 1170px;
    --focus: 0 0 0 3px rgba(255, 35, 35, .30);
}

/* --------------------------------------------------------------- reset --- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    color: var(--muted);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    margin: 0 0 .5rem;
    color: var(--ink);
    font-weight: 700;
    line-height: 1.25;
}

h1 { font-size: 1.65rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 .75rem; }

a { color: var(--brand-dark); text-decoration: none; }
a:hover { color: var(--brand-strong); text-decoration: underline; }

img, svg { max-width: 100%; }

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    box-shadow: var(--focus);
}

/* ------------------------------------------------------------ utilities --- */
.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 24px;
}

.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 50;
    background: var(--brand);
    color: #fff;
    padding: 10px 18px;
    border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; color: #fff; }

.section-title {
    margin: 0 0 18px;
    padding-left: 10px;
    border-left: 3px solid var(--brand);
    font-size: 1.1rem;
    color: var(--ink);
    text-transform: uppercase;
    letter-spacing: .02em;
}

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }

/* --------------------------------------------------------------- header --- */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    position: relative;
}
.site-header::before {
    content: "";
    display: block;
    height: 4px;
    background: linear-gradient(90deg, var(--brand) 0%, var(--brand-strong) 100%);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 76px;
    padding-top: 12px;
    padding-bottom: 12px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
}
.brand:hover { text-decoration: none; color: var(--ink); }

.brand-mark {
    display: grid;
    place-items: center;
    width: 46px; height: 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
    color: #fff;
    font-weight: 900;
    font-size: 1rem;
    letter-spacing: .02em;
    box-shadow: 0 6px 16px rgba(255, 35, 35, .28);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { color: var(--ink); font-size: 1.02rem; letter-spacing: .01em; }
.brand-text span { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .09em; }

/* The logo is configurable, so its aspect ratio is unknown: cap it instead of
   letting a wide or very tall image push the header around. */
.brand-logo {
    height: 44px;
    width: auto;
    max-width: 230px;
    max-height: 52px;
    object-fit: contain;
    display: block;
}

.header-nav { display: flex; align-items: center; gap: 14px; }

.who {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--canvas);
    color: var(--ink-soft);
    font-size: .82rem;
}
.who b { color: var(--ink); }
.who .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--ok);
    display: inline-block;
}

/* --------------------------------------------------------------- footer --- */
.site-footer {
    margin-top: 48px;
    background: var(--footer);
    color: #cfd4d8;
    font-size: .88rem;
}
.site-footer .footer-top { padding: 34px 0; }
.site-footer h3 {
    color: #fff;
    font-size: .95rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 12px;
}
.site-footer a { color: #fff; }
.site-footer a:hover { color: var(--brand); }
.footer-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 28px;
}
.footer-list { list-style: none; margin: 0; padding: 0; }
.footer-list li { margin-bottom: 6px; }
.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, .10);
    padding: 16px 0;
    color: #a9b1b7;
    font-size: .82rem;
}
.footer-bottom .container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
}

/* -------------------------------------------------------------- buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--brand);
    color: #fff;
    font-family: var(--font);
    font-size: .88rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn:hover { background: var(--brand-strong); color: #fff; text-decoration: none; }
.btn:focus-visible { box-shadow: var(--focus); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .65; cursor: not-allowed; }

.btn-block { width: 100%; }
.btn-lg { padding: 15px 26px; font-size: .95rem; }

.btn-secondary {
    background: #fff;
    border-color: var(--line);
    color: var(--ink);
}
.btn-secondary:hover { background: var(--brand); border-color: var(--brand); color: #fff; }

.btn-ghost {
    background: transparent;
    border-color: rgba(255, 255, 255, .35);
    color: #fff;
}
.btn-ghost:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.btn-link {
    background: none;
    border: 0;
    padding: 0;
    color: var(--brand-dark);
    font-weight: 700;
    text-decoration: underline;
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
}

.btn .spinner { display: none; }
.btn.is-busy .spinner { display: inline-block; }
.btn.is-busy .btn-label { opacity: .8; }

/* ---------------------------------------------------------------- cards --- */
.panel {
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.panel-pad { padding: 26px 28px; }

/* ----------------------------------------------------------- login page --- */
.login-page { display: flex; flex-direction: column; min-height: 100vh; }
.login-page main {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    padding: 40px 0 56px;
}

.login-shell {
    display: grid;
    grid-template-columns: 1fr 1.05fr;
    max-width: 1000px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-aside {
    position: relative;
    padding: 40px 36px;
    color: #fff;
    background: linear-gradient(160deg, var(--brand) 0%, #e0132a 55%, #b8122a 100%);
}
.login-aside::after {
    content: "";
    position: absolute;
    inset: auto -60px -80px auto;
    width: 260px; height: 260px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .07);
}
.login-aside h1 { color: #fff; font-size: 1.6rem; }
.login-aside p { color: rgba(255, 255, 255, .88); }
.login-aside ul {
    list-style: none;
    margin: 22px 0 0;
    padding: 0;
    position: relative;
    z-index: 1;
}
.login-aside li {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 12px;
    font-size: .92rem;
    color: rgba(255, 255, 255, .95);
}
.login-aside li::before {
    content: "";
    flex: 0 0 auto;
    width: 18px; height: 18px;
    margin-top: 3px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .55);
}

.login-form-side { padding: 40px 36px; }
.login-form-side h2 { color: var(--ink); }
.login-form-side .lead { color: var(--muted); margin-bottom: 22px; }

.field { margin-bottom: 18px; }
.field label {
    display: block;
    margin-bottom: 6px;
    color: var(--ink);
    font-size: .82rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.field .hint {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: .78rem;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}

.input {
    width: 100%;
    height: 50px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--ink);
    font-family: var(--font);
    font-size: 1rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: #b3b8bd; }
.input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--focus);
}
.input.input-validation-error { border-color: var(--brand); background: var(--brand-tint); }

.field-validation-error {
    display: block;
    margin-top: 6px;
    color: var(--brand-dark);
    font-size: .8rem;
    font-weight: 700;
}

.alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: .88rem;
    margin-bottom: 18px;
}
.alert-error { background: var(--brand-tint); border-color: var(--brand-tint-strong); color: #9b1111; }
.alert-info { background: #f2f6fb; border-color: #dbe6f3; color: #274b6d; }
.alert-warn { background: #fff8ec; border-color: #f2e2c4; color: #7a4d00; }
.alert strong { color: inherit; }

.privacy-note {
    margin-top: 20px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: var(--canvas);
    border-left: 3px solid var(--brand);
    color: var(--muted);
    font-size: .82rem;
}
.privacy-note strong { color: var(--ink); }

.login-footer-links {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    font-size: .82rem;
    color: var(--muted);
}

/* ------------------------------------------------------------- dashboard --- */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin: 28px 0 18px;
}
.page-head h1 { margin: 0; }
.page-head .subtitle { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.summary-card {
    position: relative;
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.summary-card::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--brand);
}
.summary-card .label {
    display: block;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.summary-card .value {
    display: block;
    color: var(--ink);
    font-size: 1.02rem;
    font-weight: 700;
    word-break: break-word;
}
.summary-card .value.is-empty { color: #a7adb3; font-weight: 400; }

/* ----------------------------------------------------------------- table --- */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.table-head {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: baseline;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line-soft);
}
.table-head h2 { margin: 0; }
.table-head .count { color: var(--muted); font-size: .84rem; }

.reports-table { width: 100%; border-collapse: collapse; }
.reports-table caption { text-align: left; padding: 0 22px 10px; color: var(--muted); font-size: .84rem; }
.reports-table thead th {
    padding: 12px 22px;
    background: var(--canvas);
    color: var(--ink);
    font-size: .74rem;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
    text-align: left;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.reports-table tbody td {
    padding: 14px 22px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--ink-soft);
    vertical-align: middle;
}
.reports-table tbody tr:last-child td { border-bottom: 0; }
.reports-table tbody tr:hover { background: #fcfdfe; }
.reports-table .col-serial { width: 64px; color: var(--muted); font-variant-numeric: tabular-nums; }
.reports-table .col-test { font-weight: 700; color: var(--ink); }
.reports-table .col-actions { width: 220px; text-align: right; white-space: nowrap; }

.pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.pill-pending { background: #fff8ec; color: #8a5a00; border: 1px solid #f2e2c4; }
.pill-ready { background: #eef8f2; color: #166b3c; border: 1px solid #cde9da; }

.cell-date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.cell-date .rel { display: block; color: var(--muted); font-size: .76rem; }

.action-group { display: inline-flex; gap: 8px; justify-content: flex-end; }
.btn-sm { padding: 8px 14px; font-size: .74rem; }

.empty-state {
    padding: 54px 24px;
    text-align: center;
}
.empty-state .icon {
    display: grid;
    place-items: center;
    width: 62px; height: 62px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: var(--brand-tint);
    color: var(--brand);
    font-size: 1.6rem;
    font-weight: 900;
}
.empty-state h3 { color: var(--ink); }
.empty-state p { max-width: 460px; margin: 0 auto 18px; color: var(--muted); }

/* ---------------------------------------------------------- pdf viewer --- */
.viewer-shell {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 24px 0 8px;
}
.viewer-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.viewer-bar .meta { color: var(--muted); font-size: .86rem; }
.viewer-bar .meta strong { color: var(--ink); }
.viewer-frame {
    position: relative;
    height: 78vh;
    min-height: 460px;
    background: #e9edf1;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.viewer-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.viewer-note { color: var(--muted); font-size: .84rem; }

/* Modifiers instead of inline styles: the content security policy forbids
   style attributes, so every layout tweak gets a class. */
.viewer-note.spaced { margin: 18px 0 0; }
.section-title.flush { margin: 0; }

/* --------------------------------------------------------- spinner etc. --- */
.spinner {
    width: 15px; height: 15px;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.spinner-dark {
    width: 16px; height: 16px;
    border: 2px solid var(--brand-tint-strong);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .spinner, .spinner-dark { animation-duration: 2s; }
    * { transition: none !important; }
}

.busy-overlay {
    position: fixed;
    inset: 0;
    display: none;
    place-items: center;
    background: rgba(20, 30, 45, .45);
    z-index: 60;
    backdrop-filter: blur(1px);
}
.busy-overlay.is-visible { display: grid; }
.busy-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 22px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    color: var(--ink);
    font-weight: 700;
}

/* ------------------------------------------------------------- messages --- */
.message-page { display: flex; flex-direction: column; min-height: 100vh; }
.message-page main { flex: 1 1 auto; display: grid; place-items: center; padding: 48px 0; }
.message-card {
    max-width: 560px;
    padding: 34px 32px;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.message-card .icon {
    display: grid;
    place-items: center;
    width: 62px; height: 62px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: var(--brand-tint);
    color: var(--brand);
    font-size: 1.5rem;
    font-weight: 900;
}
.message-card h1 { font-size: 1.35rem; }
.message-card p { color: var(--muted); }

/* Error pages rendered inside the report viewer's iframe (Views/Shared/_FrameLayout.cshtml).
   The frame is only 78vh tall and already sits inside the full site chrome, so
   these pages drop the 100vh min-height, use a tighter card and show no header,
   navigation or footer at all. */
body.message-page.is-framed {
    min-height: 100%;
    background: var(--canvas);
}
body.message-page.is-framed main {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    padding: 22px 16px;
}
.message-card.is-compact {
    max-width: 440px;
    padding: 26px 24px;
}
.message-card.is-compact h1 { font-size: 1.12rem; }
.message-card.is-compact p { font-size: .88rem; }
.message-card.is-compact .icon { width: 48px; height: 48px; font-size: 1.2rem; margin-bottom: 12px; }
.message-card .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }
.reference {
    display: inline-block;
    margin-top: 14px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: var(--canvas);
    color: var(--muted);
    font-size: .78rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ------------------------------------------------------------ responsive --- */
@media (max-width: 1024px) {
    .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .login-shell { grid-template-columns: 1fr; max-width: 620px; }
    .login-aside { padding: 30px 28px; }
    .login-aside::after { display: none; }
    .login-form-side { padding: 30px 28px; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 767px) {
    .container { padding: 0 16px; }
    .header-inner { min-height: 66px; }
    .brand-text span { display: none; }

    .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    /* The reports table becomes a stack of cards on small screens. */
    .reports-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .reports-table, .reports-table tbody, .reports-table tr, .reports-table td { display: block; width: 100%; }
    .reports-table tbody tr {
        padding: 14px 16px;
        border-bottom: 1px solid var(--line-soft);
    }
    .reports-table tbody tr:last-child { border-bottom: 0; }
    .reports-table tbody td { padding: 4px 0; border: 0; }
    .reports-table tbody td::before {
        content: attr(data-label);
        display: block;
        color: var(--muted);
        font-size: .7rem;
        font-weight: 800;
        letter-spacing: .08em;
        text-transform: uppercase;
    }
    .reports-table .col-actions { text-align: left; }
    .action-group { justify-content: flex-start; width: 100%; }
    .action-group .btn { flex: 1 1 auto; }

    .table-head { padding: 16px; }
    .footer-grid { grid-template-columns: 1fr; }
    .viewer-frame { height: 68vh; min-height: 380px; }
}

@media (max-width: 420px) {
    .summary-grid { grid-template-columns: 1fr; }
    .login-aside h1 { font-size: 1.35rem; }
    .btn { padding: 11px 16px; font-size: .82rem; }
}
