/* ════════════════════════════════════════════════════════
   LOGIC SCRIPT — DOCS (public/css/docs.css)
   Sistema de documentação em páginas (estilo MDN / discord.js /
   Node.js), usando os mesmos tokens visuais da Ayami definidos em
   main.css (--bg-deep, --gold, --eye-main, --hair-main, etc).
   ════════════════════════════════════════════════════════ */

body.docs-body { padding-top: 68px; }

/* ══════════════════════════════════════
   SHELL — 3 colunas: sidebar / conteúdo / TOC
   ══════════════════════════════════════ */
.docs-shell {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - 68px);
}

.docs-sidebar {
  width: 268px;
  flex-shrink: 0;
  position: sticky;
  top: 68px;
  height: calc(100vh - 68px);
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--bg-mid);
  padding: 1.25rem 0.9rem 2.5rem;
  transition: width 0.2s ease, transform 0.25s ease;
  scrollbar-width: thin;
  z-index: 30;
}

.docs-shell.is-sidebar-collapsed .docs-sidebar { width: 0; padding-left: 0; padding-right: 0; overflow: hidden; border-right: none; }

.docs-main { flex: 1; min-width: 0; }

.docs-body-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 2.5rem;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 2rem 5rem;
  align-items: start;
}

/* ══════════════════════════════════════
   TOPBAR — toggle, breadcrumb, busca
   ══════════════════════════════════════ */
.docs-topbar {
  position: sticky;
  top: 68px;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 2rem;
  background: rgba(13, 16, 33, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  max-width: 1240px;
  margin: 0 auto;
}

.docs-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 15px;
  transition: var(--transition);
}
.docs-icon-btn:hover { color: var(--white); border-color: rgba(169,214,255,0.3); }

.docs-breadcrumb {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 12.5px;
  color: var(--text-muted);
  min-width: 0;
  flex: 1;
}
.docs-breadcrumb a { color: var(--text-secondary); text-decoration: none; transition: color .12s; }
.docs-breadcrumb a:hover { color: var(--hair-main); }
.docs-breadcrumb .docs-crumb-sep { opacity: 0.5; }
.docs-breadcrumb .docs-crumb-current { color: var(--text-primary); font-weight: 600; }

.docs-search-wrap { position: relative; flex-shrink: 0; }
.docs-search-input {
  width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 12px 8px 30px;
  outline: none;
  transition: border-color .15s, width .2s;
}
.docs-search-input:focus { border-color: rgba(124,143,255,.4); width: 280px; }
.docs-search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: .55; pointer-events: none; }
.docs-search-kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 10px; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
  pointer-events: none;
}

.docs-search-results {
  position: absolute; top: calc(100% + 6px); right: 0; width: 340px; max-height: 400px;
  overflow-y: auto;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  display: none; z-index: 50;
}
.docs-search-results.is-open { display: block; }
.docs-search-result {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 9px 12px; text-decoration: none; color: var(--text-secondary);
  border-bottom: 1px solid rgba(169,214,255,.05);
  font-size: 13px;
}
.docs-search-result:last-child { border-bottom: none; }
.docs-search-result:hover, .docs-search-result.is-active { background: rgba(124,143,255,.08); color: var(--white); }
.docs-search-result-section { margin-left: auto; font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.docs-search-empty { padding: 14px 12px; font-size: 12.5px; color: var(--text-muted); text-align: center; }

/* ══════════════════════════════════════
   SIDEBAR — árvore de navegação
   ══════════════════════════════════════ */
.docs-sidebar-section { margin-bottom: 1.4rem; }
.docs-sidebar-title {
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); padding: 0 0.6rem; margin-bottom: 0.45rem;
}
.docs-sidebar-link, .docs-sidebar-sublink {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-secondary); text-decoration: none; font-size: 13px;
  transition: background .12s, color .12s;
  white-space: normal; line-height: 1.35;
}
.docs-sidebar-link:hover, .docs-sidebar-sublink:hover { background: rgba(169,214,255,.05); color: var(--white); }
.docs-sidebar-link.is-active, .docs-sidebar-sublink.is-active {
  background: rgba(124,143,255,.12); color: var(--hair-main); font-weight: 700;
  box-shadow: inset 2px 0 0 var(--eye-main);
}
.docs-sidebar-icon { flex-shrink: 0; font-size: 13px; opacity: .85; }

.docs-sidebar-group { margin-left: 0.4rem; margin-top: 2px; }
.docs-sidebar-group-toggle {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
  background: none; border: none; cursor: pointer;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 13px; font-family: var(--font-body);
  text-align: left; transition: background .12s, color .12s;
}
.docs-sidebar-group-toggle:hover { background: rgba(169,214,255,.05); color: var(--white); }
.docs-sidebar-group-arrow { margin-left: auto; font-size: 10px; transition: transform .15s; opacity: .6; }
.docs-sidebar-group.is-open > .docs-sidebar-group-toggle .docs-sidebar-group-arrow { transform: rotate(90deg); }
.docs-sidebar-group-list { display: none; padding-left: 1.4rem; border-left: 1px solid var(--border); margin-left: 0.85rem; }
.docs-sidebar-group.is-open > .docs-sidebar-group-list { display: block; }

/* ══════════════════════════════════════
   CONTEÚDO
   ══════════════════════════════════════ */
.docs-content { min-width: 0; padding-top: 2rem; }

.docs-kicker {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--eye-main); margin-bottom: 0.6rem;
}

.docs-h1 {
  font-family: var(--font-display); font-size: 2rem; font-weight: 800;
  color: var(--white); display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  margin-bottom: 0.6rem; line-height: 1.2;
}
.docs-h1 code {
  font-family: 'Cascadia Code','Fira Code',monospace; font-size: 0.75em;
  background: rgba(169,214,255,.08); padding: 2px 10px; border-radius: 8px; color: var(--hair-main);
}

.docs-lead { font-size: 15px; color: var(--text-secondary); line-height: 1.7; margin-bottom: 1.75rem; max-width: 68ch; }

.docs-content h2 {
  font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; color: var(--white);
  margin: 2.4rem 0 0.9rem; scroll-margin-top: 90px;
  padding-bottom: 0.5rem; border-bottom: 1px solid var(--border);
}
.docs-content h2:first-child { margin-top: 0; }
.docs-content h3 { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; color: var(--text-primary); margin: 1.6rem 0 0.6rem; scroll-margin-top: 90px; }
.docs-content p { font-size: 14.5px; color: var(--text-secondary); line-height: 1.75; margin-bottom: 1rem; }
.docs-content p code, .docs-content li code {
  font-family: 'Cascadia Code','Fira Code',monospace; font-size: 12.5px;
  background: rgba(124,143,255,.09); color: var(--eye-main); padding: 1px 6px; border-radius: 5px;
}
.docs-content a { color: var(--hair-main); text-decoration: none; border-bottom: 1px dotted rgba(169,214,255,.4); }
.docs-content a:hover { color: var(--white); border-bottom-color: var(--white); }
.docs-content ul, .docs-content ol { margin: 0 0 1.1rem 1.3rem; color: var(--text-secondary); font-size: 14.5px; line-height: 1.8; }
.docs-content li { margin-bottom: 0.3rem; }
.docs-content strong { color: var(--text-primary); }

/* ══════════════════════════════════════
   BADGES (New / Beta / Deprecated / Premium)
   ══════════════════════════════════════ */
.docs-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 99px; white-space: nowrap;
}
.docs-badge--new         { background: rgba(87,242,135,.12); border: 1px solid rgba(87,242,135,.3); color: var(--success); }
.docs-badge--beta        { background: rgba(124,143,255,.12); border: 1px solid rgba(124,143,255,.3); color: var(--eye-main); }
.docs-badge--deprecated  { background: rgba(237,66,69,.12); border: 1px solid rgba(237,66,69,.3); color: var(--danger); }
.docs-badge--premium     { background: rgba(255,217,102,.14); border: 1px solid rgba(255,217,102,.35); color: var(--gold); }
.docs-badge--plain       { background: rgba(169,214,255,.08); border: 1px solid var(--border); color: var(--text-secondary); }

/* ══════════════════════════════════════
   ASSINATURA / SINTAXE
   ══════════════════════════════════════ */
.docs-signature {
  font-family: 'Cascadia Code','Fira Code',monospace;
  font-size: 14.5px; color: var(--hair-main);
  background: rgba(0,0,0,.22); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 14px 18px; margin-bottom: 1.75rem; overflow-x: auto; white-space: pre;
}

/* ══════════════════════════════════════
   TABELAS de parâmetros / propriedades / métodos
   (reaproveita o padrão visual do .lsr-table)
   ══════════════════════════════════════ */
.docs-table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border); margin-bottom: 1.5rem; }
.docs-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 360px; }
.docs-table thead tr { background: rgba(169,214,255,.03); }
.docs-table th { padding: 9px 13px; text-align: left; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.docs-table td { padding: 9px 13px; border-bottom: 1px solid rgba(169,214,255,.04); color: var(--text-secondary); line-height: 1.55; vertical-align: top; }
.docs-table tr:last-child td { border-bottom: none; }
.docs-table tr:hover td { background: rgba(124,143,255,.03); }
.docs-table td:first-child { font-family: 'Cascadia Code','Fira Code',monospace; font-size: 12.5px; color: var(--hair-main); white-space: nowrap; font-weight: 500; }
.docs-type { font-family: 'Cascadia Code','Fira Code',monospace; font-size: 11.5px; color: #fab387; white-space: nowrap; }

/* ══════════════════════════════════════
   BLOCOS DE AVISO (dica / atenção / observação)
   ══════════════════════════════════════ */
.docs-admonition {
  display: flex; gap: 0.7rem; align-items: flex-start;
  border-radius: var(--radius-md); border: 1px solid var(--border);
  padding: 0.9rem 1.1rem; margin-bottom: 1.5rem; font-size: 13.5px; line-height: 1.65;
}
.docs-admonition-icon { font-size: 17px; flex-shrink: 0; margin-top: 1px; }
.docs-admonition-body { color: var(--text-secondary); }
.docs-admonition-body strong { color: var(--text-primary); }
.docs-admonition--tip     { background: rgba(87,242,135,.06); border-color: rgba(87,242,135,.22); }
.docs-admonition--tip .docs-admonition-icon { color: var(--success); }
.docs-admonition--warning { background: rgba(255,217,102,.06); border-color: rgba(255,217,102,.25); }
.docs-admonition--warning .docs-admonition-icon { color: var(--gold); }
.docs-admonition--note    { background: rgba(124,143,255,.06); border-color: rgba(124,143,255,.22); }
.docs-admonition--note .docs-admonition-icon { color: var(--eye-main); }

/* ══════════════════════════════════════
   BLOCOS DE CÓDIGO + COPIAR
   ══════════════════════════════════════ */
.docs-code {
  position: relative; margin: 0 0 1.5rem;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: rgba(0,0,0,.22); overflow: hidden;
}
.docs-code pre { margin: 0; padding: 16px 18px; overflow-x: auto; }
.docs-code code { font-family: 'Cascadia Code','Fira Code',monospace; font-size: 12.5px; line-height: 1.65; color: #d9dcea; white-space: pre; }
.docs-copy-btn {
  position: absolute; top: 8px; right: 8px;
  display: flex; align-items: center; gap: 4px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 7px;
  color: var(--text-muted); font-size: 11px; font-family: var(--font-body);
  padding: 5px 9px; cursor: pointer; opacity: 0; transition: opacity .15s, color .15s, border-color .15s;
}
.docs-code:hover .docs-copy-btn { opacity: 1; }
.docs-copy-btn:hover { color: var(--white); border-color: rgba(169,214,255,.3); }
.docs-copy-btn.is-copied { color: var(--success); border-color: rgba(87,242,135,.3); opacity: 1; }

/* ══════════════════════════════════════
   CARDS (índice, listagens de categoria, guias, exemplos)
   ══════════════════════════════════════ */
.docs-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.docs-card {
  display: flex; flex-direction: column; gap: 0.5rem;
  background: var(--card-sheen), var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.25rem; text-decoration: none; box-shadow: var(--shadow-elevated);
  transition: var(--transition);
}
.docs-card:hover { border-color: rgba(169,214,255,.3); transform: translateY(-3px); box-shadow: var(--shadow-elevated-hover); }
.docs-card-icon { font-size: 1.6rem; }
.docs-card-title { font-family: var(--font-display); font-weight: 700; color: var(--white); font-size: 15px; border-bottom: none; }
.docs-card-desc { font-size: 12.5px; color: var(--text-muted); line-height: 1.55; }
.docs-card-count { font-size: 11px; color: var(--eye-main); font-weight: 700; margin-top: auto; }

.docs-item-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 2rem; }
.docs-item-row {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 0.85rem 1.1rem; text-decoration: none; transition: var(--transition);
}
.docs-item-row:hover { border-color: rgba(169,214,255,.3); background: var(--bg-card-hover); }
.docs-item-row-icon { font-size: 1.1rem; flex-shrink: 0; }
.docs-item-row-name { font-family: 'Cascadia Code','Fira Code',monospace; color: var(--hair-main); font-size: 13.5px; }
.docs-item-row-desc { font-size: 12px; color: var(--text-muted); margin-left: 0.4rem; }
.docs-item-row-chevron { margin-left: auto; color: var(--text-muted); }

/* ══════════════════════════════════════
   RELACIONADOS + PREV/NEXT
   ══════════════════════════════════════ */
.docs-related { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 2rem; }
.docs-related-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-family: 'Cascadia Code','Fira Code',monospace;
  background: rgba(124,143,255,.08); border: 1px solid rgba(124,143,255,.2); color: var(--eye-main);
  padding: 5px 11px; border-radius: 99px; text-decoration: none; transition: background .12s;
}
.docs-related-chip:hover { background: rgba(124,143,255,.16); }

.docs-prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.docs-prevnext-link {
  display: flex; flex-direction: column; gap: 3px;
  border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0.85rem 1rem;
  text-decoration: none; transition: var(--transition);
}
.docs-prevnext-link:hover { border-color: rgba(169,214,255,.3); background: var(--bg-card-hover); }
.docs-prevnext-link.is-next { text-align: right; align-items: flex-end; grid-column: 2; }
.docs-prevnext-label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.docs-prevnext-title { font-size: 13.5px; color: var(--text-primary); font-weight: 700; }

/* ══════════════════════════════════════
   TOC direita (gerada via JS a partir dos h2/h3)
   ══════════════════════════════════════ */
.docs-toc {
  position: sticky;
  top: 130px;
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  padding-top: 2rem;
}
.docs-toc-title { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 0.6rem; }
.docs-toc-list { display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--border); }
.docs-toc-link {
  font-size: 12.5px; color: var(--text-muted); text-decoration: none;
  padding: 4px 0 4px 12px; border-left: 2px solid transparent; margin-left: -1px;
  transition: color .12s, border-color .12s;
}
.docs-toc-link:hover { color: var(--text-primary); }
.docs-toc-link.is-h3 { padding-left: 24px; font-size: 12px; }
.docs-toc-link.is-active { color: var(--hair-main); border-left-color: var(--eye-main); font-weight: 700; }
.docs-toc:empty { display: none; }

/* ══════════════════════════════════════
   RESPONSIVO
   ══════════════════════════════════════ */
@media (max-width: 1100px) {
  .docs-body-grid { grid-template-columns: 1fr; padding: 0 1.5rem 4rem; }
  .docs-toc { display: none; }
}

@media (max-width: 900px) {
  .docs-sidebar {
    position: fixed; top: 68px; left: 0; height: calc(100vh - 68px);
    width: 280px; max-width: 82vw;
    transform: translateX(-100%);
    box-shadow: 24px 0 48px rgba(0,0,0,.4);
  }
  .docs-shell.is-sidebar-collapsed .docs-sidebar { width: 280px; padding: 1.25rem 0.9rem 2.5rem; }
  .docs-shell.is-mobile-nav-open .docs-sidebar { transform: translateX(0); }
  .docs-sidebar-backdrop {
    display: none; position: fixed; inset: 68px 0 0 0; background: rgba(0,0,0,.5); z-index: 29;
  }
  .docs-shell.is-mobile-nav-open .docs-sidebar-backdrop { display: block; }

  .docs-topbar { padding: 0.75rem 1.25rem; }
  .docs-search-input, .docs-search-input:focus { width: 140px; }
  .docs-search-results { width: min(340px, 88vw); }
}

@media (max-width: 640px) {
  .docs-h1 { font-size: 1.5rem; }
  .docs-content { padding-top: 1.25rem; }
  .docs-card-grid { grid-template-columns: 1fr; }
  .docs-prevnext { grid-template-columns: 1fr; }
  .docs-prevnext-link.is-next { grid-column: 1; align-items: flex-start; text-align: left; }
  .docs-breadcrumb .docs-crumb-mid { display: none; }
  .docs-search-wrap { display: none; }
}
