/* =======================================================
   FAIL-SAFE: STOP BUTTON FLICKER
   ======================================================= */
/* Scoped to main products only */
.product-grid-item .wd-add-btn a.button,
.product-grid-item .wd-add-btn-replace a.button,
.product-grid-item .add_to_cart_button,
.product-grid-item .mtl-wishlist-btn,
.product-list-item .wd-add-btn a.button,
.product-list-item .wd-add-btn-replace a.button,
.product-list-item .add_to_cart_button,
.product-list-item .mtl-wishlist-btn {
    max-width: 100% !important;
    width: auto !important;
    display: inline-flex !important;
}

/* =======================================================
   1. FORCE 2-COLUMN GRID
   ======================================================= */
@media only screen and (min-width: 768px) {
    body.archive .products, 
    body.tax-product_cat .products {
        display: flex !important;
        flex-wrap: wrap !important;
        margin-right: -10px !important;
        margin-left: -10px !important;
        --wd-col-lg: 2 !important; 
    }

    body.archive .products .product, 
    body.tax-product_cat .products .product {
        width: 50% !important;
        max-width: 50% !important;
        flex: 0 0 50% !important;
        padding: 0 10px 20px 10px !important;
        clear: none !important;
    }
}

/* =======================================================
   2. RESTORE "GREY BOX" CARD DESIGN
   (Strictly Scoped to prevent Side Cart Issues)
   ======================================================= */
.product-grid-item .product-wrapper, 
.product-list-item .product-wrapper {
    position: relative !important;
    display: block !important;
    border: 1px solid #ccc !important;
    background-color: #ededed !important;
    padding: 10px !important;
    border-radius: 10px !important;
    box-shadow: 2px 5px 15px -5px #a0a0a0 !important;
    height: auto !important;
    min-height: 1px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    margin-bottom: 0 !important;
}

.product-grid-item .product-wrapper::after,
.product-list-item .product-wrapper::after {
    content: "";
    display: table;
    clear: both;
}

/* Unlock container ONLY for main grid */
.product-grid-item .product-list-content,
.product-list-item .product-list-content {
    position: static !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* =======================================================
   3. ELEMENT POSITIONING (Strictly Scoped)
   ======================================================= */

/* IMAGE */
.product-grid-item .product-element-top,
.product-list-item .product-element-top {
    position: relative !important;
    float: left !important;
    width: 30% !important;
    margin: 0 !important;
    display: block !important;
}
.product-grid-item .attachment-woocommerce_thumbnail,
.product-list-item .attachment-woocommerce_thumbnail {
    border-bottom-left-radius: 10px;
    border-top-left-radius: 10px;
    display: block !important;
}

/* TITLE */
.product-grid-item .wd-entities-title,
.product-list-item .wd-entities-title {
    position: absolute !important;
    left: calc(30% + 15px) !important;
    top: 10px !important;
    z-index: 5 !important;
    width: calc(55% - 10px) !important;
    max-width: 180px !important;
    text-align: left !important;
    margin: 0 !important;
    font-size: 14px !important;
    line-height: 1.3em !important;
    max-height: 2.6em !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
}

/* PLAYER */
.product-grid-item .wcmp-player-container,
.product-list-item .wcmp-player-container {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    text-align: right !important;
    z-index: 10 !important;
    width: auto !important;
}

/* PRICE */
.product-grid-item .price,
.product-list-item .price {
    position: absolute !important;
    top: 50px !important;
    right: 20px !important;
    text-align: right !important;
    display: block !important;
    font-weight: bold !important;
    color: #3e81b9 !important; 
    background: transparent !important;
}

/* =======================================================
   4. BUTTONS FIX (Strictly Scoped)
   ======================================================= */

/* Container */
.product-grid-item .wd-add-btn,
.product-grid-item .wd-add-btn-replace,
.product-list-item .wd-add-btn,
.product-list-item .wd-add-btn-replace {
    position: absolute !important;
    bottom: 10px !important;
    left: calc(30% + 15px) !important;
    right: 10px !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-end !important;
    gap: 8px !important;
    margin: 0 !important;
    z-index: 20 !important;
    height: 34px !important;
    opacity: 0; 
    animation: mtl_fade_buttons 0.3s forwards 0.2s;
}

@keyframes mtl_fade_buttons {
    to { opacity: 1; }
}

/* Buttons */
.product-grid-item .add_to_cart_button, 
.product-grid-item .mtl-wishlist-btn,
.product-list-item .add_to_cart_button, 
.product-list-item .mtl-wishlist-btn {
    flex: 1 !important;
    width: 50% !important;
    min-width: 0 !important;
    height: 34px !important;
    border-radius: 17px !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    color: #fff !important;
    background-color: #3e81b9 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    text-decoration: none !important;
}

/* Text Consistency */
.product-grid-item .add_to_cart_button,
.product-grid-item .add_to_cart_button span, 
.product-grid-item .mtl-wishlist-btn,
.product-list-item .add_to_cart_button,
.product-list-item .add_to_cart_button span, 
.product-list-item .mtl-wishlist-btn {
    font-family: inherit !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
}

.product-grid-item .add_to_cart_button:hover, 
.product-grid-item .mtl-wishlist-btn:hover,
.product-list-item .add_to_cart_button:hover, 
.product-list-item .mtl-wishlist-btn:hover {
    background-color: #333 !important;
    color: #fff !important;
}

/* =======================================================
   5. STAR RATING (Strictly Scoped)
   ======================================================= */
.product-grid-item .star-rating, 
.product-grid-item .wd-star-rating,
.product-list-item .star-rating, 
.product-list-item .wd-star-rating {
    display: block !important;
    position: absolute !important;
    left: calc(30% + 15px) !important;
    bottom: 48px !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    z-index: 15 !important;
    line-height: 1 !important;
    font-size: 12px !important;
}

/* Hide clutter ONLY in main grid */
.product-grid-item .wd-product-cats, 
.product-grid-item .wd-product-brands, 
.product-grid-item .wd-buttons.wd-pos-r-t,
.product-list-item .wd-product-cats, 
.product-list-item .wd-product-brands, 
.product-list-item .wd-buttons.wd-pos-r-t { 
    display: none !important; 
}