/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3350;
  --accent: #5b8dee;
  --accent2: #a78bfa;
  --green: #4ade80;
  --yellow: #facc15;
  --red: #f87171;
  --orange: #fb923c;
  --cyan: #22d3ee;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --code-bg: #131620;
  --radius: 8px;
  --sidebar-w: 280px;
  --header-h: 60px;
  --font-mono: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== HEADER ===== */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: rgba(15,17,23,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 100;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  text-decoration: none;
}

.logo:hover {
  text-decoration: none;
  color: var(--text);
}

.logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}

.header-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  flex: 1;
}

.header-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.75rem;
  color: var(--accent);
  white-space: nowrap;
}

/* ===== HEADER NAV LINKS ===== */
.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 16px;
}

.header-nav-link {
  padding: 5px 13px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.header-nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  text-decoration: none;
}
.header-nav-link.active {
  color: var(--accent);
  background: rgba(91, 141, 238, 0.13);
}

/* ===== LAYOUT ===== */
.layout {
  display: flex;
  padding-top: var(--header-h);
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
nav.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  z-index: 50;
}

nav.sidebar::-webkit-scrollbar { width: 4px; }
nav.sidebar::-webkit-scrollbar-track { background: transparent; }
nav.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-section-label {
  padding: 8px 20px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 8px;
}

nav.sidebar a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 20px;
  color: var(--text-muted);
  font-size: 0.875rem;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

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

nav.sidebar a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(91,141,238,0.08);
}

nav.sidebar a .nav-icon { font-size: 0.9rem; width: 18px; text-align: center; }

/* ===== MAIN CONTENT ===== */
main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 48px 48px 80px;
  max-width: calc(900px + var(--sidebar-w));
  min-width: 0;
}

/* ===== HERO ===== */
.hero {
  background: linear-gradient(135deg, rgba(91,141,238,0.12), rgba(167,139,250,0.08));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px;
  margin-bottom: 56px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(91,141,238,0.15), transparent 70%);
  pointer-events: none;
}

.hero h1 {
  font-size: 2.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text) 40%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
  line-height: 1.2;
}

.hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 560px;
  margin-bottom: 24px;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ===== SECTIONS ===== */
.section {
  margin-bottom: 64px;
  scroll-margin-top: calc(var(--header-h) + 20px);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.section-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.section-icon.blue { background: rgba(91,141,238,0.15); }
.section-icon.purple { background: rgba(167,139,250,0.15); }
.section-icon.green { background: rgba(74,222,128,0.15); }
.section-icon.yellow { background: rgba(250,204,21,0.15); }
.section-icon.red { background: rgba(248,113,113,0.15); }
.section-icon.orange { background: rgba(251,146,60,0.15); }
.section-icon.cyan { background: rgba(34,211,238,0.15); }
.section-icon.pink { background: rgba(236,72,153,0.15); }
.section-icon.teal { background: rgba(45,212,191,0.15); }

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.section p { color: var(--text-muted); margin-bottom: 16px; max-width: 720px; }
.section p strong { color: var(--text); }

/* ===== CODE BLOCKS ===== */
.code-block {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 16px 0;
  overflow: hidden;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.code-block-header .lang-badge {
  background: rgba(91,141,238,0.15);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.copy-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.15s;
}

.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-btn.copied { border-color: var(--green); color: var(--green); }

pre {
  padding: 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.75;
}

/* Syntax highlight tokens */
.kw { color: #c792ea; font-weight: 600; }   /* keywords */
.ty { color: #ffcb6b; }                      /* types */
.cm { color: #546e7a; font-style: italic; }  /* comments */
.st { color: #c3e88d; }                      /* strings */
.nu { color: #f78c6c; }                      /* numbers */
.op { color: #89ddff; }                      /* operators */
.fn { color: #82aaff; }                      /* functions/procedures */
.id { color: var(--text); }                  /* identifiers */
.co { color: #80cbc4; }                      /* constants */

/* ===== TABLES ===== */
.table-wrapper { overflow-x: auto; margin: 16px 0; }

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

th {
  background: var(--surface2);
  color: var(--text);
  font-weight: 600;
  padding: 10px 14px;
  text-align: left;
  border: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 9px 14px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  vertical-align: top;
}

td:first-child { color: var(--text); font-family: var(--font-mono); font-size: 0.82rem; }

tr:hover td { background: rgba(255,255,255,0.02); }

/* ===== CALLOUT ===== */
.callout {
  border-left: 3px solid var(--accent);
  background: rgba(91,141,238,0.07);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px;
  margin: 16px 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.callout.warning {
  border-left-color: var(--yellow);
  background: rgba(250,204,21,0.06);
}

.callout.tip {
  border-left-color: var(--green);
  background: rgba(74,222,128,0.06);
}

.callout strong { color: var(--text); display: block; margin-bottom: 4px; }

/* ===== CARDS GRID ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

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

.card:hover { border-color: var(--accent); }

.card-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.card-body {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ===== INLINE CODE ===== */
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--cyan);
}

/* ===== HEADINGS inside sections ===== */
.section h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin: 28px 0 10px;
}

/* ===== FOOTER ===== */
footer {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-left: var(--sidebar-w);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  nav.sidebar { display: none; }
  main { margin-left: 0; padding: 24px 20px 60px; }
  footer { margin-left: 0; }
  .hero { padding: 28px 24px; }
  .hero h1 { font-size: 1.7rem; }
}
