/* ساختار سه‌ستونه دسکتاپ: نوار ناوبری در راست، محتوا در مرکز، TOC در چپ */
.docs-shell {
  max-width: 1460px;
  margin-inline: auto;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--toc-width);
  gap: 28px;
  padding: 26px 20px 52px;
  align-items: start;
}

.docs-shell-two-col {
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

/* ستون راست: سایدبار ناوبری */
.docs-sidebar-nav {
  position: sticky;
  top: calc(var(--header-height) + 20px);
  max-height: calc(100vh - var(--header-height) - 40px);
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.sidebar-section-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--bg-surface-alt);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

.switcher-tab {
  text-align: center;
  padding: 6px 10px;
  border-radius: 5px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-decoration: none !important;
}

.switcher-tab.is-active {
  background: var(--bg-surface);
  color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
}

.sidebar-category {
  margin-bottom: 10px;
}

.sidebar-cat-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.91rem;
  font-weight: 700;
  padding: 8px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: start;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.sidebar-cat-toggle:hover {
  background: var(--bg-surface-alt);
  color: var(--brand-primary);
}

.sidebar-cat-main {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.sidebar-cat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand-primary);
  flex-shrink: 0;
}

.sidebar-category.is-open .sidebar-cat-icon {
  background: var(--brand-primary);
  color: #ffffff;
}

:root[data-theme="dark"] .sidebar-category.is-open .sidebar-cat-icon {
  color: #041E49;
}

.sidebar-cat-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: transform 0.18s ease, color 0.14s ease;
  flex-shrink: 0;
}

.sidebar-category.is-open .sidebar-cat-chevron {
  transform: rotate(0deg);
  color: var(--brand-primary);
}

.sidebar-category:not(.is-open) .sidebar-cat-chevron {
  transform: rotate(90deg);
}

.sidebar-category.is-open .sidebar-page-list {
  display: block;
}

.sidebar-category:not(.is-open) .sidebar-page-list {
  display: none;
}

.sidebar-page-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  padding-inline-start: 10px;
  border-inline-start: 2px solid var(--border-subtle);
}

.sidebar-page-link {
  display: block;
  padding: 6px 10px;
  margin-block: 2px;
  border-radius: var(--radius-sm);
  font-size: 0.89rem;
  color: var(--text-secondary);
  text-decoration: none !important;
}

.sidebar-page-link:hover {
  background: var(--bg-surface-alt);
  color: var(--brand-primary);
}

.sidebar-page-link.is-active {
  background: var(--brand-soft);
  color: var(--brand-soft-text);
  font-weight: 700;
}

.sidebar-empty-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 4px 10px;
}

/* ستون میانی: محتوای اصلی */
.docs-main {
  min-width: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px 38px;
  box-shadow: var(--shadow-sm);
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.article-header {
  padding-bottom: 22px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border-subtle);
}

.article-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.article-title-row h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3.2vw, 2.2rem);
  line-height: 1.35;
  color: var(--text-primary);
}

.en-title-pill {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-soft-text);
  border: 1px solid rgba(2, 125, 253, 0.2);
}

.article-lead {
  margin: 0 0 16px;
  color: var(--text-secondary);
  font-size: 1.08rem;
  line-height: 1.85;
}

.article-meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.meta-item {
  background: var(--bg-surface-alt);
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

/* Start Here Banner on Section Overview Pages */
.start-here-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 18px 22px;
  margin-bottom: 24px;
  background: var(--brand-soft);
  border: 1px solid rgba(2, 125, 253, 0.25);
  border-radius: var(--radius-md);
}

.start-here-label {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--brand-soft-text);
  margin-bottom: 4px;
}

.start-here-text {
  margin: 0;
  font-size: 0.94rem;
  color: var(--text-primary);
}

/* تایپوگرافی محتوای Markdown */
.markdown-body {
  max-width: 76ch;
  font-size: 1.02rem;
  line-height: 1.95;
  color: var(--text-secondary);
}

.markdown-body h2 {
  margin: 38px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 1.45rem;
  color: var(--text-primary);
}

.markdown-body h3 {
  margin: 26px 0 10px;
  font-size: 1.2rem;
  color: var(--text-primary);
}

.markdown-body p {
  margin: 0 0 18px;
}

.markdown-body strong {
  color: var(--text-primary);
  font-weight: 700;
}

.markdown-body ul, .markdown-body ol {
  margin: 0 0 20px;
  padding-inline-start: 26px;
}

.markdown-body li {
  margin-bottom: 8px;
}

.markdown-body code:not(pre code) {
  font-family: var(--font-mono);
  direction: ltr;
  unicode-bidi: isolate;
  background: var(--inline-code-bg);
  color: var(--inline-code-text);
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 0.88em;
  border: 1px solid rgba(2, 125, 253, 0.14);
}

.markdown-body blockquote {
  margin: 22px 0;
  padding: 15px 20px;
  background: var(--brand-soft);
  border-inline-start: 4px solid var(--brand-primary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
}

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

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.94rem;
}

.markdown-body th, .markdown-body td {
  border: 1px solid var(--border-subtle);
  padding: 11px 14px;
  text-align: start;
}

.markdown-body th {
  background: var(--bg-surface-alt);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-weight: 700;
}

/* بلوک‌های کد */
.code-block-wrapper {
  margin: 24px 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--code-border);
  background: var(--code-bg);
  direction: ltr;
  text-align: left;
  box-shadow: var(--shadow-sm);
}

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

.code-lang-badge {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: #7DD3FC;
}

.copy-code-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #F8FAFC;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 5px;
  padding: 4px 10px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  cursor: pointer;
  direction: rtl;
  transition: background-color 0.15s ease;
}

.copy-code-btn:hover {
  background: rgba(84, 197, 248, 0.22);
}

.copy-code-btn.is-copied {
  background: #027DFD;
  border-color: #54C5F8;
  color: #ffffff;
}

.code-pre {
  margin: 0;
  padding: 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--code-text);
  tab-size: 2;
}

.tok-keyword { color: var(--syn-keyword); font-weight: 700; }
.tok-type { color: var(--syn-type); }
.tok-string { color: var(--syn-string); }
.tok-number { color: var(--syn-number); }
.tok-comment { color: var(--syn-comment); font-style: italic; }
.tok-annotation { color: var(--syn-annotation); }

/* باکس انتساب و مجوز */
.attribution-box {
  margin-top: 36px;
  padding: 16px 20px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.89rem;
  color: var(--text-secondary);
}

.attribution-box p {
  margin: 0;
}

/* ناوبری قبلی / بعدی */
.pager-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 24px;
}

.pager-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 15px 18px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-page);
  color: var(--text-primary);
  text-decoration: none !important;
  transition: border-color 0.15s ease;
}

.pager-card:hover {
  border-color: var(--brand-primary);
}

.pager-next {
  text-align: end;
}

.pager-dir {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* موضوعات مرتبط */
.related-topics {
  margin-top: 34px;
  padding-top: 26px;
  border-top: 1px solid var(--border-subtle);
}

.related-topics h2 {
  margin: 0 0 16px;
  font-size: 1.28rem;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 14px;
}

.related-card {
  display: block;
  padding: 16px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-page);
  color: var(--text-primary);
  text-decoration: none !important;
  transition: border-color 0.15s ease;
}

.related-card:hover {
  border-color: var(--brand-primary);
}

.related-section-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--brand-soft);
  color: var(--brand-soft-text);
  margin-bottom: 8px;
}

.related-card h3 {
  margin: 0 0 6px;
  font-size: 1.02rem;
}

.related-card p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ستون سمت چپ: TOC */
.docs-toc {
  position: sticky;
  top: calc(var(--header-height) + 20px);
}

.toc-sticky {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
}

.toc-title {
  margin: 0 0 10px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

.toc-item {
  margin-bottom: 7px;
}

.toc-level-3 {
  padding-inline-start: 14px;
}

.toc-link {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.55;
  text-decoration: none !important;
}

.toc-link:hover, .toc-link.is-active {
  color: var(--brand-primary);
  font-weight: 600;
}

.mobile-toc-box {
  display: none;
  margin-bottom: 22px;
  padding: 12px 16px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.mobile-toc-box summary {
  font-family: var(--font-display);
  font-weight: 700;
  cursor: pointer;
}

.mobile-toc-box .toc-list {
  margin-top: 10px;
}

/* صفحات نمای کلی بخش، مرجع API و مجوزها */
.overview-grid, .api-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.overview-cat-card, .api-card, .legal-card {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
}

.overview-cat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.overview-cat-title {
  margin: 0 0 8px;
  font-size: 1.14rem;
}

.overview-cat-desc {
  margin: 0 0 12px;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.overview-page-links {
  list-style: none;
  margin: 12px 0 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.overview-page-links a {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.92rem;
}

.overview-empty {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.84rem;
  color: var(--text-muted);
}

.legal-content {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.legal-card {
  background: var(--bg-surface);
}

.legal-card h2 {
  margin: 0 0 10px;
  font-size: 1.22rem;
}

.api-card {
  display: block;
  background: var(--bg-surface);
  color: var(--text-primary);
  text-decoration: none !important;
  transition: border-color 0.15s ease;
}

.api-card:hover {
  border-color: var(--brand-primary);
}

.api-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-weight: 700;
  color: var(--brand-primary);
}

@media (max-width: 1200px) {
  .docs-shell {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  }
  .docs-toc {
    display: none;
  }
  .mobile-toc-box {
    display: block;
  }
}

@media (max-width: 1024px) {
  .docs-shell, .docs-shell-two-col {
    grid-template-columns: minmax(0, 1fr);
  }
  .docs-sidebar-nav {
    display: none;
  }
  .docs-main {
    padding: 22px 18px;
  }
  .pager-nav {
    grid-template-columns: 1fr;
  }
}
