:root {
  /* Color Palette - Modern Dark Theme */
  --bg-body: #0f172a;
  --bg-sidebar: #1e293b;
  --bg-card: #334155;
  --bg-card-hover: #475569;
  --bg-code: #1e1e2e;
  
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --primary: #60a5fa;
  --primary-dark: #3b82f6;
  --primary-light: #93c5fd;
  --primary-glow: rgba(96, 165, 250, 0.3);
  
  --secondary: #34d399;
  --accent: #a78bfa;
  --warning: #fbbf24;
  --danger: #f87171;
  
  --border-color: #334155;
  --border-light: #475569;
  --glass-border: rgba(255, 255, 255, 0.08);
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.5);
  
  --nav-height: 70px;
  --sidebar-width: 300px;
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Fira Code', 'Courier New', monospace;
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { 
  text-decoration: none; 
  color: inherit; 
  transition: var(--transition-fast); 
}

a:hover { color: var(--primary); }

ul, ol { list-style: none; }

img { max-width: 100%; height: auto; display: block; }

/* Scrollbar Styling */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { 
  background: var(--bg-body); 
  border-radius: 10px;
}
::-webkit-scrollbar-thumb { 
  background: var(--bg-card); 
  border-radius: 10px;
  border: 2px solid var(--bg-body);
}
::-webkit-scrollbar-thumb:hover { 
  background: var(--bg-card-hover); 
}

/* Selection */
::selection {
  background: var(--primary-glow);
  color: var(--text-primary);
}

/* ========================================
   LAYOUT STRUCTURE
   ======================================== */

.app-container {
  display: flex;
  min-height: 100vh;
  padding-top: var(--nav-height);
}

/* Ensure smooth initial load */
body {
  opacity: 1;
}

body.is-loading {
  opacity: 0;
}

/* ========================================
   HEADER / NAVIGATION
   ======================================== */

.global-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 0 2rem;
  box-shadow: var(--shadow-md);
}

/* Compact header on mobile */
@media (max-width: 768px) {
  .global-header {
    padding: 0 1rem;
    height: 60px; /* Slightly shorter on mobile if needed, or keep standard */
  }
  
  .header-container {
    gap: 1rem; /* Reduce gap between elements */
  }
  
  .site-logo {
    font-size: 1.25rem; /* Slightly smaller logo */
  }
}

.header-container {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1800px;
  margin: 0 auto;
  gap: 2rem;
}

.site-logo {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
  transition: var(--transition-smooth);
}

.site-logo:hover {
  transform: scale(1.05);
  filter: brightness(1.2);
}

.mobile-menu-toggle {
  display: block;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  transition: var(--transition-fast);
}

/* Hide menu button on desktop - sidebar is always visible on docs/pages, never on home */
@media (min-width: 1024px) {
  .mobile-menu-toggle {
    display: none;
  }
}

.mobile-menu-toggle:hover {
  color: var(--primary);
  transform: scale(1.1);
}

/* Search Bar */
.search-container {
  position: relative;
  width: 100%;
  max-width: 500px;
  margin: 0;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
  pointer-events: none;
  z-index: 1;
}

#search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 3rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: var(--transition-smooth);
}

#search-input::placeholder {
  color: var(--text-muted);
}

#search-input:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px var(--primary-glow);
  transform: translateY(-1px);
}

/* Search Results Dropdown */
.search-results-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  margin-top: 0.25rem;
  max-height: 450px;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  display: none;
  z-index: 1001;
  backdrop-filter: blur(20px);
}

/* Mobile Search Results - Full Width */
@media (max-width: 768px) {
  .search-results-dropdown {
    position: fixed;
    top: 60px; /* Match mobile header height */
    left: 0;
    right: 0;
    width: 100vw;
    border-radius: 0 0 12px 12px;
    border-left: none;
    border-right: none;
    margin-top: 0;
    max-height: calc(100vh - 60px);
  }
}

.search-results-dropdown::-webkit-scrollbar {
  width: 6px;
}

.search-item {
  display: block;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition-fast);
  cursor: pointer;
}

.search-item:last-child { 
  border-bottom: none; 
}

.search-item:hover { 
  background: rgba(96, 165, 250, 0.1);
  padding-left: 1.5rem;
}

.search-item-title {
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.35rem;
  font-size: 1rem;
}

.search-item-preview {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Search breadcrumb separator (Page › Section) */
.search-breadcrumb {
  color: var(--text-muted);
  margin: 0 0.15em;
  font-weight: 400;
}

/* Highlighted match inside search dropdown */
.search-mark {
  background: rgba(96, 165, 250, 0.3);
  color: var(--primary-light);
  padding: 0 2px;
  border-radius: 2px;
}

/* Keyboard-active item in dropdown */
.search-item.kb-active {
  background: rgba(96, 165, 250, 0.15);
  padding-left: 1.5rem;
}

/* On-page highlight when arriving from search */
.search-page-highlight {
  background: rgba(96, 165, 250, 0.35);
  color: var(--text-primary);
  padding: 2px 4px;
  border-radius: 3px;
  animation: hlFade 4s ease forwards;
}

@keyframes hlFade {
  0%   { background: rgba(96, 165, 250, 0.5); }
  70%  { background: rgba(96, 165, 250, 0.35); }
  100% { background: transparent; }
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-actions .github-link {
  font-size: 1.5rem;
  color: var(--text-muted);
  transition: var(--transition-smooth);
  padding: 0.5rem;
  border-radius: 8px;
}

.header-actions .github-link:hover { 
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
  transform: rotate(360deg) scale(1.1);
}

/* ========================================
   SIDEBAR
   ======================================== */

.sidebar {
  width: var(--sidebar-width);
  height: calc(100vh - var(--nav-height));
  position: fixed;
  top: var(--nav-height);
  left: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2rem 0;
  transition: transform var(--transition-smooth);
  z-index: 900;
  box-shadow: var(--shadow-lg);
}

/* Mobile/Tablet: Hidden by default, show when toggled */
@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.sidebar-open {
    transform: translateX(0);
  }
}

/* Desktop: No transition (instant), CSS controls visibility */
@media (min-width: 1024px) {
  .sidebar {
    transition: none; /* No lag - instant visibility changes */
  }
  
  body.layout-docs .sidebar,
  body.layout-page .sidebar {
    transform: translateX(0) !important;
  }
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding: 0 1.5rem;
}

.sidebar-title {
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  font-size: 0.875rem;
  letter-spacing: 1.5px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.close-sidebar {
  display: none; /* Close button not needed - hamburger menu handles toggle */
  background: var(--bg-card);
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: var(--transition-fast);
  font-size: 1.25rem;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  z-index: 10;
  position: relative;
  pointer-events: auto;
}

.close-sidebar:hover {
  background: var(--bg-card-hover);
  color: var(--danger);
  transform: rotate(90deg);
}

.close-sidebar:active {
  transform: rotate(90deg) scale(0.95);
  background: var(--danger);
  color: white;
}

/* Sidebar Navigation */
.sidebar-nav {
  padding: 0 1rem;
}

.nav-group {
  margin-bottom: 1.5rem;
}

.nav-item {
  margin-bottom: 0.5rem;
}

.nav-link {
  display: block;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  transition: var(--transition-smooth);
  position: relative;
}

.nav-link.main-link {
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.875rem;
  font-size: 1rem;
  padding: 0.875rem 1rem;
}

.nav-link.main-link i {
  font-size: 1.125rem;
  width: 20px;
  text-align: center;
  opacity: 0.8;
}

.nav-link.main-link:hover {
  background: rgba(96, 165, 250, 0.12);
  color: var(--primary-light);
  transform: translateX(4px);
}

.nav-link.main-link:hover i {
  transform: scale(1.15);
  opacity: 1;
}

/* Sub Navigation Items */
.nav-subitems {
  padding-left: 2.5rem;
  margin-top: 0.5rem;
  margin-left: 1rem;
  border-left: 2px solid var(--border-color);
  position: relative;
}

.nav-link.sub-link {
  font-size: 0.875rem;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  position: relative;
  transition: all var(--transition-fast);
}

.nav-link.sub-link::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 0;
  background: var(--primary);
  transition: height var(--transition-smooth);
}

.nav-link.sub-link:hover {
  color: var(--primary-light);
  background: rgba(96, 165, 250, 0.05);
  transform: translateX(4px);
  padding-left: 1.25rem;
}

.nav-link.sub-link:hover::before {
  height: 100%;
}

/* Active State for Current Sub-Category */
.nav-link.sub-link.active {
  color: var(--primary);
  font-weight: 600;
  background: linear-gradient(90deg, rgba(96, 165, 250, 0.15) 0%, transparent 100%);
  border-left: 3px solid var(--primary);
  padding-left: 1.25rem;
  margin-left: -2px;
  box-shadow: 0 0 20px rgba(96, 165, 250, 0.2);
}

.nav-link.sub-link.active::before {
  height: 100%;
  width: 3px;
  left: -3px;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border-color);
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 850;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-smooth);
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* ========================================
   MAIN CONTENT AREA
   ======================================== */

.main-content {
  flex: 1;
  width: 100%;
  min-height: calc(100vh - var(--nav-height));
  transition: margin-left var(--transition-smooth);
  position: relative;
}

/* On desktop, content starts after sidebar */
@media (min-width: 1024px) {
  .main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
  }
}

/* Prevent flash on page load */
[data-barba="container"] {
  opacity: 1 !important;
}

.main-content {
  opacity: 1 !important;
}

/* ========================================
   LAYOUT VARIANTS
   ======================================== */

/* Home Layout - Never show sidebar on desktop, but allow toggle on mobile */
body.layout-home .sidebar {
  width: 0;
  padding: 0;
  overflow: hidden;
  border-right: none;
}

@media (min-width: 1024px) {
  body.layout-home .sidebar {
    transform: translateX(-100%) !important;
  }
}

@media (max-width: 1023px) {
  /* Allow mobile sidebar to open */
  body.layout-home .sidebar.sidebar-open {
    width: var(--sidebar-width);
    padding: 2rem 0;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
    transform: translateX(0);
  }
}

body.layout-home .main-content {
  margin-left: 0;
  width: 100%;
}

/* Docs & Page Layout - Content spacing only */
/* Sidebar toggling is handled by base responsive rules above */

/* Prevent content jump - ensure docs layout is applied correctly */
body.layout-docs .docs-page,
body.layout-page .docs-page {
  opacity: 1;
}

/* ========================================
   DOCS PAGE STYLING
   ======================================== */

.docs-page {
  display: flex;
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 0;
}

.docs-content {
  flex: 1;
  width: 100%;
  padding: 3rem 4rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* Typography for Content */
.docs-content h1 {
  font-size: 2.75rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  line-height: 1.2;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.docs-content h2 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 3rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border-light);
  scroll-margin-top: calc(var(--nav-height) + 2rem);
}

.docs-content h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  scroll-margin-top: calc(var(--nav-height) + 2rem);
}

.docs-content h4 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 2rem;
  margin-bottom: 0.875rem;
}

.docs-content p {
  font-size: 1.0625rem;
  line-height: 1.8;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.docs-content ul,
.docs-content ol {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

.docs-content ul {
  list-style: none;
}

.docs-content ul li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.docs-content ul li::before {
  content: '▹';
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 700;
  font-size: 1.25rem;
}

.docs-content ol {
  list-style: decimal;
  list-style-position: outside;
}

.docs-content ol li {
  margin-bottom: 0.75rem;
  padding-left: 0.5rem;
  color: var(--text-secondary);
}

.docs-content a {
  color: var(--primary);
  border-bottom: 1px solid transparent;
  transition: var(--transition-fast);
}

.docs-content a:hover {
  border-bottom-color: var(--primary);
  color: var(--primary-light);
}

.docs-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.docs-content em {
  color: var(--text-primary);
  font-style: italic;
}

.docs-content blockquote {
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  background: rgba(96, 165, 250, 0.08);
  border-left: 4px solid var(--primary);
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
  font-style: italic;
}

.docs-content hr {
  margin: 3rem 0;
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-light), transparent);
}

/* Images */
.docs-content img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 2rem auto;
  display: block;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

.docs-content figure {
  margin: 2rem 0;
  text-align: center;
}

.docs-content figcaption {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ========================================
   CODE BLOCKS & SYNTAX HIGHLIGHTING
   ======================================== */

/* Inline Code */
.docs-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.2em 0.5em;
  background: rgba(96, 165, 250, 0.15);
  border: 1px solid rgba(96, 165, 250, 0.3);
  border-radius: 6px;
  color: var(--primary-light);
  font-weight: 500;
}

.docs-content pre code {
  padding: 0;
  background: none;
  border: none;
  font-size: 0.925rem;
}

/* Code Window - Mac Style */
.code-window {
  background: #1a1b26;
  border-radius: 12px;
  box-shadow: var(--shadow-xl);
  margin: 2.5rem 0;
  overflow: hidden;
  border: 1px solid var(--border-light);
  transition: var(--transition-smooth);
}

.code-window:hover {
  transform: translateY(-2px);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

.window-header {
  background: linear-gradient(135deg, #2a2b3d 0%, #1f2031 100%);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #2a2b3d;
  user-select: none;
}

.window-controls {
  display: flex;
  gap: 8px;
  margin-right: 1.25rem;
}

.control {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  transition: var(--transition-fast);
  cursor: pointer;
}

.control:hover {
  filter: brightness(1.2);
  transform: scale(1.1);
}

.control.red {
  background: linear-gradient(135deg, #ff6057, #ff3b30);
  box-shadow: 0 0 8px rgba(255, 96, 87, 0.4);
}

.control.yellow {
  background: linear-gradient(135deg, #ffbd2e, #ffaa00);
  box-shadow: 0 0 8px rgba(255, 189, 46, 0.4);
}

.control.green {
  background: linear-gradient(135deg, #28ca42, #20c933);
  box-shadow: 0 0 8px rgba(40, 202, 66, 0.4);
}

.window-title {
  color: #8b8c99;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  margin: 0 auto;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.window-title::before {
  content: '◉';
  color: var(--primary);
  font-size: 0.75rem;
}

.code-window-content {
  overflow-x: auto;
}

.code-window-content pre {
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: #1a1b26 !important;
  padding: 1.5rem 1.75rem !important;
  overflow-x: auto;
}

.code-window-content pre code {
  font-family: var(--font-mono);
  font-size: 0.925rem;
  line-height: 1.7;
  color: #c9d1d9;
  display: block;
}

/* ========================================
   SYNTAX HIGHLIGHTING - Cool Dark Theme
   ======================================== */

/* Base text color - soft white */
.highlight, .highlighter-rouge {
  color: #d4d4d4;
}

/* Keywords (if, else, for, while, class, def, return, etc.) - soft purple/blue */
.highlight .k,
.highlight .kc,
.highlight .kd,
.highlight .kn,
.highlight .kp,
.highlight .kr,
.highlight .kt {
  color: #569cd6 !important;
  font-weight: 500;
}

/* Keyword operators (and, or, not, in, is) - soft blue */
.highlight .kv,
.highlight .ow {
  color: #569cd6 !important;
}

/* Function/Method names - muted yellow */
.highlight .nf,
.highlight .fm {
  color: #dcdcaa !important;
  font-weight: normal;
}

/* Class names - soft teal/cyan */
.highlight .nc,
.highlight .nn {
  color: #4ec9b0 !important;
  font-weight: 500;
}

/* Strings - soft orange/peach */
.highlight .s,
.highlight .s1,
.highlight .s2,
.highlight .sb,
.highlight .sc,
.highlight .sd,
.highlight .se,
.highlight .sh,
.highlight .si,
.highlight .sx {
  color: #ce9178 !important;
}

/* String interpolation - soft cyan */
.highlight .sr,
.highlight .ss {
  color: #4ec9b0 !important;
}

/* Numbers - soft green */
.highlight .m,
.highlight .mb,
.highlight .mf,
.highlight .mh,
.highlight .mi,
.highlight .mo,
.highlight .il {
  color: #b5cea8 !important;
}

/* Comments - muted green */
.highlight .c,
.highlight .c1,
.highlight .ch,
.highlight .cm,
.highlight .cp,
.highlight .cpf,
.highlight .cs {
  color: #6a9955 !important;
  font-style: italic;
}

/* Variables - light blue */
.highlight .n,
.highlight .na,
.highlight .nb,
.highlight .nd,
.highlight .ni,
.highlight .ne,
.highlight .nl,
.highlight .no,
.highlight .nv,
.highlight .nx {
  color: #9cdcfe !important;
}

/* Built-in functions/constants (print, len, True, False, None) - soft yellow */
.highlight .nb,
.highlight .bp {
  color: #dcdcaa !important;
}

/* Self, this - soft purple */
.highlight .vc,
.highlight .vg,
.highlight .vi {
  color: #c586c0 !important;
}

/* Operators (+, -, *, /, =, ==, etc.) - soft white */
.highlight .o,
.highlight .ow {
  color: #d4d4d4 !important;
}

/* Punctuation (, ; : ( ) { } [ ]) - soft gray */
.highlight .p,
.highlight .punctuation {
  color: #d4d4d4 !important;
}

/* Decorators (@property, @staticmethod) - muted yellow */
.highlight .nd,
.highlight .decorator {
  color: #dcdcaa !important;
}

/* Error - muted red */
.highlight .err {
  color: #f48771 !important;
  background: rgba(244, 135, 113, 0.1);
  border-radius: 3px;
  padding: 0 2px;
}

/* Generic types - soft teal */
.highlight .nt,
.highlight .tag {
  color: #4ec9b0 !important;
}

/* Attributes in HTML/XML - light blue */
.highlight .na {
  color: #9cdcfe !important;
}

/* HTML/XML attribute values - soft orange */
.highlight .s {
  color: #ce9178 !important;
}

/* Deleted/Inserted in diffs */
.highlight .gd {
  color: #f48771 !important;
  background: rgba(244, 135, 113, 0.15);
}

.highlight .gi {
  color: #b5cea8 !important;
  background: rgba(181, 206, 168, 0.15);
}

/* C++ specific */
.highlight .cp {
  color: #6a9955 !important;
}

/* Preprocessor directives (#include, #define) - soft purple */
.highlight .cp {
  color: #c586c0 !important;
}

/* Types (int, float, string, void, etc.) - soft teal */
.highlight .kt {
  color: #4ec9b0 !important;
  font-weight: 500;
}

/* Python specific - function parameters - light blue */
.highlight .nv {
  color: #9cdcfe !important;
}

/* SQL Keywords - soft blue */
.highlight .k {
  color: #569cd6 !important;
}

/* Make keywords subtle */
.highlight .kd,
.highlight .kn,
.highlight .kp {
  font-weight: 500;
}

/* Constants/macros - light purple */
.highlight .no {
  color: #c586c0 !important;
}

/* Namespace/module - soft teal */
.highlight .nn {
  color: #4ec9b0 !important;
}

/* Scrollbar for Code Blocks */
.code-window-content pre::-webkit-scrollbar {
  height: 8px;
}

.code-window-content pre::-webkit-scrollbar-track {
  background: #16161e;
  border-radius: 0 0 12px 12px;
}

.code-window-content pre::-webkit-scrollbar-thumb {
  background: #2a2b3d;
  border-radius: 4px;
}

.code-window-content pre::-webkit-scrollbar-thumb:hover {
  background: #3a3b4d;
}

/* Code Block without Window (fallback) */
.docs-content pre:not(.code-window-content pre) {
  background: #1a1b26;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 1.5rem;
  overflow-x: auto;
  margin: 2rem 0;
  box-shadow: var(--shadow-md);
}

.docs-content pre:not(.code-window-content pre) code {
  font-family: var(--font-mono);
  font-size: 0.925rem;
  line-height: 1.7;
  color: #c9d1d9;
}

/* Ensure syntax highlighting works in all code blocks */
.docs-content .highlight,
.docs-content .highlighter-rouge,
.code-window .highlight,
.code-window .highlighter-rouge {
  background: transparent !important;
}

/* ========================================
   TABLE OF CONTENTS SIDEBAR
   ======================================== */

.toc-sidebar {
  width: 280px;
  position: sticky;
  top: calc(var(--nav-height) + 2rem);
  height: calc(100vh - var(--nav-height) - 4rem);
  overflow-y: auto;
  padding: 2rem 2rem 2rem 3rem;
  border-left: 1px solid var(--border-color);
  display: none;
}

@media (min-width: 1400px) {
  .toc-sidebar {
    display: block;
  }
}

.toc-sidebar h3 {
  font-size: 0.875rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  letter-spacing: 1.2px;
  font-weight: 700;
}

.toc-sidebar ul {
  list-style: none;
  padding: 0;
}

.toc-sidebar li {
  margin-bottom: 0.875rem;
  font-size: 0.875rem;
}

.toc-sidebar li.h3 {
  padding-left: 1rem;
  font-size: 0.8125rem;
}

.toc-sidebar a {
  color: var(--text-secondary);
  transition: var(--transition-fast);
  display: block;
  padding: 0.25rem 0;
  border-left: 2px solid transparent;
  padding-left: 0.75rem;
}

.toc-sidebar a:hover {
  color: var(--primary);
  border-left-color: var(--primary);
  transform: translateX(4px);
}

.toc-sidebar a.active {
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}

/* ========================================
   HOMEPAGE STYLING
   ======================================== */

.home-page {
  width: 100%;
  min-height: calc(100vh - var(--nav-height));
  display: flex;
  flex-direction: column;
}

.hero-section {
  min-height: calc(100vh - var(--nav-height));
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.05) 0%, rgba(167, 139, 250, 0.05) 100%);
  position: relative;
  overflow: hidden;
}

/* Animated Background Gradient */
.hero-section::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(96, 165, 250, 0.1) 0%, transparent 70%);
  animation: rotate 30s linear infinite;
}

@keyframes rotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.hero-content {
  text-align: center;
  max-width: 900px;
  padding: 2rem;
  position: relative;
  z-index: 1;
}

.hero-section h1 {
  font-size: 4.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--accent) 50%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1.5rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
  animation: fadeInUp 0.8s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-subtitle {
  font-size: 1.5rem;
  color: var(--text-secondary);
  margin-bottom: 3rem;
  line-height: 1.6;
  animation: fadeInUp 0.8s ease-out 0.2s both;
}

.hero-actions {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  animation: fadeInUp 0.8s ease-out 0.4s both;
}

/* Buttons */
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2.5rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 1.125rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: var(--transition-smooth);
  cursor: pointer;
  border: none;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: white;
  box-shadow: 0 10px 30px rgba(96, 165, 250, 0.3);
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s ease;
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:hover {
  color: white !important;
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 15px 40px rgba(96, 165, 250, 0.4);
}

.btn-primary:hover i,
.btn-primary:hover span {
  color: white !important;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 2px solid var(--border-light);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary);
  color: var(--text-primary) !important;
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(96, 165, 250, 0.2);
}

.btn-secondary:hover i,
.btn-secondary:hover span {
  color: var(--text-primary) !important;
}

.btn-large {
  font-size: 1.25rem;
  padding: 1.25rem 3rem;
}

/* Feature Cards on Homepage */
.features-section {
  padding: 6rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-top: 3rem;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 2.5rem;
  transition: var(--transition-smooth);
  cursor: pointer;
}

.feature-card:hover {
  transform: translateY(-8px);
  border-color: var(--primary);
  box-shadow: 0 20px 40px rgba(96, 165, 250, 0.2);
  background: var(--bg-card-hover);
}

.feature-icon {
  font-size: 2.5rem;
  margin-bottom: 1.5rem;
  display: block;
  color: var(--primary);
}

.feature-icon i {
  font-size: 2.5rem;
}

.feature-card h3 {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.feature-card p {
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ========================================
   TABLES
   ======================================== */

.docs-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.docs-content table thead {
  background: var(--bg-card);
}

.docs-content table th {
  padding: 1rem 1.25rem;
  text-align: left;
  font-weight: 600;
  color: var(--primary-light);
  border-bottom: 2px solid var(--primary);
  text-transform: uppercase;
  font-size: 0.875rem;
  letter-spacing: 0.5px;
}

.docs-content table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  vertical-align: top;
}

.docs-content table tbody tr {
  transition: var(--transition-fast);
}

.docs-content table tbody tr:hover {
  background: rgba(96, 165, 250, 0.05);
}

.docs-content table tbody tr:last-child td {
  border-bottom: none;
}

/* Tables - Responsive Scroll */
.docs-content table {
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}

.docs-content table thead,
.docs-content table tbody,
.docs-content table tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}

@media (max-width: 768px) {
  .docs-content table {
    font-size: 0.875rem;
  }
  
  .docs-content table th,
  .docs-content table td {
    padding: 0.75rem;
  }
}

/* ========================================
   BADGES & LABELS
   ======================================== */

.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-primary {
  background: rgba(96, 165, 250, 0.2);
  color: var(--primary-light);
  border: 1px solid var(--primary);
}

.badge-success {
  background: rgba(52, 211, 153, 0.2);
  color: var(--secondary);
  border: 1px solid var(--secondary);
}

.badge-warning {
  background: rgba(251, 191, 36, 0.2);
  color: var(--warning);
  border: 1px solid var(--warning);
}

.badge-danger {
  background: rgba(248, 113, 113, 0.2);
  color: var(--danger);
  border: 1px solid var(--danger);
}

/* ========================================
   ALERT BOXES
   ======================================== */

.alert {
  padding: 1.25rem 1.5rem;
  margin: 2rem 0;
  border-radius: 12px;
  border-left: 4px solid;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.alert-info {
  background: rgba(96, 165, 250, 0.1);
  border-left-color: var(--primary);
  color: var(--text-secondary);
}

.alert-success {
  background: rgba(52, 211, 153, 0.1);
  border-left-color: var(--secondary);
  color: var(--text-secondary);
}

.alert-warning {
  background: rgba(251, 191, 36, 0.1);
  border-left-color: var(--warning);
  color: var(--text-secondary);
}

.alert-danger {
  background: rgba(248, 113, 113, 0.1);
  border-left-color: var(--danger);
  color: var(--text-secondary);
}

.alert i {
  font-size: 1.25rem;
  margin-top: 0.125rem;
}

.alert-info i { color: var(--primary); }
.alert-success i { color: var(--secondary); }
.alert-warning i { color: var(--warning); }
.alert-danger i { color: var(--danger); }

/* ========================================
   CARDS & PANELS
   ======================================== */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
  margin: 2rem 0;
  box-shadow: var(--shadow-md);
  transition: var(--transition-smooth);
}

.card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-header {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border-light);
}

.card-body {
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

.flex { display: flex; }
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.gap-4 { gap: 2rem; }

/* Highlight Text */
.highlight-text {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Tablet */
@media (max-width: 1200px) {
  :root {
    --sidebar-width: 280px;
  }

  .docs-content {
    padding: 2.5rem 3rem;
  }

  .toc-sidebar {
    display: none;
  }

  .hero-section h1 {
    font-size: 3.5rem;
  }
}

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 280px;
  }

  .docs-content {
    padding: 2rem 2.5rem;
  }

  .docs-content h1 {
    font-size: 2.25rem;
  }

  .docs-content h2 {
    font-size: 1.75rem;
  }

  .docs-content h3 {
    font-size: 1.35rem;
  }

  .header-container {
    padding: 0 1.5rem;
  }

  .search-container {
    max-width: 350px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .global-header {
    padding: 0 1rem;
  }

  .header-container {
    gap: 1rem;
  }

  .mobile-menu-toggle {
    display: block;
    order: -1;
  }

  .site-logo {
    font-size: 1.25rem;
  }

  .search-container {
    max-width: 100%;
    order: 3;
    flex: 1;
  }

  .header-actions {
    display: none;
  }

  /* Sidebar Mobile Behavior */
  body.layout-docs .main-content,
  body.layout-page .main-content {
    margin-left: 0;
    width: 100%;
  }

  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    box-shadow: var(--shadow-xl);
    background: var(--bg-sidebar);
    z-index: 950;
  }

  /* Content Adjustments */
  .docs-content {
    padding: 1.5rem;
  }

  .docs-content h1 {
    font-size: 2rem;
  }

  .docs-content h2 {
    font-size: 1.5rem;
    margin-top: 2rem;
  }

  .docs-content h3 {
    font-size: 1.25rem;
  }

  .docs-content p,
  .docs-content li {
    font-size: 1rem;
  }

  /* Hero Section Mobile */
  .hero-section {
    min-height: calc(100vh - var(--nav-height));
    padding: 2rem 1rem;
  }

  .hero-section h1 {
    font-size: 2.5rem;
  }

  .hero-subtitle {
    font-size: 1.125rem;
  }

  .hero-actions {
    flex-direction: column;
    gap: 1rem;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    justify-content: center;
    padding: 1rem 2rem;
    font-size: 1rem;
  }

  /* Code Blocks Mobile */
  .code-window {
    margin: 1.5rem -0.5rem;
    border-radius: 8px;
  }

  .code-window-content pre {
    padding: 1rem !important;
    font-size: 0.85rem;
  }

  .window-controls {
    gap: 6px;
  }

  .control {
    width: 10px;
    height: 10px;
  }

  /* Feature Cards Mobile */
  .features-section {
    padding: 3rem 1rem;
  }

  .features-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .feature-card {
    padding: 2rem;
  }
}

@media (max-width: 480px) {
  :root {
    --nav-height: 60px;
  }

  .global-header {
    padding: 0 0.75rem;
  }

  .site-logo {
    font-size: 1.125rem;
  }

  #search-input {
    font-size: 0.875rem;
    padding: 0.625rem 0.875rem 0.625rem 2.5rem;
  }

  .search-icon {
    font-size: 0.875rem;
    left: 0.75rem;
  }

  .sidebar {
    width: 85vw;
    max-width: 300px;
  }

  .docs-content {
    padding: 1rem;
  }

  .docs-content h1 {
    font-size: 1.75rem;
  }

  .hero-section h1 {
    font-size: 2rem;
  }

  .hero-subtitle {
    font-size: 1rem;
  }

  .btn-large {
    font-size: 1rem;
    padding: 1rem 2rem;
  }

  .nav-link.main-link {
    font-size: 0.95rem;
    padding: 0.75rem 0.875rem;
  }

  .nav-link.sub-link {
    font-size: 0.8125rem;
  }
}

/* Print Styles */
@media print {
  .global-header,
  .sidebar,
  .toc-sidebar,
  .sidebar-overlay,
  .mobile-menu-toggle {
    display: none !important;
  }

  body.layout-docs .main-content,
  body.layout-page .main-content {
    margin-left: 0;
    width: 100%;
  }

  .docs-content {
    padding: 0;
  }

  .code-window {
    page-break-inside: avoid;
  }
}

/* ========================================
   RESPONSIVE TABLES
   ======================================== */

.table-wrapper {
  width: 100%;
  overflow-x: auto; /* Fallback for extreme cases */
  margin-bottom: 1.5rem;
  /* Removed bg/border to fix "double background" issue */
}

/* Ensure tables take full width and look good */
.docs-content table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.03); /* Lighter than page bg */
  border-radius: 8px; /* Rounded corners for the table itself */
  overflow: hidden; /* Clip inner content to corners */
  table-layout: auto; /* Allow columns to size based on content */
}

.docs-content th,
.docs-content td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  vertical-align: top; /* Align content to top when wrapping */
  white-space: normal; /* Allow text to wrap */
  word-break: break-word; /* Prevent overflow from long words */
}

.docs-content th {
  background: rgba(255, 255, 255, 0.05); /* Slightly lighter header */
  font-weight: 600;
  color: var(--primary-light);
  white-space: nowrap; /* Keep headers on one line if possible, or allow wrap if needed */
}

/* Allow code blocks in tables to wrap */
.docs-content td code {
  white-space: pre-wrap;
  word-break: break-all;
  display: inline-block;
}

.docs-content tr:last-child td {
  border-bottom: none;
}

.docs-content tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Mobile adjustments for tables */
@media (max-width: 768px) {
  .docs-content td {
    padding: 0.5rem 0.75rem; /* Reduce padding on mobile */
    font-size: 0.9rem; /* Keep data readable */
  }
  
  .docs-content th {
    white-space: normal; /* Allow headers to wrap on small screens */
    font-size: 0.75rem; /* Smaller text for headers as requested */
    text-transform: uppercase; /* Optional: makes small headers look better */
    letter-spacing: 0.5px;
  }
}
