/* ═══════════════════════════════════════════════════════════════
   CRHQ Docs — Wiki-style documentation layout
   Inherits design tokens from style.css
   ═══════════════════════════════════════════════════════════════ */

/* ── Layout Shell ───────────────────────────────────────────── */

.docs-layout {
  display: flex;
  min-height: 100vh;
  padding-top: 0; /* No global nav */
}

/* ── Sidebar ────────────────────────────────────────────────── */

.docs-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 50;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: var(--border-visible) transparent;
}

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

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

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

/* Sidebar header */
.docs-sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.docs-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.docs-sidebar-logo svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.docs-sidebar-logo span {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.docs-sidebar-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-left: auto;
}

/* Back to site link */
.docs-back-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px solid var(--border-subtle);
  transition: color 0.2s;
  flex-shrink: 0;
}

.docs-back-link:hover {
  color: var(--accent);
}

.docs-back-link svg {
  width: 14px;
  height: 14px;
}

/* Sidebar search */
.docs-search {
  padding: 12px 16px;
  flex-shrink: 0;
}

.docs-search-input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b6e82' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}

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

.docs-search-input:focus {
  border-color: var(--accent);
}

/* Sidebar navigation */
.docs-nav {
  flex: 1;
  padding: 4px 0 24px;
  overflow-y: auto;
}

.docs-nav-section {
  margin-bottom: 4px;
}

.docs-nav-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}

.docs-nav-section-title:hover {
  color: var(--text-primary);
}

.docs-nav-section-title svg {
  width: 12px;
  height: 12px;
  transition: transform 0.2s;
  opacity: 0.5;
}

.docs-nav-section.collapsed .docs-nav-section-title svg {
  transform: rotate(-90deg);
}

.docs-nav-section.collapsed .docs-nav-items {
  display: none;
}

.docs-nav-items {
  list-style: none;
  margin: 0;
  padding: 0 0 8px;
}

.docs-nav-item a {
  display: block;
  padding: 5px 20px 5px 28px;
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all 0.15s;
  line-height: 1.5;
}

.docs-nav-item a:hover {
  color: var(--text-primary);
  background: rgba(124, 58, 237, 0.04);
}

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

/* ── Main Content ───────────────────────────────────────────── */

.docs-main {
  flex: 1;
  margin-left: 280px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Top bar */
.docs-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 32px;
  background: rgba(6, 7, 11, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}

.docs-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.docs-breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

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

.docs-breadcrumb .sep {
  opacity: 0.4;
}

.docs-topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.docs-topbar-link {
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

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

/* Content area */
.docs-content {
  flex: 1;
  display: flex;
  max-width: 100%;
}

.docs-article-wrap {
  flex: 1;
  min-width: 0;
  max-width: 800px;
  padding: 48px 56px 80px;
}

/* Article header */
.docs-article-header {
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.docs-article-category {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.docs-article-title {
  font-size: clamp(28px, 3vw, 36px);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}

.docs-article-description {
  font-size: 17px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

/* Article body — reuse help-article patterns */
.docs-article {
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-primary);
}

.docs-article h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 48px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  letter-spacing: -0.01em;
}

.docs-article h2:first-child {
  margin-top: 0;
}

.docs-article h3 {
  font-size: 19px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 36px 0 12px;
}

.docs-article h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 28px 0 8px;
}

.docs-article p {
  margin: 0 0 16px;
  color: rgba(232, 232, 237, 0.85);
}

.docs-article a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: opacity 0.2s;
}

.docs-article a:hover {
  opacity: 0.8;
}

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

.docs-article li {
  margin-bottom: 6px;
  color: rgba(232, 232, 237, 0.85);
}

.docs-article li::marker {
  color: var(--text-muted);
}

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

.docs-article code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875em;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  color: #e8b4f8;
}

.docs-article pre {
  margin: 0 0 20px;
  padding: 16px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-visible) transparent;
}

.docs-article pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-primary);
}

.docs-article img {
  max-width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin: 8px 0 16px;
}

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

/* Tables */
.docs-table-wrap {
  overflow-x: auto;
  margin: 0 0 20px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

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

.docs-table th {
  text-align: left;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border-subtle);
}

.docs-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: rgba(232, 232, 237, 0.85);
}

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

.docs-table tr:hover td {
  background: rgba(124, 58, 237, 0.03);
}

/* Callouts */
.docs-callout {
  padding: 16px 20px;
  margin: 0 0 20px;
  border-left: 3px solid var(--border-visible);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: var(--bg-surface);
  font-size: 14px;
  line-height: 1.65;
}

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

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

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

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

/* ── Right-side Table of Contents ───────────────────────────── */

.docs-toc {
  position: sticky;
  top: 72px;
  width: 220px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  padding: 32px 24px 32px 0;
  flex-shrink: 0;
  scrollbar-width: none;
}

.docs-toc::-webkit-scrollbar {
  display: none;
}

.docs-toc-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.docs-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.docs-toc-list li {
  margin-bottom: 2px;
}

.docs-toc-list a {
  display: block;
  padding: 3px 0 3px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 1px solid var(--border-subtle);
  transition: all 0.15s;
  line-height: 1.5;
}

.docs-toc-list a:hover {
  color: var(--text-primary);
}

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

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

/* ── What's Next section ─────────────────────────────────────── */

.docs-whats-next {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border-subtle);
}

.docs-whats-next h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 16px;
  padding: 0;
  border: none;
}

.docs-whats-next-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.docs-whats-next-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all 0.2s;
}

.docs-whats-next-card:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
  transform: translateY(-1px);
}

.docs-whats-next-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--accent);
}

.docs-whats-next-desc {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Prev / Next navigation ─────────────────────────────────── */

.docs-pagination {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid var(--border-subtle);
}

.docs-pagination-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all 0.2s;
}

.docs-pagination-link:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.docs-pagination-link.next {
  text-align: right;
  grid-column: 2;
}

.docs-pagination-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.docs-pagination-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--accent);
}

/* ── Search Results Overlay ─────────────────────────────────── */

.docs-search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-visible);
  border-radius: var(--radius-md);
  max-height: 320px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.docs-search-results.visible {
  display: block;
}

.docs-search-result {
  display: block;
  padding: 10px 16px;
  text-decoration: none;
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.15s;
}

.docs-search-result:last-child {
  border-bottom: none;
}

.docs-search-result:hover {
  background: var(--accent-glow);
}

.docs-search-result-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

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

/* ── Mobile Sidebar Toggle ──────────────────────────────────── */

.docs-mobile-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  z-index: 60;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4);
  align-items: center;
  justify-content: center;
}

.docs-mobile-toggle svg {
  width: 20px;
  height: 20px;
}

.docs-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 11, 0.7);
  z-index: 45;
}

/* ── Responsive ─────────────────────────────────────────────── */

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

@media (max-width: 768px) {
  .docs-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: 280px;
    z-index: 55;
  }

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

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

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

  .docs-main {
    margin-left: 0;
  }

  .docs-article-wrap {
    padding: 32px 20px 60px;
  }

  /* Topbar: stack breadcrumbs and actions vertically */
  .docs-topbar {
    padding: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .docs-topbar-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-subtle);
  }

  .docs-topbar-mobile-header .docs-mobile-nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    padding: 6px 12px;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
  }

  .docs-topbar-mobile-header .docs-mobile-nav-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
  }

  .docs-topbar-mobile-header .docs-mobile-nav-btn svg {
    width: 16px;
    height: 16px;
  }

  .docs-topbar-actions {
    padding: 0 16px 0 0;
    flex-shrink: 0;
  }

  .docs-breadcrumb {
    display: none;
  }

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

  .docs-pagination-link.next {
    grid-column: 1;
    text-align: left;
  }
}

/* Hide mobile header elements on desktop */
.docs-topbar-mobile-header {
  display: none;
}

/* On mobile, hide the desktop actions row (shown inside mobile header instead) */
@media (max-width: 768px) {
  .docs-topbar-actions-desktop {
    display: none;
  }

  .docs-topbar-mobile-header {
    display: flex;
  }
}

/* ── Utility ────────────────────────────────────────────────── */

.docs-hidden {
  display: none !important;
}

/* Smooth scroll for anchor links */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
}
