:root {
  --background: 50 30% 96%;
  --foreground: 0 0% 5%;
  --card: 50 30% 99%;
  --primary: 262 83% 58%;
  --secondary: 45 93% 58%;
  --accent: 160 84% 39%;
  --border: 0 0% 5%;
  --muted-foreground: 0 0% 35%;
  --radius: 0.5rem;
  --neo-shadow: 4px 4px 0px hsl(0 0% 5%);
  --neo-shadow-sm: 2px 2px 0px hsl(0 0% 5%);
  --font-sans: 'Space Grotesk', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --hero-bg: 0 0% 5%;
  --hero-text: 50 30% 99%;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  border-color: hsl(var(--border));
}

body {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: var(--font-sans);
  overflow: hidden; /* layout handles scrolling */
}

/* Master-Detail Layout */
.master-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.module-sidebar {
  width: 320px;
  background: hsl(var(--card)); /* Fixed: Use theme-aware background */
  border-right: 3px solid hsl(var(--border));
  display: flex;
  flex-direction: column;
  z-index: 20;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.module-sidebar.collapsed {
  width: 80px;
}

.sidebar-header {
  padding: 2rem;
  border-bottom: 2px solid hsl(var(--border));
  position: relative;
}

.sidebar-toggle-btn {
  position: absolute;
  right: -20px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  background: hsl(var(--card)); /* Fixed: Use theme-aware background */
  border: 3px solid hsl(var(--border));
  box-shadow: 2px 2px 0px hsl(var(--border));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 30;
  transition: all 0.2s;
}

.sidebar-toggle-btn:hover {
  transform: translateY(-50%) translate(-2px, -2px);
  box-shadow: 4px 4px 0px hsl(var(--border));
}

.collapsed .logo h1, .collapsed .search-container {
  display: none;
}

.collapsed .module-item {
  justify-content: center;
  padding: 1rem 0;
}

.collapsed .module-item span {
  display: none;
}

.search-container {
  margin-top: 1.5rem;
}

.module-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.module-item {
  display: flex;
  align-items: center;
  padding: 0.8rem 1.2rem;
  margin-bottom: 0.5rem;
  text-decoration: none;
  color: hsl(var(--foreground));
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.85rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.module-item:hover {
  background: hsl(var(--secondary));
  border-color: hsl(var(--border));
  box-shadow: var(--neo-shadow-sm);
  transform: translate(-1px, -1px);
}

.module-item.active {
  background: hsl(var(--primary));
  color: white;
  border-color: hsl(var(--border));
  box-shadow: var(--neo-shadow-sm);
}

.module-icon {
  width: 20px;
  height: 20px;
  margin-right: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.module-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor; /* Ensure icons use the current text color */
  stroke-width: 2.5;
}

.collapsed .module-icon {
  margin-right: 0;
}

/* Content Area */
.module-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative; /* Fixed: Allow footer to be absolute-docked at the bottom */
}

.content-header {
  padding: 1.5rem 3rem;
  border-bottom: 2px solid hsl(var(--border));
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

#module-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 4rem 3rem 10rem 3rem; /* Increase bottom padding so footer doesn't obscure content */
  scroll-behavior: smooth;
}

.module-hero {
  max-width: 900px;
  margin-bottom: 4rem;
  padding: 3rem;
  background: hsl(var(--hero-bg));
  color: hsl(var(--hero-text));
  border: 4px solid hsl(var(--border));
  box-shadow: 6px 6px 0px hsl(var(--secondary));
  position: relative;
  z-index: 1;
}

.module-summary {
  font-size: 1.2rem;
  margin-top: 2rem;
  line-height: 1.8;
  color: inherit;
  opacity: 0.9;
}

/* Documentation Cards */
.grid-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 2rem;
  margin-bottom: 3rem;
}

.neo-card {
  background: hsl(var(--card)); /* Balanced thematic background */
  border: 4px solid hsl(var(--border));
  box-shadow: var(--neo-shadow);
  padding: 2.5rem;
  transition: all 0.2s;
  color: hsl(var(--foreground)); /* Ensure text defaults to high contrast */
}

.neo-card h3 {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  text-transform: uppercase;
}

.neo-card h3 i {
  color: hsl(var(--primary));
}

.spotlight { background: hsl(var(--background)); }
.technical { background: hsl(var(--foreground)); color: white; }
.technical i { color: hsl(var(--secondary)) !important; }

.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.tech-item strong {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.5rem;
}

.tech-item code {
  font-family: var(--font-mono);
  font-weight: 700;
  color: hsl(var(--secondary));
}

/* Utilities */
.gradient-text {
  background: linear-gradient(135deg, hsl(262, 83%, 58%), hsl(45, 93%, 58%));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.neo-badge {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: white;
  border: 2px solid hsl(var(--border));
  box-shadow: var(--neo-shadow-sm);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.neo-badge.accent { background: hsl(var(--accent)); color: white; }

/* Marketing Components */
.stat-card {
  padding: 2rem;
  background: hsl(var(--primary) / 0.05);
  border: 3px dashed hsl(var(--border));
  text-align: center;
}

.stat-card h4 {
  font-size: 2.5rem;
  font-weight: 800;
  color: hsl(var(--primary));
  margin-bottom: 0.5rem;
}

.stat-card p {
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.hero-banner {
  background: hsl(var(--hero-bg));
  color: hsl(var(--hero-text));
  padding: 4rem;
  border: 4px solid hsl(var(--border));
  box-shadow: 8px 8px 0px hsl(var(--secondary));
  margin-bottom: 4rem;
}

.hero-banner .module-summary {
  color: inherit;
}

.neo-input {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 2px solid hsl(var(--border));
  box-shadow: var(--neo-shadow-sm);
  background: hsl(var(--card)); /* Theme-aware background */
  color: hsl(var(--foreground)); /* Theme-aware text */
  font-family: var(--font-sans);
  font-weight: 600;
}

.feat-list { list-style: none; margin-top: 1rem; }
.feat-list li { margin-bottom: 1rem; font-size: 0.95rem; }
.feat-tag { font-weight: 800; text-transform: uppercase; margin-right: 0.5rem; background: hsl(var(--secondary)); padding: 0.1rem 0.4rem; }

.code-block {
  background: #0c0c0c;
  padding: 1.5rem;
  border: 2px solid #333;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  overflow-x: auto;
  line-height: 1.6;
}

.neo-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.5rem;
}
.neo-table th, .neo-table td {
  padding: 1rem;
  border: 2px solid hsl(var(--border));
  text-align: left;
}
.neo-table th { 
  background: hsl(var(--foreground)); 
  color: hsl(var(--background)); /* Invert text for contrast */
  text-transform: uppercase; 
  font-size: 0.75rem; 
}

.content-footer {
  padding: 2rem 3rem;
  border-top: 3px solid hsl(var(--border));
  background: hsl(var(--card)); /* Theme-aware background */
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: absolute; /* Fixed: No ghost space when translated down */
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
}

.content-footer.collapsed {
  transform: translateY(100%); /* Truly hide the entire bar */
}

.content-footer.collapsed .nav-btns {
  visibility: hidden; /* Prevent text from showing if any bleed occurs */
}

.footer-toggle-btn {
  position: absolute;
  top: -24px;
  right: 3rem;
  width: 48px;
  height: 48px;
  background: hsl(var(--card));
  border: 3px solid hsl(var(--border));
  box-shadow: var(--neo-shadow-sm);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 60;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.footer-toggle-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--neo-shadow);
}

.content-footer.collapsed .footer-toggle-btn {
  top: -28px; /* Stay floating above the parent edge even when parent is off-screen */
}

.nav-btns {
  display: flex;
  justify-content: space-between;
}

.neo-btn {
  padding: 1rem 2rem;
  border: 3px solid hsl(var(--border));
  box-shadow: var(--neo-shadow-sm);
  background: hsl(var(--card)); /* Theme-aware background */
  color: hsl(var(--foreground));
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
}

.neo-btn:hover:not(.disabled) { transform: translate(-2px, -2px); box-shadow: var(--neo-shadow); }
.neo-btn.disabled { opacity: 0.3; cursor: not-allowed; }

.glass-effect { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); background: rgba(255, 255, 255, 0.5); }

/* Animations */
@keyframes fade-in { 0% { opacity: 0; transform: translateY(10px); } 100% { opacity: 1; transform: translateY(0); } }
.animate-fade-in { animation: fade-in 0.4s ease-out forwards; }

.dark {
  --background: 0 0% 8%;
  --foreground: 50 30% 96%;
  --card: 0 0% 12%;
  --neo-shadow: 4px 4px 0px hsl(50 30% 80%);
  --hero-bg: 0 0% 0%;
  --hero-text: 50 30% 96%;
}
