/* CSS Variables */
:root {
  --primary: #5818C8;
  --primary-light: #8B5CF6;
  --primary-dark: #4C1D95;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --code-bg: #1e293b;
  --code-text: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  --sidebar-width: 280px;
  --topbar-height: 64px;
  --transition: 0.2s ease;
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --border-light: #1e293b;
  --code-bg: #0f172a;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Topbar */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
}

.menu-toggle:hover {
  background: var(--bg-secondary);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.25rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color var(--transition);
}

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

.btn-primary {
  background: var(--primary);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  border: none;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.theme-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  background: var(--bg-secondary);
}

.moon-icon {
  display: none;
}

[data-theme="dark"] .sun-icon {
  display: none;
}

[data-theme="dark"] .moon-icon {
  display: block;
}

/* Layout */
.layout {
  display: flex;
  padding-top: var(--topbar-height);
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--topbar-height));
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 24px 0;
  z-index: 50;
}

.sidebar-nav {
  padding: 0 16px;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-link {
  display: block;
  padding: 8px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  border-radius: 6px;
  transition: all var(--transition);
}

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

.nav-link.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
}

.nav-link.sub {
  padding-left: 24px;
  font-size: 0.8125rem;
}

.nav-group {
  margin: 8px 0;
}

.nav-group-title {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 4px 12px;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 40px 60px;
  max-width: calc(100% - var(--sidebar-width));
}

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

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

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

/* Section Header */
.section-header {
  margin-bottom: 40px;
}

.section-header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--text-primary), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.section-description {
  font-size: 1.125rem;
  color: var(--text-secondary);
}

/* Typography */
h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 40px 0 16px;
  color: var(--text-primary);
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 32px 0 12px;
  color: var(--text-primary);
}

h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 24px 0 8px;
  color: var(--text-primary);
}

p {
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.lead {
  font-size: 1.125rem;
  line-height: 1.7;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

ul, ol {
  margin: 16px 0;
  padding-left: 24px;
  color: var(--text-secondary);
}

li {
  margin-bottom: 8px;
}

code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875em;
  background: var(--bg-tertiary);
  padding: 3px 8px;
  border-radius: 6px;
  color: #0ea5e9;
}

[data-theme="dark"] code {
  background: #1e293b;
  color: #38bdf8;
}

/* Code Blocks */
.code-block {
  position: relative;
  margin: 16px 0;
  border-radius: 16px;
  overflow: hidden;
  background: var(--code-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.code-block pre {
  margin: 0;
  padding: 20px;
  overflow-x: auto;
}

.code-block code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  background: none;
  padding: 0;
  color: var(--code-text);
}

.copy-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--code-text);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  opacity: 0;
  transition: all var(--transition);
}

.code-block:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.copy-btn.copied {
  background: var(--success);
  color: white;
}

/* Code Tabs */
.code-tabs {
  margin: 16px 0;
}

.code-tab-buttons {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: 8px;
  width: fit-content;
}

.code-tab-btn {
  background: none;
  border: none;
  padding: 8px 16px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--transition);
}

.code-tab-btn:hover {
  color: var(--text-primary);
}

.code-tab-btn.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.code-tab-content {
  display: none;
}

.code-tab-content.active {
  display: block;
}

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 24px 0;
}

.card-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.card:hover {
  border-color: var(--primary);
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(88, 24, 200, 0.15);
  text-decoration: none;
}

.card-icon {
  font-size: 2rem;
  margin-bottom: 12px;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 1.125rem;
}

.card p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.card ul {
  margin: 12px 0 0;
  padding-left: 16px;
  font-size: 0.875rem;
}

.card.highlight {
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-primary));
}

.card .price {
  font-size: 1.25rem;
  color: var(--primary);
  margin: 8px 0;
}

/* Accordion */
.accordion {
  margin: 24px 0;
}

.accordion-item {
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-bottom: 8px;
  overflow: hidden;
}

.accordion-header {
  width: 100%;
  background: var(--bg-secondary);
  border: none;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: background var(--transition);
}

.accordion-header:hover {
  background: var(--bg-tertiary);
}

.accordion-icon {
  transition: transform var(--transition);
}

.accordion-item.open .accordion-icon {
  transform: rotate(180deg);
}

.accordion-content {
  display: none;
  padding: 16px 20px;
  background: var(--bg-primary);
}

.accordion-item.open .accordion-content {
  display: block;
}

/* Steps */
.steps {
  margin: 24px 0;
}

.step {
  display: flex;
  gap: 20px;
  margin-bottom: 32px;
}

.step-number {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.125rem;
}

.step-content {
  flex: 1;
}

.step-content h3 {
  margin-top: 0;
  margin-bottom: 12px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th, td {
  padding: 14px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-primary);
}

th:first-child {
  border-top-left-radius: 15px;
}

th:last-child {
  border-top-right-radius: 15px;
}

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

tr:last-child td:first-child {
  border-bottom-left-radius: 15px;
}

tr:last-child td:last-child {
  border-bottom-right-radius: 15px;
}

td {
  color: var(--text-secondary);
}

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

tr.highlight td {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-primary);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge.pending {
  background: #fbbf24;
  color: #78350f;
}

.badge.success {
  background: #10b981;
  color: #ffffff;
}

.badge.warning {
  background: #f59e0b;
  color: #78350f;
}

.badge.error {
  background: #ef4444;
  color: #ffffff;
}

.badge.info {
  background: #3b82f6;
  color: #ffffff;
}

/* Method badges */
.method {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}

.method.get {
  background: #059669;
  color: #ffffff;
}

.method.post {
  background: #2563eb;
  color: #ffffff;
}

.method.put {
  background: #d97706;
  color: #ffffff;
}

.method.delete {
  background: #dc2626;
  color: #ffffff;
}

/* Endpoint Header */
.endpoint-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.endpoint-header code {
  font-size: 1rem;
  background: var(--bg-tertiary);
  padding: 8px 16px;
  border-radius: 8px;
}

/* Params Table */
.params-table {
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg-secondary);
}

.param-row {
  display: grid;
  grid-template-columns: 200px 100px 1fr;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  align-items: start;
}

.param-row:last-child {
  border-bottom: none;
}

.param-name {
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.param-name .required {
  display: inline-block;
  font-size: 0.625rem;
  background: var(--primary);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 8px;
  text-transform: uppercase;
  font-weight: 600;
  vertical-align: middle;
}

.param-type {
  color: #0ea5e9;
  font-size: 0.8125rem;
  font-family: 'JetBrains Mono', monospace;
  background: rgba(14, 165, 233, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
}

.param-desc {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Callouts */
.callout {
  padding: 18px 24px;
  border-radius: 16px;
  margin: 16px 0;
  border-left: 4px solid;
}

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

.callout.info {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--info);
}

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

.callout.error {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--error);
}

.callout p:last-child {
  margin-bottom: 0;
}

/* Responsive */
@media (max-width: 1024px) {
  .main-content {
    padding: 32px 40px;
  }
  
  .card-grid.cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }
  
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
    max-width: 100%;
    padding: 24px 20px;
  }
  
  .section-header h1 {
    font-size: 2rem;
  }
  
  .card-grid,
  .card-grid.cols-3 {
    grid-template-columns: 1fr;
  }
  
  .param-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  
  .topbar-link {
    display: none;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

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

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Syntax Highlighting Override */
.hljs {
  background: transparent !important;
}
