.wp-block-woocommerce-product-template {
    grid-gap: 30px 12px;

    .wc-block-components-product-image,
    .wp-block-woocommerce-product-price,
    .wp-block-button.wc-block-components-product-button {
        margin: 0;
    }

    .wc-block-components-product-image__inner-container {
        padding: 0;
    }

    /* Wishlist Button: Positioned at Top Right */
    .wc-block-components-product-image button.yith-wcwl-add-to-wishlist-button.yith-wcwl-add-to-wishlist-button--icon-button {
        position: absolute;
        top: -28px;
        right: 0;
        z-index: 10;
        width: fit-content;
        margin: 0;
        background: transparent;
        border: none;
        margin-left: auto;
        padding: 0;

        .yith-wcwl-add-to-wishlist-button-icon {
            width: 17px;
            height: 17px;
            transition: transform 0.2s;

            &:hover {
            transform: scale(1.1);
            }
        }
    }

    /* Category: Truncated to 1 line */
    .taxonomy-product_cat {
        display: -webkit-box;
        overflow: hidden;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
        line-clamp: 1;
    }

    /* Product Image Container */
    .wc-block-components-product-image {
        margin-top: 10px;

        img {
            aspect-ratio: 1 / 1;
        }
    }

    /* Product Title: Truncated to 2 lines */
    .wp-block-post-title {
        margin: 10px 0;
        color: var(--wp--preset--color--contrast);
        font-size: 15px;
        font-weight: 500;
        line-height: 24px;
        text-align: left;
        text-decoration: none;
        text-underline-offset: 4px;
    }

    .wp-block-post-title,
    .wp-block-post-title a {
        display: -webkit-box;
        overflow: hidden;
        min-height: 48px;
        text-overflow: ellipsis;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }

    /* Price Section Styling */
    .wp-block-woocommerce-product-price .wc-block-components-product-price {
        font-size: 17px;
        font-weight: 700;
        line-height: 28px;

        del {
            font-size: 14px;
            margin-left: 6px;
        }

        ins {
            float:left;
        }
    }

    /* Add to Cart Button */
    .wp-block-button.wc-block-components-product-button {
        .wp-block-button__link {
            width: 100%;
            text-transform: uppercase;
            border-radius: 8px;
            padding: 14px;
            display: grid;
            line-height: 1.5;
            grid-template-columns: 1fr;
            position: relative;

            span {
                margin-inline-start: 38px;
            }

            span,
            &::before {
                grid-row-start: 1;
                grid-column-start: 1;
            }
            
            &::before {
                content: " ";
                width: 52px;
                height: 52px;
                display: inline-block;
                background-repeat: no-repeat;
                background-position: center;
                background-color: var(--wp--preset--color--primary-hover);
                border-top-left-radius: 8px;
                border-bottom-left-radius: 8px;
                margin: -14px auto -14px -14px;
                position: absolute;
                height: auto;
                bottom: 0;
                top: 0;
                margin-bottom: 0;
                background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M21.7087 6.78525C21.4979 6.53876 21.2361 6.34092 20.9414 6.20536C20.6467 6.0698 20.3261 5.99973 20.0018 6H6.40875L6.09825 4.23975C6.03705 3.89236 5.85538 3.57766 5.58517 3.35093C5.31496 3.12419 4.97349 2.99994 4.62075 3H2.25C2.05109 3 1.86032 3.07902 1.71967 3.21967C1.57902 3.36032 1.5 3.55109 1.5 3.75C1.5 3.94891 1.57902 4.13968 1.71967 4.28033C1.86032 4.42098 2.05109 4.5 2.25 4.5H4.62075L6.543 15.3915C6.63636 15.9223 6.91811 16.4017 7.3365 16.7415C6.95953 17.2027 6.75246 17.7794 6.75 18.375C6.75 19.0712 7.02656 19.7389 7.51884 20.2312C8.01113 20.7234 8.67881 21 9.375 21C10.0712 21 10.7389 20.7234 11.2312 20.2312C11.7234 19.7389 12 19.0712 12 18.375C11.9978 17.985 11.9078 17.6005 11.7367 17.25H16.0118C15.8412 17.6006 15.7517 17.9851 15.75 18.375C15.746 18.7971 15.8439 19.2139 16.0353 19.5901C16.2267 19.9663 16.5061 20.2908 16.8496 20.5361C17.1931 20.7813 17.5907 20.9401 18.0087 20.999C18.4267 21.0579 18.8527 21.0151 19.2506 20.8743C19.6485 20.7335 20.0066 20.4988 20.2945 20.1901C20.5824 19.8815 20.7916 19.5079 20.9044 19.1012C21.0172 18.6944 21.0303 18.2665 20.9425 17.8536C20.8546 17.4407 20.6686 17.0551 20.4 16.7295C20.8221 16.3785 21.1008 15.8848 21.183 15.342L22.2218 8.592C22.2719 8.27166 22.2521 7.94425 22.1635 7.63233C22.0749 7.32041 21.9198 7.03141 21.7087 6.78525ZM10.5 18.375C10.5 18.5975 10.434 18.815 10.3104 19C10.1868 19.185 10.0111 19.3292 9.80552 19.4144C9.59995 19.4995 9.37375 19.5218 9.15552 19.4784C8.93729 19.435 8.73684 19.3278 8.5795 19.1705C8.42217 19.0132 8.31502 18.8127 8.27162 18.5945C8.22821 18.3762 8.25049 18.15 8.33564 17.9445C8.42078 17.7389 8.56498 17.5632 8.74998 17.4396C8.93499 17.316 9.1525 17.25 9.375 17.25C9.67337 17.25 9.95952 17.3685 10.1705 17.5795C10.3815 17.7905 10.5 18.0766 10.5 18.375ZM18.375 19.5C18.1525 19.5 17.935 19.434 17.75 19.3104C17.565 19.1868 17.4208 19.0111 17.3356 18.8055C17.2505 18.6 17.2282 18.3738 17.2716 18.1555C17.315 17.9373 17.4222 17.7368 17.5795 17.5795C17.7368 17.4222 17.9373 17.315 18.1555 17.2716C18.3738 17.2282 18.6 17.2505 18.8055 17.3356C19.0111 17.4208 19.1868 17.565 19.3104 17.75C19.434 17.935 19.5 18.1525 19.5 18.375C19.5 18.6734 19.3815 18.9595 19.1705 19.1705C18.9595 19.3815 18.6734 19.5 18.375 19.5ZM19.704 15.114C19.6768 15.291 19.5871 15.4525 19.4512 15.5691C19.3153 15.6858 19.1421 15.7499 18.963 15.75H8.7585C8.58206 15.7502 8.41119 15.6882 8.27593 15.5749C8.14068 15.4616 8.0497 15.3043 8.019 15.1305L6.675 7.5H20.0018C20.1099 7.50004 20.2167 7.52345 20.3149 7.56863C20.4131 7.61381 20.5004 7.67968 20.5708 7.76174C20.6411 7.8438 20.693 7.94011 20.7226 8.04406C20.7523 8.14801 20.7592 8.25715 20.7428 8.364L19.704 15.114Z" fill="black"/></svg>');
            }
        }
    }

    .added_to_cart {
        margin-top: 0;
        text-transform: uppercase;
    }

    /* The li element */
    .wc-block-product {
        position: relative;

        > .wp-block-group {
            padding: 20px;
            background: var(--white, #FFF);
            border: 1px solid var(--wp--preset--color--white);
            border-radius: 8px;

            > .wp-block-group:last-child {
                margin-top: 20px;
            }
        }
    }

    &.columns-3 {
        grid-template-columns: repeat(auto-fill,minmax(max(190px,calc(33.33333% - .83333em)),1fr));
    }

    &.columns-4 {
        grid-template-columns: repeat(auto-fill,minmax(max(210px,calc(25% - .9375em)),1fr));
    }

    &.columns-5 {
        grid-template-columns: repeat(auto-fill,minmax(max(190px,calc(20% - 1em)),1fr));
    }

    &.is-style-product-style-2  {
        margin-top: 30px;

        /* The li element */
        .wc-block-product {
            > .wp-block-group {
                padding: 0;
            }
        }

        .added_to_cart {
            background: transparent;
        }

        /* Add to Cart Button */
        .wp-block-button.wc-block-components-product-button {
            align-items: flex-start;

            .wp-block-button__link {
                padding: 0;

                &::before {
                    background-color: transparent;
                    margin: 0;
                    width: 24px;
                }

                span {
                    text-align: left;
                    margin-inline-start: 34px;
                    letter-spacing: 0px;
                }
            }

            > {
                letter-spacing: 0px;
            }
        }

        .wc-block-components-product-image {
            margin-bottom: 12px;
        }
            
        .yith-wcwl-add-to-wishlist-button.yith-wcwl-add-to-wishlist-button--icon-button:is(button) { 
            top:-38px; 
            right: 0; 
            background: var(--wp--preset--color--white); 
            border-radius: 180px; 
            box-shadow: 0 6px 15px 0 rgba(64, 79, 104, 0.05); 
            height: 40px; 
            padding: 11px; 
            width: 40px;
            margin: 0 0 0 auto;
        }
    }
}

.wp-block-woocommerce-product-collection {
    &:has(.is-style-product-style-2) {
        > .wp-block-group {
            margin-top: 0;
        }
    }
}

.is-product-collection-layout-carousel {
    &.is-layout-flex {
        gap: 12px;
    }

    &.is-style-product-style-2  {
        padding: 0;
    }

    .wc-block-product {
        min-width: 100%;
    }    
}

.is-category-product {
    .is-product-collection-layout-carousel {
        margin-top: 0;
        padding: 0;

        .wc-block-product {
            min-width: 100%;
        }
    }
}

.is-category-product-v2 {
    .wp-block-woocommerce-product-template {
        margin-top: 0;
        gap: 10px;

        .wc-block-product {
            > .wp-block-group {
                padding: 20px;
                border-width: 0;
            }
        }
    }

    .is-product-collection-layout-carousel {
        .wc-block-product {
           
        }
    }
}

@media (width >= 640px) {
    .is-product-collection-layout-carousel {
        .wc-block-product {
            min-width: 50%;
        }

        &.is-style-product-style-2  {
            .wc-block-product {
                min-width: calc((100% - 12px) / 2);
            }
        }
    }
}

@media (width >= 768px) {
    .is-product-collection-layout-carousel {
        .wc-block-product {
            min-width: 33.3333333%;
        }

        &.is-style-product-style-2  {
            .wc-block-product {
                min-width: calc((100% - 24px) / 3);
            }
        }
    }

    .is-category-product {
        .is-product-collection-layout-carousel {
            .wc-block-product {
                min-width: 32.333333%;
            }
        }
    }

    .is-category-product-v2 {
        .wp-block-columns {
            column-gap: 26px;
            flex-wrap: wrap !important;

            > .wp-block-column:last-child {
                flex-basis: 100%;
            }
        }
    }
}

@media (width >= 1024px) {
    .is-product-collection-layout-carousel {
        .wc-block-product {
            min-width: calc((100% - 36px) / 4);
        }

        &.is-style-product-style-2  {
            gap: 32px;

            .wc-block-product {
                min-width: calc((100% - 96px) / 4);
            }
        }
    }

    .is-category-product {
        .is-product-collection-layout-carousel {
            .wc-block-product {
                min-width: calc((100% - 20px) / 3);
            }
        }
    }

    .is-category-product-v2 {
        .is-product-collection-layout-carousel {
            .wc-block-product {
                min-width: calc((100% - 20px) / 4);
            }

            &.is-style-product-style-2  {
                gap: 10px;
            }
        }
    }

    .is-category-product-v2 {
        .wp-block-columns {
            column-gap: 26px;
            flex-wrap: nowrap !important;

            > .wp-block-column:last-child {
                flex-basis: 0;
            }
        }
    }

    div[data-display-layout*='"type":"carousel"'][data-display-layout*='"columns":4'] {
        .is-product-collection-layout-carousel {
            &.is-style-product-style-2 {
                .wc-block-product {
                    min-width: calc((100% - 20px) / 3);
                }
            }
        }
    }
}

@media (width >= 1280px) {
    .wp-block-woocommerce-product-template:not(.is-style-product-style-2) {
        .wc-block-product > .wp-block-group:not(.wp-block) > .wp-block-group:last-child {
            margin-top: 0;
            opacity: 0;
            position: absolute;
            transition: all .1s ease-in-out;
            left: -1px;
            right: -1px;
            padding: 0 20px 20px 20px;
            background: var(--white, #FFF);
            border-color: transparent;
        }

        .wc-block-product:hover > .wp-block-group:not(.wp-block) > .wp-block-group:last-child {
            margin-top: 20px;
            opacity: 1;
            display: grid;
            border: 1px solid var(--Border, #EAEAEA);
            box-shadow: 0 6px 15px 0 rgba(64, 79, 104, 0.05);
            border-radius: 8px;
            border-top-left-radius: 0;
            border-top-right-radius: 0;
            border-top: 0;
        }

        &.is-style-default {
            .wc-block-product {
                &:hover {
                    > .wp-block-group:not(.wp-block) {
                        border-bottom-left-radius: 0;
                        border-bottom-right-radius: 0;
                        border-bottom: 0;
                    }
                }
            }
        }

        .wc-block-product {
            &:hover {
                > .wp-block-group:not(.wp-block) {
                    border: 1px solid var(--Border, #EAEAEA);
                    box-shadow: 0 6px 15px 0 rgba(64, 79, 104, 0.05);
                    z-index: 999;
                }

                .wp-block-post-title,
                .wp-block-post-title a {
                    color: var(--wp--preset--color--info);
                    text-decoration: underline;
                }
            }
        }
    }

    .is-product-collection-layout-carousel {
        .wc-block-product {
            min-width: calc((100% - 50px) / 5);
        }

        &.is-style-default {
            padding: 0 0 80px 0;
            overflow: hidden;
            
            /* This !important for to overrite default WP layout style */
            margin-block-end: -80px !important;
        }

        &.is-style-product-style-2  {
            .wc-block-product {
                min-width: calc((100% - 126px) / 5);
            }
        }
    }

    .wp-block-woocommerce-product-template {
        &.is-style-product-style-2  {
            .wc-block-product { 
                &:hover {
                    .wp-block-post-title a {
                        text-decoration: underline;
                    }
                }
            }
        }
    }

    div[data-display-layout*='"type":"carousel"'][data-display-layout*='"columns":4'] {
        .is-product-collection-layout-carousel {
            .wc-block-product {
                min-width: calc((100% - 36px) / 4);
            }

            &.is-style-product-style-2 {
                .wc-block-product {
                    min-width: calc((100% - 30px) / 4);
                }
            }
        }
    }

    div[data-display-layout*='"type":"carousel"'][data-display-layout*='"columns":6'] {
        .is-product-collection-layout-carousel {
            .wc-block-product {
                min-width: calc((100% - 60px) / 6);
            }
        }
    }

    .is-category-product-v2 {
        .wp-block-columns {
            column-gap: 76px;
        }
    }
}

@media (width >= 1536px) {
    .is-category-product-v2 {
        .wp-block-columns {
            column-gap: 117px;
        }
    }
}
