/* ==========================================================================
   DOCUMENTATION STYLES
   Ported from documentation/resources/public/app.css
   ========================================================================== */

/* Light-mode defaults for variables used by docs styles.
   These are defined in @theme of tailwind.css but tree-shaken from main.css
   because only docs.css references them via var(). */
.docs-page {
  --color-surface-subtle: #FDFDFE;
  --color-surface-nav-active: #FCF8F7;
  --color-list-marker: #D1D5DB;
  --color-module-bg-end: #FFF0F0;
  --color-outline-tree: #b3bac0;
  --color-info-2: rgb(239, 246, 255);
  --color-info-9: rgb(59, 130, 246);
  --color-info-12: rgb(30, 58, 138);
  --color-success-2: rgb(209, 250, 229);
  --color-success-9: rgb(16, 185, 129);
  --color-success-12: rgb(4, 120, 87);
  --color-warning-2: rgb(255, 244, 236);
  --color-warning-9: rgb(245, 158, 11);
  --color-warning-12: rgb(146, 64, 14);
  --color-danger-2: rgb(254, 226, 226);
  --color-danger-9: rgb(239, 68, 68);
  --color-danger-12: rgb(153, 27, 27);
  --code-font-size: 13px;
  --code-line-height: 20px;
  --code-shadow: 0px 1px 0px 0px #FFFFFF;
  --color-code-inline-border: #F6F1F0;
  --font-family-code: Menlo, "JetBrains Mono", ui-monospace, Monaco, monospace;
}


/* Module card gradient background (Landing Page) */
.module-card-gradient {
  background: linear-gradient(90deg, #FFFFFF 44.8%, var(--color-module-bg-end) 161.49%);
}

.module-card-gradient:hover {
  background: var(--color-surface);
}


/* Docs Layout Structure */
.docs-page {
  min-height: 100vh;
}

/* On mobile, docs-page uses flex column layout */
@media (max-width: 767px) {
  .docs-page {
    display: flex;
    flex-direction: column;
  }
}


/* Mobile menu button */
.docs-menu-btn {
  display: none;
  padding: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-on-surface);
  border-radius: 4px;
  transition: background-color 0.15s;
}

.docs-menu-btn:hover {
  background: var(--color-surface-hover);
}

.docs-menu-btn svg {
  display: block;
}

/* Mobile overlay */
.docs-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
}


/* Main container - 3 column grid */
.docs-container {
  display: flex;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

/* Left Sidebar (Navigation) */
.docs-sidebar {
  width: 20rem;
  flex-shrink: 0;
  position: sticky;
  top: 20px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 1.5rem;
  background: var(--color-surface);
  border-right: 1px solid var(--color-outline-subtle);
  space-y: 1rem;
}

.nav-section {
  margin-bottom: 1rem;
  overflow-wrap: break-word;
}

.nav-section:not(:first-child) {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-outline-subtle);
}

.nav-section-title {
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-brand-accessible);
  margin-bottom: 0.25rem;
  margin-top: 0.5rem;
  margin-left: 1rem;
  line-height: 1rem;
}

.nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-item {
  margin: 0;
}

.nav-item > a {
  display: flex;
  align-items: center;
  padding: 0.25rem 0;
  padding-left: 1rem;
  color: var(--color-on-surface);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 400;
  border-radius: 4px;
  transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
  min-height: 2.25rem;
  line-height: 1.25rem;
  letter-spacing: -0.025em;
}

.nav-item > a:hover {
  background: var(--color-surface-nav-active);
  color: var(--color-on-surface-secondary);
}

.nav-item.active > a {
  background: var(--color-surface-nav-active);
  color: var(--color-on-surface-secondary);
  font-weight: 500;
}

/* Active indicator for nested items */
.nav-children .nav-item.active > a {
  border-left: 2px solid var(--color-brand);
  border-radius: 0 4px 4px 0;
  padding-left: calc(1rem - 2px);
}

.nav-children {
  list-style: none;
  padding: 0;
  margin: 0 0 0 1.5rem;
  border-left: 1px solid var(--color-outline);
}

.nav-item.open > .nav-children {
  display: block;
}

.nav-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.25rem 0;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--color-on-surface);
  border-radius: 4px;
  transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
  min-height: 2.25rem;
  text-align: left;
}

.nav-summary:hover {
  background: var(--color-surface-nav-active);
  color: var(--color-on-surface-secondary);
}

.nav-summary a {
  flex: 1;
  display: block;
  color: inherit;
  text-decoration: none;
  padding-left: 1rem;
  margin-right: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  letter-spacing: -0.025em;
}

.nav-item.active > .nav-summary,
.nav-summary:has(a.active) {
  background: var(--color-surface-nav-active);
  color: var(--color-on-surface-secondary);
  font-weight: 500;
}

.nav-chevron {
  flex-shrink: 0;
  width: 0.75rem;
  height: 0.75rem;
  transition: all 0.2s;
  margin-right: 0.5rem;
}

.nav-item.open > .nav-summary .nav-chevron {
  transform: rotate(90deg);
}

.external-icon {
  opacity: 0.5;
  margin-left: 0.25rem;
  font-size: 0.75rem;
}

/* External links in content */
.docs-content a.external-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.external-link-icon {
  width: 0.75rem;
  height: 0.75rem;
  flex-shrink: 0;
  opacity: 0.6;
}

/* Main Content */
.docs-main {
  flex: 1;
  min-width: 0;
  padding: 2rem 3rem;
  max-width: 900px;
}

/* Landing page variant - wider content, no TOC constraint */
.docs-main-landing {
  max-width: 100%;
  padding: 0;
}

.docs-content-landing {
  color: var(--color-on-surface);
}

/* Letter Glitch Background Effect */
.letter-glitch-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.glitch-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 11px;
  font-weight: 400;
  color: var(--color-outline-subtle);
  user-select: none;
  line-height: 123%;
  letter-spacing: 0.45em;
  text-align: center;
  will-change: contents;
  contain: layout style;
}

.glitch-letter.active {
  color: var(--color-outline);
  font-weight: 500;
}

.hero-ellipse-overlay {
  position: absolute;
  width: 900px;
  height: 600px;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.4) 40%, transparent 70%);
  pointer-events: none;
  top: 40%;
  left: 10%;
  transform: translate(-50%, -50%);
  z-index: 1;
  mix-blend-mode: screen;
}


@media (prefers-reduced-motion: reduce) {
  .glitch-letter,
  .glitch-letter.active {
    animation: none;
    transition: none;
  }
}

@media (max-width: 768px) {
  .glitch-letter {
    font-size: 9px;
    letter-spacing: 0.35em;
  }
}

/* Page actions dropdown */
#page-actions-dropdown,
#page-actions-dropdown.absolute {
  overflow: visible !important;
}

#page-actions-dropdown a,
#page-actions-dropdown button {
  border: none;
  background: none;
}

#page-actions-dropdown a:hover,
#page-actions-dropdown button:hover {
  background: var(--color-surface-hover);
}

.docs-content {
  color: var(--color-on-surface);
}

.docs-content h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-on-surface-strong);
  margin-bottom: 1.5rem;
  line-height: 1.2;
}

.docs-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-on-surface-strong);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-outline);
}

.docs-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-on-surface-strong);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.docs-content h4 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-on-surface-strong);
  margin-top: 1rem;
  margin-bottom: 0.75rem;
}

.docs-content h5 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-on-surface-strong);
  margin-top: 0.75rem;
}

.docs-content h6 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-on-surface-strong);
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
}

.docs-content p {
  margin-bottom: 1rem;
  line-height: 1.7;
  color: var(--color-on-surface-secondary);
}

.docs-content ul,
.docs-content ol {
  margin-bottom: 1rem;
  margin-left: 2rem;
}

.docs-content ul {
  list-style: none;
}

.docs-content ol {
  list-style: decimal;
  list-style-position: outside;
}

.docs-content ul > li {
  position: relative;
  margin-top: 0.5rem;
}

.docs-content ul > li::before {
  content: "•";
  color: var(--color-list-marker);
  font-family: Arial, sans-serif;
  font-size: min(1.5em, 24px);
  line-height: 1;
  position: absolute;
  left: -1.5rem;
  top: 0;
}

/* Nested lists - ensure markers show */
.docs-content ul ul,
.docs-content ol ul {
  margin-left: 1.5rem;
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.docs-content ul ul > li::before,
.docs-content ol ul > li::before {
  content: "◦";
  font-size: 1.2em;
}

.docs-content ul ul ul > li::before,
.docs-content ol ul ul > li::before {
  content: "▪";
  font-size: 0.8em;
  top: 0.3em;
}

/* Deeply nested ordered lists */
.docs-content ol ol,
.docs-content ul ol {
  margin-left: 1.5rem;
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.docs-content li {
  margin-bottom: 0.5rem;
  line-height: 1.6;
  color: var(--color-on-surface-secondary);
}

.docs-content a {
  color: var(--color-brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.docs-content a:hover {
  color: var(--color-on-surface-strong);
}

/* Inline code */
.docs-content code:not(pre code) {
  padding: 1px 6px;
  min-width: 1.625rem;
  background: var(--color-surface-subtle);
  color: var(--color-on-surface-secondary);
  border-radius: 3px;
  font-family: var(--font-family-code);
  font-size: 0.875rem;
  line-height: var(--code-line-height);
  box-shadow: 0px 0px 0px 1px var(--color-code-inline-border) inset;
  word-break: break-word;
}

/* Code blocks */
.docs-content pre {
  margin-bottom: 1.5rem;
  margin-left: -1rem;
  margin-right: -1rem;
  border-radius: 8px;
  overflow: hidden;
}

.docs-content pre code {
  display: block;
  padding: 1rem;
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-outline);
  border-radius: 8px;
  overflow-x: auto;
  font-family: var(--font-family-code);
  font-size: var(--code-font-size);
  line-height: var(--code-line-height);
  box-shadow: var(--code-shadow);
}

.docs-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1rem 0;
}

.docs-content .hint-content img {
  max-width: min(300px, 100%);
  margin: 0;
  border-radius: 0;
}

/* Tables */
.docs-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.docs-content th,
.docs-content td {
  padding: 0.75rem;
  text-align: left;
  border: 1px solid var(--color-outline);
}

.docs-content th {
  background: var(--color-surface-alt);
  font-weight: 600;
  color: var(--color-on-surface-secondary);
}

.docs-content tr:hover {
  background: var(--color-surface-hover);
}

.docs-content td {
  color: var(--color-on-surface-secondary);
}

/* Blockquote */
.docs-content blockquote {
  margin: 1rem 0;
  padding: 1rem 1.5rem;
  border-left: 4px solid var(--color-outline);
  background: var(--color-surface-alt);
  color: var(--color-on-surface-muted);
}

/* Heading anchors */
.docs-content h2[id],
.docs-content h3[id],
.docs-content h4[id],
.docs-content h5[id],
.docs-content h6[id] {
  scroll-margin-top: 100px;
  position: relative;
}

.docs-content .heading-anchor {
  position: absolute;
  left: -1.5em;
  top: 0;
  width: 1.5em;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  text-decoration: none;
  color: var(--color-on-surface-muted);
  transition: opacity 0.15s;
}

.docs-content .heading-anchor::before {
  content: "#";
  font-weight: 400;
  font-size: 0.85em;
}

.docs-content h2 .heading-anchor {
  top: -2px;
}

.docs-content h2:hover .heading-anchor,
.docs-content h3:hover .heading-anchor,
.docs-content h4:hover .heading-anchor,
.docs-content h5:hover .heading-anchor,
.docs-content h6:hover .heading-anchor,
.docs-content .heading-anchor:focus {
  opacity: 0.6;
}

.docs-content .heading-anchor:hover {
  opacity: 1 !important;
  color: var(--color-primary);
}

/* Right Sidebar (Table of Contents) */
.docs-toc {
  max-width: 14rem;
  flex-basis: 14rem;
  flex-shrink: 0;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  margin-left: 1.5rem;
  overflow-y: auto;
  padding: 2rem 0;
  background: var(--color-surface);
}

/* Search input in TOC sidebar */
.toc-search {
  margin-bottom: 1rem;
}

.toc-search-input {
  display: flex;
  height: 2.25rem;
  width: 100%;
  align-items: center;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid var(--color-outline);
  background: var(--color-surface);
  color: var(--color-on-surface-secondary);
  transition: border-color 0.15s;
}

.toc-search-input:hover {
  border-color: var(--color-outline-input-focus);
}

.toc-search-input:focus-within {
  border-color: var(--color-outline-input-focus);
}

.toc-search-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 0.75rem;
}

.toc-search-icon svg {
  width: 1rem;
  height: 1rem;
  color: var(--color-on-surface-placeholder);
  flex-shrink: 0;
}

.toc-search-input input {
  min-width: 0;
  flex: 1;
  background: transparent;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  outline: none;
  color: var(--color-on-surface-strong);
}

.toc-search-input input::placeholder {
  font-size: 0.875rem;
  color: var(--color-on-surface-placeholder);
}

.toc {
  font-size: 0.875rem;
  padding-top: 24px;
}

.toc-title {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-on-surface-muted);
  margin-bottom: 0.5rem;
  padding-left: 0.75rem;
}

.toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 1px solid var(--color-outline-subtle);
}

.toc-item a {
  display: block;
  padding: 0.25rem 0.75rem;
  color: var(--color-on-surface-muted);
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}


.toc-item a:hover {
  color: var(--color-on-surface-strong);
}

.toc-item a.active {
  color: var(--color-on-surface-strong);
  font-weight: 500;
}


/* TOC nesting by heading level — indent children */
.toc-level-2 a { padding-left: 0.75rem; }
.toc-level-3 a { padding-left: 1.25rem; }
.toc-level-4 a { padding-left: 1.75rem; }
.toc-level-5 a { padding-left: 2.25rem; }

/* Prev/Next Navigation */
.docs-prev-next {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-outline);
}

@media (min-width: 640px) {
  .docs-prev-next {
    flex-direction: row;
    justify-content: space-between;
  }
}

.docs-prev-next a {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--color-outline-subtle);
  border-radius: 4px;
  text-decoration: none;
  transition: border-color 0.15s;
}

.docs-prev-next a:hover {
  border-color: var(--color-outline-input-focus);
}

.docs-prev-next .prev {
  flex-direction: row-reverse;
  text-align: right;
}

.docs-prev-next .label {
  display: block;
  font-size: 0.75rem;
  color: var(--color-on-surface-placeholder);
}

.docs-prev-next .title {
  display: block;
  color: var(--color-on-surface-muted);
  font-size: 0.875rem;
}

.docs-lastmod {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--color-on-surface-muted);
}

/* Stepper Step Content */
.stepper-step-content h1,
.stepper-step-content h2,
.stepper-step-content h3,
.stepper-step-content h4,
.stepper-step-content h5,
.stepper-step-content h6 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-on-surface-strong);
}

.stepper-step-content > *:first-child {
  margin-top: 0;
}

.stepper-step-content > *:last-child {
  margin-bottom: 0;
}

/* File Widget */
.file-widget,
.file-widget:hover {
  text-decoration: none !important;
}

.file-widget:hover {
  border-color: var(--color-brand);
}

/* Big Link (Content Ref) */
.big-link,
.big-link:hover {
  text-decoration: none !important;
}

.big-link a,
.docs-content .big-link a {
  text-decoration: none !important;
  color: var(--color-on-surface-strong) !important;
}

.big-link a:hover,
.docs-content .big-link a:hover {
  color: var(--color-on-surface-strong) !important;
}

.big-link:hover {
  border-color: var(--color-outline-input-focus);
}

/* Docs Responsive Design */
@media (max-width: 1200px) {
  .docs-toc {
    display: none;
  }
}

@media (max-width: 900px) {
  .docs-menu-btn {
    display: block;
  }

  .docs-sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    z-index: 95;
  }

  .docs-sidebar.docs-sidebar-open {
    transform: translateX(0);
  }

  .docs-main {
    padding: 1.5rem;
  }

  .docs-main-landing {
    padding: 0;
  }
}

/* Docs Custom Scrollbar */
.docs-sidebar::-webkit-scrollbar,
.docs-toc::-webkit-scrollbar {
  width: 8px;
}

.docs-sidebar::-webkit-scrollbar-track,
.docs-toc::-webkit-scrollbar-track {
  background: transparent;
}

.docs-sidebar::-webkit-scrollbar-thumb,
.docs-toc::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 20px;
  transition: background 0.3s ease;
}

.docs-sidebar:hover::-webkit-scrollbar-thumb,
.docs-toc:hover::-webkit-scrollbar-thumb {
  background: var(--color-outline-hover);
}

/* ============================================================
   FHIR Structure Tables
   ============================================================ */

table.fhir-structure tr:nth-child(even) {
  background-color: var(--color-surface-alt);
}

table.fhir-structure tbody.tree > tr:hover {
  background-color: var(--color-surface-hover) !important;
}

table.fhir-structure td,
table.fhir-structure th {
  border: none;
}

tbody.tree,
tbody.tree tbody {
  list-style: none;
  margin: 0;
  padding: 0;
}

table.fhir-structure {
  height: 1px;
}

table.fhir-structure tbody.tree tr {
  height: 100%;
}

table.fhir-structure tbody.tree tr td {
  height: 100%;
}

/* Vertical dotted lines for tree structure */
tbody.tree .li {
  margin: 0px 0 -10px 10px;
  padding: 0 7px;
  line-height: 20px;
  border-left: 1px dotted var(--color-outline-tree);
}

/* Last line should only be half height */
tbody.tree .li.last-li {
  height: 50% !important;
  align-self: flex-start !important;
  margin-bottom: 0 !important;
}

/* Horizontal connectors at the end of branches */
tbody.tree > tr > td > .element > span:last-child:before {
  position: relative;
  top: 0.3em;
  height: 1em;
  width: 12px;
  color: white;
  border-bottom: 1px dotted var(--color-outline-tree);
  content: '';
  display: inline-block;
}

