/* ============================================================
   FraudShield AI Engine — Documentation Stylesheet
   Audience: Fraud Operations, Data Science, Compliance, IT
   Style: Enterprise documentation portal (MadCap Flare-inspired)
   ============================================================ */

:root {
  --primary:       #1a3a5c;
  --primary-dark:  #0f2540;
  --accent:        #1d4ed8;
  --accent-light:  #eff6ff;
  --warning:       #92400e;
  --warning-bg:    #fffbeb;
  --warning-border:#f59e0b;
  --success:       #166534;
  --success-bg:    #f0fdf4;
  --danger:        #991b1b;
  --danger-bg:     #fef2f2;
  --danger-border: #fca5a5;
  --risk-low:      #166534;
  --risk-low-bg:   #dcfce7;
  --risk-med:      #92400e;
  --risk-med-bg:   #fef3c7;
  --risk-high:     #991b1b;
  --risk-high-bg:  #fee2e2;
  --risk-critical: #6b21a8;
  --risk-critical-bg: #f3e8ff;
  --text:          #1e293b;
  --text-secondary:#475569;
  --text-muted:    #94a3b8;
  --border:        #cbd5e1;
  --border-light:  #e2e8f0;
  --bg:            #f8fafc;
  --bg-card:       #ffffff;
  --code-bg:       #1e293b;
  --code-text:     #e2e8f0;
  --nav-width:     268px;
  --header-h:      56px;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
}

/* ── HEADER ── */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--primary-dark);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1.5rem;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
}
.header-brand {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #e2e8f0;
  text-decoration: none;
  white-space: nowrap;
}
.header-brand span { color: #7dd3fc; }
.header-breadcrumb {
  font-size: 0.8rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.header-breadcrumb a { color: #93c5fd; text-decoration: none; }
.header-breadcrumb a:hover { text-decoration: underline; }
.header-badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.1);
  color: #bfdbfe;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
}

/* ── SIDEBAR NAV ── */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--nav-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1.5rem 0 2rem;
  z-index: 90;
}
.nav-section {
  padding: 0.25rem 1rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 1.25rem;
}
.nav-section:first-child { margin-top: 0; }
.sidebar a {
  display: block;
  padding: 0.38rem 1rem 0.38rem 1.25rem;
  font-size: 0.84rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.sidebar a:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-left-color: var(--accent);
}
.sidebar a.active {
  background: var(--accent-light);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* ── MAIN CONTENT ── */
.main {
  margin-left: var(--nav-width);
  margin-top: var(--header-h);
  padding: 2.5rem 3rem;
  max-width: 1000px;
}

/* ── TYPOGRAPHY ── */
h1 {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.25;
  margin-bottom: 0.5rem;
}
h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--border-light);
}
h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
}
h4 {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-top: 1.25rem;
  margin-bottom: 0.4rem;
}
p { margin-bottom: 0.9rem; color: var(--text); }
p:last-child { margin-bottom: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

ul, ol {
  margin-left: 1.5rem;
  margin-bottom: 0.9rem;
}
li { margin-bottom: 0.3rem; }

.topic-meta {
  display: flex;
  gap: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}
.topic-meta span::before {
  content: '· ';
  margin-right: 0.1rem;
}
.topic-meta span:first-child::before { content: ''; }

/* ── ADMONITIONS ── */
.note, .warning, .caution, .tip {
  border-left: 4px solid;
  border-radius: 0 6px 6px 0;
  padding: 0.9rem 1.1rem;
  margin: 1.25rem 0;
  font-size: 0.88rem;
}
.note {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--primary);
}
.note strong { color: var(--accent); }
.warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning);
}
.warning strong { color: var(--warning); }
.caution {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}
.caution strong { color: var(--danger); }
.tip {
  background: var(--success-bg);
  border-color: #22c55e;
  color: var(--success);
}
.tip strong { color: var(--success); }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; margin: 1.25rem 0; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
thead th {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  padding: 0.6rem 0.9rem;
  text-align: left;
  white-space: nowrap;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
tbody tr:nth-child(odd)  { background: var(--bg); }
tbody tr:nth-child(even) { background: var(--bg-card); }
tbody tr:hover           { background: var(--accent-light); }
td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}
td code, th code {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.8rem;
  font-family: 'Cascadia Code', 'Consolas', monospace;
}

/* ── CODE BLOCKS ── */
.code-block {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin: 1.25rem 0;
  overflow-x: auto;
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.82rem;
  line-height: 1.6;
}
.code-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.c-key   { color: #93c5fd; }
.c-str   { color: #86efac; }
.c-num   { color: #fdba74; }
.c-cmt   { color: #64748b; }
.c-verb  { color: #f0abfc; font-weight: 700; }
.c-url   { color: #fde68a; }

/* ── OVERVIEW CARDS ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.1rem;
  text-decoration: none;
  display: block;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
}
.card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  border-color: var(--accent);
  transform: translateY(-1px);
  text-decoration: none;
}
.card-icon {
  font-size: 1.75rem;
  margin-bottom: 0.6rem;
  line-height: 1;
}
.card-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.4rem;
}
.card-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── SCORE BADGES ── */
.score-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.badge-low      { background: var(--risk-low-bg);      color: var(--risk-low); }
.badge-medium   { background: var(--risk-med-bg);      color: var(--risk-med); }
.badge-high     { background: var(--risk-high-bg);     color: var(--risk-high); }
.badge-critical { background: var(--risk-critical-bg); color: var(--risk-critical); }
.badge-info     { background: var(--accent-light);     color: var(--accent); }
.badge-neutral  { background: var(--border-light);     color: var(--text-secondary); }

/* ── STEP LIST ── */
.steps { list-style: none; margin-left: 0; padding: 0; counter-reset: steps; }
.steps li {
  counter-increment: steps;
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}
.steps li:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.steps li::before {
  content: counter(steps);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 700;
  margin-top: 0.15rem;
}
.step-body strong { display: block; margin-bottom: 0.2rem; font-size: 0.92rem; }
.step-body p      { font-size: 0.86rem; color: var(--text-secondary); margin: 0; }

/* ── DEFINITION LIST ── */
dl { margin-bottom: 0.9rem; }
dt { font-weight: 700; font-size: 0.88rem; margin-top: 0.85rem; color: var(--text); }
dd { font-size: 0.86rem; color: var(--text-secondary); margin-left: 1.25rem; }

/* ── ARCHITECTURE DIAGRAM ── */
.arch-diagram {
  background: var(--primary-dark);
  color: #e2e8f0;
  border-radius: 10px;
  padding: 1.5rem 2rem;
  margin: 1.5rem 0;
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.78rem;
  line-height: 1.7;
  overflow-x: auto;
}
.arch-diagram .arch-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #7dd3fc;
  margin-bottom: 0.75rem;
}

/* ── ENDPOINT BLOCK ── */
.endpoint {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 1.25rem 0;
  overflow: hidden;
}
.endpoint-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.method {
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
}
.method-post { background: #dcfce7; color: #166534; }
.method-get  { background: #dbeafe; color: #1e40af; }
.endpoint-path {
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.84rem;
  color: var(--text);
  font-weight: 600;
}
.endpoint-desc {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.endpoint-body { padding: 1rem 1.1rem; }
.endpoint-body p { font-size: 0.86rem; margin-bottom: 0.5rem; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 1.5rem; }
  .card-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .card-grid { grid-template-columns: 1fr; }
  .main { padding: 1rem; }
}

/* ═══════════════════════════════════════════════
   DARK THEME — FraudShield AI Engine
   ═══════════════════════════════════════════════ */
[data-theme="dark"] {
  --primary:          #90caf9;
  --primary-dark:     #0f2540;
  --accent:           #58a6ff;
  --accent-light:     rgba(88,166,255,0.12);
  --warning:          #fbbf24;
  --warning-bg:       rgba(251,191,36,0.12);
  --warning-border:   #f59e0b;
  --success:          #4ade80;
  --success-bg:       rgba(74,222,128,0.12);
  --danger:           #f87171;
  --danger-bg:        rgba(248,113,113,0.12);
  --danger-border:    #ef4444;
  --risk-low:         #4ade80;
  --risk-low-bg:      rgba(22,101,52,0.25);
  --risk-med:         #fbbf24;
  --risk-med-bg:      rgba(146,64,14,0.25);
  --risk-high:        #f87171;
  --risk-high-bg:     rgba(153,27,27,0.25);
  --risk-critical:    #d8b4fe;
  --risk-critical-bg: rgba(107,33,168,0.25);
  --text:             #e6edf3;
  --text-secondary:   #8b949e;
  --text-muted:       #6e7681;
  --border:           #30363d;
  --border-light:     #21262d;
  --bg:               #0d1117;
  --bg-card:          #161b22;
  --code-bg:          #0d1117;
  --code-text:        #e6edf3;
}
[data-theme="dark"] body { background: var(--bg); color: var(--text); }
[data-theme="dark"] .sidebar { background: var(--bg-card); border-right-color: var(--border); }
[data-theme="dark"] .sidebar a:hover,
[data-theme="dark"] .sidebar a.active { background: var(--accent-light); color: var(--accent); }

/* Theme toggle */
.theme-toggle {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #bfdbfe;
  cursor: pointer;
  border-radius: 5px;
  padding: 3px 9px;
  font-size: 13px;
  line-height: 1.5;
  margin-left: auto;
  transition: background 0.2s;
  white-space: nowrap;
}
.theme-toggle:hover { background: rgba(255,255,255,0.18); }


/* Footer */
.doc-footer {
  margin-top: 3rem;
  padding: 1.25rem 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: space-between;
  align-items: center;
}
.doc-footer a { color: var(--accent); text-decoration: none; }
.doc-footer a:hover { text-decoration: underline; }
