/* =============================================================
   productCard.css
   Global styles for the atomic product card built by
   js/productCard.js. Included in header/header.php so the card
   renders consistently in every context (home carousels, pasillo
   grid, Product.php suggestions, cart modals, etc.).

   Rules extracted from css/main.css and css/StyleProductsByGroup.php,
   stripped of parent-scoped selectors so they apply universally.
   ============================================================= */


/* -------- Wrapper / layout -------- */

.product-container-carousel {
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: stretch;
    -ms-flex-align: stretch;
    align-items: stretch;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    align-items: center;
}

.groups-product-item {
    padding: 0;
    margin-bottom: 5%;
    text-align: center;
    align-items: center;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.itemProductoPasilloContainer {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.groups-product-item .product-container-carousel {
    width: 100%;
    height: 100%;
    justify-content: flex-start;
    gap: 12px;
}


/* -------- Image wrapper + badges -------- */

.offer-image-wrapper {
    position: relative;
    /* padding-top:100% siempre referencia el ANCHO del contenedor, nunca su alto,
       por lo que funciona en cualquier contexto (flex-column, grid, block) sin
       depender de que la imagen haya cargado. */
    width: 100%;
    padding-top: 100%;
    height: 0;
    overflow: hidden;
    background: var(--gray-100, #f0f0f0);
}

/* shimmer visible mientras la imagen lazy-carga */
.offer-image-wrapper::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
    pointer-events: none;
}

/* quitar shimmer y fondo del skeleton una vez que la imagen termina de cargar.
   El fondo gris servía de placeholder, pero como .imagePasillo usa
   object-fit:contain + padding, deja ver el gris detrás de la imagen (parece
   una "sombra"); por eso al cargar se vuelve transparente. */
.offer-image-wrapper.img-loaded::after {
    display: none;
}

.offer-image-wrapper.img-loaded {
    background: transparent;
}

.image-container-aisle-responsive {
    width: 100%;
    margin: 0 auto;
}

/* Con el wrapper usando padding-top, el <picture> debe llenarlo en absoluto */
.product-picture {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

.imagePasillo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4%;
    box-sizing: border-box;
}

.imagePasillo[src*="no-image"] {
    opacity: 0.4;
}

.offer-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 12px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ff8e6a, var(--brand-primary));
    color: var(--gray-900);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    box-shadow: 0 10px 25px rgba(204, 33, 40, 0.35);
    animation: pulseGlow 2.4s ease-in-out infinite;
}

.offer-badge span {
    line-height: 1;
}

.offer-badge .offer-badge__percent {
    font-size: 20px;
}

@keyframes pulseGlow {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(204, 33, 40, 0.45);
    }
    60% {
        transform: scale(1.04);
        box-shadow: 0 0 20px rgba(204, 33, 40, 0.4);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(204, 33, 40, 0.45);
    }
}

.sello_agotado {
    position: absolute;
    top: 0%;
    left: 0%;
    width: 100%;
    background: var(--white);
    padding-top: 30%;
    padding-bottom: 30%;
    padding-left: 6%;
    padding-right: 6%;
    border-radius: var(--borderRadius);
    color: var(--brand-primary);
    cursor: pointer;
    font-size: var(--FONT_SIZE_TITLE);
    opacity: 80%;
}

/* Image-based "NEW COLLECTION" tag used on aisle/carousel product cards.
   Renders the PNG asset at img/new-collection-tag.png as an absolutely
   positioned overlay on the bottom-left corner of the product image. Kept
   outside the description flow so cards without the tag align identically
   with badged cards. Scoped outside #nc-carousel so it can appear on any
   surface that consumes buildProductCard. */
.nc-card-tag {
    position: absolute;
    bottom: 10px;
    left: 10px;
    width: 90px;
    max-width: 90px;
    height: auto;
    z-index: 2;
    pointer-events: none;
}


/* -------- Favorites icon -------- */

.iconFavProducts {
    width: 16px;
    opacity: .8;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible;
    flex: 0 0 15%;
}

.iconFavProducts:hover {
    opacity: 1;
}

.iconFavProducts img {
    width: 25px !important;
}


/* -------- Description / name -------- */

.product-description-carousel {
    text-align: center;
    font-size: var(--FONT_SIZE_PRIMARY);
    color: #141414;
    margin-top: 7%;
    width: 100%;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
}

.product-name-and-fav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    flex-wrap: nowrap;
}

.product-description-carousel .product-name-and-fav a,
.product-description-carousel .product-name-and-fav a p {
    display: block !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
    width: 100%;
}

.product-name-carousel {
    text-align: left;
    line-height: 1.5;
    font-size: var(--FONT_SIZE_PRIMARY);
    flex: 0 0 85%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: bolder;
    height: auto;
}

.product-name-carousel a p::first-letter {
    text-transform: uppercase;
}


/* -------- Prices -------- */

.itemAdditionalsContainer {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin-top: auto;
}

.itemAdditionalsContainer.is-suggestion {
    flex-wrap: wrap;
}

.itemPriceContainer {
    flex: 1;
}

.productPriceCarousel {
    text-align: left;
}

.offer-price-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.offer-price-wrapper.no-offer {
    flex-direction: row;
    align-items: center;
}

.offer-price-wrapper.has-offer .currentPrice {
    color: #181818;
}

.offer-price-wrapper.has-offer .productOfferPrice {
    font-size: 1rem;
    margin-bottom: 3px;
}

.currentPrice {
    color: var(--brand-secondary);
    font-size: 20px;
    line-height: 29.26px;
    font-weight: 700;
    text-transform: uppercase;
}

.productOfferPrice {
    color: #6c6c6c;
    font-size: 0.95rem;
    line-height: 1.2;
    font-weight: 600;
    text-decoration: line-through;
    text-decoration-color: var(--brand-primary);
    text-decoration-thickness: 2px;
    letter-spacing: 0.01em;
    margin-left: 8px;
}


/* -------- Color swatches (rendered by RSColorSwatches) -------- */

.color-swatches-placeholder {
    display: none;
}

.color-swatches-pasillo {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    margin-top: 8px;
    padding: 0;
    flex-wrap: nowrap;
    overflow: hidden;
}

.color-swatches-pasillo .color-swatch {
    width: 20%;
    max-width: 50px;
    aspect-ratio: 1 / 1;
    height: auto;
    border-radius: 4px;
    object-fit: contain;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    transition: border-color 0.15s ease;
    flex-shrink: 0;
    padding: 2px;
    box-sizing: border-box;
}

.color-swatches-pasillo .color-swatch:hover {
    border-color: #999;
}

.color-swatches-pasillo .color-swatch.active {
    border-color: var(--brand-primary, #333);
    border-width: 2px;
    padding: 1px;
}

.color-swatches-pasillo .more-colors {
    font-size: 12px;
    font-weight: 700;
    color: var(--white, #fff);
    background: var(--brand-primary, #cc2128);
    border: 1px solid var(--brand-primary, #cc2128);
    border-radius: 4px;
    padding: 4px 8px;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    width: 20%;
    max-width: 50px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    letter-spacing: 0.02em;
    transition: filter 0.15s ease;
}

.color-swatches-pasillo .more-colors:hover {
    filter: brightness(1.1);
    color: var(--white, #fff);
    text-decoration: none;
}


/* -------- Responsive -------- */


@media screen and (min-width: 577px) and (max-width: 900px) {
    .color-swatches-pasillo {
        gap: 5px;
    }
    .color-swatches-pasillo .color-swatch,
    .color-swatches-pasillo .more-colors {
        width: 32px;
        max-width: 32px;
        height: 32px;
        aspect-ratio: 1 / 1;
        border-radius: 6px;
    }
    .color-swatches-pasillo .more-colors {
        font-size: 11px;
    }
}

@media screen and (max-width: 576px) {
    .color-swatches-pasillo {
        gap: 4px;
        margin-top: 6px;
    }
    .color-swatches-pasillo .color-swatch {
        width: 28px;
        max-width: 28px;
        height: 28px;
        aspect-ratio: 1 / 1;
        border-radius: 50%;
        padding: 1px;
        border: 1px solid #e0e0e0;
        flex: 0 0 auto;
    }
    .color-swatches-pasillo .color-swatch.active {
        border-width: 2px;
        padding: 0;
    }
    .color-swatches-pasillo .more-colors {
        width: 28px;
        max-width: 28px;
        height: 28px;
        aspect-ratio: 1 / 1;
        border-radius: 50%;
        font-size: 10px;
        font-weight: 700;
        padding: 0;
        flex: 0 0 auto;
    }
}

@media (max-width: 541px) {
    .groups-product-item {
        margin-bottom: 44.11px;
    }
}


.product-name-carousel,
.product-name-carousel p { text-transform: uppercase; }
.sello_agotado { text-transform: uppercase; }

.card-in-cart-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--brand-primary);
    color: #fff;
    border-radius: 20px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 2;
    pointer-events: none;
}


/* -------- Skeleton placeholder card (carousel loading state) --------
   Reuses the real card layout classes (.product-container-carousel /
   .offer-image-wrapper / .product-description-carousel) so the loading
   state reserves the exact same height as the loaded product cards.
   The image placeholder is a 1:1 square that tracks the owl item width,
   so it matches the real .imagePasillo height at every breakpoint and the
   carousel container does not shift when products arrive. */
.skeleton-card .skeleton-box {
    position: relative;
    overflow: hidden;
    background: var(--gray-100, #eee);
}

.skeleton-card .skeleton-box::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, var(--gray-200, #e2e2e2), transparent);
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

/* El wrapper .offer-image-wrapper ya reserva el cuadrado via padding-top;
   skeleton-card__img rellena ese espacio en absolute igual que product-picture */
.skeleton-card__img {
    position: absolute;
    inset: 0;
}

.skeleton-card__line {
    height: 14px;
    border-radius: 6px;
    margin-top: 12px;
}

.skeleton-card__line--name { width: 85%; }
.skeleton-card__line--price { width: 55%; height: 18px; }
.skeleton-card__line--swatches { width: 60%; height: 22px; margin-top: 14px; }

@keyframes skeleton-shimmer {
    100% { transform: translateX(100%); }
}

/* -------- Skeleton de banners (imágenes y videos) --------
   Mientras la imagen/video del banner carga, se muestra un placeholder con
   shimmer y se reserva una altura parecida a la del banner, evitando que el
   contenido "aparezca de la nada" (CLS). La clase .is-loading la quita el
   onload/onerror de la imagen (buildResponsivePicture) o el evento
   'loadeddata' del video (loadLazyVideo) en loadStructure.js.
   Se ubica aquí porque productCard.css se carga directo con cache-busting,
   reutilizando el keyframe skeleton-shimmer ya definido arriba. */
.banner_picture,
.banner_video {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Video: letterbox negro (mientras no haya poster difuminado). El video va contain. */
.banner_video {
    background: #000;
}

/* Fondo difuminado para banners de imagen: reusa la MISMA imagen (mismo srcset, sin
   descarga extra), escalada + borrosa, detras de la imagen en object-fit:contain. */
.banner_blur_bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}
.banner_blur_bg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(24px);
    transform: scale(1.12);
}
.banner_picture_fg {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
}
.banner_picture .banner_picture_img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Solo en los carruseles de banner: el wrap (a/span) llena el alto del slide para que
   el fondo rellene las franjas. No afecta a los carruseles de producto. */
[class*="splide_banner"] .splide__slide > a,
[class*="splide_banner"] .splide__slide > span {
    display: block;
    width: 100%;
    height: 100%;
}

.banner_picture.is-loading,
.banner_video.is-loading {
    overflow: hidden;
    background-color: var(--gray-100, #eee);
    /* Fallback solo para banners sin altura fija. Se mantiene moderado para no
       superar la altura real de banners que sí la traen (ya reservada por el
       inline height + los atributos width/height de la imagen) y evitar saltos. */
    min-height: 200px;
}

.banner_picture.is-loading::after,
.banner_video.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, var(--gray-200, #e2e2e2), transparent);
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
    z-index: 1;
}

/* La imagen aparece con un fundido suave una vez cargada */
.banner_picture .banner_picture_img {
    transition: opacity .3s ease;
}

.banner_picture.is-loading .banner_picture_img,
.banner_video.is-loading video {
    opacity: 0;
}
