/* ============================================
   AI Algo Hub - Design System
   ============================================ */

:root {
  /* Colors - Dark Theme (default) */
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-tertiary: #1e293b;
  --bg-card: #162032;
  --bg-code: #0d1117;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-1: #6366f1;      /* Indigo */
  --accent-2: #8b5cf6;      /* Purple */
  --accent-3: #06b6d4;      /* Cyan */
  --accent-4: #10b981;      /* Emerald */
  --accent-5: #f59e0b;      /* Amber */
  --accent-6: #ef4444;      /* Red */
  --gradient-1: linear-gradient(135deg, #6366f1, #8b5cf6);
  --gradient-2: linear-gradient(135deg, #06b6d4, #10b981);
  --gradient-3: linear-gradient(135deg, #f59e0b, #ef4444);
  --gradient-hero: linear-gradient(135deg, #6366f1 0%, #8b5cf6 30%, #06b6d4 70%, #10b981 100%);
  --border-color: #1e293b;
  --border-hover: #334155;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --transition: 200ms ease;
  --max-width: 1400px;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-code: #f8f9fc;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

/* ============ Reset & Base ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-3); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-1); }
img { max-width: 100%; display: block; }
code { font-family: var(--font-mono); font-size: 0.9em; }

/* ============ Layout ============ */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }
.content-layout { display: grid; grid-template-columns: 260px 1fr; gap: 32px; padding-top: 32px; padding-bottom: 64px; }
@media (max-width: 900px) {
  .content-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.open { display: block; position: fixed; top: 60px; left: 0; right: 0; bottom: 0; z-index: 100; background: var(--bg-secondary); overflow-y: auto; padding: 16px; }
}

/* ============ Navbar ============ */
.navbar {
  position: sticky; top: 0; z-index: 200;
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  height: 64px;
}
[data-theme="light"] .navbar { background: rgba(248, 250, 252, 0.9); }
.navbar .container { display: flex; align-items: center; height: 100%; gap: 24px; }
.navbar-brand {
  font-size: 1.25rem; font-weight: 800; color: var(--text-primary);
  display: flex; align-items: center; gap: 10px; white-space: nowrap;
}
.logo-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--gradient-1); color: white;
  font-size: 1.1rem; font-weight: 800;
}
.navbar-links {
  display: flex; list-style: none; gap: 4px; margin-left: auto;
}
.navbar-links a {
  padding: 8px 14px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 0.875rem; font-weight: 500;
  transition: all var(--transition);
}
.navbar-links a:hover, .navbar-links a.active {
  color: var(--text-primary); background: var(--bg-tertiary);
}
.navbar-actions { display: flex; align-items: center; gap: 12px; }
.search-box { position: relative; }
.search-box input {
  background: var(--bg-tertiary); border: 1px solid var(--border-color);
  color: var(--text-primary); padding: 8px 16px; border-radius: var(--radius-md);
  font-size: 0.85rem; width: 220px; outline: none;
  transition: all var(--transition);
}
.search-box input:focus { border-color: var(--accent-1); width: 300px; }
.search-box input::placeholder { color: var(--text-muted); }
.search-results {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); margin-top: 4px;
  display: none; max-height: 400px; overflow-y: auto; z-index: 300;
  box-shadow: var(--shadow-lg);
}
.search-results.active { display: block; }
.search-result-item {
  padding: 10px 16px; cursor: pointer; border-bottom: 1px solid var(--border-color);
  transition: background var(--transition);
}
.search-result-item:hover { background: var(--bg-tertiary); }
.search-result-item .title { font-weight: 600; font-size: 0.9rem; }
.search-result-item .category { font-size: 0.75rem; color: var(--text-muted); }
.theme-toggle, .nav-toggle {
  background: var(--bg-tertiary); border: 1px solid var(--border-color);
  color: var(--text-primary); padding: 8px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 1rem; transition: all var(--transition);
}
.theme-toggle:hover, .nav-toggle:hover { border-color: var(--accent-1); }
.nav-toggle { display: none; }
@media (max-width: 900px) {
  .navbar-links { display: none; }
  .navbar-links.open { display: flex; flex-direction: column; position: absolute; top: 64px; left: 0; right: 0; background: var(--bg-secondary); padding: 16px; border-bottom: 1px solid var(--border-color); }
  .nav-toggle { display: block; }
  .search-box input { width: 140px; }
  .search-box input:focus { width: 200px; }
}

/* ============ Sidebar ============ */
.sidebar { position: sticky; top: 96px; height: fit-content; max-height: calc(100vh - 96px); overflow-y: auto; }
.sidebar-section { margin-bottom: 24px; }
.sidebar-title {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); padding: 8px 12px;
}
.sidebar-links { list-style: none; }
.sidebar-links a {
  display: block; padding: 6px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 0.85rem; transition: all var(--transition);
  border-left: 2px solid transparent;
}
.sidebar-links a:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.sidebar-links a.active { color: var(--accent-1); border-left-color: var(--accent-1); background: rgba(99,102,241,0.08); }

/* ============ Hero Section ============ */
.hero {
  padding: 80px 0 60px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; top: -50%; left: -50%; right: -50%; bottom: -50%;
  background: radial-gradient(ellipse at center, rgba(99,102,241,0.12) 0%, transparent 70%);
  pointer-events: none;
}
.hero-badge {
  display: inline-block; padding: 6px 16px;
  background: rgba(99,102,241,0.15); border: 1px solid rgba(99,102,241,0.3);
  border-radius: 100px; font-size: 0.8rem; color: var(--accent-1);
  font-weight: 600; margin-bottom: 20px;
}
.hero h1 {
  font-size: clamp(2.5rem, 5vw, 4rem); font-weight: 800; line-height: 1.1;
  margin-bottom: 16px; position: relative;
}
.hero h1 .gradient-text {
  background: var(--gradient-hero); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}
.hero p {
  font-size: 1.15rem; color: var(--text-secondary); max-width: 640px;
  margin: 0 auto 32px; line-height: 1.7; position: relative;
}
.hero-stats {
  display: flex; justify-content: center; gap: 48px;
  padding: 24px 0; position: relative;
}
.hero-stat { text-align: center; }
.hero-stat .number {
  display: block; font-size: 2rem; font-weight: 800;
  background: var(--gradient-1); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}
.hero-stat .label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.hero-actions { display: flex; justify-content: center; gap: 16px; margin-top: 24px; position: relative; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 28px; border-radius: var(--radius-md);
  font-weight: 600; font-size: 0.95rem; cursor: pointer;
  border: none; transition: all var(--transition);
}
.btn-primary { background: var(--gradient-1); color: white; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(99,102,241,0.4); color: white; }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { border-color: var(--accent-1); transform: translateY(-2px); }

/* ============ Category Cards ============ */
.categories-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px; margin: 40px 0;
}
.category-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 28px;
  transition: all 0.3s ease; position: relative; overflow: hidden;
}
.category-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.category-card:nth-child(1)::before { background: var(--gradient-1); }
.category-card:nth-child(2)::before { background: var(--gradient-2); }
.category-card:nth-child(3)::before { background: var(--gradient-3); }
.category-card:nth-child(4)::before { background: linear-gradient(135deg, var(--accent-2), var(--accent-6)); }
.category-card:nth-child(5)::before { background: linear-gradient(135deg, var(--accent-4), var(--accent-3)); }
.category-card:nth-child(6)::before { background: linear-gradient(135deg, var(--accent-5), var(--accent-2)); }
.category-card:hover {
  transform: translateY(-4px); border-color: var(--border-hover);
  box-shadow: var(--shadow-lg);
}
.category-icon { font-size: 2rem; margin-bottom: 12px; }
.category-card h3 { font-size: 1.15rem; margin-bottom: 8px; font-weight: 700; }
.category-card p { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 16px; line-height: 1.6; }
.category-count {
  font-size: 0.75rem; color: var(--text-muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* ============ Article Content ============ */
.article { max-width: 900px; }
.article-header { margin-bottom: 32px; padding-bottom: 20px; border-bottom: 1px solid var(--border-color); }
.article-header h1 { font-size: 2rem; font-weight: 800; margin-bottom: 12px; }
.article-meta { display: flex; gap: 16px; flex-wrap: wrap; }
.article-meta span { font-size: 0.8rem; color: var(--text-muted); padding: 4px 10px; background: var(--bg-tertiary); border-radius: var(--radius-sm); }
.article-body article { margin-bottom: 48px; padding-bottom: 32px; border-bottom: 1px solid var(--border-color); }
.article-body h2 { font-size: 1.6rem; font-weight: 700; margin-bottom: 16px; padding-top: 16px; }
.article-body h3 { font-size: 1.15rem; font-weight: 600; margin: 24px 0 12px; color: var(--accent-3); }
.article-body p { margin-bottom: 16px; color: var(--text-secondary); }
.article-body ul, .article-body ol { margin: 12px 0 20px 20px; color: var(--text-secondary); }
.article-body li { margin-bottom: 6px; }
.article-body li strong { color: var(--text-primary); }
.article-body code {
  background: var(--bg-code); padding: 2px 6px; border-radius: 4px;
  font-size: 0.85em; color: var(--accent-3);
}

/* ============ Code Blocks ============ */
pre {
  background: var(--bg-code); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 20px;
  overflow-x: auto; margin: 16px 0 24px; position: relative;
}
pre code { background: none; padding: 0; color: var(--text-primary); font-size: 0.85rem; line-height: 1.6; }

/* ============ Callouts ============ */
.callout {
  border-radius: var(--radius-md); padding: 16px 20px;
  margin: 20px 0; border-left: 4px solid;
}
.callout-title { font-weight: 700; font-size: 0.85rem; margin-bottom: 6px; }
.callout-tip { background: rgba(16,185,129,0.08); border-color: var(--accent-4); }
.callout-tip .callout-title { color: var(--accent-4); }
.callout-warning { background: rgba(245,158,11,0.08); border-color: var(--accent-5); }
.callout-warning .callout-title { color: var(--accent-5); }
.callout-info { background: rgba(99,102,241,0.08); border-color: var(--accent-1); }
.callout-info .callout-title { color: var(--accent-1); }
.callout-danger { background: rgba(239,68,68,0.08); border-color: var(--accent-6); }
.callout-danger .callout-title { color: var(--accent-6); }

/* ============ Algorithm Cards ============ */
.algo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px; margin: 24px 0;
}
.algo-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 20px;
  transition: all 0.3s ease; cursor: pointer;
}
.algo-card:hover { transform: translateY(-3px); border-color: var(--accent-1); box-shadow: var(--shadow-md); }
.algo-card .algo-type {
  display: inline-block; font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 3px 8px; border-radius: 4px; margin-bottom: 8px;
}
.algo-card .algo-type.supervised { background: rgba(99,102,241,0.15); color: var(--accent-1); }
.algo-card .algo-type.unsupervised { background: rgba(16,185,129,0.15); color: var(--accent-4); }
.algo-card .algo-type.deep-learning { background: rgba(139,92,246,0.15); color: var(--accent-2); }
.algo-card .algo-type.reinforcement { background: rgba(245,158,11,0.15); color: var(--accent-5); }
.algo-card .algo-type.nlp { background: rgba(6,182,212,0.15); color: var(--accent-3); }
.algo-card .algo-type.generative { background: rgba(239,68,68,0.15); color: var(--accent-6); }
.algo-card h4 { font-size: 1rem; margin-bottom: 6px; }
.algo-card .algo-desc { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 10px; }
.algo-card .algo-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.algo-card .algo-tag {
  font-size: 0.7rem; padding: 2px 8px; border-radius: 100px;
  background: var(--bg-tertiary); color: var(--text-muted);
}

/* ============ Decision Flowchart ============ */
.flowchart {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 32px;
  margin: 32px 0;
}
.flowchart h3 { margin-bottom: 20px; text-align: center; }
.flow-steps {
  display: flex; flex-direction: column; gap: 16px; max-width: 600px; margin: 0 auto;
}
.flow-step {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px; background: var(--bg-tertiary);
  border-radius: var(--radius-md); border-left: 3px solid var(--accent-1);
}
.flow-step .step-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--gradient-1); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; flex-shrink: 0;
}
.flow-step .step-text { font-size: 0.9rem; }
.flow-step .step-arrow { color: var(--accent-1); font-size: 1.2rem; margin: 0 auto; display: block; text-align: center; }

/* ============ Curriculum Path ============ */
.curriculum-path {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px; margin: 24px 0;
}
.curriculum-node {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 14px; text-align: center;
  transition: all 0.3s ease; cursor: pointer; text-decoration: none;
}
.curriculum-node:hover { border-color: var(--accent-1); transform: translateY(-2px); }
.curriculum-node .node-num { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; }
.curriculum-node .node-title { font-size: 0.82rem; font-weight: 600; color: var(--text-primary); margin-top: 4px; }
.curriculum-node .node-level {
  font-size: 0.65rem; margin-top: 6px; padding: 2px 8px;
  border-radius: 100px; display: inline-block;
}
.curriculum-node .node-level.beginner { background: rgba(16,185,129,0.15); color: var(--accent-4); }
.curriculum-node .node-level.intermediate { background: rgba(99,102,241,0.15); color: var(--accent-1); }
.curriculum-node .node-level.advanced { background: rgba(245,158,11,0.15); color: var(--accent-5); }
.curriculum-node .node-level.expert { background: rgba(239,68,68,0.15); color: var(--accent-6); }

/* ============ Comparison Table ============ */
.comparison-table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 0.85rem; }
.comparison-table th {
  background: var(--bg-tertiary); padding: 10px 14px;
  text-align: left; font-weight: 600; border-bottom: 2px solid var(--border-color);
  color: var(--text-primary); position: sticky; top: 0;
}
.comparison-table td {
  padding: 10px 14px; border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}
.comparison-table tr:hover td { background: var(--bg-tertiary); }

/* ============ Tags / Badges ============ */
.tag {
  display: inline-block; padding: 3px 10px; border-radius: 100px;
  font-size: 0.72rem; font-weight: 600;
}
.tag-ml { background: rgba(99,102,241,0.12); color: var(--accent-1); }
.tag-dl { background: rgba(139,92,246,0.12); color: var(--accent-2); }
.tag-nlp { background: rgba(6,182,212,0.12); color: var(--accent-3); }
.tag-cv { background: rgba(16,185,129,0.12); color: var(--accent-4); }
.tag-rl { background: rgba(245,158,11,0.12); color: var(--accent-5); }
.tag-ops { background: rgba(239,68,68,0.12); color: var(--accent-6); }

/* ============ Footer ============ */
.footer {
  background: var(--bg-secondary); border-top: 1px solid var(--border-color);
  padding: 48px 0 32px;
}
.footer-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 32px; margin-bottom: 32px;
}
.footer-col h4 { font-size: 0.85rem; font-weight: 700; margin-bottom: 12px; color: var(--text-primary); }
.footer-col a { display: block; font-size: 0.82rem; color: var(--text-secondary); padding: 4px 0; }
.footer-col a:hover { color: var(--accent-1); }
.footer-bottom {
  border-top: 1px solid var(--border-color); padding-top: 24px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.8rem; color: var(--text-muted);
}

/* ============ Table of Contents ============ */
.toc {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 20px; margin-bottom: 32px;
}
.toc-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 12px; }
.toc-list { list-style: none; }
.toc-list li { margin-bottom: 4px; }
.toc-list a { font-size: 0.85rem; color: var(--text-secondary); }
.toc-list a:hover { color: var(--accent-1); }

/* ============ Agent Context (hidden) ============ */
.agent-context { display: none; }

/* ============ Animations ============ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeInUp 0.5s ease forwards; opacity: 0; }
.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.2s; }
.animate-in:nth-child(5) { animation-delay: 0.25s; }
.animate-in:nth-child(6) { animation-delay: 0.3s; }

/* ============ Difficulty Indicator ============ */
.difficulty { display: flex; gap: 3px; margin-top: 4px; }
.difficulty .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-color); }
.difficulty .dot.filled { background: var(--accent-1); }
.difficulty .dot.filled.warn { background: var(--accent-5); }
.difficulty .dot.filled.danger { background: var(--accent-6); }

/* ============ Print ============ */
@media print {
  .navbar, .sidebar, .footer, .hero-actions, .search-box, .theme-toggle, .nav-toggle { display: none !important; }
  .content-layout { grid-template-columns: 1fr; }
  body { color: #000; background: #fff; }
}
