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

:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-bg: #eff6ff;
  --bg: #ffffff;
  --bg-secondary: #f8fafc;
  --text: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --code-bg: #1e1e2e;
  --code-text: #cdd6f4;
  --success: #10b981;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --warning-border: #fcd34d;
  --info-bg: #eff6ff;
  --info-border: #93c5fd;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --sidebar-width: 280px;
  --header-height: 60px;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 20px);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg-secondary);
}

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

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

/* ========== Header ========== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 1000;
  box-shadow: var(--shadow);
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-title .logo {
  width: 28px;
  height: 28px;
  background: var(--primary);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 14px;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  margin-right: 12px;
  border-radius: 6px;
  color: var(--text-secondary);
  transition: background 0.2s;
}

.menu-toggle:hover {
  background: var(--border-light);
}

.menu-toggle svg {
  display: block;
}

/* ========== Layout ========== */
.layout {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

/* ========== Sidebar ========== */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background: var(--bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 0;
  z-index: 900;
  transition: transform 0.3s ease;
}

.sidebar-nav {
  list-style: none;
}

.sidebar-nav .nav-section {
  padding: 8px 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 12px;
}

.sidebar-nav .nav-section:first-child {
  margin-top: 0;
}

.sidebar-nav .nav-item a {
  display: block;
  padding: 7px 20px 7px 24px;
  font-size: 14px;
  color: var(--text-secondary);
  border-left: 3px solid transparent;
  transition: all 0.2s;
  line-height: 1.5;
}

.sidebar-nav .nav-item a:hover {
  color: var(--primary);
  background: var(--primary-bg);
  text-decoration: none;
}

.sidebar-nav .nav-item a.active {
  color: var(--primary);
  background: var(--primary-bg);
  border-left-color: var(--primary);
  font-weight: 500;
}

.sidebar-nav .nav-item.sub a {
  padding-left: 40px;
  font-size: 13px;
}

/* ========== Main Content ========== */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px 40px 80px;
  max-width: 900px;
}

.content {
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 40px 48px;
  box-shadow: var(--shadow);
}

/* ========== Typography ========== */
.content h1 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text);
  line-height: 1.3;
}

.content h2 {
  font-size: 22px;
  font-weight: 700;
  margin-top: 48px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  color: var(--text);
}

.content h3 {
  font-size: 18px;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 12px;
  color: var(--text);
}

.content h4 {
  font-size: 16px;
  font-weight: 600;
  margin-top: 24px;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.content p {
  margin-bottom: 16px;
}

.content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

.content ul, .content ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.content li {
  margin-bottom: 6px;
}

.content strong {
  font-weight: 600;
}

/* ========== Base URL Banner ========== */
.base-url-banner {
  background: var(--primary-bg);
  border: 1px solid var(--info-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  font-size: 15px;
}

.base-url-banner code {
  background: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  color: var(--primary);
  border: 1px solid var(--border);
}

/* ========== Blockquote / Callout ========== */
.content blockquote {
  border-left: 4px solid var(--info-border);
  background: var(--info-bg);
  padding: 14px 18px;
  margin: 16px 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.content blockquote p {
  margin-bottom: 6px;
}

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

.content blockquote.warning {
  border-left-color: var(--warning-border);
  background: var(--warning-bg);
}

/* ========== Inline Code ========== */
.content code {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;
  font-size: 0.875em;
  color: #c7254e;
  word-break: break-word;
}

/* ========== Code Block ========== */
.code-block {
  position: relative;
  margin: 16px 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #181825;
  padding: 8px 16px;
  font-size: 12px;
  color: #a6adc8;
  font-family: "JetBrains Mono", monospace;
}

.copy-btn {
  background: transparent;
  border: 1px solid #45475a;
  border-radius: 4px;
  color: #a6adc8;
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.copy-btn:hover {
  background: #313244;
  color: #cdd6f4;
  border-color: #585b70;
}

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

.code-block pre {
  margin: 0;
  padding: 16px;
  background: var(--code-bg);
  overflow-x: auto;
}

.code-block pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--code-text);
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;
  font-size: 14px;
  line-height: 1.6;
}

/* ========== Table ========== */
.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.content thead th {
  background: var(--bg-secondary);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  border-bottom: 2px solid var(--border);
}

.content tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
}

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

.content tbody tr:hover {
  background: var(--bg-secondary);
}

.content tbody td code {
  font-size: 13px;
}

/* ========== Image ========== */
.content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 16px 0;
  box-shadow: var(--shadow-md);
}

/* ========== Step Number ========== */
.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  margin-right: 8px;
  flex-shrink: 0;
}

/* ========== Footer ========== */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* ========== Sidebar overlay ========== */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.3);
  z-index: 800;
}

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

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

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }

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

  .main {
    margin-left: 0;
    padding: 20px 16px 60px;
  }

  .content {
    padding: 24px 20px;
  }

  .content h1 {
    font-size: 22px;
  }

  .content h2 {
    font-size: 19px;
  }
}

@media (max-width: 480px) {
  .content {
    padding: 20px 16px;
  }

  .content table {
    font-size: 13px;
  }

  .content thead th,
  .content tbody td {
    padding: 8px 10px;
  }
}

/* ========== Scrollbar ========== */
.sidebar::-webkit-scrollbar {
  width: 4px;
}

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

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.code-block pre::-webkit-scrollbar {
  height: 6px;
}

.code-block pre::-webkit-scrollbar-track {
  background: #11111b;
}

.code-block pre::-webkit-scrollbar-thumb {
  background: #45475a;
  border-radius: 3px;
}
