/* ===========================
   Navbar Responsiva
   =========================== */

.custom-navbar {
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.navbar-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    justify-content: center;
}

/* Logo */
.navbar-logo {
    flex-shrink: 0;
    margin-right: auto;
}

.navbar-logo a {
    display: block;
    line-height: 0;
}

.navbar-logo img {
    height: 50px;
    width: auto;
    object-fit: contain;
}

/* Barra de búsqueda - Desktop */
.navbar-search.desktop {
    flex: 1;
    max-width: 500px;
}

.navbar-search .search-form {
    position: relative;
    display: flex;
    align-items: center;
}

.navbar-search .search-field {
    width: 100%;
    padding: 0.75rem 3rem 0.75rem 1rem;
    border: 1px solid #333;
    border-radius: 8px;
    background-color: #2a2a2a;
    color: #fff;
    font-size: 0.95rem;
    -webkit-transition: all 0.3s ease;
    transition: all 0.3s ease;
}

.navbar-search .search-field:focus {
    outline: none;
    border-color: #ff6600;
    background-color: #333;
}

.navbar-search .search-field::placeholder {
    color: #999;
}

.navbar-search .search-submit {
    position: absolute;
    right: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    -webkit-transition: color 0.3s ease;
    transition: color 0.3s ease;
}

.navbar-search .search-submit:hover {
    color: #ff6600;
}

/* Navegación - Desktop */
.navbar-menu.desktop {
    display: flex;
}

.nav-items {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 2rem;
}

.nav-item {
    position: relative;
}

.nav-item a {
    color: #fff;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    -webkit-transition: color 0.3s ease;
    transition: color 0.3s ease;
    white-space: nowrap;
    display: inline-block;
}

.nav-item a:hover {
    color: #ff6600;
}

/* Botón Tienda (mega-link) */
.nav-item.tienda-item .mega-link {
    background: none;
    border: none;
    color: #fff;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
    -webkit-transition: color 0.3s ease;
    transition: color 0.3s ease;
}

.nav-item.tienda-item .mega-link:hover {
    color: #ff6600;
}

/* Submenús Desktop */
.nav-item.has-submenu > a {
    padding-right: 1.2rem;
}

.submenu-toggle {
    position: absolute;
    right: 0;
    top: 50%;
    -webkit-transform: translateY(-50%);
    transform: translateY(-50%);
    color: #999;
    font-size: 0.8rem;
    pointer-events: none;
}

.submenu {
    position: absolute;
    top: 100%;
    left: 0;
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(15px) saturate(180%);
    -webkit-backdrop-filter: blur(15px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
    list-style: none;
    min-width: 220px;
    display: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 1000;
}

.nav-item:hover > .submenu {
    display: block;
}

.submenu-item {
    position: relative;
}

.submenu-item > a {
    display: block;
    padding: 0.75rem 1.25rem;
    color: #ddd;
    text-decoration: none;
    -webkit-transition: all 0.3s ease;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    white-space: nowrap;
}

.submenu-item > a:hover {
    background-color: rgba(255, 102, 0, 0.1);
    color: #ff6600;
    padding-left: 1.5rem;
}

.submenu-item.has-submenu > a {
    padding-right: 2rem;
}

.submenu-item .submenu-toggle {
    right: 1rem;
    color: #999;
}

/* Submenú nivel 2 (Desktop) */
.submenu.level-2 {
    top: 0;
    left: 100%;
    margin-top: 0;
    margin-left: 0.5rem;
}

.submenu-item:hover > .submenu.level-2 {
    display: block;
}

/* Carrito */
.navbar-cart {
    flex-shrink: 0;
}

.cart-toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: #fff;
    -webkit-transition: color 0.3s ease;
    transition: color 0.3s ease;
}

.cart-toggle:hover {
    color: #ff6600;
}

.cart-toggle svg {
    width: 24px;
    height: 24px;
}

.cart-count {
    position: absolute;
    top: 0;
    right: 0;
    background-color: #ff6600;
    color: #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
}

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

/* Perfil */
.navbar-perfil {
    flex-shrink: 0;
}

.perfil-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    -webkit-transition: all 0.3s ease;
    transition: all 0.3s ease;
}

.perfil-link:hover {
    background-color: #2a2a2a;
    color: #ff6600;
}

.perfil-link svg {
    width: 24px;
    height: 24px;
}

.perfil-text {
    font-size: 1rem;
    font-weight: 500;
}

/* Botones móviles */
.navbar-search-toggle.mobile,
.navbar-hamburger.mobile {
    display: none;
}

/* Menús móviles (desplegables) */
.navbar-search-mobile,
.navbar-menu-mobile {
    display: none;
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(15px) saturate(180%);
    -webkit-backdrop-filter: blur(15px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.navbar-search-mobile.active {
    display: block;
    -webkit-animation: slideDown 0.3s ease;
    animation: slideDown 0.3s ease;
}

.navbar-menu-mobile.active {
    display: block;
    -webkit-animation: slideDown 0.3s ease;
    animation: slideDown 0.3s ease;
}

/* Barra de búsqueda móvil */
.navbar-search-mobile {
    padding: 1rem 2rem;
}

.navbar-search-mobile .search-form {
    position: relative;
    display: flex;
    align-items: center;
}

.navbar-search-mobile .search-field {
    width: 100%;
    padding: 0.75rem 3rem 0.75rem 1rem;
    border: 1px solid #333;
    border-radius: 8px;
    background-color: #2a2a2a;
    color: #fff;
    font-size: 0.95rem;
}

.navbar-search-mobile .search-field:focus {
    outline: none;
    border-color: #ff6600;
    background-color: #333;
}

.navbar-search-mobile .search-submit {
    position: absolute;
    right: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
}

/* Menú móvil */
.navbar-menu-mobile {
    padding: 1rem 0;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.nav-items-mobile {
    list-style: none;
    margin: 0;
    padding: 0;
}
.nav-items-mobile a{
    text-decoration: none;
}
.nav-item-mobile {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-item-mobile:last-child {
    border-bottom: none;
}

.mobile-menu-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Nivel 1: Item principal móvil (Tienda) */
.nav-item-mobile > .mobile-menu-row > a,
.nav-item-mobile > .mobile-menu-row > .mobile-menu-label {
    display: block;
    padding: 1rem 2rem;
    color: #fff;
    text-decoration: none;
    font-size: 1.0625rem; /* ~17px - Nivel 1 móvil */
    font-weight: 600;
    line-height: 1.4;
    -webkit-transition: background-color 0.3s ease, color 0.3s ease;
    transition: background-color 0.3s ease, color 0.3s ease;
    flex: 1;
}

.nav-item-mobile a:hover {
    background-color: rgba(255, 102, 0, 0.1);
    color: #ff6600;
}

/* Span para Tienda en móvil (no navegable) */
.nav-item-mobile.tienda-mobile-item > .mobile-menu-row > .mobile-menu-label {
    cursor: default;
}

/* Toggle de submenú móvil */
.submenu-toggle-mobile {
    background: none;
    border: none;
    color: #999;
    font-size: 1.2rem;
    padding: 1rem 2rem;
    cursor: pointer;
    -webkit-transition: all 0.3s ease;
    transition: all 0.3s ease;
}

.submenu-toggle-mobile:hover {
    color: #ff6600;
}

.submenu-toggle-mobile.active {
    -webkit-transform: rotate(180deg);
    transform: rotate(180deg);
}

/* Submenús móviles */
.submenu-mobile {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    -webkit-transition: max-height 0.3s ease;
    transition: max-height 0.3s ease;
    background: rgba(0, 0, 0, 0.3);
}

.submenu-mobile.active {
    max-height: 2000px;
}

.submenu-item-mobile {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.submenu-item-mobile:last-child {
    border-bottom: none;
}

/* Nivel 2: Categorías móvil (Ciclismo, Ferretería) */
.submenu-mobile.level-1 > .submenu-item-mobile > .mobile-menu-row > a {
    padding: 0.875rem 2rem 0.875rem 3rem;
    font-size: 0.9375rem; /* ~15px - Nivel 2 móvil */
    font-weight: 500;
    line-height: 1.5;
}

/* Nivel 3: Subcategorías móvil (Bombines, Botellas) */
.submenu-mobile.level-2 > .submenu-item-mobile > a {
    display: block;
    padding: 0.75rem 2rem 0.75rem 4rem;
    font-size: 0.875rem; /* ~14px - Nivel 3 móvil */
    line-height: 1.5;
    color: #ccc;
    text-decoration: none;
    -webkit-transition: background-color 0.3s ease, color 0.3s ease;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.submenu-mobile.level-2 > .submenu-item-mobile > a:hover {
    background-color: rgba(255, 102, 0, 0.1);
    color: #ff6600;
}

/* Animación */
@-webkit-keyframes slideDown {
    from {
        opacity: 0;
        -webkit-transform: translateY(-10px);
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        -webkit-transform: translateY(-10px);
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
}

/* ===========================
   Mega menú (Desktop)
   =========================== */

.navbar-overlay {
    position: fixed;
    left: 0;
    right: 0;
    top: 0; /* se ajusta por JS al abrir */
    bottom: 0;
    background: -webkit-linear-gradient(top, rgba(0,0,0,0.7), rgba(0,0,0,0.9));
    background: linear-gradient(to bottom, rgba(0,0,0,0.7), rgba(0,0,0,0.9));
    z-index: 999; /* debajo del megamenú pero encima del contenido */
    opacity: 0;
    pointer-events: none;
    -webkit-transition: opacity 0.3s ease;
    transition: opacity 0.3s ease;
}

.navbar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.navbar-megamenu {
    position: fixed;
    left: 0;
    right: 0;
    top: 0; /* se ajusta por JS al abrir */
    background: rgba(15, 15, 15, 0.96);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    -webkit-transform: translateY(-10px);
    transform: translateY(-10px);
    -webkit-transition: opacity 0.3s ease, transform 0.3s ease;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.navbar-megamenu.active {
    opacity: 1;
    pointer-events: auto;
    -webkit-transform: translateY(0);
    transform: translateY(0);
}

.megamenu-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.megamenu-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(220px, 1fr));
    gap: 3rem;
    align-items: start; /* Alinear columnas al inicio verticalmente */
}

.mega-col {}

/* Título de categoría principal (ej: Ciclismo, Ferretería) */
.mega-title {
    color: #e6e6e6;
    font-size: 1.125rem; /* ~18px - Nivel 1: más grande */
    font-weight: 700;
    margin: 0 0 1rem 0;
    line-height: 1.4;
}

.mega-title a { 
    color: inherit; 
    text-decoration: none;
    display: inline-block;
}

.mega-title a:hover {
    color: #ff6600;
}

.mega-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Subcategorías (ej: Bombines, Botellas) */
.mega-list li a {
    display: block;
    padding: 0.5rem 0; /* Mayor espaciado vertical */
    color: #cfcfcf;
    text-decoration: none;
    font-size: 0.9375rem; /* ~15px - Nivel 2: intermedio */
    line-height: 1.5;
    -webkit-transition: color 0.2s ease, transform 0.2s ease;
    transition: color 0.2s ease, transform 0.2s ease;
}

.mega-list li a:hover {
    color: #ff6600;
    -webkit-transform: translateX(3px);
    transform: translateX(3px);
}

/* Botón Ver todos */
.mega-see-all {
    display: inline-block;
    margin-top: 1rem;
    color: #ff7233;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem; /* ~14px - Nivel 3: más pequeño */
    line-height: 1.5;
    -webkit-transition: color 0.2s ease;
    transition: color 0.2s ease;
}

.mega-see-all:hover {
    color: #ff8844;
}

/* ===========================
   Sidebar del Carrito
   =========================== */

.cart-sidebar {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 400px;
    max-width: 90vw;
    background: rgba(15, 15, 15, 0.98);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: -4px 0 30px rgba(0, 0, 0, 0.5);
    z-index: 1002;
    -webkit-transform: translateX(100%);
    transform: translateX(100%);
    -webkit-transition: transform 0.3s ease;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.cart-sidebar.active {
    -webkit-transform: translateX(0);
    transform: translateX(0);
}

.cart-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.cart-sidebar-header h3 {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.cart-close {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-transition: color 0.3s ease;
    transition: color 0.3s ease;
}

.cart-close:hover {
    color: #ff6600;
}

.cart-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.cart-empty {
    color: #999;
    text-align: center;
    padding: 2rem 0;
    font-size: 1rem;
}

.cart-items {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cart-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
}

.cart-item-image {
    flex-shrink: 0;
    width: 70px;
    height: 70px;
    border-radius: 6px;
    overflow: hidden;
}

.cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-item-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.cart-item-title {
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
}

.cart-item-price {
    color: #ff6600;
    font-size: 0.9rem;
    font-weight: 600;
}

.cart-item-quantity {
    color: #999;
    font-size: 0.85rem;
}

.cart-item-remove {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 0, 0, 0.1);
    border: none;
    color: #ff4444;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-transition: all 0.3s ease;
    transition: all 0.3s ease;
}

.cart-item-remove:hover {
    background: rgba(255, 0, 0, 0.2);
    color: #ff6666;
}

.cart-sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.125rem;
    color: #fff;
}

.cart-total strong {
    color: #ff6600;
    font-size: 1.25rem;
}

.cart-view-cart,
.cart-checkout {
    display: block;
    text-align: center;
    padding: 0.875rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    -webkit-transition: all 0.3s ease;
    transition: all 0.3s ease;
}

.cart-view-cart {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
}

.cart-view-cart:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.cart-checkout {
    background: -webkit-linear-gradient(135deg, #ff6600, #ff8833);
    background: linear-gradient(135deg, #ff6600, #ff8833);
    color: #fff;
    border: none;
}

.cart-checkout:hover {
    background: -webkit-linear-gradient(135deg, #ff7722, #ff9944);
    background: linear-gradient(135deg, #ff7722, #ff9944);
    -webkit-transform: translateY(-2px);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 102, 0, 0.3);
}

/* ===========================
   Responsive - Tablet y Móvil
   =========================== */

@media (max-width: 992px) {
    .navbar-container {
        padding: 1rem;
        gap: 1rem;
    }
        /* Mostrar botones móviles */
    .navbar-search-toggle.mobile,
    .navbar-hamburger.mobile {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0.5rem;
        color: #fff;
        -webkit-transition: color 0.3s ease;
        transition: color 0.3s ease;
    }

    /* Ocultar navegación desktop */
    .navbar-menu.desktop {
        display: none;
    }

    /* Ocultar megamenú/overlay en móvil */
    .navbar-megamenu,
    .navbar-overlay {
        display: none !important;
    }

    /* Reducir tamaño del logo */
    .navbar-logo img {
        height: 40px;
    }

    /* Ajustar perfil */
    .perfil-text {
        display: none;
    }

    .perfil-link {
        padding: 0.5rem;
    }
}

@media (max-width: 768px) {
    .navbar-container {
        gap: 0.75rem;
    }

    /* Ocultar barra de búsqueda desktop */
    .navbar-search.desktop {
        display: none;
    }

    /* Mostrar botones móviles */
    .navbar-search-toggle.mobile,
    .navbar-hamburger.mobile {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0.5rem;
        color: #fff;
        -webkit-transition: color 0.3s ease;
        transition: color 0.3s ease;
    }

    .navbar-search-toggle.mobile:hover,
    .navbar-hamburger.mobile:hover {
        color: #ff6600;
    }

    /* Menú hamburguesa SVG */
    .navbar-hamburger svg {
        display: block;
        -webkit-transition: transform 0.3s ease;
        transition: transform 0.3s ease;
    }

    .navbar-hamburger.active svg {
        -webkit-transform: rotate(90deg);
        transform: rotate(90deg);
    }

    /* Orden de elementos en móvil: Logo, Busqueda, Carrito, Perfil, Hamburguesa */
    .navbar-container {
        position: relative;
    }

    .navbar-logo {
        order: 1; /* 1er elemento */
        flex: 1;  /* Ocupa el espacio extra, empujando los iconos a la derecha */
    }

    .navbar-search-toggle {
        order: 2; /* 2do elemento */
    }

    .navbar-cart {
        order: 3; /* 3er elemento */
    }

    .navbar-perfil {
        order: 4; /* 4to elemento */
    }

    .navbar-hamburger {
        order: 5; /* 5to elemento */
    }

    /* Sidebar del carrito en móvil */
    .cart-sidebar {
        width: 100%;
        max-width: 100vw;
    }

    /* Ocultar menú desktop */
    .navbar-menu.desktop {
        display: none;
    }
}

@media (max-width: 480px) {
    .navbar-container {
        padding: 0.75rem;
    }

    .navbar-logo img {
        height: 35px;
    }
}
