/* BizFirst Deployment Models V2 - Dark Theme, Left-Sidebar Layout */

:root {
  --primary-color: #2563eb;
  --primary-dark: #1e40af;
  --primary-light: #3b82f6;
  --secondary-color: #1e293b;
  --accent-color: #06b6d4;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --bg-dark: #0f172a;
  --bg-darker: #020617;
  --bg-card: #1e293b;
  --bg-card-alt: #172033;
  --border-color: #334155;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --transition: all 0.2s ease;
  --sidebar-width: 300px;
  --topbar-height: 64px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
}

svg.icon {
  width: 1em;
  height: 1em;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.15em;
  flex-shrink: 0;
}

/* ---------- App shell ---------- */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar ---------- */
.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  background: linear-gradient(135deg, var(--bg-darker) 0%, var(--secondary-color) 100%);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.15rem;
}

.topbar .brand .brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary-light), var(--accent-color));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-darker);
  flex-shrink: 0;
}

.topbar .brand .brand-mark svg {
  width: 20px;
  height: 20px;
  stroke: var(--bg-darker);
}

.topbar .brand-sub {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.85rem;
  padding-left: 0.65rem;
  border-left: 1px solid var(--border-color);
  margin-left: 0.15rem;
}

.sidebar-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sidebar-toggle svg {
  width: 18px;
  height: 18px;
}

/* ---------- Layout ---------- */
.layout {
  display: flex;
  flex: 1;
  min-height: calc(100vh - var(--topbar-height));
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-darker);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  padding: 1.25rem 0 3rem;
}

.sidebar-home {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 1.25rem 1.25rem;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  transition: var(--transition);
}

.sidebar-home:hover {
  border-color: var(--primary-light);
  color: var(--primary-light);
  background: rgba(37, 99, 235, 0.08);
}

.nav-chapter {
  margin-bottom: 1.5rem;
}

.nav-chapter-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 1.25rem;
  margin-bottom: 0.5rem;
}

.nav-chapter ul {
  list-style: none;
}

.nav-link {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.55rem 1.25rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  border-left: 3px solid transparent;
  transition: var(--transition);
  line-height: 1.4;
}

.nav-link .nav-num {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.nav-link:hover {
  color: var(--text-primary);
  background: rgba(148, 163, 184, 0.06);
}

.nav-link.active {
  color: var(--primary-light);
  background: rgba(37, 99, 235, 0.12);
  border-left-color: var(--primary-light);
  font-weight: 600;
}

/* ---------- Content ---------- */
.content {
  flex: 1;
  min-width: 0;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 2.75rem 2.5rem 5rem;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--accent-color);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.page-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.75rem;
  border-bottom: 2px solid var(--border-color);
}

.page-header h1 {
  font-size: 2.1rem;
  margin-bottom: 0.6rem;
  background: linear-gradient(135deg, var(--primary-light), var(--accent-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-header .subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 720px;
}

/* Hero (index page only) */
.hero {
  text-align: center;
  padding: 3.5rem 2rem;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12) 0%, rgba(6, 182, 212, 0.12) 100%);
  border-radius: 14px;
  border: 1px solid var(--border-color);
  margin-bottom: 3rem;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--primary-light), var(--accent-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 640px;
  margin: 0 auto;
}

/* ---------- Sections ---------- */
section {
  margin-bottom: 2.75rem;
}

section h2 {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary-light);
}

section h2 svg.icon {
  color: var(--primary-light);
  width: 1.15em;
  height: 1.15em;
}

section h3 {
  font-size: 1.2rem;
  margin: 1.5rem 0 0.6rem 0;
  color: var(--primary-light);
}

section p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

section ul,
section ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

section li {
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  line-height: 1.75;
}

section li strong {
  color: var(--text-primary);
}

/* ---------- Cards ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.75rem;
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

a.card:hover {
  border-color: var(--primary-light);
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.2);
  transform: translateY(-3px);
}

.card-icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: rgba(37, 99, 235, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  color: var(--accent-color);
}

.card-icon svg {
  width: 24px;
  height: 24px;
}

.card h3 {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.card p {
  color: var(--text-secondary);
  margin-bottom: 0;
  flex-grow: 1;
  font-size: 0.92rem;
}

.card-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-color);
  padding: 0.25rem 0.7rem;
  border-radius: 20px;
  font-size: 0.78rem;
  margin-top: 1rem;
  width: fit-content;
  font-weight: 600;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
}

.comparison-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}

.comparison-table th {
  background: linear-gradient(135deg, var(--primary-dark), var(--secondary-color));
  color: var(--text-primary);
  padding: 1rem 1.25rem;
  text-align: left;
  font-weight: 700;
  font-size: 0.9rem;
  border-bottom: 2px solid var(--border-color);
}

.comparison-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.9rem;
  vertical-align: top;
}

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

.comparison-table tr:hover td {
  background: rgba(37, 99, 235, 0.05);
}

.feature-yes {
  color: var(--success-color);
  font-weight: 600;
}

.feature-warn {
  color: var(--warning-color);
  font-weight: 600;
}

.feature-no {
  color: var(--text-muted);
}

/* ---------- Callouts ---------- */
.callout {
  display: flex;
  gap: 0.85rem;
  padding: 1.25rem 1.5rem;
  border-radius: 10px;
  border-left: 4px solid;
  margin: 1.5rem 0;
  background-color: rgba(255, 255, 255, 0.02);
}

.callout .callout-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 0.15rem;
}

.callout .callout-body strong {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text-primary);
}

.callout .callout-body p {
  margin-bottom: 0;
}

.callout.info { border-left-color: var(--primary-light); background-color: rgba(37, 99, 235, 0.08); }
.callout.info .callout-icon { color: var(--primary-light); }

.callout.warning { border-left-color: var(--warning-color); background-color: rgba(245, 158, 11, 0.08); }
.callout.warning .callout-icon { color: var(--warning-color); }

.callout.success { border-left-color: var(--success-color); background-color: rgba(16, 185, 129, 0.08); }
.callout.success .callout-icon { color: var(--success-color); }

.callout.danger { border-left-color: var(--danger-color); background-color: rgba(239, 68, 68, 0.08); }
.callout.danger .callout-icon { color: var(--danger-color); }

/* ---------- Code ---------- */
code {
  background: var(--bg-darker);
  color: #93c5fd;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  font-family: 'Cascadia Code', 'Courier New', monospace;
  font-size: 0.88em;
}

pre {
  background: var(--bg-darker);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.4rem 1.6rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

pre code {
  background: none;
  color: #e2e8f0;
  padding: 0;
  display: block;
  font-size: 0.85rem;
  line-height: 1.7;
}

.file-label {
  display: inline-block;
  font-family: 'Cascadia Code', 'Courier New', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* ---------- Mermaid diagrams ---------- */
.diagram-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 2.5rem 2rem;
  margin: 2rem 0;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: auto;
  min-height: 420px;
}

.diagram-container.compact {
  min-height: 300px;
}

.diagram-container .mermaid {
  width: 100%;
  display: flex;
  justify-content: center;
}

.diagram-container svg {
  min-width: 640px;
}

.diagram-caption {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: -1rem;
  margin-bottom: 2rem;
}

/* animated flow edges - "nice to have" for request-flow diagrams */
.diagram-animated .edgePath .path,
.diagram-animated path.flowchart-link {
  stroke-dasharray: 8 6;
  animation: bizfirst-dash-flow 1.1s linear infinite;
}

@keyframes bizfirst-dash-flow {
  to { stroke-dashoffset: -28; }
}

/* ---------- Checklist ---------- */
.checklist {
  list-style: none;
  margin-left: 0;
}

.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  margin-bottom: 0.75rem;
}

.checklist li svg {
  width: 20px;
  height: 20px;
  color: var(--success-color);
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.checklist li .check-body strong {
  display: block;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.checklist li .check-body p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ---------- Debug entries ---------- */
.debug-entry {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
}

.debug-entry .debug-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.6rem;
  font-size: 1.05rem;
}

.debug-entry .debug-title svg {
  width: 20px;
  height: 20px;
  color: var(--danger-color);
}

.debug-entry .debug-label {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent-color);
  margin: 0.75rem 0 0.35rem;
}

/* ---------- Prev/Next footer nav ---------- */
.page-pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border-color);
}

.pager-link {
  flex: 1;
  max-width: 48%;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-secondary);
  transition: var(--transition);
}

.pager-link:hover {
  border-color: var(--primary-light);
  color: var(--primary-light);
}

.pager-link.next {
  text-align: right;
  margin-left: auto;
}

.pager-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.pager-link.next .pager-label {
  justify-content: flex-end;
}

.pager-title {
  font-weight: 600;
  color: inherit;
  font-size: 0.95rem;
}

/* ---------- Footer ---------- */
footer.site-footer {
  background: var(--secondary-color);
  border-top: 1px solid var(--border-color);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ---------- Utility ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.kv-card {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
}

.kv-card h4 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent-color);
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
}

.kv-card h4 svg { width: 18px; height: 18px; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.badge.chapter-1 { background: rgba(37, 99, 235, 0.18); color: var(--primary-light); }
.badge.chapter-2 { background: rgba(6, 182, 212, 0.18); color: var(--accent-color); }
.badge.chapter-3 { background: rgba(16, 185, 129, 0.18); color: var(--success-color); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar-toggle {
    display: flex;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar-height);
    height: calc(100vh - var(--topbar-height));
    transform: translateX(-100%);
    z-index: 150;
    box-shadow: var(--shadow);
    transition: transform 0.25s ease;
  }

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

  .layout.sidebar-open::after {
    content: '';
    position: fixed;
    inset: var(--topbar-height) 0 0 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 140;
  }

  .container {
    padding: 2rem 1.25rem 4rem;
  }

  .page-header h1 {
    font-size: 1.7rem;
  }

  .hero h1 {
    font-size: 1.9rem;
  }

  .page-pager {
    flex-direction: column;
  }

  .pager-link {
    max-width: 100%;
  }
}
