/**
 * Estilos para Intelligent Cross-Sells (ICS) - v10.6.1
 * Ajustes:
 * - Grid: el toggle se convierte visualmente en botón "Añadir al carrito"
 * - Grid: imagen más compacta y centrada (menos aire lateral)
 * - Lista: toggle con contenedor ajustado a la altura del círculo
 */

/* -- 1. Variables Globales de Diseño -- */
:root {
    --ics-padding: 8px;
    --ics-gap: 16px;
    --ics-border-radius: 20px;
    --ics-image-size: 65px;

    --ics-bg-color: #FFFFFF;
    --ics-border-color: #E8E6F1;
    --ics-text-light-color: #6D6D77;
    --ics-accent-color: #6A3FF2;

    /* Toggle (LISTA) */
    --ics-toggle-height: 30px;
    --ics-toggle-width: 60px;
    --ics-toggle-handle-size: 22px;

    /* Botón (GRID) */
    --ics-grid-btn-height: 42px;
    --ics-grid-btn-radius: 12px;
    --ics-grid-card-radius: 24px;
    --ics-grid-image-radius: 18px;
    --ics-grid-image-bg: #F5F6FB;
    --ics-grid-action-size: 36px;
}

/* -- 2. Contenedores Principales -- */
.ics-widget__title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 2rem!important;
}

.ics-products-wrapper {
    display: flex;
    flex-direction: column;
    gap: var(--ics-gap);
    list-style: none;
    padding-left: 0;
    margin: 20px 0;
}

/* -- 3. Tarjeta de Producto -- */
.ics-product {
    display: flex;
    align-items: center;
    gap: var(--ics-gap);
    padding: var(--ics-padding);
    background: var(--ics-bg-color);
    border: 1px solid var(--ics-border-color);
    border-radius: var(--ics-border-radius);
    transition: box-shadow 0.25s ease-in-out, border-color 0.25s ease-in-out;
}

.ics-product:hover {
    border-color: transparent;
    box-shadow: 0 8px 25px rgba(106, 63, 242, 0.12);
}

/* -- 4. Elementos de la Tarjeta -- */
.ics-product__image-wrapper {
    flex-shrink: 0;
    width: var(--ics-image-size);
    height: var(--ics-image-size);
    transition: width 0.3s ease, height 0.3s ease;
}

.ics-product__image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

.ics-product__details {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: gap 0.3s ease;
}

.ics-product__title {
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
    min-height: calc(1.3em * 2);
}

.ics-product__title-link {
    font-size: 14px;
    text-decoration: none;
    transition: color 0.2s ease, font-size 0.3s ease;
}

.ics-product__meta {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-shrink: 0;
    transition: gap 0.3s ease;
}

.ics-product__price {
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    transition: font-size 0.3s ease;
    line-height: 1.2;
    min-height: calc(1.2em * 2);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.ics-product__price small,
.ics-product__tax-label {
    font-size: 11px !important;
    font-weight: 400 !important;
    color: var(--ics-text-light-color) !important;
    display: block !important;
    line-height: 1.2 !important;
    min-height: 1.2em;
}

/* -- 5. Toggle (LISTA) -- */
/* Ajuste: el contenedor del toggle queda EXACTAMENTE de la altura del control */
.ics-product__action {
    position: relative;
    width: var(--ics-toggle-width);
    min-width: var(--ics-toggle-width);
    height: var(--ics-toggle-height);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ics-toggle-button {
    appearance: none;
    background-color: #F0F2F5;
    border: 1px solid #E8E6F1 !important;
    box-shadow: none !important;
    padding: 0 !important;
    text-indent: -9999px;
    font-size: 0;
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 999px !important;
    cursor: pointer;
    transition: background-color 0.4s ease, border-color 0.4s ease;
}
.ics-toggle-button:hover {
    border-color: #d8d6e1 !important;
}

.ics-toggle-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 3px;
    transform: translateY(-50%);
    width: var(--ics-toggle-handle-size);
    height: var(--ics-toggle-handle-size);
    background-color: #fff;
    border: 1px solid #d1b5db;
    border-radius: 50%;
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), background-color 0.4s ease;
}

/* Estados */
.ics-toggle-button.added {
    background-color: var(--ics-accent-color);
    border-color: var(--ics-accent-color) !important;
}
.ics-toggle-button.added::before {
    background-color: white;
    transform: translateY(-50%) translateX(calc(var(--ics-toggle-width) - var(--ics-toggle-height)));
}

.ics-toggle-button.loading {
    background-color: #F0F2F5;
    border-color: #E8E6F1 !important;
}

.ics-toggle-button.loading::before {
    box-sizing: border-box;
    background: transparent;
    border: 3px solid rgba(0, 0, 0, 0.2);
    transform: translateY(-50%) rotate(0deg);
    animation: ics-spin 0.8s linear infinite;
}

.ics-toggle-button.loading.added {
    background-color: #F0F2F5;
    border-color: #E8E6F1 !important;
}

.ics-toggle-button.loading.added::before {
    transform: translateY(-50%) rotate(0deg);
}

@keyframes ics-spin { to { transform: translateY(-50%) rotate(360deg); } }

.woocommerce a.added_to_cart { display: none !important; }

/* -- 7. Responsive Lista -- */
@media (max-width: 520px) {
    .ics-product__image-wrapper {
        width: 50px;
        height: 50px;
    }
    .ics-product { gap: 8px; }
    .ics-product__details { gap: 8px; }
    .ics-product__meta { gap: 1rem; }
    .ics-product__title-link { font-size: 13px; }
    .ics-product__price { font-size: 16px; }
}

/* --- 8. MODO GRID (CUADRÍCULA) --- */
.ics-products-wrapper.ics-layout-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}

.ics-mobile-cols-1 {
    --ics-mobile-columns: 1;
}

.ics-mobile-cols-2 {
    --ics-mobile-columns: 2;
}

/* Tarjeta */
.ics-layout-grid .ics-product {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
    padding: 16px;
    height: 100%;
    border-radius: var(--ics-grid-card-radius);
    border: 1px solid rgba(232, 230, 241, 0.8);
    box-shadow: 0 16px 32px rgba(22, 16, 46, 0.06);
}

/* Imagen: wrapper más compacto y centrado (reduce aire lateral) */
.ics-layout-grid .ics-product__image-wrapper {
    width: 100%;
    height: auto;
    aspect-ratio: var(--ics-grid-image-ratio, 1 / 1);
    overflow: hidden;
    margin-bottom: 14px;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;
    box-sizing: border-box;
    border-radius: 0;
    background: transparent;
}

.ics-layout-grid .ics-product__image-wrapper img {
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: none;
    object-fit: contain;
    border-radius: 0;
    filter: none;
}

/* Detalles */
.ics-layout-grid .ics-product__details {
    flex-direction: column;
    justify-content: flex-start;
    gap: 12px;
    flex: 1;
}

.ics-layout-grid .ics-product__title-link {
    font-size: 13px;
    font-weight: 700;
    color: #151321;
}

.ics-layout-grid .ics-product__price {
    font-size: 16px;
    font-weight: 700;
    text-align: left;
}

.ics-layout-grid .ics-product__meta {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    margin-top: auto;
    padding-top: 8px;
}

/**
 * ACTION en grid:
 * - ya NO queremos un contenedor “alto y vacío”.
 * - Queremos un botón real con altura fija.
 */
.ics-layout-grid .ics-product__action {
    width: var(--ics-grid-action-size);
    min-width: var(--ics-grid-action-size);
    height: var(--ics-grid-action-size);
}

/**
 * Convertimos el toggle en un botón de “Añadir al carrito” en GRID
 * (sin cambiar HTML).
 */
.ics-layout-grid .ics-toggle-button {
    width: var(--ics-grid-action-size);
    height: var(--ics-grid-action-size);
    border-radius: 50% !important;
    text-align: center;
    gap: 6px;

    text-indent: 0 !important;
    font-size: 0 !important;
    line-height: 0 !important;

    background: rgb(28 52 199 / 0.1) !important;
    border-color: transparent !important;
    color: rgb(28 52 199 / 1) !important;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 14px rgba(56, 73, 166, 0.15);
}

.ics-layout-grid .ics-toggle-button::before {
    display: none !important;
}

.ics-layout-grid .ics-toggle-button::after {
    content: "";
    display: block;
    width: 18px;
    height: 18px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #1c34c7;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231C34C7' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='20' r='1.5'/%3E%3Ccircle cx='18' cy='20' r='1.5'/%3E%3Cpath d='M3 4h2l2.2 10.2a2 2 0 0 0 2 1.6h7.8a2 2 0 0 0 2-1.6L21 8H7'/%3E%3Cpath d='M12 2v4'/%3E%3Cpath d='M10 4h4'/%3E%3C/svg%3E") no-repeat center / contain;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231C34C7' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='20' r='1.5'/%3E%3Ccircle cx='18' cy='20' r='1.5'/%3E%3Cpath d='M3 4h2l2.2 10.2a2 2 0 0 0 2 1.6h7.8a2 2 0 0 0 2-1.6L21 8H7'/%3E%3Cpath d='M12 2v4'/%3E%3Cpath d='M10 4h4'/%3E%3C/svg%3E") no-repeat center / contain;
}

.ics-layout-grid .ics-toggle-button.added::before {
    display: none !important;
}

.ics-layout-grid .ics-toggle-button.added::after {
    content: "✓";
    font-size: 15px;
    background-image: none;
}

.ics-layout-grid .ics-toggle-button.loading::after {
    content: "⏳";
    font-size: 13px;
    background-image: none;
}

.ics-layout-grid .ics-toggle-button.loading {
    background: #F0F2F5 !important;
    border-color: #E8E6F1 !important;
    color: #6D6D77 !important;
}

/* Hover */
.ics-layout-grid .ics-toggle-button:hover {
    background: rgb(28 52 199 / 1) !important;
    color: #fff !important;
}
.ics-layout-grid .ics-toggle-button:hover::after {
    background-color: #fff;
}

/**
 * Si tú implementaste un <a class="ics-add-to-cart">Añadir al carrito</a> en grid,
 * este bloque lo estiliza y puedes ocultar el toggle con la última regla.
 */
.ics-layout-grid .ics-add-to-cart {
    width: 100%;
    height: var(--ics-grid-btn-height);
    border-radius: var(--ics-grid-btn-radius);
    background: #1D1A27;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #1D1A27;
    transition: filter 0.2s ease;
}
.ics-layout-grid .ics-add-to-cart:hover { filter: brightness(0.96); }

/* Si hay botón real .ics-add-to-cart, ocultamos el toggle para evitar doble acción */
.ics-layout-grid .ics-product__action:has(.ics-add-to-cart) .ics-toggle-button {
    display: none !important;
}

/* RESPONSIVE GRID */
@media (max-width: 1024px) {
    .ics-products-wrapper.ics-layout-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 767px) {
    .ics-products-wrapper.ics-layout-grid {
        --ics-mobile-columns: var(--ics-mobile-columns, 1);
        grid-template-columns: none;
        grid-auto-flow: column;
        grid-auto-columns: calc((100% - (var(--ics-mobile-columns) - 1) * 16px) / var(--ics-mobile-columns));
        gap: 16px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scroll-padding-inline: 16px;
        padding-bottom: 30px;
        -webkit-overflow-scrolling: touch;
    }

    .ics-layout-grid .ics-product {
        scroll-snap-align: start;
        text-align: left;
    }
}












