/* ==========================================================================
   Documentación SPL WS — capa de estilos sobre Bootstrap 5.3
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Variables de marca + reemplazo del tema de Bootstrap
   -------------------------------------------------------------------------- */
:root {
    --primary-color: #033371;
    --secondary-color: #0066cc;
    --sidebar-width: 280px;
    --doc-surface: #ffffff;
    --doc-shadow: 0 1px 3px rgba(0, 0, 0, .1);

    /* Tema Bootstrap con los colores corporativos */
    --bs-primary: #033371;
    --bs-primary-rgb: 3, 51, 113;
    --bs-primary-text-emphasis: #022451;
    --bs-primary-bg-subtle: #dbe4f1;
    --bs-primary-border-subtle: #b7c8e3;
    --bs-link-color: #033371;
    --bs-link-color-rgb: 3, 51, 113;
    --bs-link-hover-color: #0066cc;
    --bs-link-hover-color-rgb: 0, 102, 204;
    --bs-body-color: #212529;
    --bs-border-radius: .5rem;
}

.btn-primary {
    --bs-btn-bg: var(--primary-color);
    --bs-btn-border-color: var(--primary-color);
    --bs-btn-hover-bg: var(--secondary-color);
    --bs-btn-hover-border-color: var(--secondary-color);
    --bs-btn-active-bg: #022451;
    --bs-btn-active-border-color: #022451;
    --bs-btn-disabled-bg: var(--primary-color);
    --bs-btn-disabled-border-color: var(--primary-color);
}

.btn-outline-primary {
    --bs-btn-color: var(--primary-color);
    --bs-btn-border-color: var(--primary-color);
    --bs-btn-hover-bg: var(--primary-color);
    --bs-btn-hover-border-color: var(--primary-color);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 .25rem rgba(3, 51, 113, .2);
}

:focus-visible {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

/* Utilidad de texto pequeño (Bootstrap sólo llega a .small) */
.fs-7 { font-size: .8rem; }

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
html {
    scroll-behavior: smooth;
}

body {
    background: #dce5ed;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    background-attachment: fixed;
}

/* Deja aire cuando se navega a un ancla (#filtros, etc.) */
[id] { scroll-margin-top: 1rem; }

/* --------------------------------------------------------------------------
   3. Botón para mostrar / ocultar el menú (visible en todos los tamaños)
   -------------------------------------------------------------------------- */
.doc-menu-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1035;
    padding: .6rem .75rem;
    line-height: 1;
    box-shadow: 0 4px 12px rgba(3, 51, 113, .3);
    transition: left .3s ease, background-color .2s ease, transform .15s ease;
}

.doc-menu-toggle:active { transform: scale(.95); }

/* Con el menú fijo abierto, el botón se corre para no taparlo */
@media (min-width: 992px) {
    .doc-menu-toggle { left: calc(var(--sidebar-width) + 1rem); }
    .doc-sidebar-hidden .doc-menu-toggle { left: 1rem; }
}

/* --------------------------------------------------------------------------
   4. Menú lateral (offcanvas-lg: fijo en escritorio, cajón en móvil)
   -------------------------------------------------------------------------- */
.doc-sidebar {
    --bs-offcanvas-width: min(80vw, 320px);
    background: var(--doc-surface);
}

.doc-sidebar .offcanvas-body {
    padding: 1.5rem;
}

@media (min-width: 992px) {
    .doc-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: var(--sidebar-width);
        height: 100vh;
        overflow-y: auto;
        z-index: 100;
        box-shadow: var(--doc-shadow);
        visibility: visible;
        transition: transform .3s ease, visibility 0s;
        /* Bootstrap fuerza transparent!important sobre .offcanvas-lg en ≥lg */
        background-color: var(--doc-surface) !important;
    }

    .doc-sidebar .offcanvas-body {
        display: block;
        padding: 1.5rem;
        background-color: var(--doc-surface) !important;
    }

    /* Menú colapsado: se va fuera de pantalla y el contenido ocupa todo el ancho */
    .doc-sidebar-hidden .doc-sidebar {
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform .3s ease, visibility 0s linear .3s;
    }

    .doc-sidebar-hidden .doc-main {
        margin-left: 0;
    }
}

/* Scrollbar del menú */
.doc-sidebar::-webkit-scrollbar { width: 6px; }
.doc-sidebar::-webkit-scrollbar-track { background: #f1f1f1; }
.doc-sidebar::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
.doc-sidebar::-webkit-scrollbar-thumb:hover { background: #999; }

.doc-menu-label {
    color: var(--primary-color);
    font-weight: 700;
    text-transform: uppercase;
    font-size: .75rem;
    letter-spacing: .5px;
    margin-bottom: .75rem;
}

.doc-menu {
    --bs-nav-pills-border-radius: 6px;
    --bs-nav-pills-link-active-bg: var(--primary-color);
    --bs-nav-link-padding-x: 1rem;
    --bs-nav-link-padding-y: .6rem;
    --bs-nav-link-font-size: .9rem;
    --bs-nav-link-color: #4a5568;
    --bs-nav-link-hover-color: var(--primary-color);
    gap: .15rem;
}

.doc-menu .nav-link {
    display: flex;
    align-items: center;
    gap: .5rem;
    transition: background-color .2s ease, padding-left .2s ease, color .2s ease;
}

.doc-menu .nav-link:hover {
    background: #f1f5f9;
    padding-left: 1.25rem;
}

.doc-menu .nav-link.active:hover {
    background: var(--primary-color);
    padding-left: 1rem;
}

.lock-icon {
    opacity: .6;
    font-size: .85rem;
}

/* Caja informativa del menú */
.info-box {
    background: linear-gradient(135deg, #edf0f6 0%, #c3cfe2 100%);
    padding: 1rem 1.5rem;
    border-radius: 4px;
    margin: 1rem 0;
    font-size: .9rem;
}

.info-box strong { color: var(--primary-color); }

/* --------------------------------------------------------------------------
   5. Contenido principal
   -------------------------------------------------------------------------- */
.doc-main {
    padding: 1rem;
}

@media (min-width: 992px) {
    .doc-main {
        margin-left: var(--sidebar-width);
        min-height: 100vh;
        padding: 2rem;
        transition: margin-left .3s ease;
    }
}

.doc-hero {
    padding: 2rem 1.5rem;
}

/* Sin menú fijo, el botón flotante queda sobre el encabezado: le hacemos sitio */
@media (max-width: 991.98px) {
    .doc-hero { padding-top: 4rem; }
}

.doc-hero-title { color: var(--primary-color); }

.doc-hero-subtitle {
    color: #4a5568;
    margin-bottom: .5rem;
}

.doc-footer {
    margin-top: 3rem;
    padding: 2rem 1.5rem;
}

/* --------------------------------------------------------------------------
   6. Bloques de documentación (cada vista es <section class="section">)
   -------------------------------------------------------------------------- */
.section {
    background: var(--doc-surface);
    border-radius: 12px;
    box-shadow: var(--doc-shadow);
    margin: 0 auto 2rem;
    padding: 2rem 1.5rem;
    max-width: 1400px;
}

.section > .container { padding-left: 0; padding-right: 0; }

.section .title {
    color: var(--primary-color);
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.2;
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: .75rem;
    margin-bottom: 1.5rem;
}

.section .subtitle {
    color: #4a5568;
    font-size: 1.25rem;
    font-weight: 400;
    margin-bottom: 1.5rem;
}

.section h6 {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.1rem;
    margin: 2rem 0 1rem;
}

.doc-notas {
    margin-bottom: 2rem;
}

@media (max-width: 767.98px) {
    .section { padding: 1.25rem 1rem; margin-bottom: 1rem; }
    .section .title { font-size: 1.5rem; }
    .section h6 { font-size: 1rem; }
    .doc-hero { padding: 4rem 1rem 1.5rem; }
}

/* --------------------------------------------------------------------------
   7. Tablas
   -------------------------------------------------------------------------- */
.table-responsive {
    border-radius: 8px;
    margin: 1rem 0;
}

.table {
    --bs-table-hover-bg: #f8f9fa;
    margin-bottom: 0;
}

.table > thead {
    background: var(--primary-color);
}

/* Cabeceras. La segunda y tercera regla cubren las vistas antiguas, que usan
   <table><tr><th> sin <thead> y por lo tanto caen dentro del <tbody> implícito.
   Bootstrap pinta el hover y el striped con un box-shadow inset sobre la celda
   (no con background), así que hay que anularlo para que la cabecera no se
   vuelva ilegible al pasar el mouse. */
.table > thead > tr > th,
.table > tbody > tr:first-child > th,
.table > tr:first-child > th {
    --bs-table-bg: var(--primary-color);
    --bs-table-color: #fff;
    --bs-table-bg-state: var(--primary-color);
    --bs-table-color-state: #fff;
    --bs-table-accent-bg: transparent;
    color: #fff;
    background-color: var(--primary-color);
    box-shadow: none;
    font-weight: 600;
    border-color: rgba(255, 255, 255, .15);
    vertical-align: middle;
}

/* El cursor tampoco debe sugerir que la cabecera es una fila más */
.table-hover > tbody > tr:first-child > th {
    cursor: default;
}

.table td { vertical-align: middle; }

@media (max-width: 767.98px) {
    .table { font-size: .8rem; }
}

/* --------------------------------------------------------------------------
   8. Bloques de código
   -------------------------------------------------------------------------- */
pre {
    background: #1e1e1e;
    color: #e6e6e6;
    border-radius: 8px;
    padding: 1.5rem;
    overflow-x: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .1);
    margin: 1rem 0;
    font-size: .85rem;
}

pre.prettyprint {
    background: #1e1e1e !important;
    border: 0 !important;
    border-radius: 8px !important;
    padding: 1.5rem !important;
}

pre.prettyprint ol.linenums { margin: 0 0 0 2.5rem; }

/* --------------------------------------------------------------------------
   9. Pestañas de ejemplos de código (Bootstrap tabs)
   -------------------------------------------------------------------------- */
.code-tabs {
    margin: 1.5rem 0;
}

.code-tabs .nav-tabs {
    --bs-nav-tabs-link-active-color: var(--primary-color);
    --bs-nav-tabs-link-active-border-color: #dee2e6 #dee2e6 #fff;
    --bs-nav-link-color: #4a5568;
    --bs-nav-link-hover-color: var(--primary-color);
    font-weight: 600;
}

 
.code-tabs .tab-pane pre { margin-top: .5rem; }

/* --------------------------------------------------------------------------
   10. Página de acceso denegado (_bloqueo.php)
   -------------------------------------------------------------------------- */
.doc-bloqueo {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.doc-bloqueo-card {
    box-shadow: 0 8px 30px rgba(0, 0, 0, .12);
    border: 0;
    border-radius: 1rem;
    max-width: 550px;
    width: 100%;
}

.doc-bloqueo-card .card-body { padding: 50px 30px; }

.lock-badge {
    width: 100px;
    height: 100px;
    background: #d9e0ec;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 8px 20px rgba(0, 0, 0, .12);
}

.lock-badge i {
    font-size: 3rem;
    color: #fff;
}

/* --------------------------------------------------------------------------
   11. Transición entre páginas
   -------------------------------------------------------------------------- */

/* Navegador con View Transitions (Chrome/Edge 126+): la propia navegación
   se anima, sin JavaScript. */
@view-transition {
    navigation: auto;
}

/* Sólo debe animarse el contenido. Al darle un view-transition-name propio al
   menú y al botón, éstos salen de la instantánea de la raíz y quedan fijos
   durante la navegación; lo único que queda dentro de (root) es .doc-main y el
   fondo, que es idéntico entre páginas.
   Se hace así, y no nombrando .doc-main, porque el navegador descarta la
   transición cuando la instantánea de un elemento supera el tamaño máximo de
   textura, y estas páginas de documentación son muy altas. */
.doc-sidebar     { view-transition-name: doc-sidebar; }
.doc-menu-toggle { view-transition-name: doc-menu-toggle; }

::view-transition-old(doc-sidebar),
::view-transition-new(doc-sidebar),
::view-transition-old(doc-menu-toggle),
::view-transition-new(doc-menu-toggle) {
    animation: none;
    mix-blend-mode: normal;
}

::view-transition-old(root) {
    animation: doc-fade-out .15s ease-in both;
}

/* Sólo opacidad: un desplazamiento movería también el fondo de la página */
::view-transition-new(root) {
    animation: doc-fade-in-root .3s ease-out both;
}

/* Respaldo para navegadores sin View Transitions: entrada del contenido */
@supports not (view-transition-name: none) {
    .doc-main {
        animation: doc-fade-in .3s ease-out both;
    }
}

@keyframes doc-fade-in-root {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes doc-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

@keyframes doc-fade-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    ::view-transition-group(*),
    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation: none !important;
    }

    .doc-main { animation: none; }
}

/* --------------------------------------------------------------------------
   12. Impresión
   -------------------------------------------------------------------------- */
@media print {
    .doc-sidebar,
    .doc-menu-toggle {
        display: none !important;
    }

    .doc-main { margin-left: 0; }

    .section { box-shadow: none; }
}
