/* =====================================================================
   NeoVuo clinical app — light clinical theme
   Calm, high-contrast, low-noise UI for clinical work.
   Loaded after Tailwind (see assets/js/tailwind.config.js for the palette).
   ===================================================================== */

:root {
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --line: #E3E8EF;
  --line-strong: #CFD7E2;
  --text: #0F1B2D;
  --text-2: #3D4B5F;
  --muted: #64748B;
  --primary: #1F5F9E;
  --primary-hover: #1A4E83;
  --primary-soft: #EFF5FB;
  --focus: rgba(31,95,158,.25);
  --ok: #15803D;     --ok-bg: #ECFDF3;     --ok-line: #B7E4C7;
  --warn: #B45309;   --warn-bg: #FFF8EB;   --warn-line: #F5D9A8;
  --danger: #B42318; --danger-bg: #FEF3F2; --danger-line: #F7C7C2;
}

html { background: var(--bg); color-scheme: light; }
body.nv-app {
  font-family: 'Inter', system-ui, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
::selection { background: #DCE9F6; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.font-mono, code { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* ---------------- Layout ---------------- */
.nv-sidebar { background: var(--surface); border-right: 1px solid var(--line); }
.nv-logo {
  width: 2rem; height: 2rem; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; background: var(--primary); font-size: .9rem;
}
.nv-brand { font-weight: 700; font-size: 1rem; color: var(--text); letter-spacing: -.01em; }
.nv-brand small { display: block; font-size: .68rem; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-top: -2px; }
.nav-section { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 .75rem; margin: 1.25rem 0 .35rem; }
.nav-item {
  display: flex; align-items: center; gap: .7rem; padding: .5rem .75rem; border-radius: 6px;
  color: var(--text-2); font-weight: 500; font-size: .875rem; border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.nav-item i { width: 1.1rem; text-align: center; color: #8A97A8; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.nav-item.active i { color: var(--primary); }
.nav-item.danger { color: var(--danger); }
.nav-item.danger i { color: var(--danger); }
.nav-item.danger:hover { background: var(--danger-bg); }
.nv-topbar { background: var(--surface); border-bottom: 1px solid var(--line); }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-title { font-size: 1.375rem; font-weight: 600; color: var(--text); letter-spacing: -.01em; }
.page-sub { color: var(--muted); margin-top: .15rem; }
.crumbs { font-size: .8rem; color: var(--muted); margin-bottom: .35rem; }
.crumbs a { color: var(--primary); }
.crumbs a:hover { text-decoration: underline; }

/* ---------------- Components ---------------- */
.nv-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.nv-card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--line); }
.nv-card-title { font-size: .95rem; font-weight: 600; color: var(--text); }

.nv-btn, .nv-btn-ghost, .nv-btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .5rem .9rem; border-radius: 6px; font-weight: 600; font-size: .875rem; line-height: 1.25rem;
  border: 1px solid transparent; transition: background .15s, border-color .15s, color .15s; white-space: nowrap;
}
.nv-btn { color: #fff !important; background: var(--primary); }
.nv-btn:hover { background: var(--primary-hover); }
.nv-btn-ghost { color: var(--text-2); background: var(--surface); border-color: var(--line-strong); }
.nv-btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.nv-btn-danger { color: #fff !important; background: #C4320A; }
.nv-btn-danger:hover { background: #A1290A; }
.nv-btn:disabled, .nv-btn-ghost:disabled, .nv-btn-danger:disabled { opacity: .6; cursor: not-allowed; }

.nv-input {
  width: 100%; padding: .55rem .75rem; border-radius: 6px; color: var(--text); background: #fff;
  border: 1px solid var(--line-strong); outline: none; font-size: .875rem; transition: border-color .15s, box-shadow .15s;
}
.nv-input::placeholder { color: #98A2B3; }
.nv-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
.nv-input:disabled, .nv-input[readonly] { background: var(--surface-2); color: var(--muted); }
.nv-label { display: block; font-size: .8rem; font-weight: 500; color: var(--text-2); margin-bottom: .3rem; }
.nv-help { font-size: .75rem; color: var(--muted); margin-top: .25rem; }

.nv-alert { padding: .7rem .9rem; border-radius: 6px; font-size: .85rem; display: flex; gap: .55rem; align-items: flex-start; border: 1px solid; }
.nv-alert-error { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-line); }
.nv-alert-success { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-line); }
.nv-alert-info { color: var(--primary-hover); background: var(--primary-soft); border-color: #BAD3EC; }
.nv-alert-warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }

.nv-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }

/* Clinical status badges (used for ROP results everywhere) */
.status-ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-line); }
.status-warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.status-danger { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-line); }
.status-neutral { color: var(--muted); background: var(--surface-2); border-color: var(--line); }

/* Tables */
.nv-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.nv-table thead th { text-align: left; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); padding: .6rem 1rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.nv-table tbody td { padding: .7rem 1rem; border-bottom: 1px solid #EEF2F6; vertical-align: middle; }
.nv-table tbody tr:last-child td { border-bottom: 0; }
.nv-table tbody tr.is-link { cursor: pointer; }
.nv-table tbody tr:hover { background: #F9FBFD; }

/* Stat tiles */
.stat { padding: 1rem 1.1rem; }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 1.6rem; font-weight: 600; color: var(--text); margin-top: .15rem; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: .75rem; color: var(--muted); }

/* Modals */
.nv-modal-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 20px 50px rgba(16,24,40,.18); }

/* Auth pages */
.nv-auth-bg { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: var(--bg); }
.nv-auth-card { width: 100%; max-width: 26rem; padding: 2rem; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 4px 16px rgba(16,24,40,.06); }

/* Sticky table heads inside scroll areas */
.scroll-y { max-height: 70vh; overflow-y: auto; }

.nv-fade, .animate-in { animation: none; }
.keep-light { color: #0F172A; background: #fff; }

@media print {
  .nv-sidebar, .nv-topbar, .no-print { display: none !important; }
  body.nv-app { background: #fff; }
}

/* =====================================================================
   Refinements (2.2): subtle hierarchy and finish
   ===================================================================== */

/* Main canvas: faint top band so content separates from the page edge */
.nv-canvas { background: linear-gradient(180deg, #EEF3F8 0, var(--bg) 220px); }

/* Desktop top bar */
.nv-appbar { height: 56px; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); backdrop-filter: saturate(140%) blur(6px); }
.nv-search { position: relative; width: 100%; max-width: 26rem; }
.nv-search i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: #98A2B3; font-size: .8rem; }
.nv-search input { width: 100%; height: 36px; padding: 0 2.6rem 0 2.1rem; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); font-size: .85rem; color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s, background .15s; }
.nv-search input:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
.nv-kbd { position: absolute; right: .55rem; top: 50%; transform: translateY(-50%); font: 600 .65rem 'Inter', sans-serif; color: #98A2B3; border: 1px solid var(--line); border-radius: 4px; padding: 0 .3rem; background: #fff; }

/* Sidebar polish */
.nv-sidebar .nav-item.active { background: linear-gradient(90deg, #EAF2FB, #F4F8FC); }
.nv-sidebar .nav-item:not(.active):hover i { color: var(--primary); }
.nv-user-card { border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }

/* Status chips with a leading dot */
.nv-chip.status-ok::before, .nv-chip.status-warn::before, .nv-chip.status-danger::before, .nv-chip.status-neutral::before {
  content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; opacity: .85;
}

/* Stat tiles with a thin accent and hover affordance when clickable */
.stat-card { position: relative; overflow: hidden; transition: border-color .15s, box-shadow .15s, transform .15s; }
.stat-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent, var(--primary)); }
a.stat-card:hover { border-color: var(--line-strong); box-shadow: 0 4px 12px rgba(16,24,40,.07); transform: translateY(-1px); }
.accent-blue { --accent: #1F5F9E; } .accent-green { --accent: #16A34A; } .accent-red { --accent: #DC2626; } .accent-amber { --accent: #D97706; }
.stat-icon { width: 2.25rem; height: 2.25rem; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-size: .9rem; }

/* Cards & tables */
.nv-card { transition: border-color .15s; }
.nv-card-head { background: linear-gradient(180deg, #FCFDFE, #fff); border-top-left-radius: 8px; border-top-right-radius: 8px; }
table thead th { position: sticky; top: 0; z-index: 1; }
.nv-dark-free tbody tr:hover, tr.patient-row:hover, tr.log-row:hover, tr.audit-row:hover { box-shadow: inset 3px 0 0 var(--primary); }

/* Soft initials avatars (colour picked from the name) */
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; font-weight: 600; font-size: .8rem; flex-shrink: 0; }
.avatar-0 { background: #E8F0FA; color: #1A4E83; } .avatar-1 { background: #E7F6EE; color: #166534; }
.avatar-2 { background: #FEF3E2; color: #9A4D0B; } .avatar-3 { background: #F1ECFB; color: #5B3B9A; }
.avatar-4 { background: #E6F6F8; color: #0E6170; } .avatar-5 { background: #FCEBEE; color: #9F1239; }

/* Buttons: tactile but quiet */
.nv-btn { box-shadow: 0 1px 2px rgba(16,24,40,.12), inset 0 1px 0 rgba(255,255,255,.12); }
.nv-btn:active, .nv-btn-ghost:active, .nv-btn-danger:active { transform: translateY(1px); }
.nv-btn-ghost { box-shadow: 0 1px 2px rgba(16,24,40,.04); }

/* Section heading with small leading rule */
.section-label { display: flex; align-items: center; gap: .5rem; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.section-label::before { content: ""; width: 10px; height: 2px; border-radius: 2px; background: var(--primary); }

/* Sign-in: two-panel layout */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr; background: var(--bg); }
@media (min-width: 1024px) { .auth-shell { grid-template-columns: minmax(380px, 44%) 1fr; } }
.auth-aside { display: none; position: relative; overflow: hidden; color: #E7EEF7; background: #133A63; }
@media (min-width: 1024px) { .auth-aside { display: flex; flex-direction: column; justify-content: space-between; padding: 3rem; } }
.auth-aside::after {
  content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 999px;
  border: 48px solid rgba(255,255,255,.04); pointer-events: none;
}
.auth-aside .auth-point { display: flex; gap: .75rem; align-items: flex-start; }
.auth-aside .auth-point i { width: 2rem; height: 2rem; border-radius: 6px; background: rgba(255,255,255,.08); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: .8rem; color: #CFE0F2; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 1.5rem; }

/* Record tabs (patient page) */
.tab-btn { position: relative; padding: .65rem .9rem; font-size: .875rem; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s, border-color .15s; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-count { display: inline-block; min-width: 1.25rem; padding: 0 .35rem; margin-left: .35rem; border-radius: 999px; font-size: .7rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); text-align: center; }
.tab-btn.active .tab-count { background: var(--primary-soft); color: var(--primary); border-color: #BAD3EC; }

/* History filters */
.hist-filter { padding: .25rem .7rem; border-radius: 999px; font-size: .75rem; font-weight: 500; color: var(--text-2); background: #fff; border: 1px solid var(--line); transition: all .15s; }
.hist-filter:hover { border-color: var(--line-strong); }
.hist-filter.active { color: #fff; background: var(--primary); border-color: var(--primary); }

/* Search suggestions */
.nv-suggest { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 60; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 28px rgba(16,24,40,.12); overflow: hidden; }
.nv-suggest-item { display: flex; flex-direction: column; padding: .55rem .8rem; border-bottom: 1px solid #F1F4F8; }
.nv-suggest-item:last-child { border-bottom: 0; }
.nv-suggest-item:hover, .nv-suggest-item:focus { background: var(--primary-soft); outline: none; }
.nv-suggest-empty { padding: .7rem .8rem; font-size: .8rem; color: var(--muted); }
.status-info { color: var(--primary); background: var(--primary-soft); border-color: #BAD3EC; }
.nv-chip.status-info::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; opacity: .85; }
