(function () {
    function swap(node) {
    if (!node) return;
    const t = (node.textContent || "").trim();
    if (t === "favorite") node.textContent = "star";
    else if (t === "favorite_border") node.textContent = "star_border";
}

    function patch(ctx) {
(ctx || document).querySelectorAll(".wishlist-button-add .material-icons").forEach(swap);
}

// Primera pasada
document.addEventListener("DOMContentLoaded", function(){ patch(document); });

// Re-patch en eventos de PS (Ajax, quickview, combinación, etc.)
if (window.prestashop && prestashop.on) {
["updatedProduct","updateProduct","updatedCart","updateCart","clickQuickView"].forEach(ev => {
try { prestashop.on(ev, function(){ patch(document); }); } catch(e) {}
});
}

// Observar nuevos nodos (listado paginación/Ajax)
const mo = new MutationObserver(muts => muts.forEach(m => {
m.addedNodes && m.addedNodes.forEach(n => patch(n));
}));
mo.observe(document.documentElement, { childList: true, subtree: true });
})();

/* Ocultar SOLO el flotante original en la esquina */
.thumbnail-container > .wishlist-button-add { display: none !important; }

/* Contenedor derecha: fila flex, centrado vertical */
.product-miniature .product-price-and-shipping .col-md-4.col-xs-4 .atc_div,
.product-miniature .product-actions,
.product-miniature .add-to-cart {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: .5rem;
}

/* Tamaños iguales para centrar perfecto */
.product-miniature .wishlist-button-add,
.product-miniature .add_to_cart {
    height: 34px;                 /* ajusta a la altura real de tu botón */
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.product-miniature .wishlist-button-add{
    background: none !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Estrella azul corporativo */
.product-miniature .wishlist-button-add .material-icons{
    line-height: 1;
    font-size: 22px;
    color: #145690 !important;
}
.products article .wishlist-button-add{
    top: 0rem !important;
    right: 0rem !important;
}
/* Oculta el flotante de esquina también en la PDP si lo hubiera */
.product .thumbnail-container > .wishlist-button-add { display: none !important; }

/* El título de la PDP se usa como contenedor del botón */
.product h1.h1, .product .h1 { position: relative; }

/* Botón al lado derecho del título */
.wishlist-button-add.wishlist-button-product{
    position: absolute !important;
    right: 0 !important;
    top: 0 !important;
    background: none !important;
    border: 0 !important;
    box-shadow: none !important;
    width: 34px; height: 34px;           /* homogéneo con el botón de carrito del listado */
    display: inline-flex; align-items: center; justify-content: center;
}

/* Solo la estrella en color corporativo */
.wishlist-button-add.wishlist-button-product .material-icons{
    line-height: 1;
    font-size: 22px;
    color: #145690 !important;
}
