/* ==========================================================================
   Sample Tracking — "Chain of Custody" design system.
   A clinical, trustworthy palette (deep navy + lab teal) with a technical
   type pairing, and a mono-spaced "custody rail" stepper as the signature
   element: it is a literal rendering of a sample's real journey through
   the lab (Received -> Under Processing -> Results Ready), used wherever
   a sample's status is shown.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&family=Cairo:wght@500;600;700&display=swap');

:root {
    --navy-950: #0b1220;
    --navy-800: #16233b;
    --navy-700: #1f2f4d;
    --teal-500: #12a594;
    --teal-600: #0d8a7c;
    --teal-100: #e3f6f3;
    --amber-500: #e2a63b;
    --amber-100: #fbf0dc;
    --rose-500: #d2555d;
    --rose-100: #fbe6e7;
    --slate-50: #f6f8f9;
    --slate-100: #eef1f3;
    --line: #e1e6ea;
    --ink: #182233;
    --ink-soft: #5b6572;
    --paper: #ffffff;
}

html {
    font-size: 15px;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

html {
    position: relative;
    min-height: 100%;
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, sans-serif;
    color: var(--ink);
    background: var(--slate-50);
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6,
.font-display {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-weight: 600;
    color: var(--navy-950);
    letter-spacing: -0.01em;
}

.text-mono,
code,
.barcode-tag {
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
}

a {
    color: var(--teal-600);
    font-weight: 600;
    text-decoration: none;
}

    a:hover {
        color: var(--navy-800);
    }

/* ==========================================================================
   Arabic / RTL support. Bootstrap 5's margin/padding utilities (me-*, ms-*)
   and flex layout already flip automatically under dir="rtl" — this only
   covers the pieces that don't: the Arabic-capable font stack, and barcode
   / numeric values that should stay LTR even inside an RTL page.
   ========================================================================== */
[dir="rtl"] body,
[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] h4,
[dir="rtl"] h5,
[dir="rtl"] h6,
[dir="rtl"] .font-display {
    font-family: 'Cairo', 'Inter', sans-serif;
}

/* Barcodes, dates, and other machine-readable values stay left-to-right
   even in an Arabic layout — this is standard practice and keeps them
   readable/scannable regardless of page direction. The actual date/time
   values are also formatted with CultureInfo.InvariantCulture in the views
   themselves (not just this CSS) — that's the real fix, since it prevents
   Arabic AM/PM markers or reordered digit groups from ever entering the
   string in the first place. This CSS is a second line of defense for any
   .text-mono content that might still mix scripts.
   unicode-bidi: plaintext determines direction from the content's own
   first strong character rather than only isolating from the parent —
   more robust for numeric content than isolate alone. */
.text-mono,
.barcode-tag {
    direction: ltr;
    unicode-bidi: plaintext;
}

/* text-align's default value ("start") is relative to THIS element's own
   direction, not its parent's — so forcing direction:ltr above silently
   made these left-align even inside an RTL page, drifting them away from
   their right-aligned header/siblings. This puts them back on the right
   edge of their cell (matching the rest of the RTL layout) while the
   content inside still reads left-to-right. */
[dir="rtl"] .text-mono,
[dir="rtl"] .barcode-tag {
    text-align: right;
}

[dir="rtl"] .text-mono,
[dir="rtl"] .barcode-tag {
    text-align: right;
}

/* A few custom decorative/positioned elements use physical left/right
   offsets that don't auto-flip under dir="rtl" the way Bootstrap's own
   (logical-property-based) RTL stylesheet does — these overrides fix them. */
[dir="rtl"] .custody-rail__step:not(:first-child)::before {
    right: auto;
    left: 50%;
}

[dir="rtl"] .kpi-card::before {
    left: auto;
    right: 0;
}

[dir="rtl"] .print-report__header {
    text-align: right;
}

[dir="rtl"] .print-report__header .text-end {
    text-align: left !important;
}

/* ---- Focus ring ---- */
.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 0.15rem var(--paper), 0 0 0 0.3rem var(--teal-500);
    border-color: var(--teal-600);
}

/* ==========================================================================
   Top navigation
   ========================================================================== */
.app-header {
    background: var(--navy-950);
    border-bottom: 1px solid var(--navy-700);
}

.app-header .navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.15rem;
    color: #fff !important;
    letter-spacing: -0.01em;
}

.app-header .navbar-brand__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: linear-gradient(145deg, var(--teal-500), var(--teal-600));
    color: #fff;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    font-weight: 600;
}

.app-header .nav-link {
    color: rgba(255, 255, 255, 0.72) !important;
    font-weight: 500;
    font-size: 0.92rem;
    padding: 0.85rem 0.9rem !important;
    border-bottom: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.app-header .nav-link:hover {
    color: #fff !important;
}

.app-header .nav-link.active,
.app-header .nav-item.active .nav-link {
    color: #fff !important;
    border-bottom-color: var(--teal-500);
}

.app-header .navbar-toggler {
    border-color: rgba(255, 255, 255, 0.25);
}

.app-header .navbar-toggler-icon {
    filter: invert(1);
}

/* ==========================================================================
   Page shell
   ========================================================================== */
.page-shell {
    min-height: calc(100vh - 61px - 56px);
    padding: 2rem 0 3rem;
}

.page-head {
    margin-bottom: 1.75rem;
}

.page-head__eyebrow {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--teal-600);
    margin-bottom: 0.35rem;
    display: block;
}

.page-head h1,
.page-head h2 {
    font-size: 1.65rem;
    margin: 0;
}

.page-head p {
    color: var(--ink-soft);
    margin: 0.35rem 0 0;
}

footer.app-footer {
    background: var(--navy-950);
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.85rem;
    padding: 1.1rem 0;
}

    footer.app-footer a {
        color: rgba(255, 255, 255, 0.8);
    }

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(11, 18, 32, 0.04);
}

.panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.panel + .panel {
    margin-top: 0;
}

.panel__title {
    font-size: 1.02rem;
    margin: 0 0 1.1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--line);
}

/* Key/value summary grid used on sample detail cards */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem 1.5rem;
}

.summary-grid__item dt {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: 0.2rem;
}

.summary-grid__item dd {
    margin: 0;
    font-weight: 500;
    color: var(--ink);
}

/* ==========================================================================
   KPI / dashboard cards
   ========================================================================== */
.kpi-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1.25rem 1.4rem;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--kpi-accent, var(--teal-500));
}

.kpi-card--total { --kpi-accent: var(--navy-800); }
.kpi-card--received { --kpi-accent: #6b8ab5; }
.kpi-card--processing { --kpi-accent: var(--amber-500); }
.kpi-card--ready { --kpi-accent: var(--teal-500); }

.kpi-card__label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.kpi-card__value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2.1rem;
    font-weight: 700;
    color: var(--navy-950);
    line-height: 1;
}

/* ==========================================================================
   Custody rail — signature stepper
   ========================================================================== */
.custody-rail {
    list-style: none;
    display: flex;
    align-items: flex-start;
    padding: 0;
    margin: 0 0 0.5rem;
    gap: 0;
}

.custody-rail__step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
}

.custody-rail__step:not(:first-child)::before {
    content: "";
    position: absolute;
    top: 15px;
    right: 50%;
    width: 100%;
    height: 2px;
    background: var(--line);
    z-index: 0;
}

.custody-rail__step--done:not(:first-child)::before,
.custody-rail__step--current:not(:first-child)::before {
    background: var(--teal-500);
}

.custody-rail__marker {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--paper);
    border: 2px solid var(--line);
    color: var(--ink-soft);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.custody-rail__step--done .custody-rail__marker {
    background: var(--teal-500);
    border-color: var(--teal-500);
    color: #fff;
}

.custody-rail__step--current .custody-rail__marker {
    border-color: var(--teal-500);
    color: var(--teal-600);
    box-shadow: 0 0 0 4px var(--teal-100);
}

.custody-rail__label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-soft);
}

.custody-rail__step--current .custody-rail__label,
.custody-rail__step--done .custody-rail__label {
    color: var(--navy-950);
}

/* ==========================================================================
   Status badges
   ========================================================================== */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.65rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.badge-status::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-status--received {
    background: #eaf0f8;
    color: #3f5c85;
}

.badge-status--processing {
    background: var(--amber-100);
    color: #96701d;
}

.badge-status--ready {
    background: var(--teal-100);
    color: var(--teal-600);
}

.badge-status--positive {
    background: var(--rose-100);
    color: var(--rose-500);
}

/* Barcode chip */
.barcode-tag {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    background: var(--navy-950);
    color: #fff;
    border-radius: 6px;
    font-size: 0.85rem;
    letter-spacing: 0.03em;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    border-radius: 9px;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.5rem 1.05rem;
}

.btn-primary {
    background-color: var(--teal-500);
    border-color: var(--teal-600);
}

    .btn-primary:hover,
    .btn-primary:focus {
        background-color: var(--teal-600);
        border-color: var(--teal-600);
    }

.btn-outline-secondary,
.btn-secondary {
    --bs-btn-color: var(--ink);
    background-color: var(--paper);
    border-color: var(--line);
    color: var(--ink);
}

    .btn-secondary:hover {
        background-color: var(--slate-100);
        border-color: var(--line);
        color: var(--ink);
    }

.btn-success {
    background-color: var(--teal-600);
    border-color: var(--teal-600);
}

.btn-warning {
    background-color: var(--amber-500);
    border-color: var(--amber-500);
    color: #fff;
}

.btn-danger {
    background-color: var(--rose-500);
    border-color: var(--rose-500);
}

/* ==========================================================================
   Forms
   ========================================================================== */
.form-control,
.form-select {
    border-radius: 9px;
    border-color: var(--line);
    padding: 0.5rem 0.75rem;
}

.form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 0.3rem;
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background: var(--slate-50);
    border-bottom: 1px solid var(--line);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-soft);
    padding: 0.75rem 1rem;
}

.table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table-hover tbody tr:hover {
    background: var(--slate-50);
}

/* ==========================================================================
   Alerts / empty states
   ========================================================================== */
.alert {
    border-radius: 10px;
    border: 1px solid transparent;
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: var(--ink-soft);
}

.empty-state__mark {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--teal-600);
    display: block;
    margin-bottom: 0.5rem;
}

/* ==========================================================================
   Home / hero
   ========================================================================== */
.hero {
    background: linear-gradient(160deg, var(--navy-950) 0%, var(--navy-800) 100%);
    border-radius: 18px;
    color: #fff;
    padding: 3rem 2.5rem;
    position: relative;
    overflow: hidden;
}

.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle at 85% 20%, rgba(18, 165, 148, 0.35) 0%, transparent 45%);
    pointer-events: none;
}

.hero__eyebrow {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--teal-500);
    display: block;
    margin-bottom: 0.9rem;
}

.hero h1 {
    color: #fff;
    font-size: clamp(1.8rem, 3.4vw, 2.6rem);
    max-width: 22ch;
    margin-bottom: 0.9rem;
}

.hero p {
    color: rgba(255, 255, 255, 0.75);
    max-width: 55ch;
    margin-bottom: 1.6rem;
}

.hero .btn-primary {
    padding: 0.65rem 1.4rem;
}

.role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.role-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1.25rem;
}

.role-card__code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
    color: var(--teal-600);
    font-weight: 600;
    letter-spacing: 0.05em;
}

.role-card h3 {
    font-size: 1rem;
    margin: 0.4rem 0 0.35rem;
}

.role-card p {
    color: var(--ink-soft);
    font-size: 0.88rem;
    margin: 0;
}

/* ==========================================================================
   Login page — dark navy stage with a teal-lit paper card. The barcode
   scan-line across the card top is this screen's signature detail.
   ========================================================================== */
body.login-page {
    background: radial-gradient(circle at 15% 12%, rgba(18, 165, 148, 0.18) 0%, transparent 42%),
                radial-gradient(circle at 88% 82%, rgba(18, 165, 148, 0.12) 0%, transparent 40%),
                var(--navy-950);
    min-height: 100vh;
}

body.login-page .page-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.login-card {
    position: relative;
    max-width: 420px;
    width: 100%;
    padding: 2.75rem 2.25rem 2.25rem;
    border-radius: 18px;
    background: var(--paper);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.login-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: repeating-linear-gradient(90deg, var(--teal-500) 0 10px, var(--navy-950) 10px 14px, var(--teal-500) 14px 22px, var(--navy-950) 22px 28px);
}

.login-title {
    text-align: center;
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
    font-size: 1.5rem;
}

.login-subtitle {
    text-align: center;
    margin-bottom: 1.75rem;
    font-size: 0.88rem;
    color: var(--ink-soft);
    font-weight: 500;
}

.login-card .btn-primary {
    border-radius: 9px;
}

@media (max-width: 576px) {
    .login-card {
        padding: 2.25rem 1.5rem 1.75rem;
    }
}

/* ==========================================================================
   Print / Save-as-PDF report layout
   ========================================================================== */
.print-report__header {
    display: none;
}

@media print {
    .app-header,
    .app-footer,
    .no-print,
    .page-head p {
        display: none !important;
    }

    body {
        background: #fff !important;
    }

    .page-shell {
        padding: 0 !important;
        min-height: 0 !important;
    }

    .print-report__header {
        display: flex !important;
        justify-content: space-between;
        align-items: flex-start;
        border-bottom: 2px solid #0b1220;
        padding-bottom: 0.75rem;
        margin-bottom: 1.25rem;
    }

    .print-report__header h2 {
        margin: 0 0 0.2rem;
        font-size: 1.2rem;
    }

    .print-report__header p {
        margin: 0;
        font-size: 0.85rem;
        color: #333;
    }

    .panel {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .badge-status {
        border: 1px solid currentColor;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    a[href]::after {
        content: none !important;
    }
}
