:root {
    --primary-color: rgb(0, 51, 102);
    --secondary-color:rgb(0, 102, 178);
    --background-color: rgb(240, 242, 245);
    --background-navbar: rgb(255, 255, 255);
    --text-color: rgb(51, 51, 51);
    --color-hover: rgb(0, 153, 255);
    
}
    
:root {
    /* Aplicando los colores de tu logo que definimos antes */
    --background-color: #f0f2f5;
    --background-navbar: #ffffff;
    --primary-blue: #003366;
}

body, html {
    max-width: 100%;
    overflow: auto;
    margin: 0;
    padding: 0;
    width: 100%;   
    font-family: 'Outfit', sans-serif;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* Títulos con peso fuerte para que resalten */
h1, h2, h3, .dashboard-modal-title, .title_modal {
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #003366; /* Tu azul institucional */
}

.dashboard-form-label, .table th, .table_cell_check {
    font-weight: 600;
    font-size: 0.85rem;
    color: #64748b;
}

/* Inputs y botones */
.dashboard-modal-input, .input-deqas, .dashboard-modal-btn {
    font-weight: 400;
}

.dashboard-container {
    height: 100vh;
    width: 100%;
    display: grid;
    overflow: visible;
    /* Definimos: 240px para el lateral y el resto (1fr) para el contenido */
    grid-template-columns: 240px 1fr;
    /* Definimos: 60px para el header y el resto (1fr) para el main */
    grid-template-rows: 60px 1fr;
    
    /* Creamos el mapa visual */
    grid-template-areas: 
        "sidebar topbar"
        "sidebar maincontent";
    
    /* Arreglo para Safari/iPhone */
    -webkit-overflow-scrolling: touch;
}

.nav_deqas_template {
    grid-area: sidebar;
    height: 100vh;
    background-color: var(--background-navbar);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow-x: hidden;
}

.nav_deqas_template::-webkit-scrollbar {
    display: none;
}

.logo_container {
    height: 60px; /* Misma altura que la barra superior para que alineen */
    display: flex;
    align-items: center;
    padding: 0 20px;
    /* Opcional: un borde sutil abajo si quieres separar el logo del menú */
    /* border-bottom: 1px solid #f0f0f0; */
}

.main_logo {
    max-height: 40px; /* Ajusta según el tamaño de tu logo.png */
    width: auto;
}

/* Contenedor del menú */
.sidebar_menu {
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Empuja el logout al fondo */
    height: calc(100% - 60px); /* Resta la altura del logo_container */
    padding: 20px 15px;
}

.nav_list {
    list-style: none;
    margin: 0;
    padding: 10px 15px; 
    width: 100%;
    box-sizing: border-box;
}

.nav_list li {
    margin-bottom: 10px;
}

/* Estilo base de los botones */
.nav_item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    text-decoration: none;
    color: #6c757d; /* Gris para botones inactivos */
    font-size: 14px;
    font-weight: 500;
    border-radius: 15px; /* Curva de cápsula */
    transition: all 0.3s ease;
    gap: 15px;
    width: 100%; /* Ocupa el ancho disponible del contenedor padre */
    box-sizing: border-box; /* Asegura que el padding interno no lo ensanche */
    margin: 4px 0; /* Espacio vertical entre botones */
    border-radius: 12px;
    max-height: 48px; /* Para que no se estiren demasiado */
}

/* Efecto Hover para botones normales */
.nav_item:hover:not(.active) {
    background-color: #f8f9fa;
    color: var(--primary-blue);
}

/* BOTÓN ACTIVO (Gradiente del Logo) */
.nav_item.active {
    /* Gradiente desde azul marino profundo a azul medio */
    background: linear-gradient(90deg, #003366 0%, #0066b2 100%);
    color: #ffffff;
    box-shadow: 0px 4px 10px rgba(0, 51, 102, 0.3);
}

/* Ajuste para los iconos de MDI */
.nav_item i {
    font-size: 22px; /* Tamaño ideal para visibilidad */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px; /* Ancho fijo para que el texto de todos los botones alinee */
}

/* Color de los iconos cuando el botón está activo */
.nav_item.active i {
    color: #ffffff;
}

/* Color de los iconos en reposo */
.nav_item i {
    color: #6c757d; 
    transition: color 0.3s ease;
}

.nav_item:hover i {
    color: var(--primary-blue); /* El azul marino de tu logo */
}

/* Sección de Logout al final */
.logout_section {
    margin-top: auto; /* Asegura que se vaya al fondo */
    padding-top: 20px;
    border-top: 1px solid #f0f0f0;
}

.nav_item.logout:hover {
    color: #dc3545; /* Rojo suave para indicar salida */
    background-color: #fff5f5;
}

.nav_deqas_template_top {
    grid-area: topbar; /* Solo la parte superior derecha */
    background-color: var(--background-navbar);
    position: relative; /* Necesario para que z-index funcione */
    z-index: 100;        /* Por encima del content_area pero por debajo de modales (9999+) */
    overflow: visible;
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.05);
    border-bottom: none !important; /* Eliminamos borde inferior si existía */
    box-shadow: none !important;   /* Eliminamos sombra superior */
    justify-content: space-between;
}

.content_area {
    grid-area: maincontent; /* El cuadro rojo de tu imagen */
    height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;

    box-sizing: border-box;
    background-color: var(--background-color);
    padding: 30px;
    padding-bottom: 60px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* Para Safari/iPhone - smooth scroll */
    border-top-left-radius: 0;
    position: relative;
    /* Sin z-index para no crear un stacking context que atrape los modales */
}

.topbar-right .user-profile {
    display: flex;
    align-items: center;
    gap: 12px; /* Espacio entre la foto y el texto */
}

.user-info {
    display: flex;
    flex-direction: column; /* Nombre arriba, cargo abajo */
    line-height: 1.2;
}

.user-name {
    font-weight: bold;
    font-size: 14px;
    color: var(--primary-blue);
}

.user-role {
    font-size: 12px;
    color: #888;
}

.avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%; /* Foto circular */
    object-fit: cover;
}


.hamburger-menu {
    display: none;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--primary-blue);
    cursor: pointer;
}

/* --- PANTALLA DE CARGA (LOADER) --- */
/* Contenedor del Loader (Tu clase original) */
.loading_body {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px); /* Desenfoque de fondo */
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
}

/* La tarjeta blanca central */
.loading-card {
    background: #ffffff;
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 51, 102, 0.15);
    text-align: center;
    width: 90%;
    max-width: 320px;
}

/* Spinner y posición del Icono */
.loader-visual {
    position: relative;
    width: 70px;
    height: 70px;
    margin: 0 auto 20px;
}

.custom-spinner {
    width: 100%;
    height: 100%;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #003366; /* Tu azul marino */
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

#icon_loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 22px;
    color: #003366;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Texto del Loader */
#text_loading {
    margin: 0;
    color: #333;
    font-size: 1rem;
    font-weight: 700;
}

/* Barra de progreso decorativa */
.loading-progress-bar {
    width: 100%;
    height: 4px;
    background: #eee;
    border-radius: 10px;
    margin-top: 20px;
    overflow: hidden;
}

.progress-fill {
    width: 40%;
    height: 100%;
    background: #003366;
    animation: loadingMove 1.5s infinite ease-in-out;
}

@keyframes loadingMove {
    0% { margin-left: -40%; }
    100% { margin-left: 100%; }
}

/* --- TABLETS (Hasta 992px) --- */

@media (min-width: 992px) {
    .content_area {
        border-top-left-radius: 30px;
    }
}

@media (max-width: 992px) {
    .hamburger-menu {
        display: block;
    }

    .dashboard-container {
        /* En móvil el grid solo tiene 1 columna */
        grid-template-columns: 1fr;
        grid-template-areas: 
            "topbar"
            "maincontent";        
    }

    .nav_deqas_template {
        position: fixed;
        top: 0;
        left: -250px; /* Escondido a la izquierda */
        width: 250px;
        height: 100vh;
        z-index: 9999;
        transition: left 0.3s ease;
        box-shadow: 5px 0 15px rgba(0,0,0,0.1);
    }

    /* Clase que activaremos con JS */
    .nav_deqas_template.active {
        left: 0;
    }

    .content_area {
        padding: 20px;
        padding-bottom: 0;
        margin-bottom: 0;
        
    }
    /* Ocultamos el texto de los botones, dejamos solo iconos */
    .nav_item span, .user-info, .brand-name {
        display: none;
    }

    .nav_item {
        justify-content: center;
        padding: 12px;
    }
    
}

/* --- MÓVILES (Hasta 600px) --- */
@media (max-width: 600px) {
    .dashboard-container {
        /* Cambiamos a una sola columna: el sidebar pasa a ser un menú inferior o superior */
        grid-template-columns: 1fr;
        grid-template-rows: 60px 1fr 70px; /* Topbar, Contenido, y Nav Inferior */
        grid-template-areas: 
            "topbar"
            "maincontent"
            "sidebar";
        height: 100vh;
    }

    .nav_deqas_template {
        position: fixed;
        top: 0;
        left: -260px; /* Escondido */
        width: 260px;
        height: 100vh;
        background-color: var(--background-navbar);
        display: flex;
        flex-direction: column; /* LOS PONE UNO DEBAJO DEL OTRO */
        z-index: 9999;
        transition: all 0.3s ease;
        box-shadow: 5px 0 15px rgba(0,0,0,0.1);
        padding: 0; /* Reset para controlar internamente */
    }

    .nav_deqas_template.active {
        left: 0; /* Se desliza hacia adentro */
    }

    /* Aseguramos que la lista sea vertical */
    .nav_list {
        display: flex;
        flex-direction: column;
        width: 100%;
        padding: 20px 15px;
    }

    /* FORZAMOS QUE EL TEXTO SE VEA */
    .nav_item span {
        display: inline-block !important; 
        opacity: 1 !important;
        visibility: visible !important;
    }

    .nav_item {
        justify-content: flex-start; /* Alinea icono y texto a la izquierda */
        margin-bottom: 8px;
        width: 100%;
    }

    /* Ajuste del logo en móvil para que no desaparezca */
    .logo_container {
        display: flex !important;
        justify-content: center;;
        padding: 20px;
        border-bottom: 1px solid #f0f0f0;
    }

    .content_area {
        padding: 15px;
        /* Importante: para que las tablas no rompan el layout */
        width: 100%;
        overflow-x: hidden;
    }
    
    .nav_item.active {
        /* En móvil usamos un indicador más sutil o mantenemos el gradiente */
        border-radius: 10px;
    }
}

/* ========================================================================
   AJUSTE FINAL BANDEJA DE PERFIL - DEQAS 2026
   ======================================================================== */

/* 1. Limpiar contenedores para evitar cortes visuales */
.topbar, .topbar-right, .topbar-container {
    overflow: visible !important;
}

/* 2. El Perfil (Trigger) */
.user-profile {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    border-radius: 50px;
    cursor: pointer;
    z-index: 101; /* Encima del topbar */
    transition: background 0.3s ease;
}

.user-profile:hover {
    background-color: #f1f5f9;
}

/* 3. La Bandeja Desplegable (Tray) */
.user-dropdown-tray {
    position: absolute !important;
    top: 60px !important; /* Ajusta este valor según el alto de tu topbar */
    right: 0 !important;
    width: 240px !important;
    background-color: #ffffff !important; /* Blanco sólido */
    border: 1px solid #e2e8f0 !important;
    border-radius: 16px !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2) !important;
    
    /* Forzado de visibilidad */
    display: none; 
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 500 !important; /* Sobre el contenido pero bajo los modales (9999+) */
}

/* 4. Clase que activa la bandeja */
.user-dropdown-tray.active {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
}

/* 5. Elementos internos */
.dropdown-options {
    list-style: none !important;
    margin: 0 !important;
    padding: 10px 0 !important;
}

.dropdown-options li a {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 12px 20px !important;
    color: #334155 !important;
    text-decoration: none !important;
    font-size: 14px !important;
    font-family: 'Outfit', sans-serif !important;
}

.dropdown-options li a:hover {
    background-color: #f8fafc !important;
    color: #003366 !important;
}

.dropdown-options li a i {
    font-size: 18px;
    color: #94a3b8;
}

/* Separador */
.divider {
    height: 1px;
    background-color: #f1f5f9;
    margin: 8px 0;
}

/* Rotación de flecha */
.arrow-icon {
    transition: transform 0.3s ease;
}

.user-profile.active .arrow-icon {
    transform: rotate(180deg);
}

/* ========================================================================
   MEJORAS PARA SAFARI / iPhone - RESPONSIVIDAD Y SCROLL
   ======================================================================== */

/* Arreglo para Safari iPhone - evitar problemas de viewport solo en móviles */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 1024px) {
        body, html {
            position: fixed;
            width: 100%;
            height: 100%;
            overflow: hidden;
        }
        
        .dashboard-container {
            position: fixed;
            width: 100%;
            height: 100vh;
            overflow: hidden;
        }
        
        .content_area {
            -webkit-overflow-scrolling: touch;
            overflow-y: scroll;
            -webkit-box-sizing: border-box;
            position: relative;
        }
    }
}

/* Media query para dispositivos muy pequeños (iPhone SE, etc.) */
@media (max-width: 375px) {
    .content_area {
        padding: 12px;
        padding-bottom: 50px;
    }
    
    .dashboard-modal-card {
        width: 98%;
        padding: 15px;
    }
}

/* Media query para iPhone en landscape */
@media (max-height: 500px) and (max-width: 800px) {
    .dashboard-modal-card {
        max-height: calc(100vh - 20px);
    }
    
    .dashboard-modal-body {
        max-height: calc(100vh - 200px);
    }
    
    .dashboard-modal-header {
        margin-bottom: 15px;
    }
    
    .dashboard-modal-footer {
        margin-top: 15px;
        padding-top: 10px;
    }
}

/* Asegurar que elementos con position: fixed funcionen bien en Safari */
input, textarea, select {
    -webkit-appearance: none;
    appearance: none;
}

select {
    border-radius: 8px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
    padding-right: 40px;
}

/* Scroll suave en contenedores con overflow */
.content_area,
.dashboard-modal-body,
.dashboard-modal-card {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Asegurar padding bottom para que el contenido no quede cortado */
.content_area > * {
    margin-bottom: 10px;
}

.content_area > *:last-child {
    margin-bottom: 30px;
}