/* ==========================================================================
   Documentación — layout y componentes (CSS propio, no depende de Tailwind)
   Colores alineados con el tema: primary = indigo, neutros = slate.
   Modo oscuro: clase `.dark` en un ancestro (igual que las utilidades dark: de Tailwind).
   ========================================================================== */

.docs-shell {
    --docs-header-h: 4rem;           /* altura del header: h-16 en móvil (ver más abajo el valor de md+) */

    --d-bg: #ffffff;
    --d-bg-side: #f8fafc;
    --d-border: #e2e8f0;
    --d-text: #0f172a;
    --d-muted: #475569;
    --d-faint: #94a3b8;
    --d-hover: #f1f5f9;
    --d-primary: #4f46e5;
    --d-primary-strong: #4338ca;
    --d-primary-soft: #eef2ff;

    background: var(--d-bg);
    color: var(--d-text);
}
.dark .docs-shell {
    --d-bg: #020617;
    --d-bg-side: #0f172a;
    --d-border: #1e293b;
    --d-text: #f1f5f9;
    --d-muted: #94a3b8;
    --d-faint: #64748b;
    --d-hover: #1e293b;
    --d-primary: #818cf8;
    --d-primary-strong: #a5b4fc;
    --d-primary-soft: rgba(99, 102, 241, 0.16);
}

/* El header del sitio pasa de h-16 (4rem) a md:h-20 (5rem) a partir de 768px */
@media (min-width: 768px) {
    .docs-shell { --docs-header-h: 5rem; }
}

/* ---------- Estructura: sidebar | contenido | toc ---------- */
.docs-shell { display: block; }
@media (min-width: 1024px) {
    .docs-shell { display: flex; align-items: stretch; }
}

.docs-sidebar {
    display: none;
    background: var(--d-bg-side);
    border-bottom: 1px solid var(--d-border);
}
.docs-shell.is-nav-open .docs-sidebar { display: block; }
@media (min-width: 1024px) {
    .docs-sidebar {
        display: block;
        flex: none;
        width: 16.5rem;
        border-bottom: 0;
        border-right: 1px solid var(--d-border);
    }
}

.docs-sidebar__inner { padding: 1rem 0.75rem 2rem; }
@media (min-width: 1024px) {
    .docs-sidebar__inner {
        position: sticky;
        top: var(--docs-header-h);
        height: calc(100vh - var(--docs-header-h));
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

.docs-mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.875rem 1.25rem;
    background: var(--d-bg-side);
    border: 0;
    border-bottom: 1px solid var(--d-border);
    font: inherit;
    font-weight: 500;
    color: var(--d-text);
    cursor: pointer;
}
.docs-mobile-toggle svg { transition: transform 0.15s ease; color: var(--d-faint); }
.docs-shell.is-nav-open .docs-mobile-toggle svg { transform: rotate(180deg); }
@media (min-width: 1024px) {
    .docs-mobile-toggle { display: none; }
}

.docs-main { flex: 1 1 0%; min-width: 0; background: var(--d-bg); }
.docs-main__inner {
    display: flex;
    justify-content: center;
    gap: 3rem;
    max-width: 80rem;
    margin: 0 auto;
    padding: 2.5rem 1.25rem 4rem;
}
@media (min-width: 1024px) {
    .docs-main__inner { padding: 3rem 2.5rem 5rem; }
}
.docs-content { flex: 1 1 auto; min-width: 0; max-width: 46rem; }

/* ---------- Navegación lateral ---------- */
.docs-nav, .docs-nav__children { list-style: none; margin: 0; padding: 0; }
.docs-nav > .docs-nav__item + .docs-nav__item { margin-top: 0.125rem; }

.docs-nav__row { display: flex; align-items: center; gap: 0.25rem; }

.docs-nav__link {
    display: flex;
    flex: 1 1 0%;
    min-width: 0;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    line-height: 1.35;
    color: var(--d-muted);
    text-decoration: none;
    transition: background-color 0.12s ease, color 0.12s ease;
}
.docs-nav__link:hover { background: var(--d-hover); color: var(--d-text); }
.docs-nav__link[aria-current="page"] {
    background: var(--d-primary-soft);
    color: var(--d-primary-strong);
    font-weight: 500;
}
.docs-nav__icon { flex: none; display: inline-flex; color: var(--d-faint); }
.docs-nav__link[aria-current="page"] .docs-nav__icon { color: var(--d-primary); }

.docs-nav__toggle {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--d-faint);
    cursor: pointer;
}
.docs-nav__toggle:hover { background: var(--d-hover); color: var(--d-text); }
.docs-nav__toggle svg { transition: transform 0.15s ease; }
.docs-nav__toggle[aria-expanded="true"] svg { transform: rotate(90deg); }

.docs-nav__children {
    margin: 0.125rem 0 0.5rem 1.375rem;
    padding-left: 0.5rem;
    border-left: 1px solid var(--d-border);
}
.docs-nav__children .docs-nav__link { font-size: 0.875rem; padding: 0.375rem 0.625rem; }

/* ---------- Migas de pan ---------- */
.docs-breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.875rem;
    color: var(--d-muted);
}
.docs-breadcrumb li { display: inline-flex; align-items: center; }
.docs-breadcrumb a { color: inherit; text-decoration: none; display: inline-flex; }
.docs-breadcrumb a:hover { color: var(--d-primary); }
.docs-breadcrumb__sep { color: var(--d-faint); }
.docs-breadcrumb [aria-current="page"] { color: var(--d-text); font-weight: 500; }

/* ---------- Cabecera de página ---------- */
.docs-header { margin-bottom: 2rem; }
.docs-title {
    margin: 1.5rem 0 0;
    font-size: 2rem;
    line-height: 1.15;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--d-text);
}
@media (min-width: 640px) { .docs-title { font-size: 2.375rem; } }
.docs-subtitle {
    margin: 1rem 0 0;
    font-size: 1.125rem;
    line-height: 1.7;
    color: var(--d-muted);
}
.docs-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.5rem; }
.docs-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    background: var(--d-hover);
    color: var(--d-muted);
    font-size: 0.75rem;
    line-height: 1.25rem;
}
.docs-badge--primary { background: var(--d-primary-soft); color: var(--d-primary-strong); }
.docs-header--article {
    padding-bottom: 2rem;
    margin-bottom: 2.5rem;
    border-bottom: 1px solid var(--d-border);
}

/* ---------- Tarjetas de sección (toda la tarjeta es clicable) ---------- */
.docs-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 2.5rem;
}
@media (min-width: 640px) {
    .docs-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.docs-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    padding: 1.375rem 1.5rem;
    background: var(--d-bg);
    border: 1px solid var(--d-border);
    border-radius: 0.875rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.docs-card:hover {
    border-color: var(--d-primary);
    box-shadow: 0 10px 28px -14px rgba(79, 70, 229, 0.35);
}
.docs-card:focus-within { outline: 2px solid var(--d-primary); outline-offset: 2px; }
.docs-card__head { display: flex; align-items: center; gap: 0.875rem; }
.docs-card__icon {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.625rem;
    background: var(--d-primary-soft);
    color: var(--d-primary);
}
.docs-card__title { flex: 1 1 0%; min-width: 0; margin: 0; font-size: 1.0625rem; font-weight: 600; line-height: 1.3; }
.docs-card__title a { color: var(--d-text); text-decoration: none; }
.docs-card__title a:focus { outline: none; }
/* Enlace "estirado": el ::after cubre toda la tarjeta (position: relative en .docs-card) */
.docs-card__title a::after { content: ""; position: absolute; inset: 0; }
.docs-card__arrow { flex: none; color: var(--d-faint); transition: transform 0.15s ease, color 0.15s ease; }
.docs-card:hover .docs-card__arrow { transform: translateX(3px); color: var(--d-primary); }
.docs-card__text { margin: 0; font-size: 0.9375rem; line-height: 1.65; color: var(--d-muted); }

/* ---------- Contenido (Markdown) ---------- */
.docs-prose { margin-top: 2.5rem; }
.docs-header--article + .docs-prose { margin-top: 0; }
.docs-prose h2, .docs-prose h3, .docs-prose h4 { scroll-margin-top: calc(var(--docs-header-h) + 1.5rem); letter-spacing: -0.01em; }
.docs-prose a { color: var(--d-primary); }
.docs-prose :not(pre) > code { color: var(--d-primary-strong); background: var(--d-hover); padding: 0.125rem 0.375rem; border-radius: 0.375rem; font-size: 0.875em; }
.docs-prose :not(pre) > code::before, .docs-prose :not(pre) > code::after { content: none; }
.docs-prose pre { border-radius: 0.75rem; }
.docs-prose img { border-radius: 0.75rem; }

/* Subpáginas ("En este tema") */
.docs-subpages { margin-top: 2.5rem; }
.docs-subpages h2 { margin: 0 0 1rem; font-size: 1.125rem; font-weight: 600; }
.docs-subpages ul { display: grid; gap: 0.75rem; margin: 0; padding: 0; list-style: none; }
@media (min-width: 640px) { .docs-subpages ul { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.docs-subpages a {
    display: block;
    padding: 0.875rem 1rem;
    border: 1px solid var(--d-border);
    border-radius: 0.75rem;
    color: var(--d-text);
    font-weight: 500;
    text-decoration: none;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.docs-subpages a:hover { border-color: var(--d-primary); color: var(--d-primary); }

/* ---------- Anterior / siguiente ---------- */
.docs-pager {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 3.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--d-border);
}
@media (min-width: 640px) { .docs-pager { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Cada botón es una fila: [flecha] [texto] (anterior) o [texto] [flecha] (siguiente),
   con la flecha centrada verticalmente respecto al bloque "etiqueta + título". */
.docs-pager__link {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.875rem;
    min-width: 0;
    padding: 1rem 1.25rem;
    border: 1px solid var(--d-border);
    border-radius: 0.75rem;
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.docs-pager__link:hover { border-color: var(--d-primary); box-shadow: 0 8px 24px -14px rgba(79, 70, 229, 0.35); }
.docs-pager__link:focus-visible { outline: 2px solid var(--d-primary); outline-offset: 2px; }

.docs-pager__icon {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    width: 1.25rem;
    height: 1.25rem;
    color: var(--d-faint);
    transition: color 0.15s ease, transform 0.15s ease;
}
.docs-pager__icon svg { display: block; width: 1.25rem; height: 1.25rem; margin: 0; }
.docs-pager__link:hover .docs-pager__icon { color: var(--d-primary); }
.docs-pager__link--prev:hover .docs-pager__icon { transform: translateX(-2px); }
.docs-pager__link--next:hover .docs-pager__icon { transform: translateX(2px); }

.docs-pager__text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; justify-content: center; line-height: 1.3; }
.docs-pager__link--next { text-align: right; }
.docs-pager__link--next .docs-pager__text { align-items: flex-end; }
@media (min-width: 640px) { .docs-pager__link--next { grid-column: 2; } }
.docs-pager__label { display: block; font-size: 0.8125rem; color: var(--d-muted); }
.docs-pager__title { display: block; margin-top: 0.125rem; font-weight: 600; color: var(--d-text); overflow-wrap: anywhere; }
.docs-pager__link:hover .docs-pager__title { color: var(--d-primary); }

/* ---------- "En esta página" ---------- */
.docs-toc { display: none; flex: none; width: 13.5rem; }
@media (min-width: 1280px) { .docs-toc { display: block; } }
.docs-toc__inner { position: sticky; top: calc(var(--docs-header-h) + 2rem); }
.docs-toc__title {
    margin: 0 0 0.875rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--d-text);
}
.docs-toc ul { margin: 0; padding: 0; list-style: none; border-left: 2px solid var(--d-border); }
.docs-toc a {
    display: block;
    margin-left: -2px;
    padding: 0.3125rem 0.875rem;
    border-left: 2px solid transparent;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--d-muted);
    text-decoration: none;
    transition: color 0.12s ease, border-color 0.12s ease;
}
.docs-toc a.is-h3 { padding-left: 1.625rem; }
.docs-toc a:hover { color: var(--d-text); }
.docs-toc a.is-active { border-left-color: var(--d-primary); color: var(--d-primary); font-weight: 500; }

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