/*
 * site.css — shared brand styling over Bootstrap 5.
 *
 * Brand palette ported from the legacy `Legacy_CodeRare_WebForms/CodeRareWebApp/Content/Site.css`.
 * The legacy app uses these colors:
 *   #D7230E   "rare red" — primary brand color, used on big CTAs and the chat header
 *   #C91F0D   rare-red hover
 *   #343a40   dark slate — top bar / side nav background
 *   #ccc      light gray — top-bar / side-nav text
 *   #5a2d82 → #7b4db5    admin-button purple gradient
 *
 * The legacy was Bootstrap 4 + Font Awesome 5; we're on Bootstrap 5. Utility-class
 * differences (ml-/mr- → ms-/me-, badge-* → bg-*-subtle) are handled per page —
 * this file only defines brand-tinted overrides.
 */

:root {
  /* Brand colors */
  --cr-rare:        #D7230E;
  --cr-rare-hover:  #C91F0D;
  --cr-rare-soft:   rgba(215, 35, 14, 0.10);
  --cr-slate:       #343a40;
  --cr-slate-text:  #cccccc;
  --cr-ink:         #1f2933;

  /* Admin purple gradient (used on btn-admin) */
  --cr-admin-from:  #5a2d82;
  --cr-admin-to:    #7b4db5;
  --cr-admin-hover: #9c6fe0;
}

/* ── Base ────────────────────────────────────────────────────────────────── */

body {
  color: var(--cr-ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  min-height: 60vh;
}

/* Default links use Bootstrap's blue. Brand-red color is reserved for the topbar/sidebar,
 * footer, and explicit brand CTAs (.btn-rare). The previous global `a { color: red; }` rule
 * made every content link in tables and lists bright red — too loud and confused hierarchy.
 */
.site-topbar a,
.site-side-nav a,
footer a,
nav.brand,
.brand-link {
  color: var(--cr-rare);
}
.site-topbar a:hover,
footer a:hover,
.brand-link:hover {
  color: var(--cr-rare);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

/* .btn-rare — primary brand CTA. Ported from legacy. Replaces what legacy Default.aspx
   used `btn-danger` for. Use this for major calls-to-action (Register, Learn more, etc). */
.btn-rare {
  color: #fff;
  background-color: var(--cr-rare);
  border-color: var(--cr-rare);
}
.btn-rare:hover {
  color: #fff;
  background-color: var(--cr-rare-hover);
  border-color: var(--cr-rare-hover);
}
.btn-rare:focus, .btn-rare.focus {
  box-shadow: 0 0 0 0.2rem rgba(222, 170, 12, 0.5);
  color: #fff;
}
.btn-rare:disabled, .btn-rare.disabled {
  color: #444c55;
  background-color: #b47a7a;
  border-color: #b47a7a;
}

.btn-outline-rare {
  color: var(--cr-rare);
  border-color: var(--cr-rare);
  background-color: transparent;
}
.btn-outline-rare:hover {
  color: #fff;
  background-color: var(--cr-rare);
  border-color: var(--cr-rare);
}

/* .btn-admin — purple gradient with a tiny "Admin" caption inside. Ported verbatim
   from the legacy app; the bottom-left caption is what visually distinguishes admin
   actions from regular CTAs in the UI. */
.btn-admin {
  position: relative;
  background: linear-gradient(135deg, var(--cr-admin-from), var(--cr-admin-to));
  color: #fff;
  border: none;
  font-weight: 600;
  box-shadow: 0 0 5px rgba(123, 77, 181, 0.4);
  overflow: hidden;
  padding-top:    0.35rem;
  padding-bottom: 0.7rem;  /* room for the "Admin" caption under the text */
  padding-left:   2.7rem;  /* room for the shield glyph */
}
/* Two-tone shield glyph on every admin button — a white SVG, no markup needed.
   Sized to span the full text + caption height. */
.btn-admin::before {
  content: "";
  position: absolute;
  left: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 30px;
  background: center / contain no-repeat
    url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2026'%3E%3Cpath%20fill='%23fff'%20d='M12%202%20H5%20Q3%202%203%204.5%20V13%20C3%2018.5%207%2023%2012%2024.5%20Z'/%3E%3Cpath%20fill='%23ffffffa8'%20d='M12%202%20H19%20Q21%202%2021%204.5%20V13%20C21%2018.5%2017%2023%2012%2024.5%20Z'/%3E%3C/svg%3E");
  pointer-events: none;
}
.btn-admin:hover {
  background: linear-gradient(135deg, var(--cr-admin-to), var(--cr-admin-hover));
  box-shadow: 0 0 10px rgba(156, 111, 224, 0.6);
  color: #fff;
}
/* "Admin" caption — left-aligned to start directly under the button's main text. */
.btn-admin::after {
  content: "Admin";
  position: absolute;
  left: 2.7rem;
  bottom: 3px;
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.5px;
  font-weight: 500;
  pointer-events: none;
}

/* .btn-demo — light dashed button with a small "Demo" caption, marking an
   unfinished / placeholder action. Ported verbatim from the legacy app. */
.btn-demo {
  position: relative;
  background-color: #f0f0f0;
  color: #333;
  border: 2px dashed #666;
  font-weight: 600;
  overflow: hidden;
  padding-top:    0.35rem;
  padding-bottom: 0.55rem;
  box-shadow: none;
}
.btn-demo:hover {
  background-color: #e2e2e2;
  color: #000;
  border-color: #555;
}
.btn-demo::after {
  content: "Demo";
  position: absolute;
  left: 6px;
  bottom: 2px;
  font-size: 0.6rem;
  color: rgba(51, 51, 51, 0.7);
  letter-spacing: 0.5px;
  font-weight: 500;
  pointer-events: none;
}

/* .btn-xl — oversized CTA (ported from legacy). */
.btn-xl {
  padding: 18px 28px;
  font-size: 22px;
  line-height: normal;
  border-radius: 8px;
}

/* ── Top bar / shell ─────────────────────────────────────────────────────── */

/* .site-topbar — the slate strip that runs across the top of every page. */
.site-topbar {
  background-color: var(--cr-slate);
  color: var(--cr-slate-text);
}
.site-topbar a {
  color: var(--cr-slate-text);
  text-decoration: none;
}
.site-topbar a:hover {
  color: #fff;
}
.site-topbar .brand {
  font-weight: 600;
  font-size: 1.1rem;
  color: #fff;
}
.site-topbar .brand img {
  height: 26px;
  vertical-align: -6px;
  margin-right: 0.5rem;
}

/* ── Marketing nav (<marketing-nav>) ─────────────────────────────────────── */
/*
 * The public top bar on anonymous-facing marketing pages (index, about, contact).
 * Mirrors the SurveyApp navbar: slate strip + boxed "CODE RARE" logo + section links.
 * Authenticated app pages use <site-shell> (sidebar) instead of this bar.
 */
marketing-nav { display: block; }
.marketing-nav {
  background-color: var(--cr-slate);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}
.mkt-nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.mkt-brand {
  display: flex;
  align-items: center;
  margin-right: auto;
}
.mkt-brand img {
  height: 34px;
  display: block;
}
.mkt-nav-toggle {
  display: none;
  background: transparent;
  border: 0;
  color: var(--cr-slate-text);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}
.mkt-nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.mkt-nav-links a {
  color: var(--cr-slate-text);
  text-decoration: none;
  font-size: 0.95rem;
  white-space: nowrap;
}
.mkt-nav-links a:hover { color: #fff; }
.mkt-nav-links a.active {
  color: #fff;
  border-bottom: 2px solid var(--cr-rare);
  padding-bottom: 2px;
}
.mkt-nav-links a.mkt-cta {
  background-color: var(--cr-rare);
  color: #fff;
  border-radius: 50px;
  padding: 0.35rem 1.1rem;
}
.mkt-nav-links a.mkt-cta:hover { background-color: var(--cr-rare-hover); }

@media (max-width: 768px) {
  .mkt-nav-toggle { display: inline-block; }
  .mkt-nav-links {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0 0.25rem;
  }
  .mkt-nav-links.open { display: flex; }
}

/* ── Hero ────────────────────────────────────────────────────────────────── */

.site-hero {
  background-color: #000;
  border-radius: 0.5rem;
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.site-hero img {
  width: 100%;
  display: block;
}

/* ── Cards / tiles ───────────────────────────────────────────────────────── */

.card.tile {
  border: 1px solid #e3e6ea;
  transition: box-shadow 0.15s, transform 0.15s;
  text-decoration: none;
  color: inherit;
}
.card.tile:hover {
  box-shadow: 0 4px 16px rgba(215, 35, 14, 0.08);
  transform: translateY(-2px);
  border-color: var(--cr-rare-soft);
}
.card.tile h2 {
  color: var(--cr-rare);
}

/* ── Citation chips (used by <citation-chip> on disease pages) ───────────── */

citation-chip .badge {
  background-color: var(--cr-rare-soft) !important;
  color: var(--cr-rare) !important;
  border-color: var(--cr-rare-soft) !important;
}

/* ── Section nav (<section-nav>) ─────────────────────────────────────────── */
/* Selected section: a soft brand tint + a bold left bar — mirrors the sidebar's
   active item. Subtle, not a loud solid fill, and not Bootstrap's blue. */
section-nav .list-group-item.active {
  background-color: var(--cr-rare-soft);
  color: var(--cr-ink);
  /* Bootstrap colors the active item's border blue — override the top/bottom edges
     to a darker grey, then re-assert the red left bar. */
  border-color: #adb5bd;
  border-left: 3px solid var(--cr-rare);
  padding-left: calc(1rem - 3px);
}

/* ── Site shell (Phase 10) ──────────────────────────────────────────────── */
/*
 * The <site-shell> Web Component renders a persistent black left sidebar around
 * authenticated page content. There is no top bar — once signed in, the sidebar is
 * the only chrome (the SurveyApp-style top bar lives on marketing pages instead).
 *
 * <site-shell> is a flex row: the sidebar is a fixed-basis flex item and the content
 * slot (.site-shell-main) takes the rest. Flex guarantees the content sits flush
 * against the sidebar with no gap, on any viewport width.
 *
 * Sidebar state machine — `data-menu` attribute on <site-shell>:
 *   "open"      — full 220px sidebar with icons + labels (desktop default)
 *   "collapsed" — narrow 64px sidebar, icons only (tablet default)
 *   "closed"    — hidden; a floating toggle button reopens it (mobile default)
 */

/* Host selector is the element name — <site-shell> carries no class attribute. */
site-shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

/* ── Sidebar ── */
.site-side-nav {
  flex: 0 0 220px;
  width: 220px;
  background-color: #000;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 1020;
  transition: flex-basis 0.2s ease, width 0.2s ease;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.55rem 0.6rem;
  background-color: var(--cr-slate);
}
.side-brand-link {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
}
.side-brand-link img { height: 30px; display: block; }
.side-toggle {
  background: transparent;
  border: 0;
  color: var(--cr-slate-text);
  cursor: pointer;
  padding: 0.2rem;
  line-height: 0;
}
.side-toggle:hover { color: #fff; }

.side-nav-items {
  flex: 1 1 auto;
  padding-top: 0.5rem;
}

.site-side-nav a.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  color: var(--cr-slate-text);
  text-decoration: none;
  font-size: 0.95rem;
  white-space: nowrap;
}
.site-side-nav a.nav-link .material-icons,
.site-side-nav a.nav-link i.fa {
  font-size: 24px;
  min-width: 28px;
  text-align: center;
}
/* nav-label stacks a title over an optional subtitle (e.g. "Model of Care"). */
.site-side-nav a.nav-link .nav-label {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.site-side-nav a.nav-link .nav-sub {
  font-size: 0.72rem;
  opacity: 0.55;
}
.site-side-nav a.nav-link:hover { color: #fff; background-color: rgba(255,255,255,0.05); }
.site-side-nav a.nav-link.active {
  color: #fff;
  background-color: rgba(215, 35, 14, 0.18);
  border-left: 3px solid var(--cr-rare);
  padding-left: calc(1rem - 3px);
}

.side-foot {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.6rem 1rem;
}
.side-user {
  color: var(--cr-slate-text);
  font-size: 0.8rem;
  opacity: 0.65;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.35rem;
}
.side-foot-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--cr-slate-text);
  text-decoration: none;
  font-size: 0.95rem;
}
.side-foot-link:hover { color: #fff; }
.side-foot-link .material-icons { font-size: 22px; min-width: 28px; text-align: center; }
.side-copy {
  color: var(--cr-slate-text);
  opacity: 0.4;
  font-size: 0.72rem;
  margin-top: 0.6rem;
}

/* ── Content slot ── */
.site-shell-main {
  flex: 1 1 auto;
  min-width: 0;            /* let wide tables scroll instead of stretching the layout */
}
/* Keep page content left-aligned against the sidebar. A Bootstrap `.container`
 * (or a narrow max-width page like the assistant chat) would otherwise auto-center
 * in the slot and float away from the nav. */
.site-shell-main > main {
  margin-left: 0;
  margin-right: auto;
}

/* ── Collapsed state — icons-only sidebar ── */
site-shell[data-menu="collapsed"] .site-side-nav { flex-basis: 64px; width: 64px; }
site-shell[data-menu="collapsed"] .nav-label,
site-shell[data-menu="collapsed"] .side-user,
site-shell[data-menu="collapsed"] .side-copy,
site-shell[data-menu="collapsed"] .side-brand-link { display: none; }
site-shell[data-menu="collapsed"] .side-brand { justify-content: center; padding-left: 0; padding-right: 0; }

/* ── Closed state — sidebar hidden, floating toggle reopens it ── */
site-shell[data-menu="closed"] .site-side-nav { flex-basis: 0; width: 0; }

/* Floating toggle — only visible when the sidebar is fully closed. */
.shell-mobile-toggle { display: none; }
site-shell[data-menu="closed"] .shell-mobile-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1040;
  width: 40px;
  height: 40px;
  background-color: var(--cr-slate);
  color: #fff;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ── Mobile — sidebar overlays content instead of taking layout width ── */
@media (max-width: 575.98px) {
  .site-side-nav {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
  }
  site-shell[data-menu="open"] .site-side-nav,
  site-shell[data-menu="collapsed"] .site-side-nav {
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.4);
  }
}

/* ── <source-picker> per-citation drawer ──────────────────────────────────── */
/*
 * Progressive disclosure: only ONE button group visible at a time (the current step).
 * Breadcrumb chips at the top show prior picks; clicking a chip re-opens that step.
 *
 * Layout: 5-column CSS grid. Every button is exactly 1/5 the drawer width, so a 5-button
 * group (Triage priority) spans the full row and a 3- or 4-button group (GRADE level,
 * sub-tier) sits left-aligned with empty slots on the right. Bootstrap-style rectangles
 * with the default `.25rem` corner radius — no pills.
 *
 * Colour scheme:
 *   - GRADE (level + sub-tier): all grey. Evidence certainty is the "boring" axis.
 *   - Triage priority: muted version of the priority colour by default; hover = full
 *     colour; chosen = full colour + pressed indicator. Five colours pulled from the
 *     patient-record triage palette (P1 red → P5 teal).
 *   - Triage sub-priority: borrows the SELECTED priority's colour, same muted/hover/active
 *     treatment. So if you picked P2 High (orange), the sub buttons are all orange.
 *
 * Per-button colour comes from the `--c` custom property set inline by the JS.
 */
.sp-step {
  padding-top: 0.25rem;
  position: relative;   /* anchor for the absolutely-positioned sub-tier popup */
}
.sp-step-label {
  font-size: 0.78rem; font-weight: 600; color: #495057;
  text-transform: uppercase; letter-spacing: 0.02em; margin-bottom: 0.35rem;
}

/* Four fixed columns — each button is exactly 1/4 of the drawer width. The 4 buttons in
   either GRADE or Triage span the full row. Adjacent buttons share borders (Bootstrap
   btn-group look) so the group reads as a single connected control. */
.sp-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
}

/* Base button — shared by both Grade and Triage variants. All button text is black for
   contrast consistency, even on the chosen state's saturated background. */
.sp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.6rem;
  border-radius: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: #000;
  cursor: pointer;
  transition: background-color 0.1s ease, border-color 0.1s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid;
  user-select: none;
  position: relative;
}
/* Bootstrap-style overlap: shift each non-first button 1px left so adjacent borders
   collapse into one line. Combined with `position: relative` + z-index on hover/chosen,
   this lets the active button's full border render above siblings. */
.sp-btn + .sp-btn { margin-left: -1px; }
.sp-btn:first-child {
  border-top-left-radius: 0.25rem;
  border-bottom-left-radius: 0.25rem;
}
.sp-btn:last-child {
  border-top-right-radius: 0.25rem;
  border-bottom-right-radius: 0.25rem;
}
.sp-btn:hover, .sp-btn.sp-btn-chosen { z-index: 1; }
.sp-btn:focus { outline: 2px solid rgba(0, 0, 0, 0.25); outline-offset: 1px; z-index: 2; }

/* ── GRADE buttons — per-button colour via `--c` (grey/red → grey → grey/green → green).
   Same muted/hover/chosen treatment as Triage so the two axes feel consistent. ── */
.sp-btn-grade {
  background: color-mix(in srgb, var(--c, #999) 22%, #fff);
  border-color: color-mix(in srgb, var(--c, #999) 50%, #fff);
}
.sp-btn-grade:hover {
  background: var(--c, #999);
  border-color: var(--c, #999);
}
.sp-btn-grade.sp-btn-chosen {
  background: var(--c, #999);
  border-color: var(--c, #999);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ── Triage priority + sub-priority — coloured. Muted by default; full colour on hover/chosen. ── */
.sp-btn-triage {
  background: color-mix(in srgb, var(--c, #6c757d) 18%, #fff);
  border-color: color-mix(in srgb, var(--c, #6c757d) 40%, #fff);
}
.sp-btn-triage:hover {
  background: var(--c, #6c757d);
  border-color: var(--c, #6c757d);
}
.sp-btn-triage.sp-btn-chosen {
  background: var(--c, #6c757d);
  border-color: var(--c, #6c757d);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25);
}

/* ── Sub-tier / sub-priority popup ──
 * Floats centred under the chosen parent button (via `--popup-cx` set inline) and
 * overlaps the parent row by a few pixels so it reads as "attached" rather than floating.
 * z-index lifts it above the buttons; the inset shadow on chosen parents still shows.
 */
.sp-popup {
  position: absolute;
  top: 100%;
  left: var(--popup-cx, 50%);
  transform: translateX(-50%);
  margin-top: -20px;            /* overlap the parent buttons by ~half their height */
  background: #fff;
  border: 1px solid #ced4da;
  border-radius: 0.35rem;
  padding: 0.5rem 0.6rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  z-index: 20;
  min-width: 200px;
}
.sp-popup-label {
  font-size: 0.7rem; font-weight: 600; color: #495057;
  text-transform: uppercase; letter-spacing: 0.02em;
  margin-bottom: 0.3rem;
}
.sp-popup-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
}
/* Smaller popup buttons — same connected btn-group treatment but tighter padding. */
.sp-popup-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.4rem;
  border-radius: 0;
  font-size: 0.78rem;
  font-weight: 500;
  color: #000;
  cursor: pointer;
  transition: background-color 0.1s ease, border-color 0.1s ease;
  border: 1px solid;
  user-select: none;
  position: relative;
}
.sp-popup-btn + .sp-popup-btn { margin-left: -1px; }
.sp-popup-btn:first-child {
  border-top-left-radius: 0.25rem;
  border-bottom-left-radius: 0.25rem;
}
.sp-popup-btn:last-child {
  border-top-right-radius: 0.25rem;
  border-bottom-right-radius: 0.25rem;
}
.sp-popup-btn:hover, .sp-popup-btn.sp-popup-btn-chosen { z-index: 1; }

/* GRADE sub-tier popup buttons inherit the parent level's colour via `--c` set on the
   popup element. Same muted/hover/chosen treatment as the main GRADE row. */
.sp-popup-btn-grade {
  background: color-mix(in srgb, var(--c, #999) 22%, #fff);
  border-color: color-mix(in srgb, var(--c, #999) 50%, #fff);
}
.sp-popup-btn-grade:hover {
  background: var(--c, #999);
  border-color: var(--c, #999);
}
.sp-popup-btn-grade.sp-popup-btn-chosen {
  background: var(--c, #999);
  border-color: var(--c, #999);
}

/* Coloured (parent priority's colour) scheme for Triage sub-priority popup. */
.sp-popup-btn-triage {
  background: color-mix(in srgb, var(--c, #6c757d) 18%, #fff);
  border-color: color-mix(in srgb, var(--c, #6c757d) 40%, #fff);
}
.sp-popup-btn-triage:hover {
  background: var(--c, #6c757d);
  border-color: var(--c, #6c757d);
}
.sp-popup-btn-triage.sp-popup-btn-chosen {
  background: var(--c, #6c757d);
  border-color: var(--c, #6c757d);
}
