/* Archivo: public/assets/css/shell.css */
/* Dominio: App Shell & Estructura de Scroll Controlada */

:root {
    --sidebar-width: 280px;
    --header-height: 70px;
}

/* 1. Control del Body y Prevención de Doble Scroll */
body.has-app-shell {
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden; /* Elimina permanentemente el scroll global del body */
    background-color: var(--cheisca-smoke);
}

body.has-simple-layout {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background-color: var(--cheisca-smoke);
}

/* 2. Base Shell Layout */
.app-shell-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    background-color: var(--cheisca-smoke);
}

/* Sidebar */
.shell-sidebar {
    width: var(--sidebar-width);
    background-color: var(--cheisca-white);
    border-right: 1px solid var(--cheisca-border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    flex-shrink: 0;
    transition: width 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 24px;
    display: flex; 
    align-items: center; 
    justify-content: space-between;
    border-bottom: 1px solid var(--cheisca-smoke);
}
.sidebar-logo { height: 28px; }

.sidebar-user {
    padding: 24px;
    display: flex; 
    align-items: center; 
    gap: 12px;
    border-bottom: 1px solid var(--cheisca-smoke);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
    display: flex; 
    flex-direction: column; 
    gap: 4px;
}

.nav-group-title {
    font-size: 0.75rem; 
    text-transform: uppercase; 
    letter-spacing: 0.05em;
    color: var(--cheisca-black); 
    opacity: 0.5; 
    margin: 16px 0 8px 8px; 
    font-weight: 700;
}

.nav-item {
    display: flex; 
    align-items: center; 
    gap: 12px;
    padding: 12px 16px; 
    border-radius: 12px;
    color: var(--cheisca-black); 
    text-decoration: none;
    font-weight: 500; 
    font-size: 0.95rem;
    transition: background 0.2s, color 0.2s;
}

.nav-item:hover { background: var(--cheisca-smoke); color: var(--cheisca-blue); }
.nav-item.active { background: rgba(59, 130, 246, 0.1); color: var(--cheisca-blue); font-weight: 600; }
.nav-item .material-symbols-outlined { font-size: 1.25rem; opacity: 0.8; }

/* 3. Main Content Area & Scroll Único */
.app-shell-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 0;
    overflow: hidden;
}

/* Header */
.shell-header {
    height: var(--header-height);
    background-color: var(--cheisca-white);
    border-bottom: 1px solid var(--cheisca-border);
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    padding: 0 24px;
    z-index: 900;
    flex-shrink: 0;
}

.header-left, .header-right { display: flex; align-items: center; gap: 16px; }

.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; font-weight: 600; }
.crumb-tenant { color: var(--cheisca-black); opacity: 0.5; }
.crumb-separator { font-size: 1rem; opacity: 0.3; }
.crumb-current { color: var(--cheisca-black); }

.btn-icon {
    background: transparent; 
    border: none; 
    color: var(--cheisca-black); 
    opacity: 0.7;
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    width: 40px; 
    height: 40px; 
    border-radius: 50%; 
    transition: all 0.2s;
}
.btn-icon:hover { opacity: 1; background: var(--cheisca-smoke); }

.profile-dropdown-container { position: relative; }
.btn-profile { background: transparent; border: none; cursor: pointer; padding: 4px; border-radius: 50%; }

/* Avatares */
.avatar-small { width: 44px; height: 44px; background: var(--cheisca-smoke); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; font-family: var(--font-heading); color: var(--cheisca-blue); }
.avatar-micro { width: 36px; height: 36px; background: var(--cheisca-smoke); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 0.8rem; }

/* 4. Body Content (ÚNICO CONTENEDOR CON SCROLL) */
.app-shell-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 24px 0 24px;
    background-color: var(--cheisca-smoke);
    display: flex;
    flex-direction: column;
    min-height: 0; /* Permite que el flex child encoja y habilite scroll */
}

.app-shell-content-container {
    flex: 1 0 auto; /* Permite crecer y empuja el footer a la base */
    width: 100%;
}

.main-content-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 24px;
    box-sizing: border-box;
}

.main-content-inner {
    flex: 1 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ==========================================================================
   5. CHEISCA GLOBAL FOOTER BADGE (Glassmorphism & Link a cheisca.com)
   ========================================================================== */
.cheisca-global-footer {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0 16px 0;
    margin-top: auto; /* Empuja el footer a la base del contenedor */
    flex-shrink: 0;
    z-index: 10;
}

.cheisca-footer-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(10, 10, 10, 0.08);
    border-radius: 20px;
    padding: 6px 14px;
    box-shadow: 0 2px 8px rgba(10, 10, 10, 0.03);
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.cheisca-footer-badge:hover {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.1), 0 2px 6px rgba(0, 0, 0, 0.04);
    transform: translateY(-1px);
}

.footer-flag-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.footer-badge-text {
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--cheisca-black, #0A0A0A);
    opacity: 0.85;
    letter-spacing: 0.01em;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.footer-badge-origin {
    font-weight: 600;
    color: var(--cheisca-black, #0A0A0A);
}

.footer-badge-separator {
    opacity: 0.4;
    font-size: 0.7rem;
}

.footer-badge-copyright {
    opacity: 0.75;
}

.footer-badge-external-icon {
    font-size: 13px !important;
    opacity: 0.4;
    color: var(--cheisca-black);
    transition: opacity 0.2s, transform 0.2s;
}

.cheisca-footer-badge:hover .footer-badge-external-icon {
    opacity: 0.8;
    color: var(--cheisca-blue);
    transform: translate(1px, -1px);
}

/* ==========================================================================
   6. RESPONSIVE Y ESTADOS ADAPTATIVOS
   ========================================================================== */
.sidebar-overlay { display: none; }
.mobile-only { display: none; }

@media (max-width: 900px) {
    .shell-sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
    }
    .shell-sidebar.open { transform: translateX(0); }
    .sidebar-overlay {
        display: block; 
        position: fixed; 
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(21,21,21,0.4); 
        backdrop-filter: blur(4px);
        z-index: 999; 
        opacity: 0; 
        pointer-events: none; 
        transition: opacity 0.3s;
    }
    .sidebar-overlay.active { opacity: 1; pointer-events: auto; }
    .mobile-only { display: flex; }
    .breadcrumb { display: none; }
    .app-shell-body { padding: 16px 16px 0 16px; }
}

@media (max-width: 768px) {
    .cheisca-global-footer {
        padding: 16px 0 env(safe-area-inset-bottom, 16px) 0;
    }
    .cheisca-footer-badge {
        padding: 5px 12px;
    }
    .footer-badge-text {
        font-size: 0.7rem;
    }
}

.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 12px);
    width: 220px;
    background-color: var(--cheisca-white);
    border: 1px solid var(--cheisca-border);
    border-radius: 16px;
    box-shadow: var(--shadow-medium);
    z-index: 10000;
    padding: 12px 0;
    animation: fadeIn 0.2s ease-out;
}

.dropdown-menu.hidden { display: none !important; }

.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--cheisca-black);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s;
}

.dropdown-menu a:hover {
    background-color: var(--cheisca-smoke);
}

.dropdown-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--cheisca-smoke);
    margin-bottom: 8px;
}

.shell-sidebar.collapsed {
    width: 80px;
}

.shell-sidebar.collapsed .sidebar-logo,
.shell-sidebar.collapsed .user-info,
.shell-sidebar.collapsed .nav-group-title,
.shell-sidebar.collapsed .nav-label {
    display: none;
}

.shell-sidebar.collapsed .avatar-small {
    width: 36px; height: 36px;
    margin: 0 auto;
}

.shell-sidebar.collapsed .sidebar-user {
    padding: 24px 0;
    justify-content: center;
}

.shell-sidebar.collapsed .sidebar-nav {
    padding: 24px 8px;
}

.shell-sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
}

.crumb-link {
    color: var(--cheisca-blue);
    text-decoration: none;
    transition: opacity 0.2s;
}
.crumb-link:hover { opacity: 0.8; }

/* ==========================================================================
   HUD BADGE FIA GLOBAL (CHEISCA Light UI - HU-FIA-108)
   Archivo: public/assets/css/shell.css
   ========================================================================== */

.fia-hud-container {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(212, 175, 55, 0.08); /* Gold ultra sutil */
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 20px;
    padding: 5px 12px;
    cursor: default;
    user-select: none;
    transition: all 0.25s ease;
}

.fia-hud-container:hover {
    background: rgba(212, 175, 55, 0.15);
    border-color: var(--cheisca-gold, #D4AF37);
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.15);
}

.fia-hud-icon {
    font-size: 18px !important;
    color: var(--cheisca-gold, #D4AF37);
}

.fia-hud-amount {
    font-family: var(--font-heading, 'Manrope', sans-serif);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--cheisca-black, #0A0A0A);
    letter-spacing: 0.02em;
}

@media (max-width: 768px) {
    .fia-hud-container {
        padding: 4px 8px;
        gap: 4px;
    }
    .fia-hud-icon {
        font-size: 16px !important;
    }
    .fia-hud-amount {
        font-size: 0.72rem;
    }
}

/* ==========================================================================
   HUD BADGE FIA INDIVIDUAL (CHEISCA Light UI - HU-FIA-108)
   Archivo: public/assets/css/shell.css
   ========================================================================== */

.fia-hud-container {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(212, 175, 55, 0.35); /* Gold CHEISCA */
    border-radius: 20px;
    padding: 6px 14px;
    height: 36px;
    box-sizing: border-box;
    cursor: pointer;
    user-select: none;
    position: relative;
    box-shadow: 0 1px 4px rgba(10, 10, 10, 0.03);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.fia-hud-container:hover {
    background: #FFFFFF;
    border-color: var(--cheisca-gold, #D4AF37);
    box-shadow: 0 3px 12px rgba(212, 175, 55, 0.18), 0 1px 3px rgba(0, 0, 0, 0.04);
    transform: translateY(-1px);
}

.fia-hud-icon {
    font-size: 19px !important;
    color: var(--cheisca-gold, #D4AF37);
    transition: transform 0.2s ease;
}

.fia-hud-container:hover .fia-hud-icon {
    transform: scale(1.1);
}

.fia-hud-amount {
    font-family: var(--font-heading, 'Manrope', sans-serif);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--cheisca-black, #0A0A0A);
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
}

/* Estado: Skeleton de Carga */
.fia-hud-skeleton {
    width: 54px;
    height: 14px;
    border-radius: 4px;
    display: inline-block;
}

/* Estado: Saldo Cero (No alarmista) */
.fia-hud-container.fia-hud-zero {
    border-color: rgba(10, 10, 10, 0.12);
    background: rgba(245, 245, 243, 0.9);
}

.fia-hud-container.fia-hud-zero .fia-hud-icon {
    color: var(--cheisca-black, #0A0A0A);
    opacity: 0.45;
}

.fia-hud-container.fia-hud-zero .fia-hud-amount {
    opacity: 0.6;
}

/* Indicador Offline PWA */
.fia-hud-offline-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--cheisca-orange, #F28C28);
    display: inline-block;
    position: absolute;
    top: 4px;
    right: 6px;
}

/* Animación de Pulso en Actualización de Saldo */
@keyframes fiaBalancePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); border-color: var(--cheisca-gold, #D4AF37); box-shadow: 0 0 10px rgba(212, 175, 55, 0.35); }
    100% { transform: scale(1); }
}

.fia-hud-updated {
    animation: fiaBalancePulse 0.45s ease-out;
}

/* ==========================================================================
   ADAPTABILIDAD RESPONSIVA (Mobile First, Tablet, Desktop)
   ========================================================================== */
@media (max-width: 768px) {
    .fia-hud-container {
        height: 34px;
        padding: 4px 10px;
        gap: 5px;
    }

    .fia-hud-icon {
        font-size: 17px !important;
    }

    .fia-hud-amount {
        font-size: 0.74rem;
    }
}

@media (max-width: 420px) {
    .fia-hud-container {
        padding: 4px 8px;
    }

    .fia-hud-amount {
        font-size: 0.7rem;
    }
}

/* ==========================================================================
   REFINAMIENTO UX/UI SIDEBAR - ACENTO NARANJA CHEISCA (#F28C28)
   Archivo: public/assets/css/shell.css
   ========================================================================== */

.shell-sidebar .nav-group-title {
    font-family: var(--font-heading, 'Manrope', sans-serif);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--cheisca-black, #0A0A0A);
    opacity: 0.5;
    padding: 0 16px;
    margin-bottom: 6px;
    margin-top: 16px;
}

.shell-sidebar .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    margin: 2px 8px;
    border-radius: 10px;
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--cheisca-black, #0A0A0A);
    opacity: 0.8;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.shell-sidebar .nav-item:hover:not(.active) {
    background-color: var(--cheisca-smoke, #F7F7F5);
    opacity: 1;
    color: var(--cheisca-black, #0A0A0A);
}

/* Estado Activo con Acento Naranja CHEISCA (#F28C28) */
.shell-sidebar .nav-item.active {
    background-color: rgba(242, 140, 40, 0.1) !important;
    color: var(--cheisca-orange, #F28C28) !important;
    opacity: 1 !important;
    font-weight: 700;
}

.shell-sidebar .nav-item.active .material-symbols-outlined {
    color: var(--cheisca-orange, #F28C28) !important;
}

.shell-sidebar .nav-item .material-symbols-outlined {
    font-size: 20px;
    opacity: 0.7;
    transition: color 0.2s ease;
}

.shell-sidebar .nav-item:hover .material-symbols-outlined {
    opacity: 1;
}

/* ==========================================================================
   VARIANTE DESTRUCTIVA / CIERRE DE SESIÓN EN EL SIDEBAR (CHEISCA Light UI)
   Archivo: public/assets/css/shell.css
   ========================================================================== */

.shell-sidebar .nav-item.nav-item-danger,
.shell-sidebar .nav-item#btn-shell-logout {
    color: var(--cheisca-danger, #EF4444);
    margin-top: 4px;
}

.shell-sidebar .nav-item.nav-item-danger:hover,
.shell-sidebar .nav-item#btn-shell-logout:hover {
    background-color: rgba(239, 68, 68, 0.08);
    color: var(--cheisca-danger, #EF4444);
    opacity: 1;
}

.shell-sidebar .nav-item.nav-item-danger .material-symbols-outlined,
.shell-sidebar .nav-item#btn-shell-logout .material-symbols-outlined {
    color: var(--cheisca-danger, #EF4444);
    opacity: 0.85;
}

.shell-sidebar .nav-item.nav-item-danger:hover .material-symbols-outlined,
.shell-sidebar .nav-item#btn-shell-logout:hover .material-symbols-outlined {
    opacity: 1;
}