/**
 * Documentação (app) — sidebar + canais
 * Requisitos: modo escuro fixo, sem toggle de tema.
 * Usa variáveis globais (rcs-themes.css) como base.
 */

:root {
  /* Altura aproximada da navbar global (sobre.html) */
  --doc-topbar-h: 96px;
  /* Posição dinâmica do “fim” do header no viewport (0..--doc-topbar-h) */
  --doc-header-bottom: var(--doc-topbar-h);
  --doc-sidebar-w: 264px;
}

html {
  scroll-behavior: smooth;
}

body.doc-app {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  background: var(--rcs-gradient-dark-body, #141a21);
  color: var(--rcs-text-primary, #f1f5f9);
}

/* Footer global: respeita a sidebar fixa */
body.doc-app .sc-footer {
  margin-left: var(--doc-sidebar-w);
}

/* Barra de progresso do scroll (embaixo da navbar) */
.doc-scroll-progress {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--doc-header-bottom);
  height: 3px;
  z-index: 999;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(10px);
  transition: top 0.18s ease;
}

.doc-scroll-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(37, 211, 102, 0.9), rgba(99, 179, 237, 0.85));
  box-shadow: 0 0 18px rgba(37, 211, 102, 0.25);
  border-radius: 999px;
  transform-origin: left center;
  transition: width 0.08s linear;
}

/* Botão lateral: voltar ao topo */
.doc-back-to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  width: 50px;
  height: 50px;
  border-radius: 999px;
  border: 0;
  background: var(--btn-sobre-grad, linear-gradient(318deg, #1dd1a1 25%, #54a0ff 100%));
  color: var(--btn-sobre-text, #0b1020);
  box-shadow: var(--btn-sobre-shadow, 0 10px 28px rgba(29, 209, 161, 0.28));
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease, box-shadow 0.2s ease,
    filter 0.2s ease, background 0.2s ease;
}

.doc-back-to-top:hover {
  background: var(--btn-sobre-grad-hover, linear-gradient(318deg, #18b892 25%, #4a8fe8 100%));
  box-shadow: var(--btn-sobre-shadow-hover, 0 14px 36px rgba(84, 160, 255, 0.25));
  filter: saturate(1.05);
}

.doc-back-to-top:active {
  transform: translateY(1px);
}

.doc-back-to-top.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.doc-back-to-top span {
  font-weight: 900;
  font-size: 18px;
  line-height: 1;
}

/* Topbar removida: usamos a navbar global do site (sobre.html) */

/* Layout */
.doc-layout {
  min-height: 100vh;
}

.doc-sidebar {
  position: fixed;
  left: 0;
  top: var(--doc-topbar-h);
  bottom: 0;
  width: var(--doc-sidebar-w);
  overflow: auto;
  overscroll-behavior: contain;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 12, 18, 0.58);
  backdrop-filter: blur(10px);
  padding: 12px 12px 16px;
  scrollbar-gutter: stable;
  scrollbar-color: rgba(255, 255, 255, 0.22) rgba(255, 255, 255, 0.06);
  transition: top 0.22s ease, height 0.22s ease, opacity 0.18s ease,
    transform 0.18s ease;
  height: calc(100vh - var(--doc-topbar-h));
}

body.doc-app.doc-header-hidden .doc-sidebar {
  top: 0;
  height: 100vh;
}

/* Animação do header do site (desce some, sobe aparece) */
#header {
  will-change: transform;
  transition: transform 0.22s ease;
}

#header.doc-header-hidden {
  transform: translateY(-110%);
}

.doc-sidebar::-webkit-scrollbar {
  width: 10px;
}

.doc-sidebar::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
}

.doc-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.05);
}

.doc-sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* Controles superiores (idioma) */
.doc-sidebar-controls {
  margin: 0 0 10px;
}

.doc-lang-toggle {
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
}

.doc-lang-btn {
  border: 1px solid transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.doc-lang-btn[aria-pressed="true"] {
  border-color: rgba(84, 160, 255, 0.42);
  background: linear-gradient(318deg,
      rgba(29, 209, 161, 0.18) 25%,
      rgba(84, 160, 255, 0.18) 100%);
  color: rgba(255, 255, 255, 0.92);
}

.doc-channel-toggle {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0 0 10px;
  padding: 10px;
  background: rgba(8, 12, 18, 0.62);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
}

.doc-channel-btn {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.88);
  border-radius: 999px;
  padding: 8px 10px;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.doc-channel-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.doc-channel-btn.is-active {
  background: linear-gradient(318deg, #1dd1a1 25%, #54a0ff 100%);
  border-color: rgba(29, 209, 161, 0.55);
  color: rgba(255, 255, 255, 0.96);
}

.doc-sidebar-nav {
  margin-top: 10px;
  padding-bottom: 12px;
}

.doc-sidebar-title {
  margin: 10px 10px 8px;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
}

.doc-sidebar-nav a {
  display: block;
  position: relative;
  padding: 8px 10px 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.doc-sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.95);
}

.doc-sidebar-nav a.is-active {
  background: linear-gradient(318deg,
      rgba(29, 209, 161, 0.14) 25%,
      rgba(84, 160, 255, 0.14) 100%);
  border-color: rgba(84, 160, 255, 0.35);
  color: rgba(255, 255, 255, 0.94);
}

.doc-sidebar-nav a.is-active::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(318deg, #1dd1a1 25%, #54a0ff 100%);
}

.doc-sidebar-nav a.doc-sidebar-sub {
  padding-left: 28px;
  font-weight: 700;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
}

.doc-sidebar-nav a.doc-sidebar-sub:hover {
  color: rgba(255, 255, 255, 0.92);
}

.doc-main {
  /* Header é fixo: sempre reserva espaço no topo pro conteúdo ficar abaixo */
  padding: calc(var(--doc-topbar-h) + 18px) 26px 54px;
  overflow: hidden;
  margin-left: var(--doc-sidebar-w);
}

.doc-pane {
  display: none;
}

.doc-pane.is-active {
  display: block;
}

/* Conteúdo */
.doc-hero {
  padding: 14px 0 22px;
  margin-bottom: 18px;
}

.doc-hero h1 {
  font-size: 1.65rem;
  font-weight: 800;
  margin: 0 0 8px;
  letter-spacing: -0.03em;
}

.doc-hero p {
  margin: 0;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.6;
  font-size: 0.95rem;
}

.doc-section {
  padding: 18px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  scroll-margin-top: calc(var(--doc-header-bottom) + 18px);
}

.doc-subsection {
  padding: 12px 0 2px;
  scroll-margin-top: calc(var(--doc-header-bottom) + 18px);
}

.doc-subsection h4 {
  margin-top: 0;
}

.doc-section:first-of-type {
  border-top: none;
}

.doc-section h3,
.doc-section h4,
.doc-section h5 {
  color: rgba(255, 255, 255, 0.95);
  letter-spacing: -0.02em;
}

.doc-section h3 {
  font-size: 1.12rem;
  margin: 0 0 10px;
}

.doc-section h4 {
  font-size: 1.02rem;
  margin: 16px 0 10px;
}

.doc-section h5 {
  font-size: 0.96rem;
  margin: 14px 0 8px;
}

.doc-section p,
.doc-section li {
  color: rgba(255, 255, 255, 0.76);
}

.doc-section code {
  color: #a7f3d0;
  background: rgba(167, 243, 208, 0.08);
  border: 1px solid rgba(167, 243, 208, 0.14);
  padding: 2px 6px;
  border-radius: 8px;
}

/* Bootstrap (list-group / alerts) em dark */
.doc-main .list-group {
  border-radius: 14px;
  overflow: hidden;
}

.doc-main .list-group-item {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.78);
}

.doc-main .list-group-item strong {
  color: rgba(255, 255, 255, 0.92);
}

.doc-main .alert {
  border-radius: 14px;
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.82);
}

.doc-main .alert strong {
  color: rgba(255, 255, 255, 0.94);
}

.doc-main .alert-info {
  border-color: rgba(99, 179, 237, 0.28);
  background: rgba(99, 179, 237, 0.08);
}

.doc-main .alert-success {
  border-color: rgba(72, 187, 120, 0.28);
  background: rgba(72, 187, 120, 0.08);
}

.doc-main .alert-warning {
  border-color: rgba(237, 137, 54, 0.28);
  background: rgba(237, 137, 54, 0.08);
}

.doc-main .text-muted,
.doc-main small {
  color: rgba(255, 255, 255, 0.6) !important;
}

/* Badge simples (para status) */
.doc-main .tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.95);
}

/* Code block */
pre.doc-code {
  position: relative;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 14px 14px 14px;
  overflow: auto;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
}

pre.doc-code code {
  background: none;
  border: 0;
  padding: 0;
  color: #d1fae5;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.55;
  white-space: pre;
}

.doc-copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.9);
  padding: 7px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.doc-copy-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.doc-copy-btn.is-copied {
  background: rgba(37, 211, 102, 0.18);
  border-color: rgba(37, 211, 102, 0.28);
}

/* Endpoint chip */
.doc-endpoint {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.doc-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.06em;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.92);
}

.doc-url {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
}

/* Responsivo */
@media (max-width: 900px) {
  .doc-sidebar {
    position: relative;
    left: auto;
    top: auto;
    bottom: auto;
    width: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 12px 12px 14px;
  }

  .doc-channel-toggle {
    position: relative;
    top: auto;
    margin: 0 0 10px;
    padding: 8px;
    background: rgba(8, 12, 18, 0.35);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }

  .doc-main {
    padding: 18px 16px 48px;
    margin-left: 0;
  }

  body.doc-app .sc-footer {
    margin-left: 0;
  }
}