* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Theme Variables */
:root {
  /* Light Theme */
  --bg-color: #f8f9fa;
  --text-color: #333;
  --header-bg: #2c3e50;
  --sidebar-bg: white;
  --sidebar-border: #e0e6ed;
  --content-bg: white;
  --card-bg: white;
  --code-bg: #2c3e50;
  --code-text: #ecf0f1;
  --border-color: #e0e6ed;
  --link-color: #3498db;
  --link-hover: #2980b9;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-hover: rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] {
  /* Dark Theme */
  --bg-color: #1a1a1a;
  --text-color: #e2e6ec;
  --header-bg: #1f2530;
  --sidebar-bg: #232b38;
  --sidebar-border: #2f3542;
  --content-bg: #1f2530;
  --card-bg: #2a3441;
  --code-bg: #1e1e1e;
  --code-text: #dcdcdc;
  --border-color: #394150;
  --link-color: #9aa9ff;
  --link-hover: #7f8fff;
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-hover: rgba(0, 0, 0, 0.5);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background: var(--bg-color);
  transition: background 0.3s ease, color 0.3s ease;
}

/* Header */
.header {
  background: var(--header-bg);
  color: white;
  padding: 1rem 0;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  box-shadow: 0 2px 4px var(--shadow);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
  transition: background 0.3s;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.header h1 {
  flex: 1;
  font-size: 1.5rem;
  font-weight: 600;
}

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

.theme-toggle {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

.github-link {
  color: white;
  font-size: 1.5rem;
  text-decoration: none;
  transition: color 0.3s;
}

.github-link:hover {
  color: var(--link-color);
}

/* Main Container */
.main-container {
  display: flex;
  margin-top: 70px;
  min-height: calc(100vh - 70px);
}

/* Sidebar */
.sidebar {
  width: 300px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  position: fixed;
  height: calc(100vh - 70px);
  overflow-y: auto;
  transition: transform 0.3s ease;
  z-index: 100;
}

.sidebar.hidden {
  transform: translateX(-100%);
}

.sidebar-content {
  padding: 2rem 0;
}

.sidebar-section {
  margin-bottom: 2rem;
}

.sidebar-section h3 {
  color: var(--text-color);
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 1.5rem;
  margin-bottom: 0.5rem;
}

.sidebar-section ul {
  list-style: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  color: var(--text-color);
  text-decoration: none;
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
}

.nav-link:hover {
  background: var(--bg-color);
  color: var(--link-hover);
}

.nav-link.active {
  background: var(--content-bg);
  color: var(--link-color);
  border-left-color: var(--link-color);
}

.nav-link i {
  width: 16px;
  text-align: center;
}

/* Content */
.content {
  flex: 1;
  margin-left: 300px;
  padding: 2rem;
  max-width: calc(100% - 300px);
  transition: margin-left 0.3s ease, max-width 0.3s ease;
}

.content.sidebar-hidden {
  margin-left: 0;
  max-width: 100%;
}

.content-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.content-section.active {
  display: block;
}

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

.content h1 {
  color: var(--text-color);
  font-size: 2.5rem;
  margin-bottom: 1rem;
  border-bottom: 3px solid var(--link-color);
  padding-bottom: 0.5rem;
}

.content h2 {
  color: var(--text-color);
  font-size: 1.8rem;
  margin: 2rem 0 1rem;
}

.content h3 {
  color: var(--text-color);
  font-size: 1.3rem;
  margin: 1.5rem 0 0.5rem;
}

.lead {
  font-size: 1.2rem;
  color: var(--text-color);
  opacity: 0.8;
  margin-bottom: 2rem;
  line-height: 1.7;
}

/* Carousel */
.carousel-container {
  margin: 3rem 0;
}

.carousel {
  position: relative;
  max-width: 800px;
  margin: 2rem auto;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 25px var(--shadow-hover);
  border: 1px solid var(--border-color);
}

.carousel-track {
  display: flex;
  transition: transform 0.5s ease;
}

.carousel-slide {
  min-width: 100%;
  position: relative;
}

.carousel-image {
  width: 100%;
  height: 400px;
  object-fit: cover;
}

.carousel-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  color: white;
  padding: 2rem;
}

.carousel-caption h3 {
  color: white;
  margin: 0 0 0.5rem;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  padding: 1rem;
  cursor: pointer;
  font-size: 1.2rem;
  transition: background 0.3s;
}

.carousel-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

.carousel-btn.prev {
  left: 1rem;
}

.carousel-btn.next {
  right: 1rem;
}

.carousel-indicators {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
}

.indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: background 0.3s;
}

.indicator.active {
  background: white;
}

/* Features Grid */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  margin: 3rem 0;
}

.feature-card {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 4px 15px var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border: 1px solid var(--border-color);
}

.feature-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px var(--shadow-hover);
}

.feature-card i {
  font-size: 3rem;
  color: var(--link-color);
  margin-bottom: 1rem;
}

.feature-card h3 {
  color: var(--text-color);
  margin: 1rem 0 0.5rem;
}

.feature-card p {
  color: var(--text-color);
  opacity: 0.8;
}

/* Stats Section */
.stats-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin: 3rem 0;
}

.stat-item {
  background: linear-gradient(135deg, var(--link-color), var(--link-hover));
  color: white;
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
}

.stat-item i {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.stat-item h3 {
  color: white;
  margin: 0.5rem 0;
}

.stat-item p {
  opacity: 0.9;
}

/* Quick Links */
.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.quick-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-color);
  box-shadow: 0 4px 15px var(--shadow);
  transition: all 0.3s ease;
  border: 1px solid var(--border-color);
}

.quick-link:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px var(--shadow-hover);
  text-decoration: none;
  color: var(--text-color);
}

.quick-link i {
  font-size: 2rem;
  color: var(--link-color);
}

.quick-link h3 {
  margin: 0 0 0.25rem;
  color: var(--text-color);
}

.quick-link p {
  margin: 0;
  color: var(--text-color);
  opacity: 0.7;
  font-size: 0.9rem;
}

/* Code Blocks */
.code-block {
  margin: 2rem 0;
  position: relative; /* allow absolute-positioned copy button */
}

.code-block h3 {
  color: var(--text-color);
  margin-bottom: 0.5rem;
}

.code-block pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 1.5rem;
  border-radius: 8px;
  overflow-x: auto;
  font-family: "Fira Code", Consolas, monospace;
  line-height: 1.5;
  border: 1px solid var(--border-color);
}

/* Copy button for code blocks */
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--code-text);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s, transform 0.08s;
}

.copy-btn:hover {
  background: rgba(0, 0, 0, 0.4);
  transform: translateY(-1px);
}

.copy-btn.copied {
  background: rgba(40, 160, 80, 0.9);
  color: #fff;
}

/* Normalize list and details alignment inside dynamic content sections */
.content-section ul,
.content-section ol {
  margin: 1rem 0;
  padding-left: 1.25rem;
  list-style-position: outside;
}

.content-section li {
  margin-bottom: 0.45rem;
  line-height: 1.45;
}

/* Make sure nested strong/code in li don't break alignment */
.content-section li > strong,
.content-section li > code {
  display: inline-block;
}

/* Details/summary styling to match content flow */
.content-section details {
  margin: 1rem 0;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
}

.content-section details summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  outline: none;
}

.content-section details[open] {
  box-shadow: 0 6px 18px var(--shadow-hover);
}

/* Success Message */
.success-message {
  background: var(--card-bg);
  color: var(--link-color);
  padding: 1rem 1.5rem;
  border-radius: 8px;
  border-left: 4px solid var(--link-color);
  margin: 2rem 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--border-color);
}

/* Comparison table styling */
.table-wrap {
  overflow-x: auto;
  margin: 0.5rem 0;
}
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border-color);
  font-size: 0.95rem;
}
.comparison-table caption {
  color: var(--text-muted);
}
.comparison-table th,
.comparison-table td {
  border: 1px solid var(--border-color);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
.comparison-table thead th {
  background: var(--surface-elev-1);
  font-weight: 600;
}
.comparison-table tbody tr:nth-child(odd) {
  background: var(--surface-elev-0);
}
.comparison-table td {
  line-height: 1.35;
}

@media (max-width: 700px) {
  .comparison-table th,
  .comparison-table td {
    padding: 8px;
    font-size: 0.9rem;
  }
}

/* Compact variant for comparison tables */
.comparison-table.compact th,
.comparison-table.compact td {
  padding: 8px 10px;
}
.comparison-table.compact {
  font-size: 0.9rem;
}
.comparison-table.compact thead th i {
  color: var(--link-color);
  margin-right: 6px;
}

/* Performance notes box */
.perf-notes {
  margin-top: 0.6rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.perf-notes pre {
  margin: 0;
  white-space: pre-wrap;
}

/* Endpoint stats table */
.endpoint-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border-color);
}
.endpoint-table th,
.endpoint-table td {
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  text-align: left;
  font-size: 0.92rem;
}
.endpoint-table thead th {
  background: var(--surface-elev-1);
  font-weight: 600;
}
.muted-note {
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-size: 0.92rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .content {
    margin-left: 0;
    max-width: 100%;
    padding: 1rem;
  }

  .header h1 {
    font-size: 1.2rem;
  }

  .carousel-btn {
    padding: 0.75rem;
    font-size: 1rem;
  }

  .features-grid,
  .stats-section {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 480px) {
  .header-content {
    padding: 0 0.5rem;
  }

  .content {
    padding: 0.5rem;
  }

  .carousel-image {
    height: 250px;
  }

  .carousel-caption {
    padding: 1rem;
  }
}

/* Default to dark theme */
html {
  color-scheme: dark;
}

/* Set default theme to dark */
:root {
  --bg-color: #1a1a1a;
  --text-color: #e2e6ec;
  --header-bg: #1f2530;
  --sidebar-bg: #232b38;
  --sidebar-border: #2f3542;
  --content-bg: #1f2530;
  --card-bg: #2a3441;
  --code-bg: #1e1e1e;
  --code-text: #dcdcdc;
  --border-color: #394150;
  --link-color: #9aa9ff;
  --link-hover: #7f8fff;
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-hover: rgba(0, 0, 0, 0.5);
}

/* Light theme override when specifically set */
[data-theme="light"] {
  --bg-color: #f8f9fa;
  --text-color: #333;
  --header-bg: #2c3e50;
  --sidebar-bg: white;
  --sidebar-border: #e0e6ed;
  --content-bg: white;
  --card-bg: white;
  --code-bg: #2c3e50;
  --code-text: #ecf0f1;
  --border-color: #e0e6ed;
  --link-color: #3498db;
  --link-hover: #2980b9;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-hover: rgba(0, 0, 0, 0.15);
}
