/* =====================================================================
   appShell.css — Rediseño del marco de la aplicación (financiApp)
   Cabecera + menú lateral + dropdown de usuario.

   Se carga DESPUÉS de style.css / style-responsive.css → capa de overrides.
   No edita el tema legacy: aísla el rediseño.
   Paleta corporativa azul marino (#1a2942) con acento azul.

   Objetivos de esta versión:
   - Look profesional con profundidad (premium).
   - Micro-interacciones suaves (hover/active animados).
   - Títulos largos (padres e hijos) que envuelven a 2 líneas sin romper
     el layout ni quedar cortados.
   ===================================================================== */

:root {
    --shell-base: #1a2942;
    --shell-base-dark: #0f1a2e;
    --shell-base-light: #243758;
    --shell-accent: #4f86d6;
    --shell-accent-soft: #e7eef9;
    --shell-ink: #28323a;
    --shell-muted: #8b97a0;
    --shell-line: #eceff1;
    --shell-radius: 14px;
    --shell-shadow: 0 12px 34px rgba(15, 26, 46, .20);
    --shell-shadow-sm: 0 4px 14px rgba(15, 26, 46, .18);
    --shell-ease: cubic-bezier(.4, 0, .2, 1);
}

/* =====================================================================
   1. MENÚ LATERAL (aside.left-panel)
   ===================================================================== */
aside.left-panel {
    background: linear-gradient(195deg, var(--shell-base-light) 0%, var(--shell-base) 50%, var(--shell-base-dark) 100%);
    box-shadow: 4px 0 28px rgba(15, 26, 46, .28);
    z-index: 1010;
}

/* --- Marca / logo --- */
.logo {
    padding-top: 22px;
    padding-bottom: 16px;
    margin: 0 14px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.logo-expanded {
    letter-spacing: .04em;
    font-weight: 800;
    padding: 0 10px;
}

#imagenEmpresa {
    background: rgba(255, 255, 255, .12);
    border-radius: 12px;
    padding: 4px;
    transition: transform .25s var(--shell-ease), background .25s var(--shell-ease);
}

.logo .btn-group .dropdown-toggle:hover #imagenEmpresa {
    background: rgba(255, 255, 255, .22);
    transform: scale(1.05);
}

#nombreEmpresa.nav-label {
    font-size: 17px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}

/* --- Navegación (padres) --- */
.navigation {
    margin: 14px 0 22px;
}

.navigation > ul > li {
    margin: 3px 12px;
}

.navigation > ul > li > a {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border-radius: 11px;
    font-size: 14.5px;
    font-weight: 500;
    line-height: 1.25;
    color: rgba(255, 255, 255, .85);
    position: relative;
    overflow: hidden;
    transition: background .22s var(--shell-ease), color .22s var(--shell-ease), transform .18s var(--shell-ease);
}

.navigation ul li a i {
    float: none;
    flex: 0 0 24px;          /* el ícono no se encoge ni se deforma */
    width: 24px;
    margin-right: 12px;
    font-size: 18px;
    text-align: center;
    opacity: .9;
    transition: transform .2s var(--shell-ease);
}

/* Títulos largos de padre: envuelven a 2 líneas, alineados al lado del ícono */
.navigation > ul > li > a .nav-label {
    flex: 1 1 auto;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    vertical-align: middle;
}

.navigation > ul > li > a:hover {
    background: rgba(255, 255, 255, .1);
    color: #fff;
    transform: translateX(3px);
}

.navigation > ul > li > a:hover i {
    transform: scale(1.12);
}

/* Estado activo: pastilla blanca elevada, SIN salto de tamaño de fuente */
.navigation > ul > li.active > a,
.navigation > ul > li.active:hover > a {
    background: #fff;
    color: var(--shell-base);
    font-size: 14.5px;
    font-weight: 700;
    box-shadow: var(--shell-shadow-sm);
    transform: none;
}

.navigation > ul > li.active > a i {
    opacity: 1;
    color: var(--shell-accent);
}

/* Acento lateral del item activo */
.navigation > ul > li.active > a::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60%;
    border-radius: 0 4px 4px 0;
    background: var(--shell-accent);
}

/* --- Submenús (hijos) --- */
.navigation ul li ul {
    background: rgba(0, 0, 0, .2);
    border-radius: 11px;
    margin: 4px 4px 6px;
    padding: 6px;
}

/* display:flex !important para normalizar incluso los hijos legacy
   que traen inline style="display: table-cell". white-space:normal
   anula el nowrap del tema legacy → los títulos largos envuelven. */
.navigation ul li ul li a {
    display: flex !important;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 12px !important;
    border-radius: 8px;
    margin: 1px 0;
    color: rgba(255, 255, 255, .78);
    font-size: 13.5px;
    line-height: 1.35;
    white-space: normal !important;
    word-break: break-word;
    overflow-wrap: anywhere;
    text-align: left;
    transition: background .18s var(--shell-ease), color .18s var(--shell-ease), padding-left .18s var(--shell-ease);
}

.navigation ul li ul li a i {
    flex: 0 0 18px;
    width: 18px !important;
    margin: 1px 0 0 0;
    font-size: 14px;
    text-align: center;
}

.navigation ul li ul li a:hover {
    background: rgba(255, 255, 255, .1);
    color: #fff;
    padding-left: 16px !important;
}

.navigation ul li ul li.active a {
    background: rgba(79, 134, 214, .3);
    color: #fff !important;
    font-weight: 600;
}

/* Oculta los badges "+" sueltos de algunos hijos legacy (rompían el flex) */
.navigation ul li ul li a > .badge.bg-primary {
    display: none;
}

/* --- Submenú flyout en modo COLAPSADO ---
   El tema responsive lo pinta de verde (var(--isis-color)) con alta
   especificidad. Lo igualamos al navy del resto del marco. */
@media (min-width: 769px) {
    aside.left-panel.collapsed .navigation ul li ul {
        background: var(--shell-base-dark);
        box-shadow: var(--shell-shadow);
        border-radius: 11px;
        padding: 6px;
        margin-left: 6px;
    }

    aside.left-panel.collapsed .navigation ul li ul li a {
        color: rgba(255, 255, 255, .82);
        border-radius: 8px;
        padding: 8px 16px !important;
    }

    aside.left-panel.collapsed .navigation ul li ul li a:hover {
        background: rgba(255, 255, 255, .12);
        color: #fff;
    }

    aside.left-panel.collapsed .navigation ul li ul li.active a {
        background: rgba(79, 134, 214, .32);
        color: #fff !important;
    }
}

/* =====================================================================
   2. CABECERA SUPERIOR (header.top-head)
   ===================================================================== */
header.top-head {
    background: #fff;
    border-bottom: 1px solid var(--shell-line);
    box-shadow: 0 1px 12px rgba(15, 26, 46, .05);
    padding-top: 0;
    padding-bottom: 0;
    min-height: 56px;
    display: flex;
    align-items: center;
}

/* Botón hamburguesa */
.navbar-toggle {
    margin: 0 16px 0 2px;
    padding: 8px;
    border-radius: 10px;
    transition: background .2s var(--shell-ease);
}

.navbar-toggle:hover {
    background: #eef2f7;
}

.navbar-toggle .icon-bar {
    background-color: var(--shell-base);
    height: 2px;
    border-radius: 2px;
    transition: all .25s var(--shell-ease);
}

.navbar-toggle .icon-bar + .icon-bar {
    margin-top: 4px;
}

/* Empuja el menú de usuario al extremo derecho (header es flex) */
.top-right-menu {
    margin-left: auto;
    margin-bottom: 0;
}

/* La barra lateral (vacía) no debe ocupar espacio en el flex */
header.top-head > nav.navbar-default {
    margin: 0;
    flex: 0 0 auto;
}

/* Avatar + nombre */
.top-menu li > a {
    padding: 7px 12px;
    color: var(--shell-ink);
    display: flex;
    align-items: center;
    border-radius: 12px;
    transition: background .2s var(--shell-ease);
}

.top-menu li > a:hover,
.top-menu li > a:focus,
.top-right-menu .dropdown.open > a {
    background: #eef2f7;
}

.profile-img.thumb-sm {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--shell-accent);
    transition: box-shadow .2s var(--shell-ease);
}

.top-menu li > a:hover .profile-img.thumb-sm {
    box-shadow: 0 0 0 2px var(--shell-base);
}

.username {
    font-size: 14px;
    font-weight: 600;
    color: var(--shell-ink);
    margin-left: 8px;
    text-transform: uppercase;
}

.top-right-menu .caret {
    margin-left: 6px;
    color: var(--shell-muted);
}

/* =====================================================================
   3. DROPDOWN DE USUARIO (.pro-menu)
   ===================================================================== */
.dropdown .pro-menu {
    width: 210px;
    padding: 5px;
    margin-top: 8px;
    left: auto;
    right: 0;                 /* alinea al borde derecho: no se sale de pantalla */
    border: none;
    border-radius: 11px;
    box-shadow: var(--shell-shadow);
    overflow: hidden;
    z-index: 1100;            /* por encima del marco y de cualquier backdrop */
}

/* FIX MÓVIL/TÁCTIL: en pantallas táctiles Bootstrap 3 inyecta un
   <div class="dropdown-backdrop"> transparente a pantalla completa (z-index:990)
   para cerrar el menú al tocar fuera. Como este dropdown NO está dentro de
   .navbar-nav, ese backdrop se interpone y se "traga" el toque sobre los items
   (Cambiar contraseña / Cerrar sesión), que entonces no responden al click en
   móvil. Lo neutralizamos: el cierre al tocar fuera sigue funcionando con el
   handler de click de Bootstrap y volviendo a tocar el avatar. */
.dropdown-backdrop {
    display: none !important;
}

/* El tema legacy hace .top-menu li { display:inline-block; float:left } y
   alcanza a los <li> del dropdown → los encoge y desalinea. Normalizamos. */
.dropdown .pro-menu > li {
    display: block !important;
    float: none !important;
    width: 100% !important;
    border: none;
    line-height: normal;
    text-align: left;
}

/* Items del menú */
.dropdown .pro-menu > li > a {
    display: flex !important;
    align-items: center;
    gap: 10px;
    padding: 8px 9px !important;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--shell-ink);
    transition: background .16s var(--shell-ease), color .16s var(--shell-ease);
}

.dropdown .pro-menu > li > a i {
    float: none;
    width: 18px;
    height: auto;
    margin: 0;
    text-align: center;
    background: none;
    color: var(--shell-muted);
    font-size: 15px;
    transition: color .16s var(--shell-ease);
}

/* :hover (PC) y .is-tapping (móvil, marcada por JS en touchstart) comparten el
   realce. En táctil no hay :hover y :active es poco fiable (iOS no lo dispara,
   y el destello es demasiado breve al navegar), por eso usamos la clase. */
.dropdown .pro-menu > li > a:hover,
.dropdown .pro-menu > li > a:focus,
.dropdown .pro-menu > li > a.is-tapping {
    background: #f3f6fb;
    color: var(--shell-base);
}

.dropdown .pro-menu > li > a:hover i,
.dropdown .pro-menu > li > a:focus i,
.dropdown .pro-menu > li > a.is-tapping i {
    color: var(--shell-accent);
}

/* Realce más marcado en el instante del toque (feedback inmediato) */
.dropdown .pro-menu > li > a.is-tapping {
    background: #e7eef9;
}

/* Acción de salir: acento rojo suave para diferenciarla */
.dropdown .pro-menu > li.pro-menu-logout > a:hover,
.dropdown .pro-menu > li.pro-menu-logout > a:focus,
.dropdown .pro-menu > li.pro-menu-logout > a.is-tapping {
    color: #c0392b;
}

.dropdown .pro-menu > li.pro-menu-logout > a.is-tapping {
    background: #fdecea;
}

.dropdown .pro-menu > li.pro-menu-logout > a:hover i,
.dropdown .pro-menu > li.pro-menu-logout > a:focus i,
.dropdown .pro-menu > li.pro-menu-logout > a.is-tapping i {
    color: #c0392b;
}

/* Resalte nativo del toque en Android/Chrome móvil (por defecto transparente) */
.dropdown .pro-menu > li > a {
    -webkit-tap-highlight-color: rgba(79, 134, 214, .18);
}

/* =====================================================================
   4. PIE (footer)
   ===================================================================== */
.footer {
    background: #fff;
    border-top: 1px solid var(--shell-line);
    color: var(--shell-muted);
    font-weight: 600;
    font-size: 13px;
}

.footer a {
    color: var(--shell-muted);
    transition: color .2s var(--shell-ease);
}

.footer a:hover {
    color: var(--shell-accent);
    text-decoration: none;
}
