/* ============================================================
   HIS Requirements Documentation — Custom Styles
   Supplements Tailwind CSS + @tailwindcss/typography (prose)
   ============================================================ */

/* ---------- Root variables ---------- */
:root {
  --sidebar-w: 280px;
  --toc-w: 220px;
  --color-clinical: #0d9488;
  --color-portals: #7c3aed;
  --color-rcm: #d97706;
}

/* ---------- Sidebar ---------- */
#sidebar {
  transition: transform 0.25s ease;
}
@media (max-width: 1023px) {
  #sidebar {
    position: fixed;
    z-index: 40;
    top: 0;
    left: 0;
    height: 100dvh;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,0.12);
  }
  #sidebar.open { transform: translateX(0); }
}

/* Scrollbar styling for sidebar */
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }
#sidebar::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ---------- TOC (right sidebar) ---------- */
#toc a {
  display: block;
  padding: 2px 0;
  font-size: 12px;
  color: #9ca3af;
  text-decoration: none;
  border-left: 2px solid transparent;
  padding-left: 12px;
  transition: all 0.1s;
  line-height: 1.5;
}
#toc a:hover { color: #374151; }
#toc a.active {
  color: #1d4ed8;
  border-left-color: #2563eb;
  font-weight: 500;
}
#toc a.toc-h3 { padding-left: 24px; font-size: 11.5px; }
#toc a.toc-h4 { padding-left: 36px; font-size: 11px; }

/* ---------- Code blocks — language labels ---------- */
.code-block-wrapper {
  position: relative;
  margin: 1.25em 0;
}
.code-label {
  position: absolute;
  top: 0;
  right: 0;
  padding: 2px 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 0 6px 0 6px;
  color: #fff;
  z-index: 1;
}
.code-label-sql { background: #2563eb; }
.code-label-json { background: #059669; }
.code-label-hl7-v2, .code-label-hl7 { background: #7c3aed; }
.code-label-html { background: #dc2626; }
.code-label-mermaid { background: #0d9488; }
.code-label-yaml { background: #d97706; }
.code-label-python { background: #3b82f6; }
.code-label-javascript, .code-label-js { background: #eab308; color: #1c1917; }
.code-label-bash, .code-label-shell { background: #374151; }
.code-label-text, .code-label-plaintext { background: #6b7280; }
.code-label-xml { background: #ea580c; }
.code-label-fhir { background: #059669; }
.code-label-csv { background: #6b7280; }

/* ---------- Mermaid diagrams ---------- */
.mermaid {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  margin: 1.25em 0;
  overflow-x: auto;
  text-align: center;
}
.mermaid svg { max-width: 100%; height: auto; }
.mermaid { font-size: 14px; }

/* ---------- Lists inside prose ---------- */
article ul { list-style-type: disc; padding-left: 1.625em; }
article ol { list-style-type: decimal; padding-left: 1.625em; }
article li { margin-top: 0.25em; margin-bottom: 0.25em; }

/* ---------- Wireframe preview ---------- */
.wireframe-toggle {
  margin: -0.5em 0 1.25em;
}
.wireframe-toggle summary {
  cursor: pointer;
  font-size: 12px;
  color: #2563eb;
  font-weight: 500;
}
.wireframe-toggle summary:hover { text-decoration: underline; }
.wireframe-iframe {
  width: 100%;
  min-height: 400px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  margin-top: 8px;
}

/* ---------- Tables inside prose ---------- */
article table {
  font-size: 0.85rem;
  border-collapse: collapse;
  width: 100%;
}
article th {
  background: #f3f4f6;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
article th, article td {
  padding: 6px 12px;
  border: 1px solid #d1d5db;
}
article tbody tr:nth-child(even) { background: #f9fafb; }

/* ---------- Prev / Next navigation ---------- */
.prev-next {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e5e7eb;
}
.prev-next a {
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  text-decoration: none;
  color: #374151;
  transition: border-color 0.15s, box-shadow 0.15s;
  max-width: 48%;
}
.prev-next a:hover { border-color: #2563eb; box-shadow: 0 1px 4px rgba(37,99,235,0.12); }
.prev-next .label { font-size: 11px; color: #9ca3af; margin-bottom: 2px; }
.prev-next .title { font-weight: 600; color: #1d4ed8; font-size: 13px; }

/* ---------- Breadcrumbs ---------- */
.breadcrumbs {
  font-size: 12px;
  color: #9ca3af;
}
.breadcrumbs a { color: #6b7280; text-decoration: none; }
.breadcrumbs a:hover { color: #2563eb; text-decoration: underline; }
.breadcrumbs .sep { margin: 0 6px; color: #d1d5db; }

/* ---------- Mobile overlay ---------- */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 35;
  backdrop-filter: blur(2px);
}
#sidebar-overlay.active { display: block; }

/* ---------- Search results dropdown ---------- */
#search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 400px;
  overflow-y: auto;
  z-index: 50;
  display: none;
}
#search-results.active { display: block; }
#search-results a {
  display: block;
  padding: 10px 14px;
  text-decoration: none;
  color: #374151;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
}
#search-results a:hover { background: #f9fafb; }
#search-results a:last-child { border-bottom: none; }
#search-results .result-title { font-weight: 600; color: #111827; font-size: 13px; }
#search-results .result-snippet { font-size: 12px; color: #9ca3af; margin-top: 2px; }
#search-results mark { background: #fef08a; border-radius: 2px; padding: 0 1px; }

/* ---------- Print ---------- */
@media print {
  #sidebar, #toc, #hamburger, #sidebar-overlay, .prev-next, .breadcrumbs,
  #search-container, .wireframe-toggle { display: none !important; }
  main { margin: 0 !important; max-width: 100% !important; }
  article a[href]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #666; }
  .mermaid { break-inside: avoid; }
  table { break-inside: avoid; }
}

/* ---------- Validation dashboard ---------- */
.val-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}
.val-badge-pass { background: #ecfdf5; color: #059669; }
.val-badge-warn { background: #fffbeb; color: #d97706; }
.val-badge-fail { background: #fef2f2; color: #dc2626; }

.val-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}
.val-icon-pass { background: #ecfdf5; color: #059669; }
.val-icon-warn { background: #fffbeb; color: #d97706; font-size: 8px; }
.val-icon-fail { background: #fef2f2; color: #dc2626; }

.val-progress-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  background: #f3f4f6;
}
.val-progress-fill {
  height: 100%;
  transition: width 0.3s ease;
}

.val-module-details[open] .val-chevron {
  transform: rotate(180deg);
}

.val-check-row:hover {
  background: #f9fafb;
}

/* ---------- Landing page cards ---------- */
.landing-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.landing-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.landing-validation-badge {
  transition: box-shadow 0.15s ease;
}

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