/* ══════════════════════════════════════════════
   Investra Documentation – Design System
   ══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Variables ──────────────────────────── */
:root {
  --brand-50: #eefdf7;
  --brand-100: #d7faed;
  --brand-500: #19b982;
  --brand-600: #10986c;
  --brand-700: #0e7959;
  --brand-900: #064536;
  --ink: #17202a;
  --stone-50: #fafaf9;
  --stone-100: #f5f5f4;
  --stone-200: #e7e5e4;
  --stone-300: #d6d3d1;
  --stone-400: #a8a29e;
  --stone-500: #78716c;
  --stone-600: #57534e;
  --stone-700: #44403c;
  --stone-800: #292524;
  --stone-900: #1c1917;
  --slate-200: #e2e8f0;
  --slate-600: #475569;
  --sidebar-w: 280px;
  --header-h: 57px;
}

/* ── Reset & Base ───────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 1.5rem); }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--stone-50);
  color: var(--stone-800);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── Header ─────────────────────────────────── */
.doc-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--stone-200);
  height: var(--header-h);
}
.doc-header-inner {
  max-width: 1440px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem; height: 100%; gap: 1rem;
}
.doc-header-logo { display: flex; align-items: center; gap: .75rem; text-decoration: none; }
.doc-header-logo img { height: 36px; width: auto; }
.doc-header-logo span { font-size: .8125rem; font-weight: 600; color: var(--stone-500); }
.doc-header-links { display: flex; align-items: center; gap: .25rem; }
.doc-header-links a {
  font-size: .8125rem; font-weight: 500; color: var(--stone-600);
  padding: .5rem .75rem; border-radius: .375rem; text-decoration: none;
  transition: background .15s, color .15s;
}
.doc-header-links a:hover { background: var(--stone-100); color: var(--stone-900); }

/* ── Sidebar Toggle ─────────────────────────── */
.sidebar-toggle {
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: .375rem;
  border: 1px solid var(--stone-200); background: #fff;
  color: var(--stone-700); cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.sidebar-toggle:hover { background: var(--stone-100); }
.sidebar-toggle svg { width: 20px; height: 20px; }

/* ── Layout ─────────────────────────────────── */
.doc-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  max-width: 1440px; margin: 0 auto;
  min-height: calc(100vh - var(--header-h));
}

/* ── Sidebar ────────────────────────────────── */
.doc-sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto; overflow-x: hidden;
  border-right: 1px solid var(--stone-200);
  background: #fff;
  padding: 1rem 0;
  font-size: .8125rem;
  scrollbar-width: thin;
  scrollbar-color: var(--stone-300) transparent;
}
.doc-sidebar::-webkit-scrollbar { width: 5px; }
.doc-sidebar::-webkit-scrollbar-thumb { background: var(--stone-300); border-radius: 3px; }

.sidebar-section { margin-bottom: .25rem; }
.sidebar-heading {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem 1rem; font-weight: 700; font-size: .6875rem;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--stone-500); cursor: pointer; user-select: none;
  transition: color .15s;
}
.sidebar-heading:hover { color: var(--stone-800); }
.sidebar-heading.active { color: var(--brand-700); }
.sidebar-heading svg {
  width: 14px; height: 14px; transition: transform .2s;
  flex-shrink: 0;
}
.sidebar-heading.collapsed svg { transform: rotate(-90deg); }
.sidebar-items { list-style: none; }
.sidebar-heading.collapsed + .sidebar-items { display: none; }
.sidebar-items a {
  display: block; padding: .375rem 1rem .375rem 1.5rem;
  color: var(--stone-600); text-decoration: none;
  font-weight: 500; border-left: 2px solid transparent;
  transition: all .15s;
}
.sidebar-items a:hover { color: var(--stone-900); background: var(--stone-50); }
.sidebar-items a.active {
  color: var(--brand-700); background: var(--brand-50);
  border-left-color: var(--brand-600); font-weight: 600;
}

/* ── Main Content ───────────────────────────── */
.doc-content {
  padding: 2rem 2.5rem 4rem;
  max-width: 900px; min-width: 0;
}

/* ── Breadcrumb ─────────────────────────────── */
.breadcrumb {
  display: flex; align-items: center; gap: .375rem; flex-wrap: wrap;
  font-size: .75rem; color: var(--stone-500); margin-bottom: 1.5rem;
}
.breadcrumb a { color: var(--stone-500); text-decoration: none; font-weight: 500; }
.breadcrumb a:hover { color: var(--brand-600); }
.breadcrumb .sep { color: var(--stone-400); }

/* ── Typography ─────────────────────────────── */
.doc-content h1 {
  font-size: 2rem; font-weight: 800; color: var(--ink);
  margin-bottom: 1rem; line-height: 1.25;
}
.doc-content h2 {
  font-size: 1.5rem; font-weight: 700; color: var(--ink);
  margin-top: 2.5rem; margin-bottom: .75rem; line-height: 1.3;
  padding-bottom: .5rem; border-bottom: 1px solid var(--stone-200);
}
.doc-content h3 {
  font-size: 1.125rem; font-weight: 700; color: var(--ink);
  margin-top: 2rem; margin-bottom: .5rem;
}
.doc-content h4 {
  font-size: 1rem; font-weight: 600; color: var(--stone-800);
  margin-top: 1.5rem; margin-bottom: .5rem;
}
.doc-content p { margin-bottom: 1rem; color: var(--stone-700); line-height: 1.75; }
.doc-content a { color: var(--brand-600); text-decoration: underline; text-underline-offset: 2px; }
.doc-content a:hover { color: var(--brand-700); }
.doc-content strong { font-weight: 600; color: var(--stone-900); }
.doc-content ul, .doc-content ol { margin-bottom: 1rem; padding-left: 1.5rem; color: var(--stone-700); }
.doc-content li { margin-bottom: .375rem; line-height: 1.6; }
.doc-content li::marker { color: var(--stone-400); }
.doc-content hr { border: none; border-top: 1px solid var(--stone-200); margin: 2rem 0; }
.doc-content img {
  max-width: 100%; height: auto; border-radius: .5rem;
  border: 1px solid var(--stone-200); margin: 1rem 0;
  box-shadow: 0 1px 3px rgba(28,25,23,.06), 0 8px 20px rgba(28,25,23,.04);
}
.doc-content code {
  font-family: 'JetBrains Mono', monospace; font-size: .8125em;
  background: var(--stone-100); color: var(--stone-900);
  padding: .125rem .375rem; border-radius: .25rem;
  border: 1px solid var(--stone-200);
}
.doc-content pre {
  position: relative; margin: 1rem 0;
  border-radius: .5rem; border: 1px solid var(--stone-200);
  background: var(--stone-900); overflow-x: auto;
}
.doc-content pre code {
  display: block; padding: 1rem 1.25rem;
  background: transparent; border: none;
  color: #e2e8f0; font-size: .8125rem; line-height: 1.7;
  white-space: pre; overflow-wrap: normal; word-break: normal;
}

/* ── Copy Button ────────────────────────────── */
.copy-btn {
  position: absolute; top: .5rem; right: .5rem;
  display: inline-flex; align-items: center; justify-content: center;
  padding: .375rem .625rem; font-size: .6875rem; font-weight: 700;
  font-family: 'Inter', sans-serif;
  color: #94a3b8; background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12); border-radius: .25rem;
  cursor: pointer; transition: all .15s;
}
.copy-btn:hover { color: #fff; background: rgba(255,255,255,.15); }

/* ── Tables ─────────────────────────────────── */
.doc-content table {
  width: 100%; border-collapse: collapse; margin: 1rem 0;
  font-size: .875rem; border: 1px solid var(--stone-200);
  border-radius: .5rem; overflow: hidden;
}
.doc-content th {
  background: var(--stone-100); font-weight: 600; color: var(--stone-800);
  padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--stone-200);
}
.doc-content td {
  padding: .75rem 1rem; color: var(--stone-700);
  border-bottom: 1px solid var(--stone-200);
}
.doc-content tr:last-child td { border-bottom: none; }
.doc-content tr:nth-child(even) td { background: var(--stone-50); }

/* ── Callouts ───────────────────────────────── */
.callout {
  border-radius: .5rem; padding: 1rem 1.25rem;
  margin: 1.25rem 0; border-left: 4px solid;
  font-size: .875rem; line-height: 1.6;
}
.callout-title { font-weight: 700; margin-bottom: .375rem; display: flex; align-items: center; gap: .5rem; }
.callout p { margin-bottom: .5rem; }
.callout p:last-child { margin-bottom: 0; }
.callout-note { background: #eff6ff; border-color: #3b82f6; color: #1e3a5f; }
.callout-tip { background: #f0fdf4; border-color: #22c55e; color: #14532d; }
.callout-important { background: #fefce8; border-color: #eab308; color: #713f12; }
.callout-warning { background: #fff7ed; border-color: #f97316; color: #7c2d12; }
.callout-danger { background: #fef2f2; border-color: #ef4444; color: #7f1d1d; }

/* ── Image Grid ─────────────────────────────── */
.img-grid { display: grid; gap: 1rem; margin: 1rem 0; }
.img-grid-2 { grid-template-columns: repeat(2, 1fr); }
.img-grid-3 { grid-template-columns: repeat(3, 1fr); }

/* ── Step Cards ─────────────────────────────── */
.step-card {
  display: grid; grid-template-columns: 48px 1fr; gap: 1.25rem;
  border: 1px solid var(--stone-300); border-radius: .5rem;
  background: #fff; padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(28,25,23,.06), 0 8px 20px rgba(28,25,23,.04);
  margin-bottom: 1rem;
}
.step-number {
  display: flex; width: 3rem; height: 3rem;
  align-items: center; justify-content: center;
  border-radius: .375rem;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  color: #fff; font-size: 1.125rem; font-weight: 700;
}
.step-title { font-size: 1.125rem; font-weight: 700; color: var(--ink); }
.step-text { margin-top: .5rem; color: var(--stone-700); font-size: .875rem; line-height: 1.5; }

/* ── Checklist ──────────────────────────────── */
.check-item {
  display: flex; align-items: flex-start; gap: .75rem;
  border: 1px solid var(--stone-300); border-radius: .5rem;
  background: #fff; padding: 1rem; margin-bottom: .5rem;
  color: var(--stone-800); font-size: .875rem; font-weight: 600; line-height: 1.5;
  box-shadow: 0 1px 3px rgba(28,25,23,.06);
}
.check-item input { margin-top: .25rem; width: 1rem; height: 1rem; accent-color: var(--brand-600); }

/* ── Prev/Next Navigation ───────────────────── */
.doc-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
  margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--stone-200);
}
.doc-nav a {
  display: flex; flex-direction: column; gap: .25rem;
  padding: 1rem 1.25rem; border-radius: .5rem;
  border: 1px solid var(--stone-200); background: #fff;
  text-decoration: none; transition: all .15s;
  box-shadow: 0 1px 3px rgba(28,25,23,.04);
}
.doc-nav a:hover { border-color: var(--brand-500); box-shadow: 0 0 0 2px rgba(25,185,130,.15); }
.doc-nav-label { font-size: .6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--stone-500); }
.doc-nav-title { font-size: .9375rem; font-weight: 600; color: var(--brand-700); }
.doc-nav-next { text-align: right; }

/* ── Footer ─────────────────────────────────── */
.doc-footer {
  border-top: 1px solid var(--stone-200); background: #fff;
  padding: 1.5rem 1rem; text-align: center;
  font-size: .8125rem; color: var(--stone-500);
}

/* ── Mobile overlay ─────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 40;
  background: rgba(0,0,0,.4);
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 1024px) {
  .doc-header-links { display: none; }
  .sidebar-toggle { display: inline-flex; }
  .doc-layout { grid-template-columns: 1fr; }
  .doc-sidebar {
    position: fixed; left: 0; top: var(--header-h); z-index: 45;
    transform: translateX(-100%); transition: transform .25s ease;
    width: var(--sidebar-w); box-shadow: 4px 0 16px rgba(0,0,0,.1);
  }
  .doc-sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .doc-content { padding: 1.5rem 1rem 3rem; }
}
@media (max-width: 640px) {
  .doc-content h1 { font-size: 1.5rem; }
  .doc-content h2 { font-size: 1.25rem; }
  .img-grid-2, .img-grid-3 { grid-template-columns: 1fr; }
  .step-card { grid-template-columns: 1fr; }
  .doc-nav { grid-template-columns: 1fr; }
}
