/**
 * HEADER-MOBILE.CSS
 * Estilos específicos para mejorar la responsividad del header en dispositivos móviles
 */

/* ===== HEADER RESPONSIVE PARA MÓVILES ===== */

/* Breakpoint principal para móviles */
@media (max-width: 768px) {

    /* Header más compacto */
    header {
        padding: 0.5rem 0 !important;
        min-height: auto !important;
    }

    /* Contenedor principal más compacto */
    .container {
        padding: 0 0.75rem !important;
    }

    /* Layout flexible para evitar desbordamiento */
    .flex.items-center.justify-between.flex-wrap.gap-2 {
        gap: 0.5rem !important;
        align-items: flex-start !important;
        flex-wrap: wrap !important;
    }

    /* Título del sistema más compacto */
    .flex.items-center.space-x-2.sm\:space-x-4.min-w-0.flex-1 {
        min-width: 0 !important;
        flex: 1 1 auto !important;
        max-width: 60% !important;
    }

    /* Logo y título más pequeños */
    .bg-white.bg-opacity-10.rounded-xl.px-2.sm\:px-4.py-1.sm\:py-2 {
        padding: 0.25rem 0.5rem !important;
        gap: 0.25rem !important;
    }

    .w-6.h-6.sm\:w-8.sm\:h-8.md\:w-10.md\:h-10 {
        width: 1.75rem !important;
        height: 1.75rem !important;
    }

    /* Título principal más pequeño */
    .text-sm.sm\:text-xl.md\:text-2xl {
        font-size: 1rem !important;
        line-height: 1.2 !important;
        max-width: 140px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    /* Subtítulo más pequeño */
    .text-xs.sm\:text-sm {
        font-size: 0.7rem !important;
        line-height: 1.1 !important;
        max-width: 120px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    /* Navegación oculta en móviles */
    .hidden.lg\:flex {
        display: none !important;
    }

    /* Botón hamburger visible */
    .lg\:hidden {
        display: block !important;
    }

    /* Perfil de usuario más compacto */
    .flex.items-center.space-x-2.sm\:space-x-3.md\:space-x-4.flex-shrink-0 {
        gap: 0.5rem !important;
        flex-shrink: 0 !important;
    }

    /* Información del usuario oculta en móviles pequeños */
    @media (max-width: 480px) {
        .hidden.md\:block {
            display: none !important;
        }
    }

    /* Foto de perfil más pequeña */
    .w-8.h-8.sm\:w-10.sm\:h-10.md\:w-12.md\:h-12 {
        width: 2rem !important;
        height: 2rem !important;
    }

    /* Botón de menú de usuario más compacto */
    .bg-white.bg-opacity-15.hover\:bg-opacity-25.px-2.sm\:px-3.py-1.sm\:py-2 {
        padding: 0.5rem 0.75rem !important;
    }

    /* Menú móvil mejorado */
    #menuMovil {
        padding: 0.5rem !important;
    }

    .mobile-nav-item {
        padding: 0.5rem !important;
        font-size: 0.8rem !important;
        margin-bottom: 0.5rem !important;
    }

    .mobile-nav-item i {
        font-size: 0.9rem !important;
        margin-right: 0.4rem !important;
    }
}

/* ===== MEJORAS PARA PANTALLAS PEQUEÑAS ===== */
@media (max-width: 640px) {
    .container {
        padding: 0 0.5rem !important;
    }

    .text-sm.sm\:text-xl.md\:text-2xl {
        font-size: 0.85rem !important;
        max-width: 120px !important;
    }

    .text-xs.sm\:text-sm {
        font-size: 0.6rem !important;
        max-width: 100px !important;
    }

    .w-6.h-6.sm\:w-8.sm\:h-8.md\:w-10.md\:h-10 {
        width: 1.5rem !important;
        height: 1.5rem !important;
    }

    .bg-white.bg-opacity-10.rounded-xl.px-2.sm\:px-4.py-1.sm\:py-2 {
        padding: 0.25rem 0.5rem !important;
    }

    .space-x-2.sm\:space-x-4 {
        gap: 0.25rem !important;
    }

    .lg\:hidden button {
        padding: 0.2rem !important;
    }

    .lg\:hidden button i {
        font-size: 0.9rem !important;
    }
}

/* ===== MEJORAS PARA PANTALLAS EXTRA PEQUEÑAS ===== */
@media (max-width: 480px) {
    .container {
        padding: 0 0.4rem !important;
    }

    .text-sm.sm\:text-xl.md\:text-2xl {
        font-size: 0.8rem !important;
        max-width: 100px !important;
    }

    .text-xs.sm\:text-sm {
        font-size: 0.6rem !important;
        max-width: 80px !important;
    }

    .w-6.h-6.sm\:w-8.sm\:h-8.md\:w-10.md\:h-10 {
        width: 1.25rem !important;
        height: 1.25rem !important;
    }

    .bg-white.bg-opacity-10.rounded-xl.px-2.sm\:px-4.py-1.sm\:py-2 {
        padding: 0.2rem 0.4rem !important;
    }

    .hidden.md\:block {
        display: none !important;
    }

    .bg-white.bg-opacity-15.hover\:bg-opacity-25.px-2.sm\:px-3.py-1.sm\:py-2 {
        padding: 0.3rem 0.5rem !important;
    }

    .bg-white.bg-opacity-15.hover\:bg-opacity-25.px-2.sm\:px-3.py-1.sm\:py-2 i {
        font-size: 0.8rem !important;
    }

    #menuMovil {
        padding: 0.25rem !important;
    }

    .mobile-nav-item {
        padding: 0.4rem !important;
        font-size: 0.75rem !important;
        margin-bottom: 0.4rem !important;
    }

    .mobile-nav-item i {
        font-size: 0.8rem !important;
        margin-right: 0.3rem !important;
    }

    .grid.grid-cols-2 {
        grid-template-columns: 1fr !important;
    }
}

/* ===== MEJORAS PARA PANTALLAS MUY PEQUEÑAS ===== */
@media (max-width: 360px) {
    .container {
        padding: 0 0.25rem !important;
    }

    .text-sm.sm\:text-xl.md\:text-2xl {
        font-size: 0.75rem !important;
        max-width: 90px !important;
    }

    .text-xs.sm\:text-sm {
        font-size: 0.55rem !important;
        max-width: 70px !important;
    }

    .w-6.h-6.sm\:w-8.sm\:h-8.md\:w-10.md\:h-10 {
        width: 1.125rem !important;
        height: 1.125rem !important;
    }

    .bg-white.bg-opacity-10.rounded-xl.px-2.sm\:px-4.py-1.sm\:py-2 {
        padding: 0.15rem 0.3rem !important;
    }

    .lg\:hidden button {
        padding: 0.15rem !important;
    }

    .lg\:hidden button i {
        font-size: 0.8rem !important;
    }
}

/* ===== ORIENTACIÓN LANDSCAPE EN MÓVILES ===== */
@media (max-width: 768px) and (orientation: landscape) {
    header {
        padding: 0.25rem 0 !important;
    }

    .text-sm.sm\:text-xl.md\:text-2xl {
        font-size: 0.85rem !important;
    }

    .text-xs.sm\:text-sm {
        font-size: 0.6rem !important;
    }

    .container {
        padding: 0 0.5rem !important;
    }
}

/* ===== PREVENCIÓN DE SOLAPAMIENTO ===== */
@media (max-width: 768px) {

    /* Forzar que no haya solapamiento */
    .flex.items-center.justify-between.flex-wrap.gap-2>* {
        margin-bottom: 0.25rem !important;
    }

    /* Asegurar que el título no se desborde */
    .min-w-0 {
        min-width: 0 !important;
        overflow: hidden !important;
    }

    /* Prevenir que el texto se corte */
    .leading-tight {
        line-height: 1.1 !important;
    }

    /* Asegurar que los elementos no se superpongan */
    .flex-shrink-0 {
        flex-shrink: 0 !important;
    }

    .flex-1 {
        flex: 1 1 auto !important;
    }
}

/* ===== MEJORAS DE ACCESIBILIDAD ===== */
@media (max-width: 768px) {

    /* Asegurar que los botones sean tocables */
    button,
    a {
        min-height: 44px !important;
        min-width: 44px !important;
    }

    /* Mejorar contraste en móviles */
    .text-white {
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5) !important;
    }

    /* Asegurar que los iconos sean visibles */
    i {
        display: inline-block !important;
        vertical-align: middle !important;
    }

    /* ===== MENÚ DESPLEGABLE DEL USUARIO EN MÓVILES ===== */
    #menuUsuario {
        position: fixed !important;
        top: auto !important;
        right: 0.5rem !important;
        left: 0.5rem !important;
        width: auto !important;
        min-width: 200px !important;
        max-width: 300px !important;
        margin: 0 auto !important;
        z-index: 10000 !important;
    }

    #menuUsuario.menu-activo {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateY(0) !important;
    }

    /* ===== MENÚ PRINCIPAL EN MÓVILES ===== */
    #menuPrincipal {
        position: fixed !important;
        top: auto !important;
        right: 0.5rem !important;
        left: 0.5rem !important;
        width: auto !important;
        min-width: 200px !important;
        max-width: 300px !important;
        margin: 0 auto !important;
        z-index: 10000 !important;
        overflow: visible !important;
        white-space: nowrap !important;
    }

    #menuPrincipal.menu-activo {
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateY(0) !important;
        display: block !important;
    }

    #menuPrincipal:not(.menu-activo) {
        opacity: 0 !important;
        visibility: hidden !important;
        transform: translateY(-10px) !important;
        display: none !important;
    }

    /* Asegurar que no haya overflow en móviles */
    header,
    .container,
    .flex.items-center.justify-between.flex-wrap.gap-2 {
        overflow: visible !important;
    }

    /* Botón del menú principal más accesible en móviles */
    button[onclick="toggleMenuPrincipal()"] {
        min-height: 44px !important;
        min-width: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Mejorar la visibilidad del menú principal en móviles */
    #menuPrincipal .px-4.py-2\.5 {
        padding: 0.75rem 1rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    #menuPrincipal .text-sm.text-gray-700 {
        font-size: 0.875rem !important;
        white-space: nowrap !important;
    }

    #menuPrincipal .w-4 {
        width: 1rem !important;
        flex-shrink: 0 !important;
    }

    /* Asegurar que el contenedor del menú tenga posición relativa en móviles */
    .header-menu-container {
        position: relative !important;
        z-index: 9999 !important;
        overflow: visible !important;
    }
}