/* =========================================================================
   Documentación (se carga solo en documentacion.php, después de app.css)
   ========================================================================= */

.docs { padding-top: var(--nav-h); }

.docs-bar { position: sticky; top: var(--nav-h); z-index: 50; border-bottom: 1px solid var(--border-soft); background: rgba(34, 30, 45, .88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.docs-bar-inner { display: flex; gap: 12px; align-items: center; height: 58px; }
.docs-menu-btn { display: none; }
.docs-search-btn {
    flex: 1; max-width: 460px; display: flex; gap: 10px; align-items: center; height: 40px; padding: 0 12px;
    border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-3); font-size: 14px;
    transition: border-color .2s;
}
.docs-search-btn:hover { border-color: #55497a; color: var(--text-2); }
.docs-search-btn span { flex: 1; min-width: 0; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.docs-search-btn .ic { width: 17px; height: 17px; }

.docs-grid-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr) 210px; gap: 40px; align-items: start; padding-top: 32px; padding-bottom: 96px; }

/* ---------- Árbol ---------- */

.docs-side { position: sticky; top: calc(var(--nav-h) + 58px + 20px); max-height: calc(100vh - var(--nav-h) - 58px - 40px); overflow-y: auto; padding-right: 6px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.docs-filter { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; padding: 0 10px; height: 38px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg-deep); color: var(--text-3); }
.docs-filter input { height: 36px; padding: 0; border: 0; background: transparent; font-size: 13.5px; box-shadow: none !important; }
.docs-tree ul { display: grid; gap: 1px; }
.docs-tree ul ul { margin: 2px 0 6px 13px; padding-left: 10px; border-left: 1px solid var(--border-soft); display: none; }
.docs-tree .tree-folder.open > ul { display: grid; }
.tree-toggle, .tree-link {
    width: 100%; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px;
    color: var(--text-2); font-size: 14px; text-align: left; line-height: 1.35;
}
.tree-toggle { font-weight: 600; color: var(--text); }
.tree-toggle .ic { width: 16px; height: 16px; color: var(--text-3); }
.tree-toggle span { flex: 1; }
.tree-toggle .chev { width: 14px; height: 14px; transition: transform .2s; }
.tree-folder.open > .tree-toggle .chev { transform: rotate(90deg); }
.tree-toggle:hover, .tree-link:hover { background: rgba(124, 58, 237, .04); color: var(--text); }
.tree-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.tree-home .ic { color: var(--primary); }
.docs-empty { color: var(--text-3); font-size: 14px; padding: 10px; }
.docs-help { display: flex; gap: 8px; align-items: center; margin-top: 18px; padding: 12px; border-radius: 10px; border: 1px solid var(--border); color: var(--text-2); font-size: 13.5px; }
.docs-help:hover { color: var(--text); border-color: #55497a; }
.docs-help .ic { width: 18px; height: 18px; color: #8b9bff; }

/* ---------- Portada de docs ---------- */

.docs-title { font-size: clamp(32px, 4vw, 44px); margin: 16px 0 12px; letter-spacing: -.03em; }
.docs-h2 { font-size: 20px; margin: 44px 0 16px; }
.docs-p { color: var(--text-2); margin-bottom: 16px; }
.docs-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.docs-cards .card h3 { margin: 12px 0 4px; }
.docs-cards .card:hover { border-color: #61548a; transform: translateY(-2px); }

/* ---------- Contenido de las guías ---------- */

.docs-content { min-width: 0; }
.docs-crumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 18px; color: var(--text-3); font-size: 13.5px; }
.docs-crumbs a { color: var(--primary); font-weight: 600; }
.docs-crumbs i { font-style: normal; opacity: .5; }
.docs-crumbs span:last-child { color: var(--text-2); }

.guide-body { color: var(--text-2); font-size: 15.5px; line-height: 1.75; }
.guide-body > :first-child { margin-top: 0; }
.guide-body h3 { color: var(--text); font-size: clamp(26px, 3vw, 34px); letter-spacing: -.025em; margin: 0 0 18px; scroll-margin-top: calc(var(--nav-h) + 80px); }
.guide-body h3:not(:first-child) { font-size: 22px; margin-top: 44px; padding-top: 28px; border-top: 1px solid var(--border-soft); }
.guide-body h4 { color: var(--text); font-size: 17px; margin: 32px 0 12px; scroll-margin-top: calc(var(--nav-h) + 80px); }
.guide-body p { margin: 0 0 14px; }
.guide-body strong { color: var(--text); }
.guide-body a { color: var(--primary); text-decoration: underline; text-decoration-color: rgba(124, 58, 237, .4); text-underline-offset: 3px; }
.guide-body a:hover { text-decoration-color: var(--primary); }
.guide-body ul, .guide-body ol { margin: 0 0 16px; padding-left: 22px; }
.guide-body ul { list-style: disc; }
.guide-body ol { list-style: decimal; }
.guide-body li { margin: 6px 0; }
.guide-body li::marker { color: var(--primary); }
.guide-body img { max-width: 100%; border-radius: var(--r); border: 1px solid var(--border); margin: 8px 0 18px; }
.guide-body code { padding: 2px 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border-soft); color: #c4a8ff; font-size: .86em; overflow-wrap: anywhere; }
.guide-body pre {
    position: relative; margin: 0 0 20px; padding: 18px 20px; border-radius: var(--r); overflow-x: auto;
    background: #1a1027; border: 1px solid var(--border); font-size: 13.5px; line-height: 1.6;
}
.guide-body pre code { padding: 0; background: none; border: 0; color: #d6cdef; font-size: inherit; word-break: normal; white-space: pre; }
.copy-code {
    position: absolute; top: 8px; right: 8px; padding: 4px 10px; border-radius: 7px; font-size: 12px; font-weight: 600;
    background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); opacity: 0; transition: opacity .2s;
}
.guide-body pre:hover .copy-code, .copy-code:focus-visible { opacity: 1; }
.guide-body .table-wrap { margin: 0 0 20px; }
.guide-body .table td { color: var(--text-2); font-size: 14.5px; line-height: 1.6; }
.guide-body .table td:first-child { white-space: nowrap; }

.alert { margin: 0 0 18px; padding: 14px 16px 14px 44px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); position: relative; font-size: 14.5px; color: var(--text-2); }
.alert::before { content: "i"; position: absolute; left: 14px; top: 14px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font: 700 12px var(--font); }
.alert p:last-child { margin-bottom: 0; }
.alert-info { border-color: rgba(124, 58, 237, .35); background: rgba(124, 58, 237, .07); }
.alert-info::before { background: var(--primary); color: var(--primary-ink); }
.alert-warning { border-color: rgba(217, 119, 6, .35); background: rgba(217, 119, 6, .06); }
.alert-warning::before { content: "!"; background: #fbbf24; color: #2a1a00; }
.alert-success { border-color: rgba(22, 163, 74, .35); background: rgba(22, 163, 74, .06); }
.alert-success::before { content: "✓"; background: #4ade80; color: #04210f; }
.alert-danger { border-color: rgba(220, 38, 38, .4); background: rgba(220, 38, 38, .06); }
.badge-s3, .badge-s6 { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; vertical-align: 2px; }
.badge-s3 { background: var(--gold-soft); color: var(--gold); }
.badge-s6 { background: var(--primary-soft); color: var(--primary); }

.docs-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--border-soft); }
.docs-pager a { display: grid; gap: 4px; padding: 16px 18px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); transition: border-color .2s; }
.docs-pager a:hover { border-color: #61548a; }
.docs-pager .pager-next { text-align: right; }
.docs-pager small { color: var(--text-3); font-size: 12.5px; }
.docs-pager strong { color: var(--text); font-size: 15px; }

.docs-loading { display: flex; gap: 8px; padding: 60px 0; justify-content: center; }
.docs-loading span { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); animation: blink 1s infinite ease-in-out; }
.docs-loading span:nth-child(2) { animation-delay: .15s; }
.docs-loading span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 100% { opacity: .2; transform: scale(.8); } 50% { opacity: 1; transform: none; } }

/* ---------- Índice de la página ---------- */

.docs-toc { position: sticky; top: calc(var(--nav-h) + 58px + 24px); max-height: calc(100vh - var(--nav-h) - 100px); overflow-y: auto; }
.docs-toc > span { display: block; margin-bottom: 10px; color: var(--text-3); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.docs-toc ul { display: grid; gap: 2px; border-left: 1px solid var(--border-soft); }
.docs-toc a { display: block; padding: 5px 0 5px 12px; margin-left: -1px; border-left: 2px solid transparent; color: var(--text-3); font-size: 13.5px; line-height: 1.4; }
.docs-toc li.sub a { padding-left: 24px; font-size: 13px; }
.docs-toc a:hover { color: var(--text); }
.docs-toc a.active { color: var(--primary); border-left-color: var(--primary); }

/* ---------- Buscador ---------- */

.docs-search { position: fixed; inset: 0; z-index: 250; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; background: rgba(13, 7, 24, .75); backdrop-filter: blur(4px); }
.docs-search[hidden] { display: none; }
.docs-search-card { width: min(620px, 100%); border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-lg); overflow: hidden; }
.docs-search-input { display: flex; gap: 10px; align-items: center; padding: 0 16px; border-bottom: 1px solid var(--border); color: var(--text-3); }
.docs-search-input input { height: 56px; padding: 0; border: 0; background: transparent; font-size: 16px; box-shadow: none !important; }
.docs-results { max-height: 50vh; overflow-y: auto; padding: 8px; }
.docs-results a { display: grid; gap: 2px; padding: 10px 12px; border-radius: 9px; }
.docs-results a strong { color: var(--text); font-size: 14.5px; font-weight: 600; }
.docs-results a small { color: var(--text-3); font-size: 12.5px; }
.docs-results a.active, .docs-results a:hover { background: var(--primary-soft); }
.docs-results a.active strong { color: var(--primary); }
.docs-noresult { padding: 18px; text-align: center; color: var(--text-3); }

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
    .docs-grid-layout { grid-template-columns: 250px minmax(0, 1fr); }
    .docs-toc { display: none; }
}

@media (max-width: 900px) {
    .docs-menu-btn { display: inline-flex; }
    .docs-grid-layout { grid-template-columns: minmax(0, 1fr); padding-top: 24px; }
    .docs-side {
        position: fixed; z-index: 90; top: calc(var(--nav-h) + 58px); left: 0; bottom: 0; width: min(320px, 86vw); max-height: none;
        padding: 16px; background: var(--bg); border-right: 1px solid var(--border);
        transform: translateX(-100%); transition: transform .25s var(--ease);
    }
    body.docs-menu-open .docs-side { transform: none; box-shadow: 30px 0 60px rgba(0, 0, 0, .3); }
    .docs-cards { grid-template-columns: 1fr 1fr; }
    .docs-search-btn kbd { display: none; }
}

@media (max-width: 560px) {
    .docs-cards, .docs-pager { grid-template-columns: 1fr; }
    .docs-pager .pager-next { text-align: left; }
}
