/* ============================================================
   Central de Ajuda ChatPRO — estilo "GitBook limpo"
   Tema claro/escuro via [data-tema] no <html>
   ============================================================ */

:root {
  --cb-accent: #2f6fed;
  --cb-accent-soft: #e8f0fe;
  --cb-bg: #ffffff;
  --cb-bg-soft: #f7f8fa;
  --cb-sidebar-bg: #ffffff;
  --cb-text: #1b1f24;
  --cb-text-soft: #5b6675;
  --cb-text-mut: #8a93a1;
  --cb-border: #e7e9ee;
  --cb-border-soft: #eef0f4;
  --cb-code-bg: #f4f5f7;
  --cb-code-text: #b3266f;
  --cb-pre-bg: #1b1f2b;
  --cb-pre-text: #e6e8ef;
  --cb-shadow: 0 1px 2px rgba(20,28,45,.05), 0 4px 16px rgba(20,28,45,.06);

  --cb-hint-info: #2f6fed;
  --cb-hint-warning: #d98309;
  --cb-hint-danger: #d6473b;
  --cb-hint-success: #1f9d57;

  --cb-topbar-h: 60px;
  --cb-sidebar-w: 300px;
  --cb-toc-w: 232px;
  --cb-content-max: 760px;

  --cb-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --cb-mono: "SF Mono", ui-monospace, "JetBrains Mono", "Fira Code", Consolas, Menlo, monospace;
}

html[data-tema="escuro"] {
  --cb-accent: #5b8dff;
  --cb-accent-soft: #1a2740;
  --cb-bg: #0f1115;
  --cb-bg-soft: #14171d;
  --cb-sidebar-bg: #0f1115;
  --cb-text: #e6e9ef;
  --cb-text-soft: #a7b0bf;
  --cb-text-mut: #6f7888;
  --cb-border: #242833;
  --cb-border-soft: #1c2029;
  --cb-code-bg: #1b1f29;
  --cb-code-text: #ff9ecb;
  --cb-pre-bg: #0a0c10;
  --cb-pre-text: #e6e8ef;
  --cb-shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: var(--cb-font);
  color: var(--cb-text);
  background: var(--cb-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  /* app-shell: header fixo + paineis com scroll proprio (sem scroll no body) */
  height: 100vh; overflow: hidden;
  display: flex; flex-direction: column;
}

/* Scrollbars finas e discretas (estilo GitBook) */
.cb-sidebar, .cb-scroll, .cb-toc, .cb-content pre {
  scrollbar-width: thin;
  scrollbar-color: var(--cb-border) transparent;
}
.cb-sidebar::-webkit-scrollbar, .cb-scroll::-webkit-scrollbar,
.cb-toc::-webkit-scrollbar, .cb-content pre::-webkit-scrollbar { width: 9px; height: 9px; }
.cb-sidebar::-webkit-scrollbar-thumb, .cb-scroll::-webkit-scrollbar-thumb,
.cb-toc::-webkit-scrollbar-thumb { background: var(--cb-border); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
.cb-sidebar:hover::-webkit-scrollbar-thumb, .cb-scroll:hover::-webkit-scrollbar-thumb { background: var(--cb-text-mut); background-clip: content-box; }
.cb-content pre::-webkit-scrollbar-thumb { background: rgba(255,255,255,.22); border-radius: 8px; }
.cb-sidebar::-webkit-scrollbar-track, .cb-scroll::-webkit-scrollbar-track,
.cb-toc::-webkit-scrollbar-track, .cb-content pre::-webkit-scrollbar-track { background: transparent; }

a { color: var(--cb-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */
.cb-topbar {
  flex-shrink: 0; z-index: 50;
  height: var(--cb-topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: var(--cb-bg);
  border-bottom: 1px solid var(--cb-border);
}
.cb-burger {
  display: none; background: none; border: 0; color: var(--cb-text);
  cursor: pointer; padding: 6px; border-radius: 8px;
}
.cb-burger:hover { background: var(--cb-bg-soft); }

.cb-brand { display: flex; flex-direction: column; line-height: 1.1; flex-shrink: 0; }
.cb-brand:hover { text-decoration: none; }
.cb-brand-mark { font-size: 19px; font-weight: 700; color: var(--cb-text); letter-spacing: -.2px; }
.cb-brand-mark strong { color: var(--cb-accent); }
.cb-brand-sub { font-size: 11px; color: var(--cb-text-mut); font-weight: 500; letter-spacing: .3px; text-transform: uppercase; }

/* ---------- Busca ---------- */
.cb-search {
  position: relative; flex: 1; max-width: 520px; margin: 0 auto;
}
.cb-search-ico {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--cb-text-mut); pointer-events: none;
}
#cb-search-input {
  width: 100%; height: 38px; padding: 0 38px 0 36px;
  border: 1px solid var(--cb-border); border-radius: 10px;
  background: var(--cb-bg-soft); color: var(--cb-text);
  font-size: 14px; font-family: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#cb-search-input:focus { border-color: var(--cb-accent); box-shadow: 0 0 0 3px var(--cb-accent-soft); background: var(--cb-bg); }
.cb-kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-family: var(--cb-mono); font-size: 11px; color: var(--cb-text-mut);
  border: 1px solid var(--cb-border); border-radius: 6px; padding: 1px 7px; background: var(--cb-bg);
}
.cb-search-results {
  position: absolute; top: 46px; left: 0; right: 0;
  background: var(--cb-bg); border: 1px solid var(--cb-border);
  border-radius: 12px; box-shadow: var(--cb-shadow);
  max-height: 60vh; overflow-y: auto; padding: 6px; z-index: 60;
}
.cb-sr-item { display: block; padding: 9px 12px; border-radius: 8px; color: var(--cb-text); }
.cb-sr-item:hover, .cb-sr-item.sel { background: var(--cb-accent-soft); text-decoration: none; }
.cb-sr-title { font-weight: 600; font-size: 14px; }
.cb-sr-crumb { font-size: 12px; color: var(--cb-text-mut); margin-top: 1px; }
.cb-sr-snip { font-size: 12.5px; color: var(--cb-text-soft); margin-top: 2px; }
.cb-sr-empty { padding: 16px; color: var(--cb-text-mut); text-align: center; font-size: 13px; }
.cb-sr-item mark { background: transparent; color: var(--cb-accent); font-weight: 700; }

.cb-topnav { display: flex; align-items: center; gap: 18px; flex-shrink: 0; }
.cb-topnav a {
  font-size: 12.5px; font-weight: 600; letter-spacing: .3px; color: var(--cb-text-soft);
  white-space: nowrap;
}
.cb-topnav a:hover { color: var(--cb-accent); text-decoration: none; }

.cb-theme-toggle {
  background: none; border: 1px solid var(--cb-border); color: var(--cb-text);
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cb-theme-toggle:hover { background: var(--cb-bg-soft); }
.cb-ico-moon { display: none; }
html[data-tema="escuro"] .cb-ico-sun { display: none; }
html[data-tema="escuro"] .cb-ico-moon { display: block; }

/* ---------- Layout (app-shell) ---------- */
.cb-layout { flex: 1; min-height: 0; display: flex; align-items: stretch; overflow: hidden; }

.cb-sidebar {
  width: var(--cb-sidebar-w); flex-shrink: 0;
  height: 100%;
  overflow-y: auto; overscroll-behavior: contain;
  border-right: 1px solid var(--cb-border);
  background: var(--cb-sidebar-bg);
  padding: 18px 10px 40px 16px;
}

/* painel rolavel do conteudo (uma unica barra principal) */
.cb-scroll {
  flex: 1; min-width: 0; height: 100%;
  overflow-y: auto; overscroll-behavior: contain;
  scroll-behavior: smooth;
}

/* ---------- Navegacao ---------- */
.cb-nav-list { list-style: none; margin: 0; padding: 0; }
.cb-nav-list .cb-nav-list { margin-left: 12px; border-left: 1px solid var(--cb-border-soft); padding-left: 4px; display: none; }
.cb-nav-item.open > .cb-nav-list { display: block; }

.cb-nav-row { display: flex; align-items: center; gap: 2px; border-radius: 8px; }
.cb-nav-row:hover { background: var(--cb-bg-soft); }
.cb-nav-row.active { background: var(--cb-accent-soft); }
.cb-nav-row.active > .cb-nav-link { color: var(--cb-accent); font-weight: 600; }

.cb-nav-toggle {
  background: none; border: 0; cursor: pointer; padding: 4px;
  color: var(--cb-text-mut); display: flex; flex-shrink: 0; border-radius: 6px;
  transition: transform .15s;
}
.cb-nav-item.open > .cb-nav-row > .cb-nav-toggle { transform: rotate(90deg); }
.cb-nav-spacer { width: 22px; flex-shrink: 0; }
.cb-nav-link {
  flex: 1; color: var(--cb-text-soft); padding: 6px 8px 6px 2px;
  font-size: 13.5px; border-radius: 8px; line-height: 1.35;
  display: flex; align-items: center; gap: 9px;
}
.cb-nav-link:hover { text-decoration: none; color: var(--cb-text); }
.cb-nav-icon { display: inline-flex; flex-shrink: 0; width: 16px; justify-content: center; color: var(--cb-text-mut); }
.cb-nav-ico { width: 14px; height: 14px; }
.cb-nav-row.active .cb-nav-icon { color: var(--cb-accent); }
.cb-nav-text { flex: 1; min-width: 0; }

/* Cabecalho de grupo (nao-clicavel) */
.cb-nav-item.is-group { margin-top: 18px; }
.cb-nav-item.is-group:first-child { margin-top: 0; }
.cb-nav-grouptitle {
  flex: 1; padding: 6px 8px 6px 2px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--cb-text-mut); line-height: 1.3;
}
.cb-nav-item.is-group > .cb-nav-list { border-left: 0; margin-left: 4px; padding-left: 0; }

/* ---------- Main / conteudo ---------- */
.cb-main {
  min-width: 0;
  display: flex; gap: 28px; justify-content: center;
  padding: 28px 40px 40px;
}
.cb-article { flex: 1; min-width: 0; max-width: var(--cb-content-max); }

.cb-breadcrumbs { font-size: 12.5px; color: var(--cb-text-mut); margin-bottom: 14px; }
.cb-breadcrumbs a { color: var(--cb-text-mut); }
.cb-breadcrumbs a:hover { color: var(--cb-accent); }
.cb-breadcrumbs .cb-sep { margin: 0 7px; opacity: .6; }
.cb-breadcrumbs .cb-current { color: var(--cb-text-soft); }

/* ---------- Tipografia do conteudo ---------- */
.cb-content { font-size: 15.5px; }
.cb-content h1 { font-size: 32px; line-height: 1.2; letter-spacing: -.5px; margin: 0 0 18px; font-weight: 750; }
.cb-content h2 { font-size: 23px; margin: 40px 0 14px; padding-top: 8px; font-weight: 700; letter-spacing: -.3px; }
.cb-content h3 { font-size: 18px; margin: 30px 0 10px; font-weight: 650; }
.cb-content h4 { font-size: 15.5px; margin: 24px 0 8px; font-weight: 650; }
.cb-content p { margin: 14px 0; }
.cb-content ul, .cb-content ol { padding-left: 24px; margin: 14px 0; }
.cb-content li { margin: 6px 0; }
.cb-content li > ul, .cb-content li > ol { margin: 6px 0; }
.cb-content hr { border: 0; border-top: 1px solid var(--cb-border); margin: 32px 0; }
.cb-content img { max-width: 100%; height: auto; border-radius: 10px; }
.cb-content figure { margin: 20px 0; }
.cb-content figure img { border: 1px solid var(--cb-border); box-shadow: var(--cb-shadow); }
.cb-content figcaption { font-size: 12.5px; color: var(--cb-text-mut); text-align: center; margin-top: 8px; }

.cb-anchor { opacity: 0; margin-left: 8px; color: var(--cb-text-mut); font-weight: 400; text-decoration: none; }
.cb-content h2:hover .cb-anchor, .cb-content h3:hover .cb-anchor { opacity: 1; }

/* Codigo */
.cb-content code {
  font-family: var(--cb-mono); font-size: .87em;
  background: var(--cb-code-bg); color: var(--cb-code-text);
  padding: .15em .4em; border-radius: 5px;
}
.cb-content pre {
  background: var(--cb-pre-bg); color: var(--cb-pre-text);
  padding: 16px 18px; border-radius: 12px; overflow-x: auto;
  font-size: 13.5px; line-height: 1.55; margin: 18px 0;
}
.cb-content pre code { background: none; color: inherit; padding: 0; font-size: inherit; }

/* Tabelas */
.cb-content table { border-collapse: collapse; width: 100%; margin: 18px 0; font-size: 14px; display: block; overflow-x: auto; }
.cb-content th, .cb-content td { border: 1px solid var(--cb-border); padding: 9px 13px; text-align: left; vertical-align: top; }
.cb-content th { background: var(--cb-bg-soft); font-weight: 650; }
.cb-content tr:nth-child(even) td { background: color-mix(in srgb, var(--cb-bg-soft) 50%, transparent); }

/* Blockquote */
.cb-content blockquote {
  margin: 18px 0; padding: 2px 18px; border-left: 3px solid var(--cb-border);
  color: var(--cb-text-soft);
}

/* Hint / callouts GitBook */
.cb-hint {
  margin: 18px 0; padding: 14px 16px 14px 18px; border-radius: 10px;
  border: 1px solid var(--cb-border); border-left-width: 4px;
  background: var(--cb-bg-soft); font-size: 14.5px;
}
.cb-hint > :first-child { margin-top: 0; }
.cb-hint > :last-child { margin-bottom: 0; }
.cb-hint--info { border-left-color: var(--cb-hint-info); }
.cb-hint--warning { border-left-color: var(--cb-hint-warning); }
.cb-hint--danger { border-left-color: var(--cb-hint-danger); }
.cb-hint--success { border-left-color: var(--cb-hint-success); }

/* ---------- Feedback "Isso foi útil?" ---------- */
.cb-feedback {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 40px; padding: 16px 18px;
  border: 1px solid var(--cb-border); border-radius: 12px; background: var(--cb-bg-soft);
}
.cb-feedback-q { font-weight: 600; font-size: 14px; }
.cb-feedback-btns { display: flex; gap: 8px; }
.cb-feedback-btns button {
  border: 1px solid var(--cb-border); background: var(--cb-bg); color: var(--cb-text);
  font: inherit; font-size: 13px; padding: 6px 14px; border-radius: 8px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.cb-feedback-btns button:hover { border-color: var(--cb-accent); color: var(--cb-accent); }
.cb-feedback-thanks { font-size: 14px; color: var(--cb-hint-success); font-weight: 600; }

/* ---------- Pager anterior/proximo ---------- */
.cb-pager { display: flex; gap: 14px; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--cb-border); }
.cb-pager a {
  flex: 1; display: flex; flex-direction: column; gap: 3px;
  border: 1px solid var(--cb-border); border-radius: 12px; padding: 14px 16px;
  color: var(--cb-text);
}
.cb-pager a:hover { border-color: var(--cb-accent); text-decoration: none; background: var(--cb-bg-soft); }
.cb-pager-next { text-align: right; }
.cb-pager-label { font-size: 12px; color: var(--cb-text-mut); }
.cb-pager-title { font-weight: 600; font-size: 14.5px; color: var(--cb-accent); }

/* ---------- TOC direita ---------- */
.cb-toc {
  position: sticky; top: 4px;
  width: var(--cb-toc-w); flex-shrink: 0;
  max-height: calc(100vh - var(--cb-topbar-h) - 40px); overflow-y: auto;
  font-size: 13px;
}
.cb-toc-title { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--cb-text-mut); font-weight: 700; margin-bottom: 10px; }
.cb-toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--cb-border); }
.cb-toc li a { display: block; padding: 5px 0 5px 14px; color: var(--cb-text-soft); border-left: 2px solid transparent; margin-left: -1px; }
.cb-toc li a:hover { color: var(--cb-accent); text-decoration: none; }
.cb-toc li a.active { color: var(--cb-accent); border-left-color: var(--cb-accent); font-weight: 600; }
.cb-toc-l3 a { padding-left: 26px; font-size: 12.5px; }

/* ---------- Footer ---------- */
.cb-footer {
  border-top: 1px solid var(--cb-border); padding: 22px 40px;
  color: var(--cb-text-mut); font-size: 13px; text-align: center;
}

/* ---------- Backdrop mobile ---------- */
.cb-backdrop { display: none; }

/* ---------- Responsivo ---------- */
@media (max-width: 1180px) {
  .cb-toc { display: none; }
}
@media (max-width: 1180px) {
  .cb-topnav { display: none; }
}
@media (max-width: 980px) {
  .cb-burger { display: flex; }
  .cb-search { margin: 0; }
  .cb-brand-sub { display: none; }
  .cb-sidebar {
    position: fixed; top: var(--cb-topbar-h); left: 0; bottom: 0; z-index: 45;
    height: auto;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: var(--cb-shadow); width: 86vw; max-width: 340px;
  }
  body.cb-nav-open .cb-sidebar { transform: translateX(0); }
  body.cb-nav-open .cb-backdrop {
    display: block; position: fixed; inset: var(--cb-topbar-h) 0 0 0;
    background: rgba(10,14,22,.45); z-index: 40;
  }
  .cb-main { padding: 22px 18px 70px; }
}
@media (max-width: 560px) {
  .cb-kbd { display: none; }
  .cb-content h1 { font-size: 26px; }
  .cb-pager { flex-direction: column; }
}
