/* =========================================================
   MedCare HMS — UI theme (Bootstrap 5.3 base)
   ========================================================= */
:root {
    --hms-primary: #0f766e;        /* clinical teal */
    --hms-primary-600: #0d6560;
    --hms-primary-50: #e7f5f3;
    --hms-ink: #0f172a;
    --hms-muted: #64748b;
    --hms-line: #e5e9f0;
    --hms-bg: #f4f6f9;
    --hms-card: #ffffff;
    --hms-sidebar: #0b1f2a;
    --hms-sidebar-ink: #a9bccb;
    --hms-sidebar-active: #13303f;
    --hms-radius: 12px;

    --bs-primary: var(--hms-primary);
    --bs-primary-rgb: 15, 118, 110;
    --bs-link-color: var(--hms-primary);
    --bs-link-color-rgb: 15, 118, 110;
    --bs-link-hover-color: var(--hms-primary-600);
    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-color: var(--hms-ink);
    --bs-body-bg: var(--hms-bg);
    --bs-border-color: var(--hms-line);
}

body { font-size: .925rem; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, h6 { font-weight: 650; letter-spacing: -.01em; }
.text-muted { color: var(--hms-muted) !important; }
.fw-semibold { font-weight: 600 !important; }

/* ---------- Buttons ---------- */
.btn { border-radius: 8px; font-weight: 500; }
.btn-primary { --bs-btn-bg: var(--hms-primary); --bs-btn-border-color: var(--hms-primary); --bs-btn-hover-bg: var(--hms-primary-600); --bs-btn-hover-border-color: var(--hms-primary-600); --bs-btn-active-bg: var(--hms-primary-600); --bs-btn-disabled-bg: var(--hms-primary); --bs-btn-disabled-border-color: var(--hms-primary); }
.btn-outline-primary { --bs-btn-color: var(--hms-primary); --bs-btn-border-color: var(--hms-primary); --bs-btn-hover-bg: var(--hms-primary); --bs-btn-hover-border-color: var(--hms-primary); --bs-btn-active-bg: var(--hms-primary); }
.btn-icon { width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.35rem; padding: 0; }
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--hms-line); }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 258px; flex: 0 0 258px; background: var(--hms-sidebar); color: var(--hms-sidebar-ink);
    position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow-y: auto; z-index: 1040;
}
.brand { display: flex; align-items: center; gap: .75rem; padding: 1.15rem 1.25rem; text-decoration: none; color: #fff; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #14b8a6, #0f766e); display: grid; place-items: center; font-size: 1.15rem; color: #fff; flex-shrink: 0; }
.brand-text strong { display: block; font-size: .98rem; line-height: 1.2; }
.brand-text small { color: var(--hms-sidebar-ink); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.nav-menu { padding: .75rem .65rem 1rem; flex: 1; }
.nav-menu a {
    display: flex; align-items: center; gap: .7rem; padding: .55rem .8rem; margin-bottom: 2px; border-radius: 8px;
    color: var(--hms-sidebar-ink); text-decoration: none; font-weight: 500; font-size: .9rem; transition: background .15s, color .15s;
}
.nav-menu a i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.nav-menu a:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-menu a.active { background: var(--hms-sidebar-active); color: #fff; box-shadow: inset 3px 0 0 #2dd4bf; }
.nav-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: #5f7a8c; padding: 1rem .8rem .35rem; font-weight: 600; }
.sidebar-foot { padding: .9rem 1.25rem; font-size: .78rem; border-top: 1px solid rgba(255,255,255,.06); display: flex; align-items: center; gap: .5rem; }
.sidebar-foot .dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.sidebar-backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 1030; background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--hms-line); padding: .6rem 1.5rem; display: flex; align-items: center; gap: 1rem; min-height: 62px;
}
.content { padding: 1.5rem; flex: 1; }

@media (max-width: 991.98px) {
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.open { transform: none; }
    .sidebar.open + .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1035; }
    .content { padding: 1rem; }
    .topbar { padding: .5rem 1rem; }
}

/* ---------- Global search ---------- */
.global-search { position: relative; flex: 1; max-width: 520px; }
.global-search > i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--hms-muted); }
.global-search .form-control { padding-left: 2.4rem; background: var(--hms-bg); border-color: transparent; border-radius: 10px; }
.global-search .form-control:focus { background: #fff; border-color: var(--hms-primary); box-shadow: 0 0 0 .2rem rgba(15,118,110,.12); }
.search-results, .picker-results {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--hms-line); border-radius: 10px;
    box-shadow: 0 12px 32px rgba(15,23,42,.12); display: none; max-height: 360px; overflow-y: auto; z-index: 1060;
}
.picker-results { min-width: 340px; }
.search-results.show, .picker-results.show { display: block; }
.result-item { display: block; padding: .6rem .9rem; cursor: pointer; color: inherit; text-decoration: none; border-bottom: 1px solid #f1f4f8; }
.result-item:last-child { border-bottom: 0; }
.result-item:hover, .result-item.active { background: var(--hms-primary-50); }
.result-item strong { display: block; font-weight: 600; }
.result-item small { color: var(--hms-muted); }
.result-empty { padding: .8rem .9rem; color: var(--hms-muted); font-size: .875rem; }

/* ---------- User chip ---------- */
.user-chip { display: flex; align-items: center; gap: .6rem; background: none; border: 0; padding: .25rem .4rem; border-radius: 10px; }
.user-chip:hover { background: var(--hms-bg); }
.user-chip strong { display: block; font-size: .85rem; line-height: 1.15; }
.user-chip small { color: var(--hms-muted); font-size: .74rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--hms-primary-50); color: var(--hms-primary); display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex-shrink: 0; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.45rem; margin: 0; }
.page-head .sub { color: var(--hms-muted); margin-top: .2rem; font-size: .9rem; }
.breadcrumb { font-size: .8rem; margin-bottom: .25rem; }

/* ---------- Cards ---------- */
.card { border: 1px solid var(--hms-line); border-radius: var(--hms-radius); box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.card-header { background: transparent; border-bottom: 1px solid var(--hms-line); padding: .9rem 1.15rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.card-header .actions { margin-left: auto; display: flex; gap: .4rem; }
.card-body { padding: 1.15rem; }
.card-title-sm { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--hms-muted); font-weight: 600; margin-bottom: .6rem; }

.stat-card { padding: 1.05rem 1.15rem; display: flex; flex-direction: row; gap: .9rem; align-items: center; height: 100%; text-decoration: none; color: inherit; }
a.stat-card:hover { border-color: #cfd8e3; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; flex-shrink: 0; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--hms-muted); font-size: .8rem; font-weight: 500; }
.tint-teal { background: #e7f5f3; color: #0f766e; }
.tint-blue { background: #e8f0fe; color: #1d4ed8; }
.tint-amber { background: #fef4e2; color: #b45309; }
.tint-rose { background: #fdebee; color: #be123c; }
.tint-violet { background: #f1ebfe; color: #6d28d9; }
.tint-slate { background: #eef2f6; color: #334155; }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .7rem .9rem; border-bottom-color: #eef1f5; }
.table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--hms-muted); font-weight: 600; background: #fafbfc; white-space: nowrap; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f7fafb; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-link { cursor: pointer; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--hms-muted); }
.empty-state i { font-size: 2.2rem; display: block; margin-bottom: .5rem; color: #c3cdd8; }

/* ---------- Forms ---------- */
.form-label { font-weight: 500; font-size: .85rem; margin-bottom: .3rem; }
.form-control, .form-select { border-radius: 8px; border-color: #d9e0e8; }
.form-control:focus, .form-select:focus { border-color: var(--hms-primary); box-shadow: 0 0 0 .2rem rgba(15,118,110,.12); }
.form-section { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--hms-primary); font-weight: 700; margin: 1.25rem 0 .75rem; padding-bottom: .4rem; border-bottom: 1px dashed var(--hms-line); }
.form-section:first-child { margin-top: 0; }
.required::after { content: " *"; color: #dc2626; }
.picker { position: relative; }
.picker-selected { display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem; border: 1px solid var(--hms-primary); background: var(--hms-primary-50); border-radius: 8px; }
.picker-selected .clear { margin-left: auto; }

/* ---------- Badges & chips ---------- */
.badge { font-weight: 600; letter-spacing: .01em; padding: .38em .62em; }
.badge-soft-success { background: #dcfce7; color: #166534; }
.badge-soft-danger { background: #fee2e2; color: #991b1b; }
.badge-soft-warning { background: #fef3c7; color: #92400e; }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #eef2f6; color: #334155; }
.chip-danger { background: #fee2e2; color: #991b1b; }

/* ---------- Patient banner ---------- */
.patient-banner { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: center; }
.patient-banner .meta { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; color: var(--hms-muted); font-size: .85rem; }
.patient-banner .meta b { color: var(--hms-ink); font-weight: 600; }
.alert-allergy { background: #fff1f2; border: 1px solid #fecdd3; color: #9f1239; border-radius: 8px; padding: .45rem .75rem; font-size: .85rem; font-weight: 500; }

/* ---------- Vitals ---------- */
.vital-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .6rem; }
.vital { border: 1px solid var(--hms-line); border-radius: 10px; padding: .6rem .75rem; background: #fff; }
.vital .lbl { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--hms-muted); font-weight: 600; }
.vital .val { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.vital .val small { font-size: .72rem; font-weight: 500; color: var(--hms-muted); }
.vital.flag { border-color: #fca5a5; background: #fff5f5; }
.vital.flag .val { color: #b91c1c; }

/* ---------- Tabs ---------- */
.nav-tabs-clean { border-bottom: 1px solid var(--hms-line); gap: .25rem; flex-wrap: nowrap; overflow-x: auto; }
.nav-tabs-clean .nav-link { border: 0; border-bottom: 2px solid transparent; color: var(--hms-muted); font-weight: 600; padding: .7rem 1rem; white-space: nowrap; border-radius: 0; }
.nav-tabs-clean .nav-link.active { color: var(--hms-primary); border-bottom-color: var(--hms-primary); background: none; }
.nav-tabs-clean .nav-link .badge { font-size: .65rem; }

/* ---------- Queue ---------- */
.queue-pill { display: inline-flex; align-items: center; gap: .45rem; padding: .45rem .85rem; border-radius: 999px; border: 1px solid var(--hms-line); background: #fff; color: var(--hms-ink); text-decoration: none; font-weight: 500; font-size: .85rem; }
.queue-pill.active { border-color: var(--hms-primary); color: var(--hms-primary); background: var(--hms-primary-50); }
.queue-pill .count { background: #eef2f6; border-radius: 999px; padding: 0 .5rem; font-weight: 700; font-size: .78rem; }
.prio-emergency { box-shadow: inset 4px 0 0 #dc2626; }
.prio-urgent { box-shadow: inset 4px 0 0 #f59e0b; }
.wait-long { color: #b91c1c; font-weight: 600; }

/* ---------- Test picker ---------- */
.test-group { border: 1px solid var(--hms-line); border-radius: 10px; padding: .6rem .8rem; margin-bottom: .6rem; }
.test-group h6 { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--hms-muted); margin-bottom: .4rem; }
.test-option { display: flex; align-items: center; gap: .5rem; padding: .25rem 0; }
.test-option .price { margin-left: auto; color: var(--hms-muted); font-size: .8rem; font-variant-numeric: tabular-nums; }

/* ---------- Mini chart ---------- */
.mini-chart { width: 100%; height: 220px; display: block; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { background: radial-gradient(circle at 20% 20%, #14b8a6 0, transparent 45%), linear-gradient(160deg, #0b1f2a, #0f766e); color: #e6fffb; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h2 { font-size: 2.1rem; color: #fff; max-width: 440px; line-height: 1.2; }
.auth-feature { display: flex; gap: .75rem; align-items: flex-start; margin-bottom: 1rem; max-width: 420px; }
.auth-feature i { font-size: 1.2rem; color: #5eead4; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem; background: #fff; }
.auth-form .inner { width: 100%; max-width: 380px; }
@media (max-width: 860px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }

/* ---------- Help centre ---------- */
.help-hero { background: linear-gradient(135deg, #f0faf8 0%, #ffffff 60%); border-color: #d5ece8; }
.help-hero .card-body { padding: 1.75rem; }
.help-search { position: relative; max-width: 680px; }
.help-search > i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--hms-muted); z-index: 2; }
.help-search .form-control { padding-left: 2.7rem; border-radius: 12px; }
.help-card { text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s; }
.help-card:hover { border-color: #9fd3cb; box-shadow: 0 4px 14px rgba(15,118,110,.08); }
.help-topic-list li { padding: .5rem 1.15rem; border-bottom: 1px solid #f1f4f8; }
.help-topic-list li:last-child { border-bottom: 0; }
.help-topic-list a { text-decoration: none; font-weight: 500; }
.help-btn { font-size: 1.1rem; border-radius: 50%; width: 36px; height: 36px; }
.help-nav { position: sticky; top: 78px; max-height: calc(100vh - 96px); overflow-y: auto; }
.help-nav a { display: block; padding: .35rem .6rem; border-radius: 6px; color: var(--hms-ink); text-decoration: none; font-size: .86rem; }
.help-nav a:hover { background: var(--hms-bg); }
.help-nav a.active { background: var(--hms-primary-50); color: var(--hms-primary); font-weight: 600; }
.help-nav .nav-label { color: var(--hms-muted); padding-top: .9rem; }
.help-article-wrap { padding: 1.75rem 2rem; }
.help-toc { border-left: 3px solid var(--hms-primary-50); padding: .25rem 0 .25rem 1rem; margin-bottom: 1.5rem; }
.help-toc a { display: inline-block; margin: 0 1rem .25rem 0; font-size: .875rem; }
.help-article { font-size: .975rem; line-height: 1.7; max-width: 860px; }
.help-article h2 { font-size: 1.3rem; margin: 2rem 0 .75rem; padding-top: .25rem; scroll-margin-top: 80px; }
.help-article h3 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; }
.help-article p, .help-article ul, .help-article ol { margin-bottom: 1rem; }
.help-article li { margin-bottom: .3rem; }
.help-article li > ul, .help-article li > ol { margin: .3rem 0 .3rem; }
.help-article code { background: #f1f5f9; color: #0f172a; padding: .1rem .35rem; border-radius: 4px; font-size: .88em; }
.help-article table { margin: .5rem 0 1.25rem; font-size: .9rem; }
.help-article table th { background: #f6f9fb; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--hms-muted); }
.help-article table td, .help-article table th { padding: .5rem .7rem; border: 1px solid var(--hms-line); }
.help-figure { margin: 1.25rem 0 1.5rem; }
.help-figure img { max-width: 100%; border: 1px solid var(--hms-line); border-radius: 10px; box-shadow: 0 6px 24px rgba(15,23,42,.08); }
.help-figure figcaption { font-size: .82rem; color: var(--hms-muted); margin-top: .5rem; text-align: center; }
.help-callout { border-radius: 10px; padding: .85rem 1rem; margin: 1.25rem 0; border: 1px solid; }
.help-callout p:last-child { margin-bottom: 0; }
.help-tip { background: #effaf7; border-color: #bfe6dd; }
.help-note { background: #eff5ff; border-color: #c9dafc; }
.help-warn { background: #fff7ed; border-color: #fed7aa; }
kbd { background: #fff; color: var(--hms-ink); border: 1px solid #cbd5e1; border-bottom-width: 2px; padding: .05rem .4rem; border-radius: 4px; font-size: .8em; }
@media (max-width: 575.98px) { .help-article-wrap { padding: 1.15rem; } }

/* ---------- Print ---------- */
.print-sheet { max-width: 800px; margin: 1.5rem auto; background: #fff; padding: 2rem 2.25rem; border: 1px solid var(--hms-line); border-radius: 8px; }
.print-sheet.receipt { max-width: 380px; padding: 1.25rem; font-size: .85rem; }
.print-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--hms-ink); padding-bottom: .9rem; margin-bottom: 1.1rem; gap: 1rem; }
.print-head h2 { margin: 0; font-size: 1.35rem; }
.print-toolbar { max-width: 800px; margin: 1rem auto 0; display: flex; gap: .5rem; justify-content: flex-end; }
@media print {
    @page { margin: 12mm; }
    body { background: #fff; }
    .no-print, .sidebar, .topbar, .print-toolbar { display: none !important; }
    .help-article-wrap { padding: 0; } .card { border: 0; box-shadow: none; } .help-figure img { box-shadow: none; max-height: 380px; }
    .print-sheet { border: 0; margin: 0; padding: 0; max-width: none; }
    .print-sheet.receipt { max-width: 80mm; }
    a { text-decoration: none; color: inherit; }
}
