﻿/* ==========================================================
   VARIABLES GLOBALES
   ========================================================== */

:root {
    /* Colores generales del layout */
    --layout-bg-0: #07111f;
    --layout-bg-1: #0b1628;
    --layout-bg-2: #0f172a;
    --layout-bg-3: #111827;
    --surface-soft: rgba(255, 255, 255, 0.045);
    --surface-soft-2: rgba(255, 255, 255, 0.065);
    --surface-border: rgba(255, 255, 255, 0.095);
    --accent-main: rgba(96, 165, 250, 0.32);
    --accent-soft: rgba(96, 165, 250, 0.14);
    --accent-muted: rgba(148, 163, 184, 0.14);
    --text-main: #e5e7eb;
    --text-muted: #cbd5e1;
    --shadow-soft: 0 18px 42px rgba(0, 0, 0, 0.22);
    /* ======================================================
       JERARQUÍA GLOBAL DE CAPAS

       Contenido normal          0
       Sidebar                  20
       Botón sidebar            25
       Barra superior           30

       Modales                1000+
       Toast / alertas        1100+
       Error global           1200
       ====================================================== */

    --z-content: 0;
    --z-sidebar: 20;
    --z-menu-toggle: 25;
    --z-topbar: 30;
    --z-modal-backdrop: 1000;
    --z-modal: 1010;
    --z-toast: 1100;
    --z-system: 1200;
}


/* ==========================================================
   RESET GLOBAL
   ========================================================== */

html,
body {
    height: 100% !important;
    width: 100%;
    max-width: 100%;
    margin: 0 !important;
    padding: 0 !important;
    overflow-x: hidden;
}

body {
    background-color: rgb(15, 30, 50) !important;
    font-family: 'Calibri', sans-serif !important;
    color: white !important;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}


/* =========================================================
   BARRA LATERAL
   Moderna / elegante / alineada al layout principal
   ========================================================= */

.nav-scrollable {
    width: 100%;
    height: calc(100vh - 3.5rem);
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    padding: 0.85rem 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.32) transparent;
}

    .nav-scrollable::-webkit-scrollbar {
        width: 6px;
    }

    .nav-scrollable::-webkit-scrollbar-track {
        background: transparent;
    }

    .nav-scrollable::-webkit-scrollbar-thumb {
        background: rgba(148, 163, 184, 0.26);
        border-radius: 999px;
    }

        .nav-scrollable::-webkit-scrollbar-thumb:hover {
            background: rgba(148, 163, 184, 0.42);
        }


nav.flex-column {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}


.nav-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}


/* =========================================================
   ENCABEZADOS DE GRUPO
   ========================================================= */

.nav-group-header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.82rem 0.95rem;
    color: #e5e7eb;
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    background: linear-gradient( 180deg, rgba(255, 255, 255, 0.060), rgba(255, 255, 255, 0.035) );
    border: 1px solid rgba(148, 163, 184, 0.13);
    border-radius: 13px;
    cursor: pointer;
    user-select: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035), 0 8px 18px rgba(0, 0, 0, 0.10);
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}


    .nav-group-header::before {
        content: "";
        position: absolute;
        left: 0;
        top: 10px;
        bottom: 10px;
        width: 2px;
        border-radius: 0 999px 999px 0;
        background: rgba(96, 165, 250, 0.42);
        opacity: 0;
        transition: opacity 0.18s ease;
    }


    .nav-group-header:hover {
        color: #ffffff;
        background: linear-gradient( 180deg, rgba(255, 255, 255, 0.082), rgba(255, 255, 255, 0.045) );
        border-color: rgba(148, 163, 184, 0.22);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045), 0 10px 22px rgba(0, 0, 0, 0.13);
    }


        .nav-group-header:hover::before {
            opacity: 1;
        }


    .nav-group-header .bi {
        margin-right: 0.12rem;
        opacity: 0.82;
        font-size: 1rem;
    }


    /* Cuando el header contiene un NavLink */
    .nav-group-header ::deep .nav-link {
        display: flex;
        align-items: center;
        gap: 0.55rem;
        width: 100%;
        color: inherit;
        text-decoration: none;
        background: none;
        padding: 0;
        margin: 0;
    }


/* =========================================================
   SUBITEMS
   ========================================================= */

.nav-subitem {
    padding-left: 0.42rem;
}


    .nav-subitem.expandido {
        display: flex;
        flex-direction: column;
        gap: 0.34rem;
        margin-top: 0.12rem;
    }


    .nav-subitem.colapsado {
        display: none;
    }


    .nav-subitem ::deep .nav-link {
        position: relative;
        display: flex;
        align-items: center;
        gap: 0.58rem;
        width: 100%;
        box-sizing: border-box;
        padding: 0.72rem 0.85rem 0.72rem 0.9rem;
        color: #cbd5e1;
        text-decoration: none;
        border-radius: 11px;
        border: 1px solid transparent;
        background: rgba(255, 255, 255, 0.030);
        line-height: 1.32;
        white-space: normal;
        word-break: break-word;
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.018);
        transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
    }


        .nav-subitem ::deep .nav-link::before {
            content: "";
            position: absolute;
            left: 0;
            top: 9px;
            bottom: 9px;
            width: 2px;
            border-radius: 0 999px 999px 0;
            background: rgba(96, 165, 250, 0.56);
            opacity: 0;
            transition: opacity 0.18s ease;
        }


        .nav-subitem ::deep .nav-link:hover {
            background: rgba(255, 255, 255, 0.060);
            border-color: rgba(148, 163, 184, 0.14);
            color: #ffffff;
            transform: translateX(2px);
        }


            .nav-subitem ::deep .nav-link:hover::before {
                opacity: 0.8;
            }


    .nav-subitem ::deep a.active {
        background: linear-gradient( 90deg, rgba(96, 165, 250, 0.17), rgba(255, 255, 255, 0.055) );
        border-color: rgba(96, 165, 250, 0.22);
        color: #ffffff;
        font-weight: 700;
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.040), 0 8px 20px rgba(15, 23, 42, 0.18);
    }


        .nav-subitem ::deep a.active::before {
            opacity: 1;
        }


/* =========================================================
   ICONOS
   ========================================================= */

.bi {
    color: #cbd5e1;
    opacity: 0.78;
    transition: color 0.18s ease, opacity 0.18s ease, transform 0.18s ease;
}


.nav-group-header:hover .bi,
.nav-subitem ::deep .nav-link:hover .bi,
.nav-subitem ::deep a.active .bi {
    color: #dbeafe;
    opacity: 1;
}


.nav-subitem ::deep .nav-link:hover .bi {
    transform: translateX(1px);
}


/* =========================================================
   LINKS DESHABILITADOS
   ========================================================= */

.nav-link.deshabilitado {
    color: rgba(148, 163, 184, 0.58) !important;
    pointer-events: none;
    opacity: 0.55;
    filter: grayscale(1);
}


/* =========================================================
   BARRA LATERAL - CELULAR
   ========================================================= */

@media (max-width: 640.98px) {

    .nav-scrollable {
        height: auto;
        max-height: calc(100vh - 3.5rem);
        padding: 0.65rem;
    }

    nav.flex-column {
        gap: 0.55rem;
    }

    .nav-group-header {
        padding: 0.74rem 0.82rem;
        font-size: 0.90rem;
        border-radius: 12px;
    }

    .nav-subitem {
        padding-left: 0.22rem;
    }

        .nav-subitem ::deep .nav-link {
            padding: 0.68rem 0.78rem;
            font-size: 0.90rem;
            border-radius: 10px;
        }
}


/* =========================================================
   ACCESIBILIDAD BARRA LATERAL
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    .nav-group-header,
    .nav-subitem ::deep .nav-link,
    .bi {
        transition: none !important;
    }

        .nav-subitem ::deep .nav-link:hover {
            transform: none;
        }
}


/* ==========================================================
   BARRA SUPERIOR
   ========================================================== */

.top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 1.15rem;
    height: 3.75rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: white;
    font-family: 'Segoe UI', sans-serif;
    box-shadow: 0 8px 22px rgba(2, 6, 23, 0.18);
    position: relative;
    /*
     * IMPORTANTE:
     *
     * La barra superior pertenece a topbar-shell,
     * que controla la capa global.
     *
     * Este z-index solamente ordena elementos INTERNOS
     * de la barra superior.
     */
    z-index: 2;
    overflow: visible;
}


/* ==========================================================
   BOTONES PRINCIPALES
   ========================================================== */

.menu-toggle,
.btn-home,
.btn-logout,
.btn-campana {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 1.1rem;
    cursor: pointer;
    color: #e5e7eb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    flex-shrink: 0;
    align-self: center;
    padding: 0;
}


    .menu-toggle:hover,
    .btn-home:hover,
    .btn-logout:hover,
    .btn-campana:hover {
        color: #ffffff;
        background: rgba(255, 255, 255, 0.06);
        border-color: rgba(255, 255, 255, 0.08);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
        transform: none;
    }


    .menu-toggle:focus-visible,
    .btn-home:focus-visible,
    .btn-logout:focus-visible,
    .btn-campana:focus-visible,
    .btn-usuario:focus-visible {
        outline: none;
        border-color: rgba(96, 165, 250, 0.45);
        box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.16);
    }


/* ==========================================================
   FECHA CENTRADA
   ========================================================== */

.fecha-hoy {
    font-weight: 600;
    font-size: 0.92rem;
    text-align: center;
    flex: 1 1 auto;
    min-width: 0;
    color: #cbd5e1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.01em;
    user-select: none;
}


/* ==========================================================
   CAMPANA
   ========================================================== */

.btn-campana {
    position: relative;
    font-size: 1.16rem;
    overflow: visible;
}


.campana-animada {
    animation: campana-move 1s infinite alternate;
    color: #f87171 !important;
}


.contador-notificaciones {
    font-weight: 800;
    font-size: 0.68rem;
    position: absolute;
    top: -3px;
    right: -3px;
    background: #ffffff;
    color: #dc2626;
    border-radius: 999px;
    padding: 2px 6px;
    line-height: 1;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(220, 38, 38, 0.10);
    pointer-events: none;
}


@keyframes campana-move {

    0% {
        transform: rotate(-10deg);
    }

    100% {
        transform: rotate(10deg);
    }
}


/* ==========================================================
   USUARIO
   ========================================================== */

.usuario-box {
    position: relative;
    display: flex;
    align-items: center;
    margin-left: 0.35rem;
    flex-shrink: 0;
    /*
     * Capa local dentro de top-row.
     * Ya no utilizamos 11100.
     */
    z-index: 3;
    min-width: 0;
}


.btn-usuario {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    align-self: center;
    border-radius: 999px;
    flex-shrink: 0;
}


.usuario-avatar {
    background: linear-gradient( 135deg, #60a5fa, #2563eb );
    color: white;
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    border-radius: 50%;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: box-shadow 0.2s ease, filter 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
    position: relative;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.10);
    user-select: none;
}


    .usuario-avatar:hover {
        filter: brightness(1.04);
    }


.usuario-box.abierto .usuario-avatar {
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.34);
    border-color: rgba(147, 197, 253, 0.28);
}


/* ==========================================================
   DROPDOWN USUARIO
   ========================================================== */

.usuario-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 8px;
    display: none;
    min-width: 220px;
    max-width: calc(100vw - 1rem);
    /*
     * Capa LOCAL.
     * topbar-shell ya mantiene toda la barra en z-index 30.
     */
    z-index: 4;
    box-shadow: 0 20px 44px rgba(2, 6, 23, 0.34);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    overflow: hidden;
}


    .usuario-dropdown a,
    .usuario-dropdown button {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        max-width: 100%;
        padding: 10px 12px;
        color: #e5e7eb;
        text-decoration: none;
        font-size: 0.92rem;
        font-weight: 600;
        border-radius: 10px;
        background: transparent;
        border: none;
        text-align: left;
        cursor: pointer;
        transition: background-color 0.18s ease, color 0.18s ease;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }


        .usuario-dropdown a:hover,
        .usuario-dropdown button:hover {
            background: rgba(255, 255, 255, 0.06);
            color: #ffffff;
        }


        .usuario-dropdown a:focus-visible,
        .usuario-dropdown button:focus-visible {
            outline: none;
            background: rgba(59, 130, 246, 0.12);
            box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.22);
        }


.usuario-box.abierto .usuario-dropdown {
    display: block;
}


.usuario-dropdown .dropdown-divider {
    height: 1px;
    margin: 6px 0;
    background: rgba(255, 255, 255, 0.08);
}


/* ==========================================================
   OVERLAY DEL MENÚ DE USUARIO

   Importante:
   - queda debajo de top-row
   - queda encima del contenido normal
   - todo topbar-shell completo está muy por debajo de un modal
   ========================================================== */

.overlay-dropdown {
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 1;
}


/* ==========================================================
   MODALES - JERARQUÍA GLOBAL
   ========================================================== */

/*
 * Estas clases establecen una convención general.
 *
 * Un modal SIEMPRE debe estar por encima de:
 * - contenido
 * - sidebar
 * - botón hamburguesa
 * - barra superior
 * - dropdown usuario
 */

.modal-overlay,
.modal-backdrop,
.modal-autorizacion-overlay {
    z-index: var(--z-modal-backdrop) !important;
}


/*
 * Para ventanas Bootstrap o modales que utilicen
 * directamente la clase .modal.
 */
.modal {
    z-index: var(--z-modal) !important;
}


/*
 * Si utilizamos contenedores propios dentro del overlay,
 * se puede aplicar cualquiera de estas clases.
 */
.modal-container,
.modal-content-container,
.modal-dialog-container {
    position: relative;
    z-index: var(--z-modal);
}


/* ==========================================================
   RESPONSIVE BARRA SUPERIOR
   ========================================================== */

@media (max-width: 768px) {

    .top-row {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding: 0.45rem 0.65rem;
        gap: 0.35rem;
        height: 3.4rem;
    }

    .menu-toggle,
    .btn-home,
    .btn-logout,
    .btn-campana {
        width: 34px;
        height: 34px;
        min-width: 34px;
        min-height: 34px;
        font-size: 1rem;
    }

    .fecha-hoy {
        font-size: 0.8rem;
        min-width: 0;
    }

    .usuario-box {
        margin-left: 0.15rem;
    }

    .usuario-avatar {
        width: 34px;
        height: 34px;
        min-width: 34px;
        min-height: 34px;
        font-size: 0.8rem;
    }

    .usuario-dropdown {
        min-width: 190px;
        max-width: calc(100vw - 1rem);
        right: 0;
    }
}


@media (max-width: 576px) {

    .top-row {
        padding: 0.4rem 0.5rem;
        gap: 0.25rem;
    }

    .fecha-hoy {
        font-size: 0.72rem;
    }

    .contador-notificaciones {
        font-size: 0.6rem;
        top: -2px;
        right: -2px;
        padding: 2px 5px;
        min-width: 16px;
    }

    .usuario-avatar {
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
        font-size: 0.72rem;
    }

    .usuario-dropdown {
        min-width: 170px;
        max-width: calc(100vw - 1rem);
    }

        .usuario-dropdown a,
        .usuario-dropdown button {
            font-size: 0.85rem;
            padding: 9px 10px;
        }
}


@media (max-width: 390px) {

    .top-row {
        padding: 0.35rem 0.4rem;
        gap: 0.2rem;
    }

    .menu-toggle,
    .btn-home,
    .btn-logout,
    .btn-campana {
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
        font-size: 0.92rem;
        border-radius: 8px;
    }

    .fecha-hoy {
        font-size: 0.68rem;
    }

    .usuario-avatar {
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
        font-size: 0.68rem;
    }

    .usuario-box {
        margin-left: 0;
    }
}
