﻿/*
 * BizFirst AI Documentation — Design System v2
 * Dark mode · Enterprise · Node Lifecycle & Expression Engine
 */

:root {
  --bg:           #0b0e1a;
  --surface:      #111425;
  --surface-2:    #181d33;
  --surface-3:    #1e2440;
  --border:       #252c4a;
  --border-light: #2e3860;

  --accent:       #6c8cff;
  --accent-dim:   rgba(108,140,255,0.10);
  --accent-2:     #a78bfa;
  --accent-2-dim: rgba(167,139,250,0.10);
  --success:      #34d399;
  --success-dim:  rgba(52,211,153,0.09);
  --warn:         #fbbf24;
  --warn-dim:     rgba(251,191,36,0.09);
  --danger:       #f87171;
  --danger-dim:   rgba(248,113,113,0.09);

  --text:         #e2e8f0;
  --text-muted:   #8892a4;
  --text-subtle:  #4e5a72;

  --code-bg:      #080b17;
  --code-text:    #a8c4ff;

  --sidebar-w:    264px;
  --topbar-h:     58px;
  --radius:       8px;
  --content-max:  900px;

  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'Cascadia Code', 'Fira Code', Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  font-size: 15px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Top Bar ──────────────────────────────────────────────────── */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  background: rgba(11,14,26,0.90);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 300;
}

.topbar-logo { height: 26px; width: auto; flex-shrink: 0; }

.topbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border-light);
  flex-shrink: 0;
}

.topbar-site {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.topbar-links { margin-left: auto; display: flex; gap: 4px; }

.topbar-links a {
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 6px;
  transition: all 0.15s;
}

.topbar-links a:hover,
.topbar-links a.current {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

.topbar-links a.current { color: var(--accent); }

/* ── Layout ───────────────────────────────────────────────────── */

.layout {
  display: flex;
  min-height: 100vh;
  padding-top: var(--topbar-h);
}

/* ── Sidebar ──────────────────────────────────────────────────── */

nav.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 32px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}

.sidebar-header {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  color: var(--text-subtle);
  margin-bottom: 3px;
}

.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.sidebar-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  color: var(--text-subtle);
  padding: 16px 18px 4px;
}

nav.sidebar a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 18px;
  font-size: 13.5px;
  color: var(--text-muted);
  transition: color 0.12s, background 0.12s;
  border-left: 2px solid transparent;
}

nav.sidebar a:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

nav.sidebar a.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-left-color: var(--accent);
}

.nav-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.55;
}

nav.sidebar a:hover .nav-icon,
nav.sidebar a.active .nav-icon { opacity: 1; }

/* ── Content ──────────────────────────────────────────────────── */

main.content {
  flex: 1;
  padding: 48px 56px 80px;
  max-width: var(--content-max);
  min-width: 0;
}

/* ── Page Header ──────────────────────────────────────────────── */

.page-header {
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.page-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--accent);
  margin-bottom: 12px;
}

.page-tag::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.page-header h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-bottom: 14px;
  background: linear-gradient(130deg, #e2e8f0 30%, #8caeff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.lead {
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.8;
  max-width: 680px;
}

/* ── Layer Badges ─────────────────────────────────────────────── */

.layer-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  margin-bottom: 14px;
}

.layer-badge.l1 { background:rgba(108,140,255,0.12); color:#7da0ff; border:1px solid rgba(108,140,255,0.22); }
.layer-badge.l2 { background:rgba(167,139,250,0.12); color:#b8a3fb; border:1px solid rgba(167,139,250,0.22); }
.layer-badge.l3 { background:rgba(52,211,153,0.12);  color:#4dd9a6; border:1px solid rgba(52,211,153,0.22);  }
.layer-badge.l4 { background:rgba(251,191,36,0.12);  color:#fbbf24; border:1px solid rgba(251,191,36,0.22);  }

/* ── Typography ───────────────────────────────────────────────── */

h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 44px 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-2);
  margin: 28px 0 10px;
}

h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin: 14px 0 6px;
}

p { color: var(--text); margin-bottom: 14px; }
ul, ol { margin: 0 0 14px 22px; }
li { margin-bottom: 6px; }
strong { font-weight: 600; }

/* ── Code ─────────────────────────────────────────────────────── */

code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--code-text);
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  overflow-x: auto;
  margin: 18px 0;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.855rem;
  color: #c5d1e8;
  line-height: 1.65;
}

/* ── Mermaid Diagrams ─────────────────────────────────────────── */

.diagram {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  margin: 20px 0;
  overflow: hidden;
}

.diagram .mermaid {
  display: flex;
  justify-content: center;
  align-items: center;
}

.mermaid svg { max-width: 100%; height: auto; }

@keyframes edgeFlow {
  to { stroke-dashoffset: -36; }
}

/* ── Cards ────────────────────────────────────────────────────── */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin: 20px 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s, transform 0.15s;
}

.card:hover { border-color: var(--border-light); transform: translateY(-1px); }

.card.c1 { border-top: 3px solid var(--accent); }
.card.c2 { border-top: 3px solid var(--accent-2); }
.card.c3 { border-top: 3px solid var(--success); }
.card.c4 { border-top: 3px solid var(--warn); }

.card h4 { margin-top: 0; margin-bottom: 8px; }
.card .card-desc { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 10px; }
.card a  { font-size: 0.85rem; }

/* ── Pipeline Steps ───────────────────────────────────────────── */

.pipeline { margin: 24px 0; }

.step {
  display: flex;
  gap: 16px;
  position: relative;
}

.step:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 16px;
  top: 36px;
  bottom: -8px;
  width: 2px;
  background: linear-gradient(to bottom, var(--border-light), transparent);
}

.step-num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 1;
  position: relative;
}

.step-num.p2 { background: var(--accent-2); }
.step-num.ok { background: var(--success); color: #0b0e1a; }
.step-num.wa { background: var(--warn); color: #0b0e1a; }

.step-body { flex: 1; padding-bottom: 28px; }
.step-body h4 { margin-top: 6px; }

/* ── Lifecycle Stage Grid ─────────────────────────────────────── */

.stages {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 10px;
  margin: 20px 0;
}

.stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  border-top-width: 3px;
  border-top-style: solid;
}

.stage.entry    { border-top-color: #60a5fa; }
.stage.validate { border-top-color: var(--accent-2); }
.stage.guard    { border-top-color: var(--warn); }
.stage.process  { border-top-color: var(--success); }
.stage.post     { border-top-color: var(--danger); }
.stage.exit     { border-top-color: #64748b; }

.stage .snum {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-subtle);
  margin-bottom: 3px;
}

.stage h4 { margin: 2px 0 6px; font-size: 0.875rem; }
.stage p  { font-size: 0.8rem; color: var(--text-muted); margin: 0; }

/* ── Callouts ─────────────────────────────────────────────────── */

.callout {
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 18px 0;
  border-left: 3px solid;
  font-size: 0.925rem;
}

.callout strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.callout.info    { background: var(--accent-dim);   border-color: var(--accent);   }
.callout.info strong    { color: var(--accent); }
.callout.warning { background: var(--warn-dim);     border-color: var(--warn);     }
.callout.warning strong { color: var(--warn); }
.callout.success { background: var(--success-dim);  border-color: var(--success);  }
.callout.success strong { color: var(--success); }
.callout.danger  { background: var(--danger-dim);   border-color: var(--danger);   }
.callout.danger strong  { color: var(--danger); }

/* ── Tables ───────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  margin: 18px 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

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

thead th {
  background: var(--surface-2);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

/* ── Page Navigation ──────────────────────────────────────────── */

.page-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  gap: 16px;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
  text-decoration: none;
}

.nav-btn svg { flex-shrink: 0; }
.spacer { flex: 1; }

/* ── Directive Cards ──────────────────────────────────────────── */

.directive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.directive {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.directive code.key {
  display: block;
  font-size: 0.9rem;
  color: var(--accent);
  margin-bottom: 6px;
  background: none;
  border: none;
  padding: 0;
}

.directive .dir-tier {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-subtle);
  margin-bottom: 4px;
}

.directive p { font-size: 0.825rem; color: var(--text-muted); margin: 0; }

/* ── Scrollbar ────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

/* Logo in sidebar */
.sidebar-logo {
  display: block;
  width: 110px;
  margin-bottom: 10px;
  background: #ffffff;
  padding: 5px 8px;
  border-radius: 6px;
}
