/* Estilos base de la navbar */
.navbar {
    background: rgba(255, 255, 255, 0);
    padding: 1rem;
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    height: clamp(60px, 10vh, 80px);
    transition: all 0.3s ease;
}

/* Contenedor principal de la navbar */
.navbar-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr; /* Cambiado para tener 3 columnas con el logo en el centro */
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    height: 100%;
}

/* Logo */
.navbar-logo {
    grid-column: 2; /* Posiciona el logo en la columna central */
    background: transparent;
    font-family: "Cormorant Garamond", serif;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    color: #ffffff;
    text-decoration: none;
    text-align: center;
    font-weight: 500;
    letter-spacing: clamp(3px, 0.5vw, 6px);
    white-space: nowrap;
    transition: all 0.3s ease;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

/* Imagen del logo en navbar */
.navbar-logo-img {
    height: 65px;
    width: auto;
    max-width: 94px;
    object-fit: contain;
    transition: all 0.3s ease;
    filter: brightness(1.1);
}

/* Texto del logo */
.navbar-logo-text {
    font-family: "Cormorant Garamond", serif;
    font-size: inherit;
    font-weight: inherit;
    letter-spacing: inherit;
    color: inherit;
}

/* Botón hamburguesa */
.hamburger-menu {
    grid-column: 1; /* Posiciona el botón hamburguesa a la izquierda */
    justify-self: start;
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
    position: relative;
    width: 30px;
    height: 30px;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    transition: all 0.3s ease;
    border-radius: 4px;
    pointer-events: all;
    user-select: none;
}

.hamburger-menu:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.hamburger-menu:focus {
    outline: 2px solid #D4AF37;
    outline-offset: 2px;
}

.hamburger-line {
    display: block;
    width: 22px;
    height: 2px;
    background-color: #ffffff;
    transition: all 0.3s ease;
    transform-origin: center;
    border-radius: 1px;
}

.hamburger-menu.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-menu.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Contenedor derecho */
.navbar-right {
    grid-column: 3; /* Posiciona el menú y búsqueda a la derecha */
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2rem;
}

/* Menú principal */
.navbar-menu {
    display: flex;
    gap: 2rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.navbar-menu a {
    color: #ffffff;
    text-decoration: none;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: color 0.3s ease;
    background: transparent;
}

/* Estilos para los submenús */
.has-submenu {
    position: relative;
    display: inline-block; /* Asegurar que el contenedor tenga el ancho correcto */
}

.submenu {
    position: absolute;
    top: 100%;
    left: 0;
    transform: none !important;
    background: rgba(255, 255, 255, 0.98);
    min-width: 220px;
    max-width: 280px; /* Evitar submenús demasiado anchos */
    width: max-content; /* Ajustar al contenido pero respetar min/max */
    padding: 1rem 0;
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.15);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 0.8rem;
    z-index: 1000;
    list-style: none;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(212, 175, 55, 0.2);
    white-space: nowrap; /* Evitar que el contenido se rompa en múltiples líneas */
}

/* Flecha del submenú */
.submenu::before {
    content: '';
    position: absolute;
    top: -9px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-bottom: 9px solid rgba(255, 255, 255, 0.98);
    filter: drop-shadow(0 -2px 4px rgba(0,0,0,0.1));
}

/* Hover efecto para mostrar submenú - SIN MOVIMIENTO */
.has-submenu:hover .submenu {
    opacity: 1;
    visibility: visible;
    transform: none !important;
    margin-top: 0.4rem;
}

/* Elementos del submenú */
.submenu li {
    padding: 0;
    margin: 0;
}

.submenu a {
    color: #1a1a1a !important;
    padding: 0.8rem 1.5rem;
    display: block;
    text-align: left;
    font-size: 0.9rem !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    position: relative;
    border-radius: 4px;
    margin: 0 0.5rem;
    font-weight: 500;
}

/* Efecto hover en los items del submenú */
.submenu a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: linear-gradient(to bottom, #D4AF37, #B8860B);
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 2px;
}

.submenu a:hover {
    background: rgba(212, 175, 55, 0.08);
    color: #1a1a1a !important;
    transform: translateX(4px);
    padding-left: 1.8rem;
}

.submenu a:hover::before {
    height: 20px;
}

/* Ajustes para múltiples submenús */
.navbar-menu > li {
    position: relative;
    margin: 0 0.5rem;
}

.navbar-menu > li > a {
    padding: 0.5rem 1rem;
    position: relative;
}

.navbar-menu > li.has-submenu > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

/* Nuevo sistema de flechitas elegante */
.submenu-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.submenu-arrow::before {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Estados hover y activo para desktop */
.has-submenu:hover .submenu-arrow::before {
    transform: rotate(225deg);
    border-color: #D4AF37;
}

.has-submenu:hover .submenu-arrow {
    transform: translateY(-1px);
}

/* Eliminar el sistema anterior */
.navbar-menu > li.has-submenu > a::after {
    display: none;
}

/* Estilos del botón del carrito en navbar */
.navbar-cart {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.3s ease;
    color: #2c2c2c;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
}

.navbar-cart:hover {
    background-color: rgba(44, 44, 44, 0.1);
    transform: translateY(-1px);
}

.navbar-cart svg {
    transition: transform 0.2s ease;
}

.navbar-cart:hover svg {
    transform: scale(1.1);
}

/* Contador del carrito */
.cart-count {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    min-width: 18px;
    font-family: 'Cormorant Garamond', serif;
}

.cart-count.hidden {
    display: none;
}

@keyframes cartBounce {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Media queries para dispositivos móviles */
@media screen and (max-width: 768px) {
    .navbar-container {
        grid-template-columns: auto 1fr auto; /* Ajuste para móvil */
        padding: 0 1rem;
    }

    .hamburger-menu {
        display: flex;
    }

    .navbar-logo {
        font-size: clamp(1.2rem, 3vw, 1.8rem);
        padding: 0 1rem;
        gap: 8px;
    }
    
    .navbar-logo-img {
        height: 53px;
        max-width: 75px;
    }

    .navbar-menu {
        position: fixed;
        top: 80px;
        left: -100%;
        width: 100%;
        height: calc(100vh - 80px);
        background: rgba(255, 255, 255, 0.95);
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        padding-top: 2rem;
        transition: all 0.3s ease;
        opacity: 0;
        visibility: hidden;
        overflow-y: auto;
    }

    .navbar-menu.active {
        left: 0;
        opacity: 1;
        visibility: visible;
    }

    .navbar-menu li {
        margin: 8px 0;
        width: 90%;
        max-width: 300px;
    }

    .navbar-menu a {
        font-size: 1.1rem;
        color: #1a1a1a !important;
        padding: 12px 20px;
        display: block;
        width: 100%;
        text-align: center;
        border-radius: 8px;
        transition: all 0.3s ease;
        text-decoration: none;
    }

    .navbar-menu a:hover {
        background-color: rgba(212, 175, 55, 0.1);
        color: #D4AF37 !important;
    }

    .submenu {
        position: static;
        transform: none;
        background: transparent;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        padding: 0;
        margin: 0;
        max-height: 0;
        overflow: hidden;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        backdrop-filter: none;
        border: none;
    }

    .submenu::before {
        display: none;
    }
    
    .has-submenu.active .submenu {
        max-height: 400px;
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
        background: linear-gradient(135deg, 
            rgba(245, 245, 240, 0.4) 0%, 
            rgba(212, 175, 55, 0.05) 100%);
        border-radius: 12px;
        padding: 0.8rem 0;
        box-shadow: inset 0 2px 8px rgba(212, 175, 55, 0.1);
        border: 1px solid rgba(212, 175, 55, 0.15);
    }

    .submenu a {
        padding: 0.8rem 2rem;
        font-size: 1rem !important;
        opacity: 0.85;
        text-align: left;
        margin: 2px 0.8rem;
        border-radius: 8px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        position: relative;
        overflow: hidden;
    }

    .submenu a::before {
        left: 0;
        width: 3px;
        height: 0;
        background: linear-gradient(to bottom, #D4AF37, #B8860B);
        transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .submenu a:hover {
        background: rgba(212, 175, 55, 0.2);
        opacity: 1;
        transform: translateX(6px);
        color: #1a1a1a !important;
    }

    .submenu a:hover::before {
        height: 24px;
    }

    /* Animación de entrada para los elementos del submenú */
    .has-submenu.active .submenu a {
        animation: slideInSubmenu 0.3s ease forwards;
    }

    .has-submenu.active .submenu a:nth-child(1) { animation-delay: 0.1s; }
    .has-submenu.active .submenu a:nth-child(2) { animation-delay: 0.15s; }
    .has-submenu.active .submenu a:nth-child(3) { animation-delay: 0.2s; }
    .has-submenu.active .submenu a:nth-child(4) { animation-delay: 0.25s; }

    @keyframes slideInSubmenu {
        from {
            opacity: 0;
            transform: translateX(-20px);
        }
        to {
            opacity: 0.85;
            transform: translateX(0);
        }
    }    
    
    /* Flechitas mejoradas para móviles */
    .navbar-menu > li.has-submenu > a {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.8rem 1rem;
        border-bottom: 1px solid rgba(212, 175, 55, 0.1);
    }

    .submenu-arrow {
        width: 20px;
        height: 20px;
        margin-left: 12px;
        background: rgba(212, 175, 55, 0.1);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .submenu-arrow::before {
        width: 8px;
        height: 8px;
        border-right: 2px solid #D4AF37;
        border-bottom: 2px solid #D4AF37;
        transform: rotate(45deg);
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .has-submenu.active .submenu-arrow {
        background: rgba(212, 175, 55, 0.2);
        transform: rotate(180deg);
    }

    .has-submenu.active .submenu-arrow::before {
        border-color: #B8860B;
    }

    /* Animación suave al hacer tap */
    .has-submenu > a:active .submenu-arrow {
        transform: scale(0.9);
        background: rgba(212, 175, 55, 0.3);
    }

    /* Eliminar el sistema anterior para móviles */
    .navbar-menu > li.has-submenu > a::after {
        display: none;
    }

    /* Mejoras táctiles adicionales */
    .has-submenu > a {
        -webkit-tap-highlight-color: rgba(212, 175, 55, 0.2);
        tap-highlight-color: rgba(212, 175, 55, 0.2);
        touch-action: manipulation;
    }

    .submenu a {
        -webkit-tap-highlight-color: rgba(212, 175, 55, 0.15);
        tap-highlight-color: rgba(212, 175, 55, 0.15);
        touch-action: manipulation;
    }

    /* Feedback visual mejorado para elementos tocados */
    .has-submenu > a:active {
        background: rgba(212, 175, 55, 0.1);
        transform: scale(0.98);
    }

    .submenu a:active {
        background: rgba(212, 175, 55, 0.25);
        transform: translateX(8px) scale(0.98);
    }
}

/* Efectos hover */
.navbar:hover {
    background: rgba(255, 255, 255, 1);
}

.navbar:hover .navbar-logo,
.navbar:hover .navbar-menu a,
.navbar:hover .navbar-search {
    color: #1a1a1a;
}

/* Estilos para el enlace de administración */
.navbar-menu .admin {
    color: #1a1a1a;
    position: relative;
}

.navbar-menu .admin::after {
    content: "";
    position: absolute;
    width: 100%;
    height: 2px;
    bottom: -4px;
    left: 0;
    background: transparent;
    transition: background 0.3s ease;
}

.navbar-menu .admin:hover::after {
    background: #1a1a1a;
}

/* Estilos para el enlace de usuario */
.navbar-menu .user {
    color: #1a1a1a;
    position: relative;
}

.navbar-menu .user::after {
    content: "";
    position: absolute;
    width: 100%;
    height: 2px;
    bottom: -4px;
    left: 0;
    background: transparent;
    transition: background 0.3s ease;
}

.navbar-menu .user:hover::after {
    background: #1a1a1a;
}

/* Estilos para el enlace de perfil */
.navbar-menu .profile {
    color: #1a1a1a;
    position: relative;
}

.navbar-menu .profile::after {
    content: "";
    position: absolute;
    width: 100%;
    height: 2px;
    bottom: -4px;
    left: 0;
    background: transparent;
    transition: background 0.3s ease;
}

.navbar-menu .profile:hover::after {
    background: #1a1a1a;
}

/* Estilos para el enlace de configuración */
.navbar-menu .settings {
    color: #1a1a1a;
    position: relative;
}

.navbar-menu .settings::after {
    content: "";
    position: absolute;
    width: 100%;
    height: 2px;
    bottom: -4px;
    left: 0;
    background: transparent;
    transition: background 0.3s ease;
}

.navbar-menu .settings:hover::after {
    background: #1a1a1a;
}

/* Estilos para el enlace de ayuda */
.navbar-menu .help {
    color: #1a1a1a;
    position: relative;
}

.navbar-menu .help::after {
    content: "";
    position: absolute;
    width: 100%;
    height: 2px;
    bottom: -4px;
    left: 0;
    background: transparent;
    transition: background 0.3s ease;
}

.navbar-menu .help:hover::after {
    background: #1a1a1a;
}

/* Estilos para el enlace de contacto */
.navbar-menu .contact {
    color: #1a1a1a;
    position: relative;
}

.navbar-menu .contact::after {
    content: "";
    position: absolute;
    width: 100%;
    height: 2px;
    bottom: -4px;
    left: 0;
    background: transparent;
    transition: background 0.3s ease;
}

.navbar-menu .contact:hover::after {
    background: #1a1a1a;
}

/* Estilos para el enlace de soporte técnico */
.navbar-menu .tech-support {
    color: #1a1a1a;
    position: relative;
}

.navbar-menu .tech-support::after {
    content: "";
    position: absolute;
    width: 100%;
    height: 2px;
    bottom: -4px;
    left: 0;
    background: transparent;
    transition: background 0.3s ease;
}

.navbar-menu .tech-support:hover::after {
    background: #1a1a1a;
}

/* Estilos para el enlace de informes de bug */
.navbar-menu .bug-report {
    color: #1a1a1a;
    position: relative;
}

.navbar-menu .bug-report::after {
    content: "";
    position: absolute;
    width: 100%;
    height: 2px;
    bottom: -4px;
    left: 0;
    background: transparent;
    transition: background 0.3s ease;
}

.navbar-menu .bug-report:hover::after {
    background: #1a1a1a;
}

/* ======= MODO OSCURO AUTOMÁTICO PARA FONDOS CLAROS ======= */

/* Cuando la navbar detecta un fondo claro, cambia a modo oscuro */
.navbar.dark-mode {
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

/* Logo en modo oscuro */
.navbar.dark-mode .navbar-logo {
    color: #1a1a1a;
}

.navbar.dark-mode .navbar-logo-text {
    color: #1a1a1a;
}

.navbar.dark-mode .navbar-logo-img {
    filter: brightness(0.2) saturate(1.2);
}

/* Botón hamburguesa en modo oscuro */
.navbar.dark-mode .hamburger-line {
    background-color: #1a1a1a;
}

.navbar.dark-mode .hamburger-menu:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* Botón del carrito en modo oscuro */
.navbar.dark-mode .navbar-cart {
    color: #1a1a1a;
}

.navbar.dark-mode .navbar-cart:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* Menú de navegación en modo oscuro */
.navbar.dark-mode .navbar-menu > li > a {
    color: #1a1a1a;
}

.navbar.dark-mode .navbar-menu > li > a:hover {
    color: #d4af37;
}

/* Flecha del submenú en modo oscuro */
.navbar.dark-mode .submenu-arrow {
    color: #1a1a1a;
}

/* Submenús en modo oscuro - mantenemos el fondo claro para contraste */
.navbar.dark-mode .submenu {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.navbar.dark-mode .submenu::before {
    border-bottom-color: rgba(255, 255, 255, 0.98);
}

/* Elementos del submenú siguen siendo oscuros para mejor legibilidad */
.navbar.dark-mode .submenu a {
    color: #1a1a1a;
}

.navbar.dark-mode .submenu a:hover {
    color: #d4af37;
    background: rgba(212, 175, 55, 0.1);
}