/* ===== CSS VARIABLES ===== */
:root {
  --primary-color: #2563eb;
  --primary-dark: #1d4ed8;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --bg: #ffffff;
  --bg-light: #f8fafc;
  --bg-dark: #0f172a;
  --border: #e2e8f0;
  --shadow: rgba(15, 23, 42, 0.08);
  --nav-height: 64px;
  --sidebar-width: 260px;
  --radius: 0.5rem;
  --radius-lg: 0.875rem;
  --font: 'Inter', sans-serif;
  --transition: 0.2s ease;
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
  --bg: #0f172a;
  --bg-light: #1e293b;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-light: #64748b;
  --border: #334155;
  --shadow: rgba(0, 0, 0, 0.4);
}
[data-theme="dark"] .navbar       { background: rgba(15,23,42,0.97); border-bottom-color: #334155; }
[data-theme="dark"] .sidebar      { background: #111827; border-right-color: #334155; }
[data-theme="dark"] .sidebar-link { color: #94a3b8; }
[data-theme="dark"] .sidebar-link:hover,
[data-theme="dark"] .sidebar-link.active { background: #1e293b; color: #e2e8f0; }
[data-theme="dark"] .sidebar-group-title { color: #64748b; }
[data-theme="dark"] .card         { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .card h3      { color: #e2e8f0; }
[data-theme="dark"] .card p       { color: #94a3b8; }
[data-theme="dark"] .badge-soon   { background: #1e293b; color: #64748b; border-color: #334155; }
[data-theme="dark"] .badge-new    { background: #0d1f3c; color: #60a5fa; border-color: #1e40af; }
[data-theme="dark"] .item-row     { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .item-row h4  { color: #e2e8f0; }
[data-theme="dark"] .item-row p   { color: #94a3b8; }
[data-theme="dark"] .item-row:hover { border-color: #2563eb; }
[data-theme="dark"] .section-hero { background: linear-gradient(135deg, #0a1628 0%, #0f172a 100%); }
[data-theme="dark"] .breadcrumb   { color: #64748b; }
[data-theme="dark"] .search-box   { background: #1e293b; border-color: #334155; color: #e2e8f0; }
[data-theme="dark"] .search-box::placeholder { color: #475569; }

/* ===== RESET ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 16px; }
body { font-family: var(--font); color: var(--text-primary); background: var(--bg); line-height: 1.6; overflow-x: hidden; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

/* ===== NAVBAR ===== */
.navbar {
  position: fixed; top: 0; width: 100%; z-index: 200;
  height: var(--nav-height);
  background: rgba(255,255,255,0.97);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.nav-inner {
  max-width: 1400px; margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.nav-logo a {
  font-size: 1.1rem; font-weight: 700; color: var(--primary-color);
}
.nav-logo span { font-weight: 400; color: var(--text-secondary); }
.nav-links { display: flex; align-items: center; gap: 0.25rem; }
.nav-links a {
  font-size: 0.88rem; font-weight: 500; color: var(--text-secondary);
  padding: 0.35rem 0.75rem; border-radius: var(--radius);
  transition: all var(--transition);
}
.nav-links a:hover, .nav-links a.active { background: #eff6ff; color: var(--primary-color); }
.nav-right { display: flex; align-items: center; gap: 0.5rem; }
.nav-visit-main {
  font-size: 0.82rem; font-weight: 600;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
  padding: 0.3rem 0.85rem; border-radius: 999px;
  transition: all var(--transition);
}
.nav-visit-main:hover { background: var(--primary-color); color: white; }
.theme-toggle {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border); background: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text-primary); font-size: 0.85rem;
  transition: all var(--transition);
}
.theme-toggle:hover { background: var(--primary-color); border-color: var(--primary-color); color: white; }
.hamburger {
  display: none; flex-direction: column; gap: 4px;
  cursor: pointer; padding: 4px;
}
.hamburger span { width: 22px; height: 2px; background: var(--text-primary); border-radius: 2px; transition: all var(--transition); }

/* ===== DOCS LAYOUT ===== */
.docs-layout {
  display: flex;
  min-height: 100vh;
  padding-top: var(--nav-height);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-light);
  border-right: 1px solid var(--border);
  position: fixed;
  top: var(--nav-height);
  left: 0;
  height: calc(100vh - var(--nav-height));
  overflow-y: auto;
  padding: 1.25rem 0;
  transition: transform var(--transition);
  z-index: 100;
}
.sidebar-group { margin-bottom: 1.5rem; }
.sidebar-group-title {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-light);
  padding: 0 1.1rem; margin-bottom: 0.35rem;
}
.sidebar-link {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 0.875rem; color: var(--text-secondary);
  padding: 0.4rem 1.1rem; border-radius: 0;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}
.sidebar-link i { font-size: 0.8rem; width: 14px; text-align: center; color: var(--text-light); }
.sidebar-link:hover { background: #eff6ff; color: var(--primary-color); border-left-color: #bfdbfe; }
.sidebar-link:hover i { color: var(--primary-color); }
.sidebar-link.active { background: #eff6ff; color: var(--primary-color); font-weight: 600; border-left-color: var(--primary-color); }
.sidebar-link.active i { color: var(--primary-color); }

/* Main content */
.docs-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  padding: 2rem 2.5rem 4rem;
  max-width: 960px;
}

/* ===== LANDING PAGE ===== */
.landing-hero {
  padding: calc(var(--nav-height) + 48px) 0 48px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 60%, #2563eb 100%);
  text-align: center;
  color: white;
}
.landing-hero h1 { font-size: 2.6rem; font-weight: 700; margin-bottom: 0.75rem; }
.landing-hero p  { font-size: 1.05rem; color: #94a3b8; max-width: 560px; margin: 0 auto 1.75rem; }

.search-bar-wrap { max-width: 520px; margin: 0 auto; position: relative; }
.search-box {
  width: 100%; padding: 0.75rem 1.25rem 0.75rem 2.75rem;
  border-radius: 999px; border: 1px solid #334155;
  font-size: 0.95rem; font-family: var(--font);
  background: rgba(255,255,255,0.08); color: white;
  outline: none; transition: all var(--transition);
}
.search-box::placeholder { color: #64748b; }
.search-box:focus { background: rgba(255,255,255,0.14); border-color: #2563eb; }
.search-icon { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: #64748b; font-size: 0.9rem; }

/* Category cards grid on landing */
.landing-body { max-width: 1200px; margin: 0 auto; padding: 3.5rem 1.5rem; }
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-bottom: 3rem;
}

/* ===== CARD ===== */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 2px 10px var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}
.card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(37,99,235,0.12); }
.card-icon {
  width: 48px; height: 48px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; margin-bottom: 1rem;
}
.card h3 { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); margin-bottom: 0.4rem; }
.card p  { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.6; margin-bottom: 1rem; }
.card-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 1rem; }
.card-tag  { font-size: 0.75rem; background: var(--bg-light); color: var(--text-secondary); border: 1px solid var(--border); border-radius: 999px; padding: 0.15rem 0.6rem; }
.card-link { font-size: 0.875rem; font-weight: 600; color: var(--primary-color); display: inline-flex; align-items: center; gap: 0.35rem; transition: gap var(--transition); }
.card-link:hover { gap: 0.6rem; }

/* ===== ITEM ROWS (within section pages) ===== */
.item-row {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.4rem;
  margin-bottom: 0.75rem;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.item-row:hover { border-color: var(--primary-color); box-shadow: 0 2px 10px rgba(37,99,235,0.08); }
.item-row-body { flex: 1; }
.item-row h4 { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); margin-bottom: 0.2rem; }
.item-row p  { font-size: 0.85rem; color: var(--text-secondary); }
.item-row-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; flex-shrink: 0; }

/* ===== BADGES ===== */
.badge-soon {
  font-size: 0.72rem; font-weight: 600; padding: 0.2rem 0.6rem;
  border-radius: 999px; background: #f1f5f9; color: #94a3b8;
  border: 1px solid var(--border); white-space: nowrap;
}
.badge-new {
  font-size: 0.72rem; font-weight: 600; padding: 0.2rem 0.6rem;
  border-radius: 999px; background: #eff6ff; color: #2563eb;
  border: 1px solid #bfdbfe; white-space: nowrap;
}
.badge-video {
  font-size: 0.72rem; font-weight: 600; padding: 0.2rem 0.6rem;
  border-radius: 999px; background: #fff1f2; color: #e11d48;
  border: 1px solid #fecdd3; white-space: nowrap;
}
.badge-ext {
  font-size: 0.72rem; font-weight: 600; padding: 0.2rem 0.6rem;
  border-radius: 999px; background: #f0fdf4; color: #16a34a;
  border: 1px solid #bbf7d0; white-space: nowrap;
}

/* ===== SECTION PAGE COMPONENTS ===== */
.section-hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  padding: 2rem 2.5rem;
  margin: -2rem -2.5rem 2rem;
  color: white;
}
.breadcrumb { font-size: 0.8rem; color: #94a3b8; margin-bottom: 0.6rem; }
.breadcrumb a { color: #93c5fd; }
.breadcrumb a:hover { text-decoration: underline; }
.section-hero h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.4rem; }
.section-hero p  { font-size: 0.95rem; color: #94a3b8; }

.content-group { margin-bottom: 2.5rem; }
.content-group-title {
  font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-light);
  margin-bottom: 0.85rem; padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* ===== SECTION COUNT PILLS ===== */
.section-stats {
  display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem;
}
.stat-pill {
  font-size: 0.8rem; color: #93c5fd;
  display: flex; align-items: center; gap: 0.35rem;
}

/* ===== FOOTER ===== */
.docs-footer {
  background: var(--bg-dark);
  color: #94a3b8;
  padding: 1.5rem 1.5rem;
  text-align: center;
  font-size: 0.85rem;
}
.docs-footer a { color: #60a5fa; }
.docs-footer a:hover { text-decoration: underline; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-260px); width: 260px; box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.15); }
  .docs-main { margin-left: 0; }
  .hamburger { display: flex; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 99; backdrop-filter: blur(2px); }
  .sidebar-overlay.show { display: block; }
  .docs-main { padding: 1.75rem 2rem 3rem; }
}

@media (max-width: 768px) {
  .nav-links { display: none; }
  .docs-main { padding: 1.5rem 1.25rem 5rem; }
  .landing-body { padding: 2.5rem 1.25rem 5rem; }
  .cat-grid { grid-template-columns: 1fr 1fr; gap: 1rem; }
  .landing-hero { padding: calc(var(--nav-height) + 32px) 1.25rem 32px; }
  .landing-hero h1 { font-size: 2rem; }
  .section-hero { padding: 1.5rem 1.25rem; margin: -1.5rem -1.25rem 1.5rem; }
  .section-hero h1 { font-size: 1.5rem; }
}

@media (max-width: 640px) {
  .cat-grid { grid-template-columns: 1fr; }
  .landing-hero h1 { font-size: 1.75rem; }
  .nav-visit-main { display: none; }
  /* Bottom nav takes 64px — pad content so it doesn't hide behind it */
  .docs-main, .landing-body { padding-bottom: 76px; }
}

/* ===== MOBILE BOTTOM NAV ===== */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 62px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  z-index: 150;
  /* safe area for devices with home bar */
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -4px 20px var(--shadow);
}
.mobile-bottom-nav-inner {
  display: flex;
  height: 62px;
  align-items: stretch;
}
.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-light);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 0.35rem 0.25rem;
  transition: color var(--transition), background var(--transition);
  border-radius: 0;
  min-height: 44px; /* accessibility touch target */
}
.mobile-nav-item i { font-size: 1.1rem; }
.mobile-nav-item:hover, .mobile-nav-item.active {
  color: var(--primary-color);
  background: #eff6ff;
}
[data-theme="dark"] .mobile-nav-item:hover,
[data-theme="dark"] .mobile-nav-item.active {
  background: #1e293b;
  color: #60a5fa;
}
[data-theme="dark"] .mobile-bottom-nav {
  background: #0f172a;
  border-top-color: #334155;
}

@media (max-width: 640px) {
  .mobile-bottom-nav { display: block; }
}

/* ===== TOUCH TARGET SAFETY ===== */
.sidebar-link { min-height: 40px; }
.theme-toggle, .hamburger { min-width: 40px; min-height: 40px; }
.nav-links a { min-height: 40px; display: inline-flex; align-items: center; }

/* ===== TABLET CARD GRID IMPROVEMENT ===== */
@media (min-width: 641px) and (max-width: 900px) {
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== SCROLL BEHAVIOUR ===== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}