/**
 * menu.css - Menú y Navegación para CRESA
 * Header Responsivo sin Menú Hamburguesa
 */

/* Ancho y padding del header: solo en main.css (.header-container) */

/* Logo: reglas globales en main.css (.logo-section, .logo-link, .logo-img) */

/* ============================================
   NAVEGACIÓN DESKTOP - Alineada a la derecha
   ============================================ */

.nav-menu {
    display: none;
}

@media (min-width: 769px) {
    .nav-menu {
        display: flex;
        flex: 1 1 auto;
        min-width: 0;
        justify-content: flex-end;
        align-items: center;
        margin: 0;
        position: relative;
        left: auto;
        transform: none;
        z-index: 1;
    }
    
    .nav-menu ul {
        list-style: none;
        margin: 0;
        padding: 0;
        display: flex;
        gap: 2.5rem;
        justify-content: flex-end;
        align-items: center;
    }
    
    @media (min-width: 1024px) {
        .nav-menu ul {
            gap: 3rem;
        }
    }
    
    .nav-menu ul li {
        margin: 0;
        padding: 0;
    }
    
    .nav-menu ul li a {
        color: #333;
        text-decoration: none;
        font-weight: 500;
        font-size: 1rem;
        transition: color 0.3s ease;
        padding: 0.5rem 0;
        position: relative;
        white-space: nowrap;
    }
    
    .nav-menu ul li a:hover {
        color: #E07A5F;
    }
    
    .nav-menu ul li a::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        width: 0;
        height: 2px;
        background-color: #E07A5F;
        transition: width 0.3s ease;
    }
    
    .nav-menu ul li a:hover::after {
        width: 100%;
    }
    
    .nav-menu ul li a.active::after {
        width: 100%;
        background-color: #000000;
    }
    
    .nav-menu ul li a.active {
        color: #000000;
        font-weight: 600;
    }
}

/* ============================================
   ÍCONOS DESKTOP (Carrito y Usuario) - Derecha
   ============================================ */

.desktop-icons-container {
    display: none;
}

@media (min-width: 769px) {
    .desktop-icons-container {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 16px;
        flex-shrink: 0;
        position: relative;
        overflow: visible !important;
        z-index: 1010;
    }
}

/* Carrito Desktop */
.desktop-cart-container {
    position: relative;
}

.cart-icon-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: 2px solid #333;
    border-radius: 50%;
    color: #333;
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
}

.cart-icon-link:hover {
    background-color: rgba(0, 0, 0, 0.05);
    border-color: #E07A5F;
    color: #E07A5F;
}

.cart-icon {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
}

.cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #000000;
    color: #ffffff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    border: 2px solid #fff;
    min-width: 20px;
    padding: 0 4px;
    box-sizing: border-box;
    transition: none;
}

.cart-badge:not(:empty) {
    display: flex;
}

/* Menú Usuario Desktop */
.desktop-user-menu-container {
    position: relative !important;
    z-index: 1013 !important;
    overflow: visible !important;
}

.desktop-icons-container {
    position: relative !important;
    overflow: visible !important;
    z-index: 1010 !important;
}

.desktop-user-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: 2px solid #333;
    border-radius: 50%;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
    position: relative;
    z-index: 1013;
    pointer-events: auto;
}

.desktop-user-menu-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    border-color: #E07A5F;
    color: #E07A5F;
}

.desktop-user-icon {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
}

.desktop-user-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    left: auto;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 280px;
    max-width: 320px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    z-index: 9999;
    pointer-events: none;
    overflow: visible;
    display: block;
}

.desktop-user-menu-dropdown[aria-hidden="false"],
.desktop-user-menu-dropdown.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
    display: block;
}

.desktop-user-menu-header {
    padding: 1.25rem;
    background: linear-gradient(135deg, #2a2a2a 0%, #1f1f1f 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.desktop-user-name {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    margin: 0 0 0.5rem 0;
}

.desktop-user-profile-label {
    display: inline-block;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 0.25rem;
}

.desktop-user-menu-item {
    padding: 0.5rem 0;
}

.desktop-user-menu-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    color: #333;
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.desktop-user-menu-link:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #E07A5F;
}

.desktop-user-menu-icon {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    flex-shrink: 0;
}

.desktop-user-menu-divider {
    height: 1px;
    background-color: #e0e0e0;
    margin: 0.5rem 0;
}

/* ============================================
   HEADER MÓVIL (max-width: 768px)
   ============================================ */

@media (max-width: 768px) {
    /* Ocultar navegación desktop */
    .nav-menu {
        display: none !important;
    }
    
    /* Ocultar íconos desktop */
    .desktop-icons-container {
        display: none !important;
    }
    
    /* Contenedor de acciones móviles */
    .mobile-header-actions {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 16px;
        flex-shrink: 0;
        height: 100%;
    }
    
    /* Menú Usuario Móvil */
    .mobile-user-menu-container {
        position: relative;
        flex-shrink: 0;
        z-index: 1013;
        overflow: visible;
    }
    
    .mobile-user-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        background: transparent;
        border: 2px solid #333;
        border-radius: 50%;
        color: #333;
        cursor: pointer;
        transition: all 0.3s ease;
        padding: 0;
        position: relative;
        z-index: 1011;
        pointer-events: auto;
        flex-shrink: 0;
    }
    
    .mobile-user-menu-btn:hover {
        background-color: rgba(0, 0, 0, 0.05);
        border-color: #E07A5F;
        color: #E07A5F;
    }
    
    .mobile-user-icon {
        width: 18px;
        height: 18px;
        stroke: currentColor;
        fill: none;
        flex-shrink: 0;
    }
    
    .mobile-user-menu-dropdown {
        position: absolute;
        top: 100%;
        right: 0;
        left: auto;
        background: #fff;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
        min-width: 200px;
        max-width: calc(100vw - 2rem);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
        z-index: 9999;
        pointer-events: none;
        overflow: visible;
        display: block;
    }
    
    .mobile-user-menu-dropdown[aria-hidden="false"],
    .mobile-user-menu-dropdown.is-open {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        pointer-events: auto;
        display: block;
    }
    
    .mobile-user-menu-header {
        padding: 1rem;
        background: linear-gradient(135deg, #2a2a2a 0%, #1f1f1f 100%);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .mobile-user-name {
        font-size: 0.9rem;
        font-weight: 600;
        color: #fff;
        margin: 0 0 0.25rem 0;
    }
    
    .mobile-user-email {
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
        margin: 0 0 0.25rem 0;
    }
    
    .mobile-user-role {
        font-size: 0.75rem;
        color: rgba(255, 255, 255, 0.8);
    }
    
    .mobile-user-menu-item {
        padding: 0.5rem 0;
    }
    
    .mobile-user-menu-divider {
        height: 1px;
        background-color: #e0e0e0;
        margin: 0.5rem 0;
    }
    
    .mobile-user-menu-link {
        display: block;
        padding: 0.75rem 1rem;
        color: #333;
        text-decoration: none;
        font-size: 0.9rem;
        transition: all 0.3s ease;
    }
    
    .mobile-user-menu-link:hover {
        background-color: rgba(0, 0, 0, 0.05);
        color: #E07A5F;
    }
    
    /* Ícono de Bolsa Móvil - Fijo a la derecha */
    .mobile-bolsa-link {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        background: transparent;
        border: 2px solid #333;
        border-radius: 50%;
        color: #333;
        text-decoration: none;
        transition: all 0.3s ease;
        position: relative;
        flex-shrink: 0;
    }
    
    .mobile-bolsa-link:hover {
        background-color: rgba(0, 0, 0, 0.05);
        border-color: #E07A5F;
        color: #E07A5F;
    }
    
    .bolsa-icon {
        width: 20px;
        height: 20px;
        stroke: currentColor;
        flex-shrink: 0;
        fill: none;
    }
    
    /* Contador de bolsa - Círculo negro */
    .bolsa-contador {
        position: absolute;
        top: -4px;
        right: -4px;
        background-color: #000000;
        color: #ffffff;
        border-radius: 50%;
        width: 18px;
        height: 18px;
        display: none;
        align-items: center;
        justify-content: center;
        font-size: 0.65rem;
        font-weight: bold;
        border: 2px solid #fff;
        min-width: 18px;
        padding: 0 3px;
        box-sizing: border-box;
        line-height: 1;
    }
    
    /* Mostrar solo cuando tiene contenido y cantidad > 0 */
    .bolsa-contador:not(:empty) {
        display: flex;
    }
    
    .bolsa-contador:empty {
        display: none !important;
    }
}

/* Ocultar acciones móviles en desktop */
@media (min-width: 769px) {
    .mobile-header-actions {
        display: none !important;
    }
}
