/* ==================== CSS Variables ==================== */
:root {
  --bg-primary: #0a0c10;
  --bg-secondary: #12151c;
  --bg-tertiary: #181c25;
  --bg-card: #12151c;
  --bg-card-hover: #181c25;
  --sidebar-bg: #0f1218;
  --border-color: #1e232e;
  --border-subtle: #1e232e;
  --text-primary: #e8eaed;
  --text-secondary: #8b919e;
  --text-muted: #5a6070;
  --accent: #4ade80;
  --accent-2: #60a5fa;
  --accent-hover: #34d399;
  --accent-glow: rgba(74, 222, 128, 0.15);
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
  --purple: #a78bfa;
  --bg-gradient: linear-gradient(180deg, #0f1218 0%, #0a0c10 100%);
  --sidebar-width: 280px;
  --header-height: 0px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
}

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

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.7;
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent);
  color: white;
}

/* ==================== Sidebar ==================== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 18px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: #0b0d13;
  flex-shrink: 0;
  box-shadow: 0 8px 16px rgba(124, 241, 199, 0.2);
}

.logo-mark {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.logo-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
}

.logo-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

/* Search */
.search-container {
  position: relative;
  padding: 12px 18px;
}

.search-input {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 9px 12px 9px 36px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.search-icon {
  position: absolute;
  left: 30px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-kbd {
  position: absolute;
  right: 30px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-sans);
  pointer-events: none;
}

/* Search Results */
.search-results {
  display: none;
  padding: 0 18px 12px;
  max-height: 300px;
  overflow-y: auto;
}

.search-results.active {
  display: block;
}

.search-result-item {
  display: block;
  padding: 8px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}

.search-result-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.search-result-item .search-match {
  color: var(--accent);
  font-weight: 600;
}

.search-result-section {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.search-no-results {
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px 12px;
}

@keyframes searchTargetFlash {
  0% {
    outline-color: rgba(74, 222, 128, 0.85);
    background: rgba(74, 222, 128, 0.22);
  }
  100% {
    outline-color: rgba(74, 222, 128, 0);
    background: transparent;
  }
}

.search-target-highlight {
  outline: 2px solid rgba(74, 222, 128, 0);
  outline-offset: 3px;
  border-radius: 6px;
  animation: searchTargetFlash 1.8s ease;
}

/* Navigation */
.nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.nav::-webkit-scrollbar {
  width: 4px;
}

.nav::-webkit-scrollbar-track {
  background: transparent;
}

.nav::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.nav-section {
  padding: 4px 0;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 10px 18px 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 18px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 450;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.nav-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.15s;
}

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

.nav-link:hover svg {
  opacity: 0.9;
}

.nav-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(74, 222, 128, 0.1);
  font-weight: 550;
}

.nav-link.active svg {
  opacity: 1;
  color: var(--accent);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border-subtle);
}

.sidebar-footer-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.sidebar-footer-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 4px 0;
  transition: color 0.2s;
}

.sidebar-footer-link:hover {
  color: var(--accent);
}

.sidebar-footer-link svg {
  flex-shrink: 0;
  opacity: 0.6;
}

.version-badge {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

/* ==================== Main Content ==================== */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  padding: 0 0 80px;
}

.content-section {
  display: none;
  padding: 0 48px;
  max-width: 900px;
}

.content-section.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

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

/* Section Hero */
.section-hero {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 32px;
}

.section-hero h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 8px;
}

.hero-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Typography */
h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 36px 0 14px;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

h3 {
  font-size: 17px;
  font-weight: 650;
  margin: 24px 0 10px;
  color: var(--text-primary);
}

p {
  margin-bottom: 14px;
  color: var(--text-secondary);
  line-height: 1.75;
}

ul, ol {
  margin-bottom: 14px;
  padding-left: 24px;
}

li {
  color: var(--text-secondary);
  margin-bottom: 6px;
  line-height: 1.65;
}

li strong {
  color: var(--text-primary);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

code {
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.88em;
  color: var(--accent);
}

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

/* ==================== Components ==================== */

/* Info Grid (Home) */
.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 0 0 32px;
}

.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.info-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.info-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.info-card-icon svg {
  width: 22px;
  height: 22px;
}

.info-card h3 {
  font-size: 15px;
  font-weight: 650;
  margin: 0 0 6px;
}

.info-card p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.6;
}

/* Callout */
.callout {
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin: 20px 0;
  border: 1px solid;
}

.callout h4 {
  font-size: 14px;
  font-weight: 650;
  margin-bottom: 6px;
}

.callout p {
  font-size: 14px;
  margin: 0;
  line-height: 1.65;
}

.callout-info {
  background: rgba(96, 165, 250, 0.1);
  border-color: rgba(96, 165, 250, 0.28);
}

.callout-info h4 {
  color: var(--accent);
}

.callout-success {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.25);
}

.callout-success h4 {
  color: var(--success);
}

.callout-warning {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.25);
}

.callout-warning h4 {
  color: var(--warning);
}

/* Badges */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
  vertical-align: middle;
  margin-left: 4px;
}

.badge-live {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-dev {
  background: rgba(167, 139, 250, 0.15);
  color: var(--purple);
  border: 1px solid rgba(167, 139, 250, 0.3);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Tables */
.table-container {
  overflow-x: auto;
  margin: 16px 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead {
  background: var(--bg-tertiary);
}

th {
  text-align: left;
  padding: 10px 16px;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: 10px 16px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

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

tr:hover td {
  background: var(--bg-card);
}

.impact-high {
  color: var(--success);
  font-weight: 600;
}

.impact-medium {
  color: var(--warning);
  font-weight: 600;
}

/* Spec Grid */
.spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
}

.spec-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.spec-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.spec-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Metric Grid */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin: 16px 0 20px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  border-left: 3px solid var(--accent);
}

.metric-name {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 4px;
}

.metric-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Formula Box */
.formula-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin: 16px 0;
  text-align: center;
}

.formula-box code {
  font-size: 18px;
  background: none;
  border: none;
  color: var(--accent);
  display: block;
  margin-bottom: 10px;
}

.formula-box p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

/* Back to Top */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 42px;
  height: 42px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 50;
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--accent-hover);
}

.back-to-top svg {
  width: 20px;
  height: 20px;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  width: 40px;
  height: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.mobile-menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.mobile-menu-toggle.active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.mobile-menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 90;
  backdrop-filter: blur(4px);
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-lg);
  }

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

  .sidebar-overlay.active {
    display: block;
  }

  .main {
    margin-left: 0;
  }

  .content-section {
    padding: 0 20px;
  }

  .section-hero {
    padding-top: 72px;
  }

  .section-hero h1 {
    font-size: 24px;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .spec-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) and (max-width: 1100px) {
  .content-section {
    padding: 0 32px;
  }

  .info-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==================== Print ==================== */
@media print {
  .sidebar, .mobile-menu-toggle, .back-to-top, .sidebar-overlay {
    display: none !important;
  }

  .main {
    margin-left: 0;
  }

  .content-section {
    display: block !important;
    page-break-after: always;
    padding: 0 20px;
  }

  body {
    background: white;
    color: black;
  }
}
