/* === Docs Layout === */
.docs-layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: calc(100vh - 64px);
  padding-top: 64px;
}

/* === Sidebar === */
.docs-sidebar {
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  padding: 32px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.docs-sidebar::-webkit-scrollbar {
  width: 4px;
}

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

.docs-sidebar-header {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
}

.docs-sidebar-header a {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-solid);
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.docs-sidebar-header a:hover {
  text-decoration: none;
  color: var(--text-primary);
}

.docs-sidebar-header .docs-back-arrow {
  font-size: 1rem;
  line-height: 1;
}

.docs-sidebar-section {
  padding: 0 0 12px;
}

.docs-sidebar-section h4 {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 8px 20px 6px;
}

.docs-sidebar a {
  display: block;
  padding: 7px 20px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.docs-sidebar a:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
  text-decoration: none;
}

.docs-sidebar a.active {
  color: var(--accent-solid);
  border-left-color: var(--accent-solid);
  background: var(--accent-glow);
  font-weight: 500;
}

/* Mobile sidebar toggle */
.docs-sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 200;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  border: none;
  cursor: pointer;
  color: #fff;
  font-size: 1.2rem;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.docs-sidebar-toggle:hover {
  transform: scale(1.05);
}

/* === Main Content === */
.docs-content {
  max-width: 720px;
  padding: 48px 48px 80px;
  overflow-x: hidden;
}

.docs-content > h1 {
  font-family: var(--font-mono);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 8px;
}

.docs-content > .docs-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 40px;
}

.docs-content h2 {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 56px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
  line-height: 1.3;
}

.docs-content h3 {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: 36px;
  margin-bottom: 12px;
  line-height: 1.3;
}

.docs-content h4 {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 28px;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

.docs-content p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 16px;
}

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

.docs-content li {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 6px;
}

.docs-content li code,
.docs-content p code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--bg-surface);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--accent-solid);
}

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

.docs-content a {
  color: var(--accent-solid);
  text-decoration: underline;
  text-decoration-color: rgba(124, 110, 246, 0.3);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.15s;
}

.docs-content a:hover {
  text-decoration-color: var(--accent-solid);
}

/* === TOC (Right Side) === */
.docs-toc {
  position: fixed;
  top: 100px;
  right: 32px;
  width: 200px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.docs-toc h4 {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.docs-toc a {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 0 4px 12px;
  border-left: 2px solid var(--border-color);
  transition: color 0.15s, border-color 0.15s;
}

.docs-toc a:hover {
  color: var(--text-secondary);
  text-decoration: none;
}

.docs-toc a.active {
  color: var(--accent-solid);
  border-left-color: var(--accent-solid);
}

.docs-toc a.toc-h3 {
  padding-left: 24px;
  font-size: 0.75rem;
}

/* === Callout Boxes === */
.docs-callout {
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin: 24px 0;
  border-left: 4px solid;
  font-size: 0.9rem;
  line-height: 1.65;
}

.docs-callout p {
  margin-bottom: 8px;
  font-size: 0.9rem;
}

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

.docs-callout-title {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.82rem;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.docs-callout.tip {
  background: rgba(34, 197, 94, 0.06);
  border-left-color: var(--success);
}

.docs-callout.tip .docs-callout-title {
  color: var(--success);
}

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

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

.docs-callout.danger {
  background: rgba(239, 68, 68, 0.06);
  border-left-color: var(--error);
}

.docs-callout.danger .docs-callout-title {
  color: var(--error);
}

.docs-callout.info {
  background: var(--accent-glow);
  border-left-color: var(--accent-solid);
}

.docs-callout.info .docs-callout-title {
  color: var(--accent-solid);
}

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

.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.docs-table thead {
  background: var(--bg-elevated);
}

.docs-table th {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.docs-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  line-height: 1.5;
  vertical-align: top;
}

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

.docs-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.015);
}

.docs-table td code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg-surface);
  padding: 2px 5px;
  border-radius: 3px;
  color: var(--accent-solid);
  white-space: nowrap;
}

.docs-table .required {
  color: var(--error);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
}

/* === Code Blocks === */
.docs-code {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin: 20px 0;
  overflow: hidden;
}

.docs-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-color);
}

.docs-code-lang {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.docs-code-copy {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.docs-code-copy:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

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

.docs-code pre {
  padding: 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin: 0;
}

.docs-code pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* === Breadcrumb === */
.docs-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  font-size: 0.8rem;
}

.docs-breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.docs-breadcrumb a:hover {
  color: var(--text-secondary);
}

.docs-breadcrumb .sep {
  color: var(--text-muted);
}

.docs-breadcrumb .current {
  color: var(--text-secondary);
}

/* === Step Lists === */
.docs-steps {
  counter-reset: step;
  list-style: none;
  padding-left: 0;
  margin: 24px 0;
}

.docs-steps li {
  counter-increment: step;
  position: relative;
  padding-left: 48px;
  margin-bottom: 24px;
}

.docs-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* === Next/Prev Navigation === */
.docs-nav-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--border-color);
}

.docs-nav-link {
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.docs-nav-link:hover {
  border-color: var(--accent-solid);
  background: var(--accent-glow);
  text-decoration: none;
}

.docs-nav-link.prev {
  align-items: flex-start;
}

.docs-nav-link.next {
  align-items: flex-end;
  text-align: right;
}

.docs-nav-link .docs-nav-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.docs-nav-link .docs-nav-title {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-solid);
}

/* === Architecture Diagram === */
.docs-arch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 24px 0;
}

.docs-arch-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.docs-arch-card .arch-icon {
  font-size: 1.4rem;
  margin-bottom: 8px;
}

.docs-arch-card h4 {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 4px;
}

.docs-arch-card p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

/* === Responsive === */
@media (max-width: 1100px) {
  .docs-toc {
    display: none;
  }
}

@media (max-width: 768px) {
  .docs-layout {
    grid-template-columns: 1fr;
  }

  .docs-sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

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

  .docs-sidebar-overlay {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 140;
  }

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

  .docs-sidebar-toggle {
    display: flex;
  }

  .docs-content {
    padding: 32px 20px 80px;
    max-width: 100%;
  }

  .docs-nav-bottom {
    grid-template-columns: 1fr;
  }

  .docs-nav-link.next {
    align-items: flex-start;
    text-align: left;
  }
}

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

  .docs-content h2 {
    font-size: 1.15rem;
  }

  .docs-table-wrapper {
    font-size: 0.8rem;
  }
}
