/* ========================================
   HEADER MÓVIL COMPLETO Y OPTIMIZADO
   Versión limpia, sin duplicados, consistente
   ======================================== */

/* ========================================
   BASE - TODOS LOS TAMAÑOS
   ======================================== */


/* ========================================
   DESKTOP (> 768px)
   ======================================== */


/* ========================================
   MÓVIL (≤ 768px)
   ======================================== */

@media (max-width: 768px) {
    
    /* ===== ESTRUCTURA BASE ===== */
    
    .site-header .header-container {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 12px 16px !important;
        gap: 12px !important;
        max-width: 100% !important;
    }
    
    /* ===== LOGO - IZQUIERDA ===== */
    
    .site-header .logo-container {
        order: 1 !important;
        flex-shrink: 0 !important;
    }
    
    .site-header .logo {
        height: 36px !important;
        width: auto !important;
    }
    
    /* ===== ÁREA DERECHA - BOTONES + MENÚ ===== */
    
    .site-header .header-right {
        order: 3 !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px !important;
        margin-left: auto !important;
        flex-shrink: 0 !important;
    }
    
    .site-header #auth-container {
        order: 1 !important;
        display: flex !important;
        gap: 6px !important;
    }
    
    .site-header .menu-toggle {
        order: 2 !important;
    }
    
    /* ===== BOTONES DE LOGIN/REGISTRO ===== */
    
    .site-header .btn-auth {
        min-height: 48px !important;
        padding: 0 16px !important;
        
        font-size: 14px !important;
        font-weight: 600 !important;
        white-space: nowrap !important;
        
        background: rgba(114, 214, 255, 0.15) !important;
        border: 2px solid rgba(114, 214, 255, 0.4) !important;
        border-radius: 12px !important;
        color: #72d6ff !important;
        
        box-shadow: 0 2px 8px rgba(114, 214, 255, 0.2) !important;
        
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px !important;
        
        transition: all 0.2s ease !important;
        cursor: pointer !important;
    }
    
    .site-header .btn-auth:active {
        transform: scale(0.95) !important;
        background: rgba(114, 214, 255, 0.25) !important;
    }
    
    .site-header .btn-auth .btn-icon {
        font-size: 18px !important;
    }
    
    /* Login más destacado */
    .site-header .btn-login {
        background: rgba(114, 214, 255, 0.2) !important;
        border-color: rgba(114, 214, 255, 0.5) !important;
    }
    
    /* ===== USUARIO LOGUEADO - AVATAR ===== */
    
    .site-header .user-logged {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
        
        min-width: 48px !important;
        height: 48px !important;
        padding: 0 12px !important;
        
        background: rgba(114, 214, 255, 0.15) !important;
        border: 2px solid rgba(114, 214, 255, 0.4) !important;
        border-radius: 12px !important;
        
        box-shadow: 0 2px 8px rgba(114, 214, 255, 0.2) !important;
        
        transition: all 0.2s ease !important;
        cursor: pointer !important;
        overflow: hidden !important;
    }
    
    .site-header .user-logged:active {
        transform: scale(0.95) !important;
        background: rgba(114, 214, 255, 0.25) !important;
    }
    
    .site-header .user-avatar {
        width: 32px !important;
        height: 32px !important;
        border-radius: 50% !important;
        border: 2px solid rgba(114, 214, 255, 0.6) !important;
        object-fit: cover !important;
        flex-shrink: 0 !important;
    }
    
    /* Username visible */
    .site-header .user-username {
        display: inline !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        color: #72d6ff !important;
        max-width: 60px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
    
    /* ===== BOTÓN HAMBURGUESA ===== */
    
    .site-header .menu-toggle {
        width: 48px !important;
        height: 48px !important;
        padding: 0 !important;
        
        background: rgba(114, 214, 255, 0.15) !important;
        border: 2px solid rgba(114, 214, 255, 0.4) !important;
        border-radius: 12px !important;
        
        box-shadow: 0 2px 8px rgba(114, 214, 255, 0.2) !important;
        
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 5px !important;
        
        transition: all 0.2s ease !important;
        cursor: pointer !important;
        flex-shrink: 0 !important;
    }
    
    .site-header .menu-toggle:active {
        transform: scale(0.95) !important;
        background: rgba(114, 214, 255, 0.25) !important;
    }
    
    .site-header .hamburger-line {
        width: 20px !important;
        height: 3px !important;
        background: #72d6ff !important;
        border-radius: 2px !important;
        transition: all 0.3s ease !important;
    }
    
    /* Animación hamburguesa activa */
    .mobile-nav-active .hamburger-line:nth-child(1) {
        transform: rotate(45deg) translate(6px, 6px) !important;
    }
    
    .mobile-nav-active .hamburger-line:nth-child(2) {
        opacity: 0 !important;
    }
    
    .mobile-nav-active .hamburger-line:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -6px) !important;
    }
    
    /* ===== OCULTAR NAV DESKTOP ===== */
    
    .site-header nav:not(.mobile-nav) {
        display: none !important;
    }
    
    /* ===== MENÚ LATERAL MEJORADO ===== */
    
    .mobile-nav {
   position: fixed !important;
        top: 0 !important;
        right: -100% !important;
        left: auto;
        width: 280px !important;
        height: 100vh !important;
        background: linear-gradient(180deg, #1a1a2e 0%, #0f0c29 100%) !important;
        z-index: 9999 !important;
        padding: 60px 20px 20px !important;
        overflow-y: auto !important;
        transition: right 0.3s ease !important;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5) !important;
    }
    
    .mobile-nav.active {
        right: 0 !important;
    }
    
    /* ===== SECCIÓN DE USUARIO EN MENÚ ===== */
    
    .mobile-nav-user {
        padding: 18px !important;
        margin-bottom: 24px !important;
        
        background: rgba(114, 214, 255, 0.08) !important;
        border: 2px solid rgba(114, 214, 255, 0.25) !important;
        border-radius: 16px !important;
        
        display: flex !important;
        align-items: center !important;
        gap: 14px !important;
        
        box-shadow: 0 4px 12px rgba(114, 214, 255, 0.1) !important;
    }
    
    .mobile-nav-user .user-avatar {
        width: 52px !important;
        height: 52px !important;
        border-radius: 50% !important;
        border: 3px solid rgba(114, 214, 255, 0.5) !important;
        object-fit: cover !important;
        flex-shrink: 0 !important;
    }
    
    .mobile-nav-user-info {
        flex: 1 !important;
        min-width: 0 !important;
    }
    
    .mobile-nav-user-name {
        font-size: 17px !important;
        font-weight: 700 !important;
        color: #fff !important;
        margin-bottom: 4px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
    
    .mobile-nav-user-email {
        font-size: 13px !important;
        color: rgba(114, 214, 255, 0.8) !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
    
    /* ===== ENLACES DEL MENÚ ===== */
    

    .mobile-nav a {
        background: rgba(114, 214, 255, 0.1);
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 16px;
        color: #72d6ff;
        text-decoration: none;
        font-size: 16px;
        font-weight: 500;
        border-radius: 10px;
        margin-bottom: 6px;
        transition: all 0.2s ease;
        border: 1px solid transparent;
    }
    
    .mobile-nav a:active {
        background: rgba(114, 214, 255, 0.1);
        border-color: rgba(114, 214, 255, 0.3);
        color: #72d6ff;
    }
    
    .mobile-nav a.active {
        background: linear-gradient(135deg, rgba(114, 214, 255, 0.15), rgba(255, 127, 255, 0.15));
        border-color: rgba(114, 214, 255, 0.4);
        color: #72d6ff;
    }
    /* ===== DIVIDER ===== */
    
    .mobile-nav-divider {
        height: 2px !important;
        background: linear-gradient(
            90deg,
            transparent,
            rgba(114, 214, 255, 0.2) 20%,
            rgba(114, 214, 255, 0.2) 80%,
            transparent
        ) !important;
        margin: 20px 0 !important;
    }
    
    /* ===== ACCIONES DE USUARIO (en menú) ===== */
    
    #mobile-nav-user-actions a {
        font-size: 15px !important;
    }
    
    /* Cerrar sesión en rojo */
    #mobile-nav-user-actions a[onclick*="cerrarSesion"] {
        color: rgba(255, 107, 107, 0.9) !important;
    }
    
    #mobile-nav-user-actions a[onclick*="cerrarSesion"]:active {
        background: rgba(255, 107, 107, 0.15) !important;
        border-color: rgba(255, 107, 107, 0.3) !important;
        color: #ff6b6b !important;
    }
    
    /* ===== FOOTER DEL MENÚ ===== */
    
    .mobile-nav-footer {
        margin-top: auto !important;
        padding-top: 24px !important;
        border-top: 2px solid rgba(255, 255, 255, 0.08) !important;
        text-align: center !important;
        font-size: 11px !important;
        color: rgba(255, 255, 255, 0.4) !important;
        line-height: 1.6 !important;
    }
    
    .mobile-nav-footer a {
        color: rgba(114, 214, 255, 0.6) !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        background: none !important;
        display: inline !important;
        font-size: 11px !important;
        text-decoration: none !important;
        transition: color 0.2s ease !important;
    }
    
    .mobile-nav-footer a:active {
        color: #72d6ff !important;
        background: none !important;
        transform: none !important;
    }
    
    /* ===== SCROLLBAR DEL MENÚ ===== */
    
    .mobile-nav::-webkit-scrollbar {
        width: 6px !important;
    }
    
    .mobile-nav::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.03) !important;
    }
    
    .mobile-nav::-webkit-scrollbar-thumb {
        background: rgba(114, 214, 255, 0.3) !important;
        border-radius: 3px !important;
    }
    
    .mobile-nav::-webkit-scrollbar-thumb:hover {
        background: rgba(114, 214, 255, 0.5) !important;
    }
    
    /* ===== OVERLAY ===== */
    
    .nav-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background: rgba(0, 0, 0, 0.65) !important;
        backdrop-filter: blur(6px) !important;
        -webkit-backdrop-filter: blur(6px) !important;
        z-index: 9998 !important;
        display: none !important;
        opacity: 0 !important;
        transition: opacity 0.3s ease !important;
    }
    
    .nav-overlay.active {
        display: block !important;
        opacity: 1 !important;
    }
}

/* ========================================
   BREAKPOINTS ESPECÍFICOS MÓVIL
   ======================================== */

/* ===== PANTALLAS MEDIANAS (360-400px) ===== */
/* Solo íconos en botones */
@media (min-width: 360px) and (max-width: 400px) {
    .site-header .btn-auth {
        width: 48px !important;
        min-width: 48px !important;
        padding: 0 !important;
    }
    
    .site-header .btn-auth .btn-text {
        display: none !important;
    }
    
    .site-header .btn-auth .btn-icon {
        font-size: 22px !important;
    }
    
    .site-header .user-logged {
        width: 48px !important;
        min-width: 48px !important;
        padding: 0 !important;
    }
    
    .site-header .user-username {
        display: none !important;
    }
    
    .site-header .user-avatar {
        width: 36px !important;
        height: 36px !important;
    }
}

/* ===== PANTALLAS PEQUEÑAS (< 360px) ===== */
@media (max-width: 359px) {
    .site-header .header-container {
        padding: 10px 12px !important;
        gap: 6px !important;
    }
    
    .site-header .logo {
        height: 32px !important;
    }
    
    .site-header .header-right {
        gap: 6px !important;
    }
    
    .site-header .btn-auth,
    .site-header .user-logged,
    .site-header .menu-toggle {
        width: 44px !important;
        min-width: 44px !important;
        height: 44px !important;
    }
    
    .site-header .btn-auth .btn-text {
        display: none !important;
    }
    
    .site-header .btn-auth .btn-icon {
        font-size: 20px !important;
    }
    
    .site-header .user-username {
        display: none !important;
    }
    
    .site-header .user-avatar {
        width: 32px !important;
        height: 32px !important;
    }
    
    .site-header .hamburger-line {
        width: 18px !important;
        height: 2.5px !important;
    }
}

/* ===== LANDSCAPE MÓVIL ===== */
@media (max-width: 768px) and (orientation: landscape) and (max-height: 500px) {
    .site-header .header-container {
        padding: 8px 12px !important;
    }
    
    .site-header .logo {
        height: 30px !important;
    }
    
    .site-header .btn-auth,
    .site-header .user-logged,
    .site-header .menu-toggle {
        min-height: 40px !important;
        height: 40px !important;
    }
    
    .mobile-nav {
        padding: 60px 20px 20px !important;
    }
}

/* ========================================
   ACCESIBILIDAD
   ======================================== */

/* Áreas de toque mínimas */
@media (max-width: 768px) {
    .site-header .btn-auth,
    .site-header .user-logged,
    .site-header .menu-toggle {
        min-width: 44px !important;
        min-height: 44px !important;
    }
}

/* Focus visible */
.site-header .btn-auth:focus-visible,
.site-header .user-logged:focus-visible,
.site-header .menu-toggle:focus-visible,
.mobile-nav a:focus-visible {
    outline: 3px solid #72d6ff !important;
    outline-offset: 2px !important;
}


/* ========================================
   ANIMACIONES
   ======================================== */

@keyframes slideInFromRight {
    from {
        right: -100%;
        opacity: 0.5;
    }
    to {
        right: 0;
        opacity: 1;
    }
}

.mobile-nav.active {
    animation: slideInFromRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}