/* ===== CSS VARIABLES ===== */
:root {
  --navy: #1B3A6B;
  --navy-dark: #122850;
  --navy-light: #2563a8;
  --blue-mid: #3578c9;
  --accent: #E8A020;
  --accent-dark: #c88410;
  --success: #27ae60;
  --danger: #e74c3c;
  --warning: #f39c12;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #5a6a82;
  --border: #d0daea;
  --sidebar-width: 260px;
  --topbar-height: 60px;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(27,58,107,0.10);
}

/* ===== BASE (Bootstrap handles reset) ===== */
html { scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
code {
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.88em;
  background: #e8eef8;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--navy-dark);
}

/* ===== PROGRESS BAR ===== */
#progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--blue-mid));
  z-index: 2000;
  transition: width 0.1s linear;
}

/* ===== TOPBAR (Bootstrap navbar overrides) ===== */
#topbar {
  top: 3px;
  height: var(--topbar-height);
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 100%) !important;
  box-shadow: 0 2px 10px rgba(18,40,80,0.35);
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
  color: #fff !important;
  text-decoration: none;
}
.brand-icon { font-size: 1.3rem; }
.brand-sub {
  font-size: 0.7rem;
  color: #a0b8e0;
  font-weight: 400;
  line-height: 1;
}
.nav-links {
  flex: 1;
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links .nav-link {
  color: #c8d8f0 !important;
  font-size: 0.78rem;
  padding: 0.3rem 0.65rem !important;
  border-radius: 20px;
  white-space: nowrap;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}
.nav-links .nav-link:hover,
.nav-links .nav-link.active {
  background: rgba(232,160,32,0.25);
  color: var(--accent) !important;
}

/* ===== LAYOUT ===== */
.layout {
  display: flex;
  padding-top: calc(var(--topbar-height) + 3px);
  min-height: 100vh;
}

/* ===== SIDEBAR (Bootstrap offcanvas-lg overrides) ===== */
@media (min-width: 992px) {
  #sidebar {
    position: fixed !important;
    top: calc(var(--topbar-height) + 3px);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width) !important;
    height: calc(100vh - var(--topbar-height) - 3px) !important;
    background: var(--surface) !important;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 900;
    transform: none !important;
    visibility: visible !important;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }
  #sidebar .offcanvas-body {
    display: block !important;
    overflow-y: visible;
    padding: 1.5rem 0 2rem;
    flex-grow: 0;
  }
}

.sidebar-section { margin-bottom: 1.5rem; }
.sidebar-heading {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0 1.2rem 0.4rem;
}
#sidebar a {
  display: block;
  padding: 0.45rem 1.2rem 0.45rem 1.5rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  border-left: 3px solid transparent;
  transition: all 0.2s;
  text-decoration: none;
}
#sidebar a:hover {
  color: var(--navy);
  background: #f0f4fb;
  text-decoration: none;
  border-left-color: var(--navy-light);
}
#sidebar a.active {
  color: var(--navy);
  font-weight: 600;
  background: #e8eef8;
  border-left-color: var(--accent);
}

/* ===== MAIN CONTENT ===== */
#content {
  flex: 1;
  padding: 2.5rem 2.5rem 4rem;
  max-width: 960px;
}
@media (min-width: 992px) {
  #content { margin-left: var(--sidebar-width); }
}

/* ===== SECTIONS ===== */
.doc-section {
  margin-bottom: 3.5rem;
}
.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
}
.section-icon {
  font-size: 1.5rem;
}
.section-header h2 {
  font-size: 1.5rem;
  color: var(--navy-dark);
  font-weight: 700;
}
.section-lead {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  line-height: 1.7;
}

/* ===== HERO ===== */
#hero {
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy-light) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 3rem 2.5rem 2.5rem;
  margin-bottom: 3rem;
  position: relative;
  overflow: hidden;
}
#hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% 20%, rgba(232,160,32,0.15), transparent 60%);
  pointer-events: none;
}
.hero-badge {
  display: inline-block;
  background: rgba(232,160,32,0.25);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.3rem 0.9rem;
  border-radius: 20px;
  border: 1px solid rgba(232,160,32,0.4);
  margin-bottom: 1rem;
}
.hero-title {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 0.5rem;
  color: #fff;
}
.hero-title span {
  color: var(--accent);
}
.hero-subtitle {
  font-size: 1rem;
  color: #a8c0e0;
  margin-bottom: 1.8rem;
}
.hero-pills {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.pill {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: #d0e4f8;
  font-size: 0.78rem;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* ===== INFO CARDS (Bootstrap card overrides) ===== */
.info-card {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}
.info-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(27,58,107,0.14);
}
.info-card .card-icon {
  font-size: 1.6rem;
  margin-bottom: 0.6rem;
}
.info-card .card-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.3rem;
}
.info-card .card-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

/* ===== BOOTSTRAP ALERT OVERRIDES ===== */
.alert { font-size: 0.88rem; border-radius: var(--radius); }
.alert p { margin: 0; }

/* ===== ARCHITECTURE DIAGRAM ===== */
.arch-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.arch-client-row {
  display: flex;
  justify-content: center;
  margin-bottom: 0;
}
.arch-box {
  border-radius: 8px;
  padding: 0.7rem 1.2rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  min-width: 130px;
}
.arch-client {
  background: linear-gradient(135deg, #2d3748, #4a5568);
  color: #e2e8f0;
  border: 2px solid #718096;
}
.arch-client .arch-label { font-size: 0.68rem; color: #a0aec0; font-weight: 400; }

.arch-split-row {
  display: flex;
  justify-content: center;
  gap: 4rem;
  margin: 1.2rem 0;
}
.arch-api-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}
.arch-api-ben {
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  color: #fff;
  border: 2px solid var(--blue-mid);
  min-width: 160px;
}
.arch-api-apo {
  background: linear-gradient(135deg, #1a5276, #2e86c1);
  color: #fff;
  border: 2px solid #2980b9;
  min-width: 160px;
}
.arch-api-ben .arch-label,
.arch-api-apo .arch-label {
  font-size: 0.65rem;
  opacity: 0.8;
  font-weight: 400;
}
.arch-orgs-group {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 240px;
}
.arch-org {
  background: #f7fafc;
  border: 1px solid #cbd5e0;
  color: #4a5568;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}
.arch-connector {
  text-align: center;
  font-size: 1.2rem;
  color: var(--text-muted);
  line-height: 1;
}
.arch-split-connector {
  display: flex;
  justify-content: center;
  gap: 4rem;
  margin-bottom: 0;
}
.arch-split-connector span {
  font-size: 1.2rem;
  color: var(--text-muted);
}
.arch-legend {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-muted);
}
.arch-legend span {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.arch-legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-navy { background: var(--navy); }
.dot-blue { background: #2e86c1; }
.dot-gray { background: #718096; }

/* ===== ENDPOINT ACCORDION (Bootstrap accordion overrides) ===== */
.endpoint-accordion-item {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.endpoint-accordion-item .accordion-button {
  --bs-accordion-btn-color: var(--text);
  --bs-accordion-btn-bg: var(--surface);
  --bs-accordion-active-color: var(--navy-dark);
  --bs-accordion-active-bg: #f0f5ff;
  gap: 0.6rem;
  padding: 1rem 1.2rem;
}
.endpoint-accordion-item .accordion-button:focus {
  box-shadow: 0 0 0 0.2rem rgba(27,58,107,0.15);
}
.method-badge {
  font-size: 0.7rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.55rem !important;
  min-width: 46px;
  text-align: center;
}
.method-get  { background: #d4edda !important; color: #155724 !important; }
.method-post { background: #cce5ff !important; color: #004085 !important; }
.method-put  { background: #fff3cd !important; color: #856404 !important; }
.method-delete { background: #f8d7da !important; color: #721c24 !important; }
.endpoint-path {
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.88rem;
  color: var(--navy-dark);
  font-weight: 600;
}
.endpoint-desc { font-size: 0.78rem; color: var(--text-muted); }

/* ===== CODE BLOCKS ===== */
.code-block {
  background: #1e2d45;
  border-radius: 8px;
  overflow: hidden;
  margin: 1rem 0;
  position: relative;
}
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: rgba(255,255,255,0.06);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.code-lang {
  font-size: 0.68rem;
  color: #8ba5c8;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.copy-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: #8ba5c8;
  font-size: 0.72rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.copy-btn:hover { background: rgba(255,255,255,0.18); color: #fff; }
.code-block pre {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.82rem;
  line-height: 1.7;
  color: #d0e4f8;
  white-space: pre;
}

/* ===== API TABLES (Bootstrap table overrides) ===== */
.api-table thead tr { background: var(--navy); color: #fff; }
.api-table thead th {
  color: #fff !important;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-color: rgba(255,255,255,0.2) !important;
}
.api-table td { vertical-align: middle; font-size: 0.82rem; }
.api-table tbody tr:hover { background: #f7faff; }

/* ===== STATUS CODES ===== */
.status-code {
  font-size: 1.8rem;
  font-weight: 800;
  font-family: 'Cascadia Code', monospace;
  line-height: 1;
  margin-bottom: 0.4rem;
}
.status-name {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 0.3rem;
}
.status-desc { font-size: 0.78rem; }

/* ===== BENEFIT TYPES TABLE ===== */
.types-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-top: 1rem;
}
.types-table th {
  background: var(--navy);
  color: #fff;
  padding: 0.6rem 1rem;
  text-align: left;
  font-size: 0.75rem;
}
.types-table td {
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
}
.types-table tbody tr:last-child td { border-bottom: none; }
.types-table tbody tr:hover { background: #f7faff; }
.types-table td:first-child {
  font-family: monospace;
  font-weight: 700;
  color: var(--navy);
}

/* ===== FILE TREE ===== */
.file-tree {
  background: #1e2d45;
  border-radius: 8px;
  padding: 1.2rem 1.5rem;
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.8rem;
  color: #d0e4f8;
  line-height: 2;
}
.file-tree .folder { color: var(--accent); }
.file-tree .file { color: #8ba5c8; }
.file-tree .comment { color: #506080; }

/* LAW ALERT → use Bootstrap .alert.alert-primary in HTML */

/* ===== FOOTER ===== */
footer {
  background: var(--navy-dark);
  color: #a0b8d8;
  text-align: center;
  padding: 2rem 1.5rem;
  font-size: 0.8rem;
  margin-top: 4rem;
}
footer .footer-brand {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.5rem;
}
footer a { color: var(--accent); }
footer .footer-copy {
  margin-top: 0.75rem;
  font-size: 0.7rem;
  color: #607090;
}

/* ===== BACK TO TOP ===== */
#back-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 40px;
  height: 40px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 3px 10px rgba(27,58,107,0.3);
  transition: background 0.2s;
  z-index: 800;
  text-decoration: none;
}
#back-top:hover { background: var(--navy-light); }

/* ===== RESPONSIVE ===== */
@media (max-width: 991.98px) {
  #content { padding: 1.5rem 1.2rem 3rem; }
}
@media (max-width: 600px) {
  .hero-title { font-size: 1.6rem; }
  #hero { padding: 2rem 1.2rem 1.5rem; }
  .arch-split-row { gap: 1.5rem; }
}
