:root {
    --primary-color: #007dc3;
    --primary-hover: #0066a0;
    --dark-bg: #111;
    --light-bg: #f8fafc;
    --text-main: #1e293b;
    --text-muted: #64748b;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background-color: var(--light-bg);
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

/* Navbar */
.main-navbar {
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.nav-link {
    font-weight: 500;
    transition: color 0.3s ease;
}

/* Accordion-style Nested Dropdowns with Smooth Transition */
.dropdown-menu .dropdown-menu {
    position: static !important;
    display: block !important;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    border-radius: 0 0 12px 12px !important; /* Redondeado solo abajo para todos los niveles */
    box-shadow: none !important;
    padding: 0 !important; /* Eliminamos el padding para que los ítems toquen los bordes */
    margin: 0 !important;
    background: rgba(0, 125, 195, 0.1) !important;
    width: 100% !important;
    transition: max-height 0.4s ease-in-out, opacity 0.3s ease !important;
}

.dropdown-menu .dropdown-menu.show {
    max-height: 3000px;
    opacity: 1;
}

/* Sangría para los ítems dentro de los submenús para jerarquía (DESACTIVADO POR EL MOMENTO) */
.dropdown-menu .dropdown-menu .dropdown-item,
.dropdown-menu .dropdown-menu .dropdown-divider {
    padding-left: 1.5rem !important; /* Volvemos al estándar para que no se sumen excesivamente */
    /* padding-left: 2.5rem !important; */
}

/* Sangría aún mayor para niveles más profundos (DESACTIVADO POR EL MOMENTO) */
.dropdown-menu .dropdown-menu .dropdown-menu .dropdown-item {
    padding-left: 1.5rem !important;
    /* padding-left: 3.5rem !important; */
}

/* Estilo para el botón "Ver todo" al final de los submenús (Reset agresivo para todos los niveles) */
.dropdown-menu .dropdown-menu .dropdown-menu .btn-ver-todo,
.dropdown-menu .dropdown-menu .btn-ver-todo,
.dropdown-menu .btn-ver-todo {
    background-color: transparent !important; /* Sin fondo */
    border-radius: 0 0 12px 12px !important; /* Redondeado solo abajo */
    margin: 0 !important;
    padding-top: 8px !important;
    padding-bottom: 8px !important;
    padding-left: 0 !important; /* Reset total de sangría */
    padding-right: 0 !important;
    border-top: 1px solid rgba(0, 125, 195, 0.1) !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 8px;
    width: 100% !important;
    text-align: center !important;
}

.btn-ver-todo:hover {
    background-color: rgba(0, 125, 195, 0.2) !important;
}

/* Arrow rotation on toggle */
.dropdown-toggle::after {
    transition: transform 0.3s ease !important;
    display: inline-block !important;
    vertical-align: middle !important;
}

.dropdown-toggle[aria-expanded="true"]::after {
    transform: rotate(180deg) !important;
}

/* Fix for nested toggles spacing and look */
.dropdown-item.dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
    transition: background-color 0.3s ease, color 0.3s ease !important;
}

/* Remove default vertical padding from dropdown menus */
.dropdown-menu {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    overflow: hidden; /* To ensure the border-radius of the parent cuts the background of first/last items */
}

/* Animación de entrada para los menús principales (desplazamiento suave) - SOLO ESCRITORIO */
@media (min-width: 992px) {
    .navbar-nav > .nav-item > .dropdown-menu {
        display: block !important;
        visibility: hidden;
        opacity: 0;
        transform: translateY(-20px); /* Empieza más arriba para que "baje" */
        transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.3s ease !important;
        pointer-events: none;
    }

    .navbar-nav > .nav-item > .dropdown-menu.show {
        visibility: visible;
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }
}

/* Ajustes para Móvil: Evitar espacios y mejorar legibilidad */
@media (max-width: 991px) {
    .navbar-collapse {
        padding: 2rem 0;
        max-height: 85vh;
        overflow-y: auto;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE / Edge */
    }
    
    .navbar-collapse::-webkit-scrollbar {
        display: none; /* Chrome, Safari, Opera */
    }
    
    .navbar-nav {
        gap: 0.5rem; /* Espacio controlado entre ítems */
    }

    .nav-item {
        width: 100%;
        text-align: center;
    }

    .nav-link {
        padding-top: 0.8rem !important;
        padding-bottom: 0.8rem !important;
        font-size: 1.1rem;
    }

    .dropdown-item {
        color: rgba(255,255,255,0.9) !important;
        padding-top: 0.7rem !important;
        padding-bottom: 0.7rem !important;
    }

    /* En móvil el dropdown debe ser estático para el acordeón y no ocupar espacio oculto */
    .navbar-nav > .nav-item > .dropdown-menu {
        position: static !important;
        display: block !important; /* Forzamos block para que la animación de max-height funcione */
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        float: none;
        width: 100%;
        margin: 0;
        border: none;
        background: rgba(0, 125, 195, 0.1) !important;
        transition: max-height 0.4s ease-in-out, opacity 0.3s ease !important;
    }

    .navbar-nav > .nav-item > .dropdown-menu.show {
        max-height: 3500px; /* Suficiente para categorías con muchos hijos */
        opacity: 1;
    }
}

/* Estilo para el ítem padre cuando está expandido (acordeón abierto) */
.dropdown-item.dropdown-toggle[aria-expanded="true"] {
    background-color: var(--primary-color) !important;
    color: #fff !important;
}

/* Evitar fondo blanco residual al cerrar o perder el foco */
.dropdown-item:focus, .dropdown-item:active {
    background-color: transparent !important;
    color: inherit;
}

/* Pero mantener el hover primario */
.dropdown-menu .dropdown-item:hover {
    background-color: var(--primary-color) !important;
    color: #fff !important;
}

/* Gallery & Ticker */
.image-ticker-container {
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    padding: 20px 0;
    background: #f1f5f9;
}

.image-ticker {
    display: inline-flex;
    animation: ticker-move 20s linear infinite;
}

.image-ticker:hover {
    animation-play-state: paused;
}

@keyframes ticker-move {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.ticker-item {
    flex: 0 0 280px;
    height: 200px;
    margin-right: 20px;
    border-radius: 15px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(0,0,0,0.08);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
    display: block;
}

.ticker-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.15);
}

.ticker-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Lupita Overlay */
.lupita-trigger {
    position: relative;
    display: block;
    cursor: zoom-in;
    overflow: hidden;
}

.lupita-overlay {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: var(--primary-color);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 5;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.lupita-trigger:hover .lupita-overlay {
    opacity: 1;
    transform: scale(1);
}

/* Floating WhatsApp */
.btn-whatsapp-floating {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background-color: #25d366;
    color: #fff !important;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
    z-index: 9999;
    text-decoration: none;
}

.btn-whatsapp-floating::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: #25d366;
    opacity: 0.6;
    z-index: -1;
    animation: pulse-whatsapp 2s infinite;
}

@keyframes pulse-whatsapp {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* Gallery Layout & Aspect Ratio */
#productGallery {
    aspect-ratio: 1 / 1;
    background-color: #fff;
}

#productGallery .carousel-inner,
#productGallery .carousel-item {
    height: 100%;
}

#productGallery .carousel-item a {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
}

#productGallery img {
    max-height: 100%;
    max-width: 100%;
    width: auto !important;
    height: auto !important;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.gallery-thumbs {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 0;
    justify-content: center;
    scrollbar-width: none;
}

.gallery-thumbs::-webkit-scrollbar {
    display: none;
}

.thumb-item {
    flex: 0 0 100px;
    height: 75px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    overflow: hidden;
}

.thumb-item.active {
    border-color: var(--primary-color);
}

.thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* General Utilities */
.card-premium {
    border: none;
    border-radius: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

.card-premium:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 25px rgba(0,0,0,0.1);
}

@media (max-width: 767px) {
    #productGallery {
        aspect-ratio: 1 / 1;
    }
}

/* Category Card Slider Arrows */
.carousel-control-prev, .carousel-control-next {
    width: 15%;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10; /* Above stretched link */
}

.card:hover .carousel-control-prev, 
.card:hover .carousel-control-next {
    opacity: 1;
}

.carousel-control-prev-icon, .carousel-control-next-icon {
    background-color: rgba(0,0,0,0.3);
    background-size: 50% 50%;
    border-radius: 50%;
    padding: 15px;
}

/* Show slider arrows on mobile always */
@media (max-width: 767px) {
    .carousel-control-prev, .carousel-control-next {
        opacity: 0.8 !important;
    }
    .carousel-control-prev-icon, .carousel-control-next-icon {
        padding: 12px; /* Slightly smaller for mobile */
    }
}

/* Ensure Carousel is above stretched-link to allow swipe/clicks on buttons */
.card .carousel {
    position: relative;
    z-index: 5;
}

/* Balanced Aspect Ratio and sizing for Gallery */
#productGallery {
    aspect-ratio: 4 / 3 !important; /* Back to 4:3 for better fit on desktop */
    max-height: 550px;
    width: 100%;
    max-width: 750px;
    margin: 0 auto;
    background-color: #fff;
}

#productGallery .carousel-inner, 
#productGallery .carousel-item, 
#productGallery .carousel-item a {
    height: 100%;
    width: 100%;
}

#productGallery img {
    max-height: 100%;
    max-width: 100%;
    width: auto !important;
    height: auto !important;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

@media (max-width: 767px) {
    #productGallery {
        aspect-ratio: 1 / 1 !important; /* Keep square on mobile as requested before */
        max-height: none;
    }
}


@media (max-width: 767px) {
    .thumb-item {
        flex: 0 0 30% !important; /* Prueba con 20% para que entren 5 por fila */
        height: auto !important; 
        aspect-ratio: 1 / 1; /* Opcional: hacerlas cuadraditas para que ocupen menos espacio vertical */
    }
}


/* --- SISTEMA DE BUSQUEDA PREMIUM --- */

/* Resaltado de terminos */
mark {
    padding: 0;
}

/* Sugerencias en app-buscador.php */
.search-suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    z-index: 1100;
    margin-top: 5px;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 1rem !important;
}

.suggestion-label { 
    font-size: 0.7rem; 
    text-transform: uppercase; 
    letter-spacing: 0.5px;
}

.list-group-item-action {
    transition: all 0.2s ease;
}

.list-group-item-action:hover {
    background-color: #f8faff;
    padding-left: 1.25rem !important;
}

/* Navbar Search Overlay */
.search-navbar-overlay {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 2000;
    display: none;
    opacity: 0;
    transition: all 0.3s ease;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.search-navbar-overlay.active {
    display: block;
    opacity: 1;
}

.search-container-inner {
    width: 100%;
    max-width: 900px;
    position: relative;
}

@media (min-width: 992px) {
    .search-container-inner {
        width: 65%;
    }
}

#navbarSearchInput::placeholder { color: #aaa; }
#navbarSearchInput:focus { box-shadow: none; outline: none; }

/* Resultados AJAX dentro de la Navbar */
.navbar-search-results {
    background: white;
    max-height: 400px;
    overflow-y: auto;
    width: 100%;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 2001;
    margin-top: 15px;
}

.navbar-search-results .suggestion-label { 
    font-size: 0.75rem; 
    text-transform: uppercase; 
    color: #999; 
    padding: 15px 15px 5px; 
    font-weight: bold; 
    letter-spacing: 1px;
}
