/* portal.css — RxGranted client portal (multi-page build) */

:root {
  --blue: #2563EB;
  --blue-hover: #1D4ED8;
  --navy: #0B1929;
  --white: #FFFFFF;
  --bg: #F7F9FC;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --border-strong: #CBD5E1;
  --text: #0B1929;
  --text-muted: #475569;
  --text-faint: #94A3B8;

  --ok: #059669;
  --ok-bg: #D1FAE5;
  --warn: #B45309;
  --warn-bg: #FEF3C7;
  --danger: #B91C1C;
  --danger-bg: #FEE2E2;
  --info: #1D4ED8;
  --info-bg: #DBEAFE;
  --neutral: #475569;
  --neutral-bg: #F1F5F9;

  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow: 0 2px 6px rgba(15,23,42,.08);

  --sidebar-w: 240px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-hover); text-decoration: underline; }

button {
  font: inherit;
  cursor: pointer;
}

/* ── Layout: sidebar + topbar + main ─────────────────────────── */

.portal-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}

.sidebar {
  grid-area: sidebar;
  background: var(--navy);
  color: var(--white);
  padding: 20px 0;
  border-right: 1px solid rgba(255,255,255,.08);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 12px;
}
.sidebar__brand img { width: 28px; height: 28px; }
.sidebar__brand-name {
  font-weight: 600;
  letter-spacing: .01em;
  font-size: 15px;
}

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; padding: 4px 10px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #CBD5E1;
  font-size: 14px;
  line-height: 1;
  text-decoration: none !important;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: var(--white); }
.nav-item.is-active {
  background: var(--blue);
  color: var(--white);
  font-weight: 500;
}
.nav-item--disabled {
  color: #64748B;
  opacity: .5;
  cursor: not-allowed;
  pointer-events: auto;
}
.nav-item--disabled:hover { background: transparent; color: #64748B; }
.nav-item--disabled::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: #0B1929;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s;
  border: 1px solid rgba(255,255,255,.15);
  z-index: 10;
}
.nav-item--disabled:hover::after { opacity: 1; }

/* ── Topbar ──────────────────────────────────────────────────── */

.topbar {
  grid-area: topbar;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar__practice {
  font-weight: 600;
  color: var(--navy);
  font-size: 15px;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.notif-bell {
  position: relative;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center; justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
}
.notif-bell:hover { background: #EEF2F7; }
.notif-bell__dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--surface);
  display: none;
}
.notif-bell[data-unread="1"] .notif-bell__dot { display: block; }

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--blue);
  color: var(--white);
  display: inline-flex;
  align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .02em;
}

/* ── Main ────────────────────────────────────────────────────── */

.main {
  grid-area: main;
  padding: 28px 32px 48px;
  overflow: auto;
}
.main h1 {
  margin: 0 0 6px;
  font-size: 22px;
  color: var(--navy);
}
.main .subhead {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 14px;
}

/* ── Card grid: 4 / 2 / 1 responsive ────────────────────────── */

.card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
@media (max-width: 1100px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .card-grid { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.card__label {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
  font-weight: 500;
}
.card__value {
  font-size: 28px;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.1;
}
.card__value--muted { color: var(--text-faint); }

/* ── Table ───────────────────────────────────────────────────── */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel__head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  margin: 0;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td {
  text-align: left;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: #FAFBFD;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table__empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}

/* ── Status badges ───────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  border: 1px solid transparent;
}
.badge--queued     { background: var(--info-bg);    color: var(--info);    border-color: #BFDBFE; }
.badge--delivered  { background: var(--ok-bg);      color: var(--ok);      border-color: #A7F3D0; }
.badge--neutral    { background: var(--neutral-bg); color: var(--neutral); border-color: var(--border); }

/* ── Forms ───────────────────────────────────────────────────── */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #F7F9FC 0%, #EEF2F7 100%);
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  width: 100%;
  max-width: 400px;
  padding: 32px 28px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.auth-card__logo {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}
.auth-card__logo img { width: 52px; height: 52px; }
.auth-card__title {
  text-align: center;
  margin: 0 0 4px;
  font-size: 18px;
  color: var(--navy);
}
.auth-card__sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 20px;
}

.form-field { margin-bottom: 14px; }
.form-field label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 6px;
  letter-spacing: .02em;
}
.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  background: var(--white);
  transition: border-color .12s, box-shadow .12s;
}
.form-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-input[aria-invalid="true"] {
  border-color: var(--danger);
}

.btn {
  display: inline-block;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--blue);
  color: var(--white);
  font-weight: 500;
  font-size: 14px;
  transition: background .12s;
}
.btn:hover { background: var(--blue-hover); }
.btn:disabled { background: #93C5FD; cursor: not-allowed; }
.btn--block { width: 100%; }
.btn--ghost {
  background: transparent;
  color: var(--blue);
  border-color: var(--border-strong);
}
.btn--ghost:hover { background: var(--bg); }

.form-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #FCA5A5;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}
.hidden { display: none !important; }

/* ── Inactivity warning modal ────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11,25,41,.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-backdrop.is-open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  max-width: 420px;
  width: calc(100% - 32px);
}
.modal h2 {
  margin: 0 0 8px;
  font-size: 17px;
  color: var(--navy);
}
.modal p { color: var(--text-muted); margin: 0 0 18px; font-size: 14px; }
.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.modal__countdown {
  font-weight: 600;
  color: var(--danger);
}

/* ════════════════════════════════════════════════════════════════
   Day 3 additions — pages: patients, case-detail, new-request
   Additive only. Existing classes (login.html, dashboard.html) untouched.
   ════════════════════════════════════════════════════════════════ */

/* Extended status badges (queued/delivered/neutral remain above) */
.badge--blue   { background: var(--info-bg);    color: var(--info);    border-color: #BFDBFE; }
.badge--green  { background: var(--ok-bg);      color: var(--ok);      border-color: #A7F3D0; }
.badge--red    { background: var(--danger-bg);  color: var(--danger);  border-color: #FCA5A5; }
.badge--orange { background: var(--warn-bg);    color: var(--warn);    border-color: #FCD34D; }

/* STAT badge — high-visibility amber pill, used in page headers and lists */
.badge--stat {
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FCD34D;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-size: 11px;
  padding: 3px 9px;
}

/* Page header (patients / case-detail / new-request) */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 0 0 24px;
}
.page-header__title h1 { margin: 0; font-size: 22px; color: var(--navy); }
.page-header__sub { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; }
.page-header__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Section card (free-form content panels beyond tables) */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.section-card__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-card h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
}
.section-card__sub { margin: 0 0 12px; font-size: 13px; color: var(--text-muted); }

/* Definition list (case overview, patient demographics) */
.kv-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  row-gap: 8px;
  column-gap: 16px;
  font-size: 14px;
  margin: 0;
}
.kv-grid dt { color: var(--text-muted); font-weight: 500; }
.kv-grid dd { margin: 0; color: var(--text); }
@media (max-width: 560px) {
  .kv-grid { grid-template-columns: 1fr; row-gap: 4px; }
  .kv-grid dt { padding-top: 4px; }
}

/* Search bar */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.search-bar input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--white);
  color: var(--text);
}
.search-bar input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* Tab pill (Upload Chart | Fill Manually) */
.tabs {
  display: inline-flex;
  background: var(--neutral-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 18px;
}
.tabs__btn {
  padding: 8px 16px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}
.tabs__btn.is-active {
  background: var(--white);
  color: var(--navy);
  box-shadow: var(--shadow-sm);
}

/* Pill radio (Standard / STAT) */
.pill-radio {
  display: inline-flex;
  background: var(--neutral-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  position: relative;
}
.pill-radio label {
  padding: 6px 16px;
  font-size: 13px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
  user-select: none;
}
.pill-radio input { position: absolute; opacity: 0; pointer-events: none; }
.pill-radio input:checked + label { background: var(--blue); color: var(--white); }
.pill-radio input.is-stat:checked + label { background: var(--warn); color: var(--white); }

/* File dropzone */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.dropzone:hover, .dropzone.is-active { border-color: var(--blue); background: #EFF6FF; color: var(--text); }
.dropzone__hint { font-size: 13px; margin-top: 6px; }
.dropzone input[type="file"] { display: none; }

/* Message thread */
.thread { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg--inbound  { align-self: flex-end;   background: var(--blue);        color: var(--white); border-bottom-right-radius: 4px; }
.msg--outbound { align-self: flex-start; background: var(--neutral-bg);  color: var(--text);  border-bottom-left-radius: 4px; }
.msg__meta { font-size: 11px; opacity: .75; margin-top: 4px; }

/* Reply composer */
.composer {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: flex-start;
}
.composer textarea {
  flex: 1;
  min-height: 48px;
  max-height: 200px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  resize: vertical;
}
.composer textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* Banner */
.banner {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid transparent;
}
.banner--info    { background: var(--info-bg);   color: var(--info);    border-color: #BFDBFE; }
.banner--ok      { background: var(--ok-bg);     color: var(--ok);      border-color: #A7F3D0; }
.banner--warn    { background: var(--warn-bg);   color: var(--warn);    border-color: #FCD34D; }
.banner--danger  { background: var(--danger-bg); color: var(--danger);  border-color: #FCA5A5; }

/* Empty state */
.empty-state {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state .btn { margin-top: 12px; }

/* Form layout helpers */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  background: var(--white);
  min-height: 100px;
  resize: vertical;
}
.form-textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-helper { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Step therapy row */
.step-therapy-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.step-therapy-row input { flex: 1; }

/* Icon button (Add/Remove row) */
.btn-icon {
  background: var(--white);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 1;
  cursor: pointer;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }

/* Sticky case header */
.case-sticky {
  position: sticky;
  top: var(--topbar-h);
  z-index: 4;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  margin: -28px -32px 16px;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}
.case-sticky__left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.case-sticky__id   { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-muted); font-size: 13px; }
.case-sticky__drug { font-weight: 600; color: var(--navy); font-size: 16px; }

/* Modal — sized variant for forms */
.modal--lg { max-width: 540px; }
.modal h3 { margin: 0 0 8px; font-size: 16px; color: var(--navy); }
.modal__form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }

/* File list */
.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 14px;
}
.file-row__name { font-weight: 500; color: var(--text); }
.file-row__type { color: var(--text-muted); font-size: 12px; }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 12px; padding-left: 4px; }
.timeline__row {
  position: relative;
  padding-left: 18px;
  border-left: 2px solid var(--border);
  padding-bottom: 6px;
}
.timeline__row::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid var(--surface);
}
.timeline__when { font-size: 12px; color: var(--text-muted); }
.timeline__what { font-size: 14px; color: var(--text); }

/* Patient profile header */
.patient-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.patient-header__name {
  margin: 0 0 8px;
  font-size: 22px;
  color: var(--navy);
  font-weight: 600;
}
.patient-header__meta {
  display: flex; gap: 18px; flex-wrap: wrap;
  font-size: 13px; color: var(--text-muted);
}
.patient-header__meta span strong {
  color: var(--text);
  font-weight: 500;
  margin-right: 4px;
}

/* ── Responsive: sidebar collapse at <=768px ─────────────────── */

@media (max-width: 768px) {
  .portal-shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) auto 1fr;
    grid-template-areas:
      "topbar"
      "sidebar"
      "main";
  }
  .sidebar {
    position: static;
    height: auto;
    padding: 10px 0 14px;
  }
  .sidebar__brand { display: none; }
  .sidebar__nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }
  .nav-item { padding: 8px 12px; font-size: 13px; }
  .nav-item--disabled::after { display: none; }
  .main { padding: 20px 16px 32px; }
  .topbar { padding: 0 16px; }
}
