/* Frontend Badge Styles */

/* Ensure parent is relative so absolute badges work */
.woocommerce ul.products li.product .woocommerce-loop-product__link,
.woocommerce div.product .woocommerce-product-gallery__wrapper,
.woocommerce div.product .woocommerce-product-gallery__image {
    position: relative !important;
}

/* Hide default WooCommerce Sale Badge */
.woocommerce span.onsale {
    display: none !important;
}

.opb-badges-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 99999 !important; /* Extremely high value */
    
    /* iOS Safari Force Render Fix - Level 2 */
    -webkit-transform: translate3d(0, 0, 10px); /* Move towards user */
    transform: translate3d(0, 0, 10px);
    -webkit-perspective: 1000px;
    perspective: 1000px;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    overflow: visible !important;
}

/* Single Product Specifics */
.opb-single-product-badges-container {
    /* For single product, we might need to be more specific or aggressive depending on the theme structure */
}

/* Badge Zone (Container for stacked badges) */
.opb-zone {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 5px; /* Space between stacked badges */
    z-index: 1000; /* Higher than image and container */
    /* Safari Fixes */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Badge Wrapper (Individual Badge) */
.opb-badge-wrapper {
    position: relative; /* Changed from absolute */
    pointer-events: none;
    line-height: 1;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    /* Reset individual positioning */
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    transform: translateZ(0); /* iOS rendering fix */
    -webkit-transform: translateZ(0);
}

/* Badge Content */
.opb-badge-text {
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    border-radius: 3px;
    white-space: nowrap;
}

.opb-badge-img {
    max-width: 60px;
    height: auto;
    display: block;
}

/* Zone Positions */
.opb-zone-top-left {
    top: 10px;
    left: 10px;
    align-items: flex-start;
}
.opb-zone-top-center {
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    align-items: center;
}
.opb-zone-top-right {
    top: 10px;
    right: 10px;
    align-items: flex-end;
}

.opb-zone-middle-left {
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    align-items: flex-start;
}
.opb-zone-middle-center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    align-items: center;
}
.opb-zone-middle-right {
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    align-items: flex-end;
}

.opb-zone-bottom-left {
    bottom: 10px;
    left: 10px;
    align-items: flex-start;
}
.opb-zone-bottom-center {
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    align-items: center;
}
.opb-zone-bottom-right {
    bottom: 10px;
    right: 10px;
    align-items: flex-end;
}

/* Legacy position classes override (if still present on wrapper) */
.opb-badge-wrapper.opb-pos-top-left,
.opb-badge-wrapper.opb-pos-top-center,
.opb-badge-wrapper.opb-pos-top-right,
.opb-badge-wrapper.opb-pos-middle-left,
.opb-badge-wrapper.opb-pos-middle-center,
.opb-badge-wrapper.opb-pos-middle-right,
.opb-badge-wrapper.opb-pos-bottom-left,
.opb-badge-wrapper.opb-pos-bottom-center,
.opb-badge-wrapper.opb-pos-bottom-right {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    transform: none;
}

/* Mobile Adjustments (Optional) */
@media (max-width: 768px) {
    .opb-badge-text {
        font-size: 10px;
        padding: 3px 6px;
    }
    .opb-badge-img {
        max-width: 40px;
    }
}
