/* #region DIDEMEX - Product Card */

/*
 * Tarjeta DAF heredada.
 * Se conserva porque puede seguir utilizándose fuera del loop nativo de WooCommerce.
 */

.daf-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0.75rem;
    overflow: hidden;

    border: 1.5px solid #111111;
    border-radius: 0.875rem;
    background: #ffffff;
}

.daf-card__media {
    display: block;
    margin-bottom: 0.625rem;
    overflow: hidden;
    border-radius: 0.625rem;
}

.daf-card__media img {
    display: block;
    width: 100%;
    height: auto;
}

.daf-card__body {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    text-align: center;
}

.daf-card__title {
    margin: 0.375rem 0 0.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
}

.daf-card__title a {
    color: #111111;
    text-decoration: none;
}

.daf-card__price {
    margin-bottom: 0.625rem;
    color: #d80000;
    font-weight: 700;
}

.daf-card a.daf-btn-options.button,
.daf-card a.daf-btn-options.button:visited {
    display: block !important;
    width: 100% !important;
    margin-top: auto;
    padding: 0.625rem 0;

    border: 0 !important;
    border-radius: 0.375rem;
    background: #d80000 !important;
    box-shadow: none !important;
    color: #ffffff !important;
    opacity: 1 !important;

    font-weight: 700;
    text-align: center;
    text-decoration: none !important;
    text-transform: uppercase;
}

.daf-card a.daf-btn-options.button:hover {
    background: #b30000 !important;
    color: #ffffff !important;
    opacity: 1 !important;
}

/* #endregion DIDEMEX - Product Card */


/* #region DIDEMEX - SHOP - WOO PRODUCT CARDS */

/* #region Variables */

:root {
    --didemex-card-bg: #ffffff;
    --didemex-card-border: #eeeeee;
    --didemex-card-border-hover: #d8e6ff;
    --didemex-card-text: #202020;
    --didemex-filter-muted: #626262;
    --didemex-card-blue: #0066ff;
    --didemex-card-danger: #d93025;
    --didemex-card-radius: 1.25rem;
    --didemex-card-shadow-hover: 0 0.75rem 2rem rgba(0, 102, 255, 0.12);

    /*
     * Acento de descuento: mismo naranja del gradiente del badge
     * (#d93025 -> #ff6a00), usado en baja opacidad para el borde
     * de la tarjeta y el halo del badge.
     */
    --didemex-card-border-sale: rgba(255, 106, 0, 0.35);
    --didemex-card-border-sale-hover: rgba(255, 106, 0, 0.65);
    --didemex-card-shadow-sale-hover: 0 0.75rem 2rem rgba(255, 106, 0, 0.10);
    --didemex-badge-halo-color: rgba(255, 106, 0, 0.55);
}

/* #endregion Variables */


/* #region Card Base */

body.woocommerce ul.products li.product,
body.woocommerce-page ul.products li.product {
    position: relative;
    padding: clamp(0.75rem, 0.6rem + 0.6vw, 1rem) !important;
    overflow: visible !important;

    border: 1px solid var(--didemex-card-border);
    border-radius: var(--didemex-card-radius);
    background: var(--didemex-card-bg);

    transition:
        transform 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease;
}

body.woocommerce ul.products li.product:hover,
body.woocommerce-page ul.products li.product:hover {
    transform: translateY(-0.1875rem);
    border-color: var(--didemex-card-border-hover);
    box-shadow: var(--didemex-card-shadow-hover);
}

body.woocommerce ul.products li.product.sale,
body.woocommerce-page ul.products li.product.sale {
    padding-top: 1rem !important;
}

/* #endregion Card Base */


/* #region Sale Card Highlight */

/*
 * Refuerzo visual muy sutil para tarjetas con descuento.
 * Usa la clase nativa `.sale` que WooCommerce agrega a li.product
 * (ver #region Card Base), no un selector genérico ni :has().
 * Solo cambia border-color/box-shadow, nunca el grosor del borde
 * ni el transform, para no alterar el equal height ni el layout.
 */
body.woocommerce ul.products li.product.sale,
body.woocommerce-page ul.products li.product.sale {
    border-color: var(--didemex-card-border-sale);
}

body.woocommerce ul.products li.product.sale:hover,
body.woocommerce-page ul.products li.product.sale:hover {
    border-color: var(--didemex-card-border-sale-hover);
    box-shadow: var(--didemex-card-shadow-sale-hover);
}

/* #endregion Sale Card Highlight */


/* #region Product Link and Image */

body.woocommerce ul.products li.product a.woocommerce-LoopProduct-link,
body.woocommerce-page ul.products li.product a.woocommerce-LoopProduct-link {
    display: flex;
    flex-direction: column;
    height: 100%;
}

body.woocommerce ul.products li.product a img,
body.woocommerce-page ul.products li.product a img {
    display: block;
    width: 100%;
    max-width: 12.5rem;
    height: 9.5rem;
    margin: 0 auto 0.05rem !important;
    object-fit: contain;

    transition: transform 0.18s ease;
}

body.woocommerce ul.products li.product:hover a img,
body.woocommerce-page ul.products li.product:hover a img {
    transform: scale(1.025);
}

/* #endregion Product Link and Image */


/* #region Product Title */

body.woocommerce ul.products li.product .woocommerce-loop-product__title,
body.woocommerce-page ul.products li.product .woocommerce-loop-product__title,
body.woocommerce ul.products li.product .dmx-loop-product-model,
body.woocommerce-page ul.products li.product .dmx-loop-product-model {
    display: -webkit-box;
    overflow: hidden;
    margin: 0 0 0.5rem !important;
    padding: 0 !important;

    color: var(--didemex-card-text);
    font-size: 0.9375rem;
    font-weight: 900;
    line-height: 1.12;
    letter-spacing: -0.02em;
    text-align: center;

    /*
     * Reserva altura de 2 líneas siempre, aunque el modelo quepa en 1.
     * Así el precio y los pills quedan a la misma altura en toda la fila,
     * sin importar si el nombre del producto es corto o largo.
     */
    min-height: calc(1.12em * 2);
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

body.woocommerce ul.products li.product a:hover .woocommerce-loop-product__title,
body.woocommerce-page ul.products li.product a:hover .woocommerce-loop-product__title,
body.woocommerce ul.products li.product a:hover .dmx-loop-product-model,
body.woocommerce-page ul.products li.product a:hover .dmx-loop-product-model {
    color: var(--didemex-card-blue);
}

/* #endregion Product Title */


/* #region Product Price */

body.woocommerce ul.products li.product .price,
body.woocommerce-page ul.products li.product .price {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.05rem;

    margin: 0 !important;
    color: var(--didemex-card-muted) !important;

    font-size: 0.9375rem !important;
    font-weight: 700;
    line-height: 1.05;
    text-align: center;
}

/*
 * Precio tachado: tratado como dato de referencia, no como
 * precio real. Más chico y más ligero para que no compita
 * con el precio de oferta, y pegado a él (gap casi nulo arriba)
 * para leerse como una sola unidad, no como dos líneas sueltas.
 */
body.woocommerce ul.products li.product .price del,
body.woocommerce-page ul.products li.product .price del {
    color: #9a9a9a !important;
    opacity: 1 !important;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.1;
}

body.woocommerce ul.products li.product .price ins,
body.woocommerce-page ul.products li.product .price ins {
    color: var(--didemex-card-danger) !important;
    text-decoration: none !important;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.1;
}

body.woocommerce ul.products li.product .price > .woocommerce-Price-amount,
body.woocommerce-page ul.products li.product .price > .woocommerce-Price-amount {
    color: var(--didemex-card-muted);
    font-weight: 800;
}

/* #endregion Product Price */


/* #region Stock Availability Pill */

/*
 * Señal de disponibilidad, NO un pill de atributo ni una promoción.
 * Por eso usa su propia familia visual (fondo tintado + punto),
 * distinta de .dmx-attr-pill (atributos) y de .onsale (badge flotante
 * de oferta): vive dentro del flujo de la card, debajo del precio,
 * en minúsculas y sin emoji para sentirse como una alerta discreta.
 */
body.woocommerce ul.products li.product .dmx-stock-pill,
body.woocommerce-page ul.products li.product .dmx-stock-pill {
    display: inline-flex;
    align-self: center;
    align-items: center;
    gap: 0.3rem;

    margin-top: 0.55rem;
    padding: 0.15rem 0.5rem;

    border: 1px solid rgba(217, 48, 37, 0.16);
    border-radius: 999px;
    background: rgba(217, 48, 37, 0.06);

    color: #b3261e;
    font-size: 0.6875rem;
    font-weight: 550;
    line-height: 1;
    white-space: nowrap;
}

body.woocommerce ul.products li.product .dmx-stock-pill--last-unit::before,
body.woocommerce-page ul.products li.product .dmx-stock-pill--last-unit::before {
    content: "";
    flex-shrink: 0;

    width: 0.375rem;
    height: 0.375rem;

    border-radius: 50%;
    background: #d93025;
}

/* #endregion Stock Availability Pill */


/* #region Sale Badge Floating Edge */

body.woocommerce ul.products li.product span.onsale,
body.woocommerce-page ul.products li.product span.onsale {
    top: 0 !important;
    right: auto !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 5 !important;

    min-width: auto !important;
    min-height: auto !important;
    padding: 0.32rem 0.78rem !important;

    border: 2px solid #ffffff !important;
    border-radius: 999px !important;
    background: linear-gradient(135deg, #d93025 0%, #ff6a00 100%) !important;
    box-shadow: 0 0.25rem 0.7rem rgba(255, 106, 0, 0.22) !important;
    color: #ffffff !important;

    font-size: 0.66rem !important;
    font-weight: 650 !important;
    line-height: 1 !important;
    white-space: nowrap !important;
}

/* #endregion Sale Badge Floating Edge */


/* #region Sale Badge Halo */

/*
 * Halo discreto detrás del badge de oferta. span.onsale ya llega
 * como position: absolute desde WooCommerce core (necesario para
 * el top/left/transform de arriba), así que solo aislamos su
 * stacking context; el ::before hereda ese absolute para anclarse
 * al propio badge sin afectar el layout de la tarjeta.
 */
body.woocommerce ul.products li.product span.onsale,
body.woocommerce-page ul.products li.product span.onsale {
    isolation: isolate;
}

body.woocommerce ul.products li.product span.onsale::before,
body.woocommerce-page ul.products li.product span.onsale::before {
    content: "";
    position: absolute;
    inset: -4px;
    z-index: -1;

    border: 1px solid var(--didemex-badge-halo-color);
    border-radius: inherit;
    pointer-events: none;

    animation: dmx-sale-badge-halo 2.8s ease-out infinite;
}

@keyframes dmx-sale-badge-halo {
    0%,
    42% {
        opacity: 0;
        transform: scale(1);
    }

    50% {
        opacity: 0.55;
    }

    85%,
    100% {
        opacity: 0;
        transform: scale(1.18);
    }
}

@media (prefers-reduced-motion: reduce) {
    body.woocommerce ul.products li.product span.onsale::before,
    body.woocommerce-page ul.products li.product span.onsale::before {
        animation: none;
        opacity: 0;
    }
}

/* #endregion Sale Badge Halo */


/* #region Product Button */

body.woocommerce ul.products li.product .button,
body.woocommerce-page ul.products li.product .button {
    width: 100%;
    margin-top: 0.875rem !important;
    padding: 0.75rem 1rem !important;

    border: 1px solid var(--didemex-card-blue) !important;
    border-radius: 999px !important;
    background: var(--didemex-card-blue) !important;
    color: #ffffff !important;

    font-size: 0.8125rem !important;
    font-weight: 800 !important;
    letter-spacing: 0.02em;
    text-align: center;
    text-transform: uppercase;

    transition:
        background-color 0.18s ease,
        color 0.18s ease,
        border-color 0.18s ease;
}

body.woocommerce ul.products li.product .button:hover,
body.woocommerce-page ul.products li.product .button:hover {
    background: transparent !important;
    color: var(--didemex-card-blue) !important;
}

/* #endregion Product Button */


/* #region Product Attribute Pills (contexto: card) */

/*
 * Apariencia base (color, padding, tipografía) de .dmx-attribute-pills
 * y .dmx-attr-pill vive en css/woocommerce/global/dmx-attribute-pills.css
 * -- compartida con el shortcode [dmx_selected_variation_pills] de
 * Product Page. Aquí solo el comportamiento específico de la card.
 */

body.woocommerce ul.products li.product .dmx-loop-product-title-wrap,
body.woocommerce-page ul.products li.product .dmx-loop-product-title-wrap {
    margin: 0 0 0.5rem;
    text-align: center;
}

/*
 * Los pills (almacenamiento, color, estética) SIEMPRE en una sola
 * línea dentro de la card. flex-wrap: nowrap + los clamp() del CSS
 * global reducen tipografía/padding en pantallas angostas antes de
 * recurrir al ellipsis de seguridad (no debería activarse con los
 * valores reales: "256GB", "Azul Titanio", "Excelente"...).
 */
body.woocommerce ul.products li.product .dmx-attribute-pills,
body.woocommerce-page ul.products li.product .dmx-attribute-pills {
    flex-wrap: nowrap;
    justify-content: center;
    width: 100%;
    margin-top: 0.4rem;
}

/* #endregion Product Attribute Pills (contexto: card) */


/* #region Responsive Product Grid - Mobile */

@media (max-width: 599px) {

    /*
     * Grid moderno de dos columnas.
     * Reemplaza los floats, clears, anchos y márgenes antiguos de Divi.
     */
    body.woocommerce ul.products,
    body.woocommerce-page ul.products {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-rows: 1fr;
        align-items: stretch;
        gap: 1.5rem 0.6rem !important;
    }

    /*
     * Evita que los clearfix de WooCommerce/Divi
     * ocupen una celda invisible dentro del grid.
     */
    body.woocommerce ul.products::before,
    body.woocommerce ul.products::after,
    body.woocommerce-page ul.products::before,
    body.woocommerce-page ul.products::after {
        display: none !important;
        content: none !important;
    }

    /*
     * Neutraliza por completo el sistema anterior de columnas de Divi.
     */
    body.woocommerce ul.products li.product:nth-child(n),
    body.woocommerce-page ul.products li.product:nth-child(n) {
        width: auto !important;
        max-width: none !important;
        height: 100% !important;
        margin: 0 !important;
        float: none !important;
        clear: none !important;
    }

    /*
     * Mantiene todas las tarjetas con la misma altura dentro de cada fila.
     */
    body.woocommerce ul.products li.product,
    body.woocommerce-page ul.products li.product {
        display: flex;
        flex-direction: column;
        padding: 0.75rem !important;
    }

    body.woocommerce ul.products li.product a.woocommerce-LoopProduct-link,
    body.woocommerce-page ul.products li.product a.woocommerce-LoopProduct-link {
        display: flex;
        flex-direction: column;
        flex-grow: 1;
        height: 100%;
    }

    body.woocommerce ul.products li.product a img,
    body.woocommerce-page ul.products li.product a img {
        width: 100%;
        max-width: 10.5rem;
        height: 10.5rem;
        margin-bottom: 1rem !important;
        object-fit: contain;
    }

    body.woocommerce ul.products li.product .woocommerce-loop-product__title,
    body.woocommerce-page ul.products li.product .woocommerce-loop-product__title,
    body.woocommerce ul.products li.product .dmx-loop-product-model,
    body.woocommerce-page ul.products li.product .dmx-loop-product-model {
        font-size: 0.875rem;
    }

    /*
     * En grid de 2 columnas la tarjeta es más angosta que lo que
     * el vw global asume, así que bajamos el piso de los pills
     * para garantizar que los 3 sigan cabiendo en una sola línea.
     */
    body.woocommerce ul.products li.product .dmx-attr-pill,
    body.woocommerce-page ul.products li.product .dmx-attr-pill {
        padding: clamp(0.1rem, 0.9vw, 0.175rem) clamp(0.22rem, 1.8vw, 0.4rem);
        font-size: clamp(0.5rem, 0.44rem + 0.6vw, 0.625rem);
    }

    /*
     * Badge Oferta estandarizado para tablet y mobile.
     * Conserva los valores que ya habías elegido.
     */
    body.woocommerce ul.products li.product span.onsale,
    body.woocommerce-page ul.products li.product span.onsale {
        min-width: 92px !important;
        padding: 7px 14px !important;
        border-radius: 999px !important;

        font-size: 0.85rem !important;
        font-weight: 650 !important;
        line-height: 1 !important;
    }
}

/* #endregion Responsive Product Grid - Mobile */


/* #region Small Mobile */

@media (max-width: 479px) {

    body.woocommerce ul.products,
    body.woocommerce-page ul.products {
        gap: 1rem 0.625rem !important;
    }
}

/* #endregion Small Mobile */


/* #region Responsive Product Grid - Tablet / Small Desktop (3 columnas) */

@media (min-width: 600px) and (max-width: 1079px) {

    /*
     * Tres columnas: el mismo layout de 4 columnas se siente
     * apretado en este rango de ancho, así que reducimos a 3
     * hasta llegar al desktop grande (1080px+).
     */
    body.woocommerce ul.products,
    body.woocommerce-page ul.products {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        grid-auto-rows: 1fr;
        align-items: stretch;
        gap: 1rem 0.5rem !important;
    }

    /*
     * Evita que los clearfix de WooCommerce/Divi
     * ocupen una celda invisible dentro del grid.
     */
    body.woocommerce ul.products::before,
    body.woocommerce ul.products::after,
    body.woocommerce-page ul.products::before,
    body.woocommerce-page ul.products::after {
        display: none !important;
        content: none !important;
    }

    /*
     * Neutraliza por completo el sistema de columnas por floats
     * que WooCommerce/Divi aplican de forma nativa en este rango.
     */
    body.woocommerce ul.products li.product:nth-child(n),
    body.woocommerce-page ul.products li.product:nth-child(n) {
        width: auto !important;
        max-width: none !important;
        height: 100% !important;
        margin: 0 !important;
        float: none !important;
        clear: none !important;
    }

    /*
     * Cada tarjeta se estira al alto disponible de su fila.
     * El enlace interno (.woocommerce-LoopProduct-link) ya ocupa
     * el 100% de esa altura por la regla global de la línea 140.
     */
    body.woocommerce ul.products li.product,
    body.woocommerce-page ul.products li.product {
        display: flex;
        flex-direction: column;
    }
}

/* #endregion Responsive Product Grid - Tablet / Small Desktop (3 columnas) */


/* #region Responsive Product Grid - Desktop Grande (4 columnas) */

@media (min-width: 1080px) {

    /*
     * Grid moderno de cuatro columnas.
     * Reemplaza el sistema de floats nativo de WooCommerce/Divi
     * para poder igualar la altura de las tarjetas por fila.
     */
    body.woocommerce ul.products,
    body.woocommerce-page ul.products {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        grid-auto-rows: 1fr;
        align-items: stretch;
        gap: 3rem 1.15rem !important;
    }

    /*
     * Evita que los clearfix de WooCommerce/Divi
     * ocupen una celda invisible dentro del grid.
     */
    body.woocommerce ul.products::before,
    body.woocommerce ul.products::after,
    body.woocommerce-page ul.products::before,
    body.woocommerce-page ul.products::after {
        display: none !important;
        content: none !important;
    }

    /*
     * Neutraliza por completo el sistema de columnas por floats
     * que WooCommerce/Divi aplican de forma nativa en desktop.
     */
    body.woocommerce ul.products li.product:nth-child(n),
    body.woocommerce-page ul.products li.product:nth-child(n) {
        width: auto !important;
        max-width: none !important;
        height: 100% !important;
        margin: 0 !important;
        float: none !important;
        clear: none !important;
    }

    /*
     * Cada tarjeta se estira al alto disponible de su fila.
     * El enlace interno (.woocommerce-LoopProduct-link) ya ocupa
     * el 100% de esa altura por la regla global de la línea 140.
     */
    body.woocommerce ul.products li.product,
    body.woocommerce-page ul.products li.product {
        display: flex;
        flex-direction: column;
    }
}

/* #endregion Responsive Product Grid - Desktop Grande (4 columnas) */

/* #endregion DIDEMEX - SHOP - WOO PRODUCT CARDS */
