/* ==========================================================================
   Central de Ajuda — leitor de documentacao (docs/ajuda)
   Tema escuro, alinhado ao design system (tokens.css).
   ========================================================================== */

:root {
    --help-header: 64px;
    --help-sidebar: 300px;
}

body.help-page {
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(30, 107, 255, .10), transparent 60%),
        radial-gradient(900px 500px at -10% 10%, rgba(124, 58, 237, .10), transparent 55%),
        var(--bg-deep);
    color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* ---------- Cabecalho ---------- */
.help-header {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--help-header);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 20px;
    background: rgba(7, 17, 31, .82);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
}

.help-menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 7px;
    cursor: pointer;
}

.help-menu-toggle .icon {
    width: 18px;
    height: 18px;
    filter: var(--icon-on-dark-filter);
    opacity: var(--icon-on-dark-opacity);
}

.help-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    font-weight: 800;
    font-size: 16px;
    letter-spacing: .2px;
}

.help-brand img {
    border-radius: 8px;
}

.help-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
}

.help-lang {
    display: flex;
    border: 1px solid var(--line);
    border-radius: 999px;
    overflow: hidden;
}

.help-lang a {
    padding: 5px 11px;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-decoration: none;
}

.help-lang a.is-active {
    background: var(--blue);
    color: #fff;
}

.help-lang a:hover {
    color: var(--text);
}

/* ---------- Shell ---------- */
.help-shell {
    display: flex;
    align-items: flex-start;
    max-width: 1280px;
    margin: 0 auto;
}

.help-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 25;
}

/* ---------- Sidebar ---------- */
.help-sidebar {
    flex: 0 0 var(--help-sidebar);
    width: var(--help-sidebar);
    position: sticky;
    top: var(--help-header);
    align-self: flex-start;
    height: calc(100vh - var(--help-header));
    overflow-y: auto;
    padding: 22px 16px 40px;
    border-right: 1px solid var(--line);
}

.help-nav-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 9px 12px;
    margin-bottom: 18px;
}

.help-nav-search .icon {
    width: 16px;
    height: 16px;
    filter: var(--icon-on-dark-filter);
    opacity: .6;
}

.help-nav-search input {
    background: transparent;
    border: 0;
    outline: none;
    color: var(--text);
    font-size: 13px;
    width: 100%;
}

.help-nav-search input::placeholder {
    color: var(--muted-2);
}

.help-nav-group {
    margin-bottom: 18px;
}

.help-nav-cat {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: var(--muted-2);
    padding: 0 10px 8px;
}

.help-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.help-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--r-sm);
    color: var(--muted);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: background .15s, color .15s;
}

.help-nav-link .icon {
    width: 16px;
    height: 16px;
    filter: var(--icon-on-dark-filter);
    opacity: .7;
    flex: 0 0 16px;
}

.help-nav-link:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.help-nav-link.is-active {
    background: linear-gradient(180deg, rgba(30, 107, 255, .22), rgba(30, 107, 255, .10));
    color: #fff;
    box-shadow: inset 0 0 0 1px var(--line-strong);
}

.help-nav-link.is-active .icon {
    opacity: 1;
}

/* ---------- Sumario (H1 > H2) ---------- */
.help-toc {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px dashed var(--line);
}

.help-toc-title {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: var(--muted-2);
    padding: 0 10px 10px;
}

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

.help-toc-list .help-toc-list {
    margin-top: 2px;
}

.help-toc-item {
    line-height: 1.3;
}

.help-toc-item a {
    display: block;
    padding: 5px 10px;
    color: var(--muted);
    text-decoration: none;
    font-size: 12.5px;
    border-left: 2px solid transparent;
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.help-toc-l2 a {
    padding-left: 22px;
    font-size: 12px;
}

.help-toc-item a:hover {
    color: var(--text);
    background: var(--surface-soft);
}

.help-toc-item a.is-active {
    color: var(--cyan);
    border-left-color: var(--cyan);
    background: rgba(0, 223, 255, .08);
}

/* ---------- Conteudo ---------- */
.help-main {
    flex: 1 1 auto;
    min-width: 0;
    padding: 36px clamp(20px, 5vw, 64px) 80px;
}

.help-content {
    max-width: 820px;
    margin: 0 auto;
}

.help-doc-head {
    margin-bottom: 28px;
}

.help-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
}

.help-back .icon {
    width: 15px;
    height: 15px;
    filter: var(--icon-on-dark-filter);
    opacity: .8;
}

.help-back:hover {
    color: var(--text);
}

.help-doc-title {
    font-size: clamp(26px, 4vw, 34px);
    font-weight: 800;
    line-height: 1.15;
    margin: 0 0 10px;
    background: linear-gradient(90deg, #fff, #cfe0ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.help-doc-lead {
    color: var(--muted);
    font-size: 15px;
    margin: 0;
}

/* ---------- Tipografia do markdown ---------- */
.markdown {
    font-size: 15.5px;
    line-height: 1.75;
    color: #dbe4f0;
}

.markdown h1,
.markdown h2,
.markdown h3 {
    color: #fff;
    font-weight: 700;
    line-height: 1.25;
    scroll-margin-top: calc(var(--help-header) + 18px);
}

.markdown h1 {
    font-size: 24px;
    margin: 38px 0 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.markdown h2 {
    font-size: 19px;
    margin: 30px 0 12px;
}

.markdown h3 {
    font-size: 16px;
    margin: 22px 0 10px;
    color: #e8eefb;
}

.markdown p {
    margin: 12px 0;
}

.markdown a {
    color: var(--cyan);
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 223, 255, .35);
}

.markdown a:hover {
    border-bottom-color: var(--cyan);
}

.markdown strong {
    color: #fff;
    font-weight: 700;
}

.markdown ul,
.markdown ol {
    margin: 12px 0;
    padding-left: 24px;
}

.markdown li {
    margin: 6px 0;
}

.markdown li::marker {
    color: var(--blue);
}

.markdown code {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 1px 6px;
    font-size: 13px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: #ffd9a8;
}

.markdown pre {
    background: #060d18;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 16px 18px;
    overflow-x: auto;
    margin: 16px 0;
}

.markdown pre code {
    background: none;
    border: 0;
    padding: 0;
    color: #cfe0ff;
    font-size: 13px;
}

.markdown blockquote {
    margin: 16px 0;
    padding: 12px 18px;
    border-left: 3px solid var(--violet);
    background: rgba(124, 58, 237, .10);
    border-radius: 0 var(--r-md) var(--r-md) 0;
    color: #e6dcff;
}

.markdown blockquote p {
    margin: 4px 0;
}

.markdown table {
    width: 100%;
    border-collapse: collapse;
    margin: 18px 0;
    font-size: 14px;
    overflow: hidden;
    border-radius: var(--r-md);
}

.markdown th,
.markdown td {
    border: 1px solid var(--line);
    padding: 10px 12px;
    text-align: left;
}

.markdown th {
    background: var(--surface-2);
    color: #fff;
    font-weight: 700;
}

.markdown tr:nth-child(even) td {
    background: rgba(255, 255, 255, .02);
}

.markdown img {
    max-width: 100%;
    border-radius: var(--r-md);
    border: 1px solid var(--line);
}

.markdown hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 28px 0;
}

.help-doc-foot {
    margin-top: 40px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
}

/* ---------- Estados vazios / erro ---------- */
.help-empty {
    text-align: center;
    padding: 60px 20px;
}

.help-empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 18px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: var(--surface-2);
    border: 1px solid var(--line);
}

.help-empty-icon .icon {
    width: 28px;
    height: 28px;
    filter: var(--icon-on-dark-filter);
    opacity: .8;
}

.help-empty-title {
    font-size: 22px;
    font-weight: 800;
    margin: 0 0 8px;
}

.help-empty-text {
    color: var(--muted);
    margin: 0 0 6px;
}

.help-empty-sub {
    color: var(--muted-2);
    font-size: 13px;
    margin: 0 0 20px;
    word-break: break-all;
}

/* ---------- Responsivo ---------- */
@media (max-width: 900px) {
    .help-menu-toggle {
        display: inline-flex;
    }

    .help-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        background: var(--surface);
        z-index: 28;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: var(--shadow-md);
    }

    .help-sidebar.is-open {
        transform: translateX(0);
    }

    .help-main {
        padding: 24px 18px 64px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}