/* ==========================================================================
   NYL PROGRAMMING LANGUAGE - DOCUMENTATION LAYOUT & STYLES
   ========================================================================== */

body.docs-page {
  overflow-x: hidden;
}

/* Layout Geral de Documentação */
.docs-layout {
  display: flex;
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: calc(100vh - var(--header-height));
  width: 100%;
  min-width: 0;
  position: relative;
}

/* Backdrop escuro ao abrir a Sidebar no Mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--header-height);
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 999;
  transition: opacity var(--transition);
}

.sidebar-backdrop.active {
  display: block;
}

/* --- Sidebar Fixa --- */
.docs-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  background-color: var(--bg-body);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-search-box {
  padding: 1.25rem 1rem 0.75rem;
  position: relative;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-search-box .search-icon {
  position: absolute;
  left: 1.75rem;
  color: var(--text-muted);
  pointer-events: none;
}

.sidebar-search-box input {
  width: 100%;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 2.25rem 0.65rem 2.25rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  outline: none;
  transition: var(--transition);
}

.sidebar-search-box input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 10px var(--accent-glow);
}

.search-kbd {
  position: absolute;
  right: 1.65rem;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem 2rem;
  scroll-behavior: smooth;
}

/* Scrollbar Sutil */
.sidebar-nav::-webkit-scrollbar {
  width: 5px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background-color: var(--border-subtle);
  border-radius: 4px;
}

/* Sumário Hierárquico (TOC) */
.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc-title {
  margin-top: 1rem;
  margin-bottom: 0.35rem;
}

.toc-title .toc-link {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.4rem 0.75rem;
}

.toc-item .toc-link {
  font-size: 0.885rem;
  color: var(--text-secondary);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  display: block;
}

.toc-subitem .toc-link {
  font-size: 0.825rem;
  color: var(--text-muted);
  padding: 0.3rem 0.75rem 0.3rem 1.5rem;
  border-left: 1px solid var(--border-subtle);
  margin-left: 0.75rem;
  display: block;
}

.toc-link:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-elevated);
}

.toc-link.active {
  color: var(--accent-primary);
  background-color: rgba(56, 189, 248, 0.08);
  font-weight: 600;
  border-left-color: var(--accent-primary);
}

.search-empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* --- Área Principal de Leitura --- */
.docs-main {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 2.5rem 3.5rem 6rem;
}

.docs-content {
  min-width: 0;
  width: 100%;
  color: var(--text-primary);
  line-height: 1.75;
  overflow-wrap: break-word;
  word-break: break-word;
}

.doc-h1, .doc-h2, .doc-h3, .doc-h4, .doc-h5, .doc-h6 {
  scroll-margin-top: calc(var(--header-height) + 1.5rem);
  overflow-wrap: break-word;
  word-break: break-word;
}

.doc-h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.doc-h2 {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-top: 3rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.doc-h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent-primary);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.doc-h4 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
}

.doc-h5 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 1.25rem;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.doc-paragraph {
  font-size: 1.025rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  overflow-wrap: break-word;
  word-break: break-word;
}

.doc-list {
  margin: 1rem 0 1.5rem 1.5rem;
  color: var(--text-secondary);
  font-size: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow-wrap: break-word;
  word-break: break-word;
}

.doc-list li {
  line-height: 1.6;
}

.doc-divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 2.5rem 0;
}

.doc-blockquote {
  border-left: 4px solid var(--accent-primary);
  background-color: var(--bg-surface);
  padding: 0.85rem 1.25rem;
  margin: 1.5rem 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
  overflow-wrap: break-word;
  word-break: break-word;
}

.doc-inline-code {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--accent-primary);
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  word-break: break-word;
  overflow-wrap: break-word;
}

.doc-link {
  color: var(--accent-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  word-break: break-word;
}

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

/* --- Blocos de Código em Documentação --- */
.code-block-wrapper {
  background-color: var(--bg-code);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin: 1.5rem 0;
  overflow: hidden;
  max-width: 100%;
  min-width: 0;
}

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

.code-lang-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.copy-code-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.copy-code-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-elevated);
}

.copy-code-btn.copied {
  color: var(--status-success-text);
}

.code-block-wrapper pre {
  margin: 0;
  padding: 1.15rem 1.25rem;
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--text-primary);
}

.code-block-wrapper pre code {
  white-space: pre;
  display: block;
}

[data-theme="light"] .code-block-wrapper {
  background-color: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .code-block-header {
  background-color: #f8fafc;
  border-bottom-color: #e2e8f0;
}

[data-theme="light"] .code-block-wrapper pre {
  color: #0f172a;
}

[data-theme="light"] .copy-code-btn {
  color: #475569;
}

[data-theme="light"] .copy-code-btn:hover {
  background-color: #f1f5f9;
  color: #0f172a;
}

/* Botão Mobile da Sidebar */
.mobile-sidebar-toggle {
  display: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Footer de Navegação da Doc */
.docs-footer-nav {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
}

.back-to-top-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: var(--transition);
}

.back-to-top-btn:hover {
  color: var(--accent-primary);
}

/* --- Responsividade de Documentação --- */
@media (max-width: 968px) {
  .mobile-sidebar-toggle {
    display: flex;
  }

  .docs-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: 300px;
    max-width: 85vw;
    height: calc(100vh - var(--header-height));
    background-color: var(--bg-surface);
    transform: translateX(-100%);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.45);
    z-index: 1000;
  }

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

  .docs-main {
    padding: 2rem 1.5rem 4rem;
  }
}

@media (max-width: 768px) {
  .docs-main {
    padding: 1.25rem 1rem 4rem;
  }

  .doc-h1 {
    font-size: 1.75rem;
    line-height: 1.25;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
  }

  .doc-h2 {
    font-size: 1.35rem;
    line-height: 1.3;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.35rem;
  }

  .doc-h3 {
    font-size: 1.125rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
  }

  .doc-h4 {
    font-size: 1rem;
    margin-top: 1.25rem;
  }

  .doc-paragraph {
    font-size: 0.95rem;
    line-height: 1.65;
    margin-bottom: 1rem;
  }

  .doc-list {
    margin: 0.75rem 0 1.25rem 1.25rem;
    font-size: 0.95rem;
  }

  .code-block-wrapper {
    margin: 1.25rem 0;
    border-radius: var(--radius-sm);
  }

  .code-block-wrapper pre {
    padding: 0.85rem 0.95rem;
    font-size: 0.8125rem;
    line-height: 1.55;
  }

  .code-block-header {
    padding: 0.35rem 0.65rem;
  }

  .docs-footer-nav {
    margin-top: 2.5rem;
  }
}

@media (max-width: 480px) {
  .docs-main {
    padding: 1rem 0.75rem 3.5rem;
  }

  .doc-h1 {
    font-size: 1.45rem;
  }

  .doc-h2 {
    font-size: 1.2rem;
  }

  .doc-h3 {
    font-size: 1.05rem;
  }

  .code-block-wrapper pre {
    padding: 0.75rem 0.85rem;
    font-size: 0.775rem;
  }
}

