/* ============================================================
   FHIR R4 Documentation Portal — Main Stylesheet
   Theme: Dark navy / clean technical white / teal accent
   ============================================================ */

/* --- CSS Custom Properties ----------------------------------- */
:root {
  --navy: #0a1628;
  --navy-light: #0f1d36;
  --navy-border: #1a2a4a;
  --white: #ffffff;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --teal: #14b8a6;
  --teal-light: #2dd4bf;
  --teal-dark: #0d9488;
  --amber: #f59e0b;
  --amber-light: #fbbf24;
  --amber-dark: #d97706;
  --red: #ef4444;
  --red-light: #fca5a5;
  --red-dark: #dc2626;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono',
    'Consolas', 'Liberation Mono', monospace;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08),
    0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-input: 0 1px 2px rgba(0, 0, 0, 0.04);

  --max-width: 1280px;
  --header-height: 64px;
  --side-padding: 24px;
}

/* --- Reset & Base -------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--gray-800);
  background-color: var(--gray-50);
  min-height: 100vh;
}

a {
  color: var(--teal);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--teal-dark);
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--gray-900);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

p {
  margin-bottom: 1rem;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: var(--gray-100);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
}

pre {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.5;
  overflow-x: auto;
}

img {
  max-width: 100%;
  height: auto;
}

/* ============================================================
   LAYOUT
   ============================================================ */

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--side-padding);
}

/* --- Sticky Navigation -------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: var(--navy);
  border-bottom: 1px solid var(--navy-border);
  height: var(--header-height);
  display: flex;
  align-items: center;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--white);
  text-decoration: none;
  white-space: nowrap;
}

.site-logo:hover {
  color: var(--teal);
  text-decoration: none;
}

.site-logo .logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--teal);
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* --- Navigation Links ---------------------------------------- */
.main-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.main-nav a,
.main-nav .nav-link {
  color: var(--gray-300);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  transition: color 0.2s ease, background-color 0.2s ease;
  white-space: nowrap;
  cursor: pointer;
}

.main-nav a:hover,
.main-nav .nav-link:hover {
  color: var(--white);
  background-color: var(--navy-light);
  text-decoration: none;
}

.main-nav a.active,
.main-nav .nav-link.active {
  color: var(--teal);
  background-color: rgba(20, 184, 166, 0.1);
}

/* --- Dropdown Menu ------------------------------------------- */
.nav-dropdown {
  position: relative;
}

.nav-dropdown .dropdown-toggle {
  color: var(--gray-300);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  transition: color 0.2s ease, background-color 0.2s ease;
  white-space: nowrap;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-dropdown .dropdown-toggle:hover {
  color: var(--white);
  background-color: var(--navy-light);
}

.nav-dropdown .dropdown-toggle::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid currentColor;
  margin-left: 2px;
  transition: transform 0.2s ease;
}

.nav-dropdown:hover .dropdown-toggle::after {
  transform: rotate(180deg);
}

.nav-dropdown .dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 260px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  z-index: 1001;
  margin-top: 0.25rem;
}

.nav-dropdown:hover .dropdown-menu,
.nav-dropdown .dropdown-menu:hover {
  display: block;
}

.nav-dropdown .dropdown-menu a {
  display: block;
  color: var(--gray-700);
  font-size: 0.8125rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  white-space: normal;
  line-height: 1.4;
}

.nav-dropdown .dropdown-menu a:hover {
  color: var(--teal-dark);
  background-color: var(--gray-50);
}

.nav-dropdown .dropdown-menu a .dropdown-desc {
  display: block;
  font-size: 0.7rem;
  color: var(--gray-400);
  font-weight: 400;
  margin-top: 0.1rem;
}

.nav-dropdown .dropdown-menu a .dropdown-tag {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  margin-left: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

/* Dropdown active state */
.nav-dropdown.active .dropdown-toggle {
  color: var(--teal);
}

/* Line indicators in dropdown */
.nav-dropdown .dropdown-menu .line-badge {
  display: inline-block;
  font-size: 0.55rem;
  font-weight: 700;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  margin-right: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

/* Header right actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- Mobile Menu Toggle -------------------------------------- */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
}

.menu-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--gray-300);
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* --- Main Content Area ---------------------------------------- */
.main-content {
  padding-top: 2rem;
  padding-bottom: 4rem;
  min-height: calc(100vh - var(--header-height) - 200px);
}

/* --- Page Header -------------------------------------------- */
.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-200);
}

.page-header h1 {
  margin-bottom: 0.5rem;
}

.page-header p {
  color: var(--gray-500);
  font-size: 1.125rem;
  margin-bottom: 0;
}

/* --- Footer ------------------------------------------------- */
.site-footer {
  background-color: var(--navy);
  color: var(--gray-400);
  padding: 2rem 0;
  font-size: 0.875rem;
  border-top: 1px solid var(--navy-border);
}

.site-footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-footer a {
  color: var(--gray-300);
}

.site-footer a:hover {
  color: var(--teal);
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* --- Cards -------------------------------------------------- */
.card {
  background-color: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--gray-100);
}

.card-header h2,
.card-header h3 {
  margin-bottom: 0;
}

.card-body {
  line-height: 1.6;
}

.card-footer {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--gray-100);
  font-size: 0.875rem;
  color: var(--gray-500);
}

/* Card grid layout */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

/* --- Badges & Tags ------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  line-height: 1.4;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-teal {
  background-color: rgba(20, 184, 166, 0.12);
  color: var(--teal-dark);
  border: 1px solid rgba(20, 184, 166, 0.25);
}

.badge-amber {
  background-color: rgba(245, 158, 11, 0.12);
  color: var(--amber-dark);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-red {
  background-color: rgba(239, 68, 68, 0.12);
  color: var(--red-dark);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.badge-gray {
  background-color: var(--gray-100);
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
}

/* --- Status Indicators ---------------------------------------- */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
}

.status-indicator::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-passed::before,
.status-validated::before {
  background-color: var(--teal);
  box-shadow: 0 0 6px rgba(20, 184, 166, 0.4);
}

.status-draft::before,
.status-experimental::before {
  background-color: var(--amber);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}

.status-error::before,
.status-critical::before {
  background-color: var(--red);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.status-neutral::before {
  background-color: var(--gray-400);
}

/* --- Alerts & Callouts ---------------------------------------- */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  font-size: 0.875rem;
  line-height: 1.5;
  border-left: 4px solid;
}

.alert-teal {
  background-color: rgba(20, 184, 166, 0.06);
  border-left-color: var(--teal);
  color: var(--gray-700);
}

.alert-amber {
  background-color: rgba(245, 158, 11, 0.06);
  border-left-color: var(--amber);
  color: var(--gray-700);
}

.alert-red {
  background-color: rgba(239, 68, 68, 0.06);
  border-left-color: var(--red);
  color: var(--red-dark);
}

.alert-gray {
  background-color: var(--gray-50);
  border-left-color: var(--gray-400);
  color: var(--gray-600);
}

.alert-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
  display: block;
}

/* --- Buttons -------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  line-height: 1.4;
}

.btn:hover {
  text-decoration: none;
}

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

.btn-primary:hover {
  background-color: var(--teal-dark);
  border-color: var(--teal-dark);
  color: var(--white);
}

.btn-secondary {
  background-color: var(--white);
  color: var(--gray-700);
  border-color: var(--gray-200);
}

.btn-secondary:hover {
  background-color: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--gray-900);
}

.btn-ghost {
  background-color: transparent;
  color: var(--gray-500);
  border-color: transparent;
}

.btn-ghost:hover {
  background-color: var(--gray-100);
  color: var(--gray-700);
}

.btn-sm {
  font-size: 0.8125rem;
  padding: 0.375rem 0.875rem;
}

.btn-lg {
  font-size: 1rem;
  padding: 0.625rem 1.5rem;
}

/* --- Tables --------------------------------------------------- */
.table-wrapper {
  overflow-x: auto;
  margin-bottom: 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  background-color: var(--gray-50);
}

th {
  font-weight: 600;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--gray-200);
  color: var(--gray-600);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

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

tr:hover td {
  background-color: var(--gray-50);
}

/* --- Forms ---------------------------------------------------- */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 0.375rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  background-color: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  color: var(--gray-800);
  box-shadow: var(--shadow-input);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--gray-400);
}

.form-help {
  font-size: 0.8125rem;
  color: var(--gray-400);
  margin-top: 0.25rem;
}

/* --- JSON Code Viewer ----------------------------------------- */
.json-viewer {
  background-color: var(--gray-800);
  color: #e2e8f0;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
  tab-size: 2;
  position: relative;
}

.json-viewer .json-key {
  color: #67e8f9;   /* cyan */
}

.json-viewer .json-string {
  color: #a5f3fc;   /* light cyan */
}

.json-viewer .json-number {
  color: #fbbf24;   /* amber */
}

.json-viewer .json-boolean {
  color: #e879f9;   /* fuchsia */
}

.json-viewer .json-null {
  color: #94a3b8;   /* slate */
}

.json-viewer .json-bracket {
  color: #cbd5e1;   /* slate light */
}

.json-viewer .json-colon {
  color: #64748b;   /* slate muted */
}

.json-viewer .json-comma {
  color: #475569;   /* slate dark */
}

/* JSON viewer toolbar */
.json-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background-color: var(--gray-900);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-size: 0.75rem;
  color: var(--gray-400);
  border-bottom: 1px solid var(--gray-700);
}

.json-toolbar + .json-viewer {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* --- Code Block (general) ------------------------------------- */
.code-block {
  background-color: var(--gray-800);
  color: #e2e8f0;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background-color: var(--gray-900);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-size: 0.75rem;
  color: var(--gray-400);
  border-bottom: 1px solid var(--gray-700);
}

.code-block-header + .code-block {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  margin-top: 0;
}

/* --- Section / Article spacing -------------------------------- */
.section {
  margin-bottom: 2.5rem;
}

.section-title {
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--gray-200);
}

/* --- Tag list (inline) ---------------------------------------- */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
}

/* --- Breadcrumbs ---------------------------------------------- */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--gray-400);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.breadcrumbs a {
  color: var(--gray-500);
}

.breadcrumbs a:hover {
  color: var(--teal);
}

.breadcrumbs .separator {
  color: var(--gray-300);
  user-select: none;
}

.breadcrumbs .current {
  color: var(--gray-700);
  font-weight: 500;
}

/* --- Tabs ----------------------------------------------------- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.tab {
  display: inline-flex;
  align-items: center;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font-sans);
}

.tab:hover {
  color: var(--gray-700);
  border-bottom-color: var(--gray-300);
}

.tab.active {
  color: var(--teal-dark);
  border-bottom-color: var(--teal);
}

/* --- Search Input --------------------------------------------- */
.search-input-wrapper {
  position: relative;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 0.875rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  background-color: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  color: var(--gray-800);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

.search-input::placeholder {
  color: var(--gray-400);
}

/* --- Filter / Sidebar panel ----------------------------------- */
.filter-panel {
  background-color: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.filter-panel-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
}

/* ============================================================
   DOCUMENTATION ARTICLE STYLES
   ============================================================ */

.doc-article {
  background-color: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: 2rem;
  max-width: 900px;
}

.doc-article h1 {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.doc-article h2 {
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--gray-100);
}

.doc-article h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.doc-article h4 {
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.doc-article p,
.doc-article li {
  line-height: 1.7;
  color: var(--gray-700);
}

.doc-article ul,
.doc-article ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.doc-article li {
  margin-bottom: 0.25rem;
}

.doc-article blockquote {
  border-left: 4px solid var(--gray-200);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  background-color: var(--gray-50);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--gray-600);
  font-style: italic;
}

.doc-article hr {
  border: none;
  border-top: 1px solid var(--gray-200);
  margin: 2rem 0;
}

/* --- Definition lists (FHIR parameter tables) ----------------- */
.doc-article dl {
  margin-bottom: 1rem;
}

.doc-article dt {
  font-weight: 600;
  color: var(--gray-800);
  margin-top: 1rem;
  margin-bottom: 0.25rem;
}

.doc-article dd {
  margin-left: 0;
  color: var(--gray-600);
  margin-bottom: 0.5rem;
}

/* --- Inline FHIR references ----------------------------------- */
.fhir-ref {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--teal-dark);
  font-weight: 500;
}

/* ============================================================
   SIDEBAR / LAYOUT COLUMNS
   ============================================================ */

.content-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.content-main {
  flex: 1;
  min-width: 0;
}

.content-sidebar {
  width: 280px;
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--header-height) + 1.5rem);
}

.sidebar-card {
  background-color: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.sidebar-card-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
}

.sidebar-nav {
  list-style: none;
}

.sidebar-nav li {
  margin-bottom: 0.25rem;
}

.sidebar-nav a {
  display: block;
  padding: 0.375rem 0.5rem;
  font-size: 0.875rem;
  color: var(--gray-500);
  border-radius: var(--radius-sm);
  transition: color 0.2s ease, background-color 0.2s ease;
}

.sidebar-nav a:hover {
  color: var(--teal-dark);
  background-color: rgba(20, 184, 166, 0.06);
  text-decoration: none;
}

.sidebar-nav a.active {
  color: var(--teal-dark);
  background-color: rgba(20, 184, 166, 0.08);
  font-weight: 500;
}

/* ============================================================
   ON THIS PAGE — Table of Contents
   ============================================================ */

.toc {
  list-style: none;
  font-size: 0.8125rem;
}

.toc li {
  margin-bottom: 0.25rem;
}

.toc a {
  color: var(--gray-500);
  display: block;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: color 0.2s ease;
}

.toc a:hover {
  color: var(--teal);
  text-decoration: none;
}

.toc .toc-h2 {
  padding-left: 0.5rem;
}

.toc .toc-h3 {
  padding-left: 1.25rem;
  font-size: 0.75rem;
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

.text-teal { color: var(--teal); }
.text-amber { color: var(--amber); }
.text-red { color: var(--red); }
.text-muted { color: var(--gray-500); }
.text-white { color: var(--white); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }

.font-mono { font-family: var(--font-mono); }
.font-sans { font-family: var(--font-sans); }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-8 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-8 { margin-bottom: 2rem; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }

.w-full { width: 100%; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   RESPONSIVE — Mobile (< 768px)
   ============================================================ */

@media (max-width: 767px) {
  :root {
    --side-padding: 16px;
  }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  h3 { font-size: 1.125rem; }

  /* --- Collapse navigation ------------------------------------- */
  .menu-toggle {
    display: flex;
  }

  .main-nav {
    display: none;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background-color: var(--navy);
    flex-direction: column;
    padding: 0.5rem 1rem 1rem;
    border-bottom: 1px solid var(--navy-border);
    box-shadow: var(--shadow-lg);
  }

  .main-nav.open {
    display: flex;
  }

  .main-nav a {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
  }

  /* --- Single column layout ------------------------------------ */
  .content-with-sidebar {
    flex-direction: column;
  }

  .content-sidebar {
    width: 100%;
    position: static;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .doc-article {
    padding: 1.25rem;
  }

  /* --- Footer stacks vertically -------------------------------- */
  .site-footer .container {
    flex-direction: column;
    text-align: center;
  }

  /* --- Tables scroll natively ---------------------------------- */
  .table-wrapper {
    margin-left: calc(-1 * var(--side-padding));
    margin-right: calc(-1 * var(--side-padding));
    border-left: none;
    border-right: none;
    border-radius: 0;
  }

  /* --- Sidebar toggles into top section ------------------------ */
  .filter-panel {
    padding: 1rem;
  }

  /* --- Tabs scroll horizontally -------------------------------- */
  .tabs {
    margin-left: calc(-1 * var(--side-padding));
    margin-right: calc(-1 * var(--side-padding));
    padding-left: var(--side-padding);
  }
}

/* ============================================================
   RESPONSIVE — Tablet (768px–1024px)
   ============================================================ */

@media (min-width: 768px) and (max-width: 1024px) {
  .content-sidebar {
    width: 220px;
  }

  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .main-nav a {
    font-size: 0.8125rem;
    padding: 0.5rem;
  }
}

/* ============================================================
   PRINT
   ============================================================ */

@media print {
  .site-header,
  .site-footer,
  .menu-toggle,
  .content-sidebar,
  .breadcrumbs,
  .tabs,
  .btn {
    display: none !important;
  }

  .main-content {
    padding-top: 0;
  }

  .doc-article {
    border: none;
    padding: 0;
    max-width: 100%;
  }

  a {
    color: var(--gray-900);
    text-decoration: underline;
  }

  .json-viewer {
    background-color: var(--gray-50) !important;
    color: var(--gray-800) !important;
    border: 1px solid var(--gray-200);
  }

  .card {
    box-shadow: none;
    border: 1px solid var(--gray-200);
    break-inside: avoid;
  }
}
