/* ==========================================================================
   TARJETA DE PRODUCTO GLOBAL (PRODUCT CARD)
   ========================================================================== */

/* 1. Tarjeta contenedora principal */
.popular-product-card,
.related-product-card,
.product-card-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: #ffffff;
    border: 1px solid #f0f0f0;
    border-radius: 20px;
    padding: 16px;
    box-sizing: border-box;
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.3s cubic-bezier(0.25, 1, 0.5, 1), border-color 0.3s ease;
    height: 100%;
}

/* Efecto Flotante Eleve / Shadow al pasar el mouse */
.popular-product-card:hover,
.related-product-card:hover,
.product-card-item:hover {
    transform: translateY(-6px);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.07);
}

/* 2. Envoltorio de la Imagen con Marco Tonal Suave */
.product-image-box {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1.05;
    background-color: #f4f5f7; /* Gris suave de estudio */
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px !important; /* Margen para que respire el polo */
    box-sizing: border-box;
}

/* Variaciones dinámicas de tono pastel elegante por tarjeta */
.popular-product-card:nth-child(1) .product-image-box { background-color: #f3f4f6; }
.popular-product-card:nth-child(2) .product-image-box { background-color: #f6f5f3; }
.popular-product-card:nth-child(3) .product-image-box { background-color: #f2f5f4; }
.popular-product-card:nth-child(4) .product-image-box { background-color: #f5f3f6; }

.related-product-card:nth-child(1) .product-image-box { background-color: #f3f4f6; }
.related-product-card:nth-child(2) .product-image-box { background-color: #f6f5f3; }
.related-product-card:nth-child(3) .product-image-box { background-color: #f2f5f4; }
.related-product-card:nth-child(4) .product-image-box { background-color: #f5f3f6; }

/* Configuración de la imagen */
.product-image-box img.img-primary,
.product-image-box img.img-secondary {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important; /* Ajuste orgánico sin distorsión */
    mix-blend-mode: multiply; /* Fusiona el fondo blanco del polo con el fondo suave */
    display: block;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.product-image-box .img-secondary {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    opacity: 0;
    pointer-events: none;
}

.product-image-box.has-hover-image:hover .img-primary {
    opacity: 0;
}

.product-image-box.has-hover-image:hover .img-secondary {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.03);
}

/* Etiqueta / Badge "Oferta" sobre la imagen */
.product-image-box .onsale {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 5;
    background-color: #111111;
    color: #ffffff;
    font-family: var(--gn-font-headings, 'Syne', sans-serif);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 4px 10px;
    border-radius: 4px;
    line-height: 1;
    margin: 0;
    min-height: auto;
    min-width: auto;
}

/* 3. Swatches / Puntos de variación & Tooltip Flotante */
.product-swatches-wrapper {
    min-height: 28px;
    margin-top: 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.color-swatches-list {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Anillo exterior con borde sutil translúcido */
.swatch-ring {
    position: relative; /* Indispensable para posicionar el tooltip */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.15);
    background-color: #ffffff;
    box-sizing: border-box;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.swatch-ring:hover {
    border-color: #111111;
    transform: scale(1.15);
}

/* Círculo de color interior */
.swatch-circle {
    display: block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); /* Sombra suave para que el blanco no se pierda */
}

/* Tooltip caja de texto */
.swatch-ring::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    background-color: #111111;
    color: #ffffff;
    font-family: var(--gn-font-headings, 'Syne', sans-serif);
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Tooltip flechita */
.swatch-ring::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(2px);
    border-width: 5px 5px 0 5px;
    border-style: solid;
    border-color: #111111 transparent transparent transparent;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 10;
}

.swatch-ring:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-8px);
}

.swatch-ring:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-3px);
}

/* Texto del número restante (+5, +3) */
.swatch-more {
    font-family: var(--gn-font-headings, 'Syne', sans-serif);
    font-size: 11px;
    font-weight: 600;
    color: #666666;
    margin-left: 3px;
}

/* 4. Información de Producto */
.product-info-box {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.product-card-title {
    font-family: var(--gn-font-headings, 'Syne', sans-serif);
    font-size: clamp(0.875rem, 0.7614rem + 0.5682vw, 1rem);
    font-weight: 700;
    line-height: 1.35;
    margin: 0 0 6px 0;
    color: #111111;
}

.product-card-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.product-card-title a:hover {
    color: var(--gn-accent-color, #f8cb3a);
}

.product-card-price {
    font-size: 16px;
    font-weight: 600;
    color: #444444;
    margin-bottom: 14px;
    font-family: var(--gn-font-headings, 'Syne', sans-serif);
}

/* Corrección de Precios en Rebaja */
.product-card-price del {
    color: #999999 !important;
    font-weight: 400 !important;
    text-decoration: line-through !important; /* Tachado limpio */
    margin-right: 8px !important; /* Separación con el precio final */
    display: inline-block;
}

.product-card-price ins {
    background: transparent !important;
    text-decoration: none !important; /* Quita el subrayado */
    font-weight: 700 !important;
    color: #111111 !important;
    display: inline-block;
}

/* 5. Botón de Acción Estilo Premium */
.pop-btn-add-to-cart,
.related-btn-add-to-cart,
.popular-product-card .button,
.related-product-card .button {
    width: 100%;
    text-align: center;
    background-color: #111111 !important;
    color: #ffffff !important;
    font-family: var(--gn-font-headings, 'Syne', sans-serif) !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    letter-spacing: 0.8px !important;
    text-transform: uppercase !important;
    padding: 12px 16px !important;
    text-decoration: none !important;
    border: none !important;
    box-sizing: border-box;
    transition: background-color 0.25s ease, color 0.25s ease, transform 0.2s ease !important;
    display: block;
}

.pop-btn-add-to-cart:hover,
.related-btn-add-to-cart:hover,
.popular-product-card .button:hover,
.related-product-card .button:hover {
    background-color: var(--gn-accent-color, #f8cb3a) !important;
    color: #111111 !important;
}

/* Responsive exclusivo de Tarjetas */
@media (max-width: 576px) {
    .product-image-box {
        padding: 10px !important;
    }

    .pop-btn-add-to-cart,
    .popular-product-card .button {
        padding: 8px 10px !important;
        font-size: 10px !important;
    }
}



/* ==========================================================================
   ESTADOS DE BOTÓN AJAX (CARGANDO Y AÑADIDO)
   ========================================================================== */

/* Botón en estado de carga */
.pop-btn-add-to-cart.loading {
    opacity: 0.7;
    position: relative;
    pointer-events: none;
}

.pop-btn-add-to-cart.loading::after {
    content: "";
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 8px;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: popSpinner 0.6s linear infinite;
    vertical-align: middle;
}

/* Spinner de rotación */
@keyframes popSpinner {
    to {
        transform: rotate(360deg);
    }
}

/* Ocultar la palomita/check por defecto de WooCommerce si rompe el diseño */
.pop-btn-add-to-cart + .added_to_cart,
.related-btn-add-to-cart + .added_to_cart {
    display: none !important;
}



/* ==========================================================================
   SECCIÓN: PRODUCTOS RELACIONADOS (ESTRUCTURA Y GRID)
   ========================================================================== */

.sibenito-related-products {
    width: 100%;
    padding: 60px 0 100px;
    box-sizing: border-box;
}

.related-section-title {
    font-family: var(--gn-font-headings, 'Syne', sans-serif);
    font-size: 30px;
    font-weight: 700;
    color: #111111;
    margin: 0 0 35px 0;
    letter-spacing: -0.5px;
    border-top: 4px solid #898989;
    padding-top: 60px;
}

/* Grid de productos relacionados */
.related-products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 25px;
}

/* Responsive Grid Productos Relacionados */
@media (max-width: 1024px) {
    .related-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (max-width: 576px) {
    .related-section-title {
        font-size: 26px;
    }

    .related-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
}