/**
 * JEStarter Product Badges - Frontend Styles
 */

/* Badge Container */
.jestarter-badges-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

/* Badge Wrapper - for filter-based badges (widgets, sliders, shortcodes) */
.jestarter-badge-wrapper {
    position: relative !important;
    display: inline-block !important;
    width: 100%;
}

.jestarter-badge-wrapper img {
    display: block;
    width: 100%;
    height: auto;
}

.jestarter-badge-wrapper .jestarter-badges-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

/* Ensure product image containers have relative positioning */
.woocommerce ul.products li.product .astra-shop-thumbnail-wrap,
.woocommerce ul.products li.product .attachment-woocommerce_thumbnail,
.woocommerce ul.products li.product .woocommerce-product-gallery,
.woocommerce-product-gallery,
.woocommerce-product-gallery__wrapper,
.woocommerce ul.products li.product .wp-post-image,
.astra-shop-thumbnail-wrap,
.product-thumb-wrap,
ul.products li.product,
.woocommerce div.product div.images,
.woocommerce #content div.product div.images,
.jestarter-badge-wrapper,
.jestarter-single-product-badges-wrapper,
.jestarter-gallery-badge-wrapper,
.woocommerce-product-gallery__image {
    position: relative !important;
}

/* Single Product Page - Main Gallery */
.woocommerce div.product div.images {
    position: relative !important;
}

.woocommerce div.product div.images .jestarter-badges-container {
    z-index: 100;
    pointer-events: none;
}

.jestarter-single-product-badges-wrapper {
    position: relative;
}

.jestarter-single-product-badges-wrapper .jestarter-badges-container {
    z-index: 100;
}

.jestarter-gallery-badge-wrapper {
    position: relative;
    display: block;
}

.jestarter-gallery-badge-wrapper .jestarter-badges-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
}

/* JavaScript Injected Badges */
.jestarter-badges-injected {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    pointer-events: none !important;
    z-index: 100 !important;
}

.jestarter-badges-injected .jestarter-badges-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Ensure gallery containers have relative positioning for injected badges */
.woocommerce-product-gallery__wrapper,
.woocommerce-product-gallery,
.flex-viewport,
.ast-woocommerce-product-gallery {
    position: relative !important;
}

/* Badge Groups - Positioning */
.jestarter-badges-group {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 11;
}

.jestarter-badges-top-right {
    top: 10px;
    right: 10px;
    align-items: flex-end;
}

.jestarter-badges-top-left {
    top: 10px;
    left: 10px;
    align-items: flex-start;
}

.jestarter-badges-bottom-right {
    bottom: 10px;
    right: 10px;
    align-items: flex-end;
}

.jestarter-badges-bottom-left {
    bottom: 10px;
    left: 10px;
    align-items: flex-start;
}

/* Base Badge Styles */
.jestarter-badge {
    display: inline-block;
    padding: 5px 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.4;
    white-space: nowrap;
    pointer-events: auto;
    text-align: center;
    box-sizing: border-box;
}

/* Responsive Badge Scaling */

/* DEFAULT: Small badges for all contexts */
.jestarter-badge {
    font-size: 10px !important;
    padding: 3px 8px !important;
    letter-spacing: 0.3px;
}

/* Shop pages - small badges */
ul.products .jestarter-badge,
.jestarter-badge-wrapper .jestarter-badge {
    font-size: 10px !important;
    padding: 3px 8px !important;
}

/* Medium size for 3-column layouts on desktop */
@media (min-width: 768px) {
    ul.products.columns-3 .jestarter-badge {
        font-size: 11px !important;
        padding: 4px 10px !important;
    }
}

/* Larger badges ONLY for confirmed large displays */
/* Single Product Page */
.single-product .woocommerce-product-gallery .jestarter-badge,
.single-product .jestarter-single-image-wrapper .jestarter-badge,
.single-product .jestarter-single-product-badges-overlay .jestarter-badge,
/* 1-2 column layouts */
ul.products.columns-1 .jestarter-badge,
ul.products.columns-2 .jestarter-badge {
    font-size: 14px !important;
    padding: 8px 16px !important;
    letter-spacing: 0.5px;
}

/* Even larger on desktop for single product */
@media (min-width: 992px) {
    .single-product .woocommerce-product-gallery .jestarter-badge,
    .single-product .jestarter-single-image-wrapper .jestarter-badge,
    .single-product .jestarter-single-product-badges-overlay .jestarter-badge,
    ul.products.columns-1 .jestarter-badge {
        font-size: 16px !important;
        padding: 10px 20px !important;
    }
}

/* Badge position groups - tighter spacing for small badges */
.jestarter-badges-group {
    gap: 4px;
}

.jestarter-badges-top-right {
    top: 8px;
    right: 8px;
}

.jestarter-badges-top-left {
    top: 8px;
    left: 8px;
}

.jestarter-badges-bottom-right {
    bottom: 8px;
    right: 8px;
}

.jestarter-badges-bottom-left {
    bottom: 8px;
    left: 8px;
}

/* Larger spacing for single product and 1-2 col layouts */
.single-product .jestarter-badges-group,
ul.products.columns-1 .jestarter-badges-group,
ul.products.columns-2 .jestarter-badges-group {
    gap: 6px;
}

.single-product .jestarter-badges-top-right,
.single-product .woocommerce-product-gallery .jestarter-badges-top-right,
ul.products.columns-1 .jestarter-badges-top-right,
ul.products.columns-2 .jestarter-badges-top-right {
    top: 12px;
    right: 12px;
}

.single-product .jestarter-badges-top-left,
.single-product .woocommerce-product-gallery .jestarter-badges-top-left,
ul.products.columns-1 .jestarter-badges-top-left,
ul.products.columns-2 .jestarter-badges-top-left {
    top: 12px;
    left: 12px;
}

.single-product .jestarter-badges-bottom-right,
.single-product .woocommerce-product-gallery .jestarter-badges-bottom-right,
ul.products.columns-1 .jestarter-badges-bottom-right,
ul.products.columns-2 .jestarter-badges-bottom-right {
    bottom: 12px;
    right: 12px;
}

.single-product .jestarter-badges-bottom-left,
.single-product .woocommerce-product-gallery .jestarter-badges-bottom-left,
ul.products.columns-1 .jestarter-badges-bottom-left,
ul.products.columns-2 .jestarter-badges-bottom-left {
    bottom: 12px;
    left: 12px;
}

/* Round badge scaling */
.jestarter-badge-round {
    min-width: 40px;
    min-height: 40px;
    padding: 6px;
}

.single-product .jestarter-badge-round,
.single-product .woocommerce-product-gallery .jestarter-badge-round,
ul.products.columns-1 .jestarter-badge-round,
ul.products.columns-2 .jestarter-badge-round {
    min-width: 70px;
    min-height: 70px;
    padding: 12px;
}

@media (min-width: 992px) {
    .single-product .jestarter-badge-round,
    .single-product .woocommerce-product-gallery .jestarter-badge-round,
    ul.products.columns-1 .jestarter-badge-round {
        min-width: 90px;
        min-height: 90px;
        padding: 15px;
    }
}

/* Rectangle Style */
.jestarter-badge-rectangle {
    border-radius: 0;
}

/* Rounded Rectangle Style */
.jestarter-badge-rounded {
    border-radius: 4px;
}

/* Round/Circle Style */
.jestarter-badge-round {
    border-radius: 50%;
    min-width: 50px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    aspect-ratio: 1;
}

/* Ribbon Style */
.jestarter-badge-ribbon {
    position: relative;
    padding: 6px 15px 6px 12px;
    margin-right: -10px;
}

.jestarter-badges-top-right .jestarter-badge-ribbon,
.jestarter-badges-bottom-right .jestarter-badge-ribbon {
    border-radius: 3px 0 0 3px;
    margin-right: -10px;
    margin-left: 0;
}

.jestarter-badges-top-right .jestarter-badge-ribbon::before,
.jestarter-badges-bottom-right .jestarter-badge-ribbon::before {
    content: '';
    position: absolute;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
}

.jestarter-badges-top-right .jestarter-badge-ribbon::before {
    bottom: -6px;
    border-width: 0 10px 6px 0;
    border-color: transparent currentColor transparent transparent;
    filter: brightness(0.7);
}

.jestarter-badges-bottom-right .jestarter-badge-ribbon::before {
    top: -6px;
    border-width: 6px 10px 0 0;
    border-color: currentColor transparent transparent transparent;
    filter: brightness(0.7);
}

.jestarter-badges-top-left .jestarter-badge-ribbon,
.jestarter-badges-bottom-left .jestarter-badge-ribbon {
    border-radius: 0 3px 3px 0;
    margin-left: -10px;
    margin-right: 0;
    padding: 6px 12px 6px 15px;
}

.jestarter-badges-top-left .jestarter-badge-ribbon::before,
.jestarter-badges-bottom-left .jestarter-badge-ribbon::before {
    content: '';
    position: absolute;
    left: 0;
    width: 0;
    height: 0;
    border-style: solid;
}

.jestarter-badges-top-left .jestarter-badge-ribbon::before {
    bottom: -6px;
    border-width: 6px 0 0 10px;
    border-color: transparent transparent transparent currentColor;
    filter: brightness(0.7);
}

.jestarter-badges-bottom-left .jestarter-badge-ribbon::before {
    top: -6px;
    border-width: 0 0 6px 10px;
    border-color: transparent transparent currentColor transparent;
    filter: brightness(0.7);
}

/* Banner Style */
.jestarter-badge-banner {
    position: relative;
    padding: 8px 20px;
    clip-path: polygon(0% 0%, 100% 0%, 95% 50%, 100% 100%, 0% 100%, 5% 50%);
}

.jestarter-badges-top-left .jestarter-badge-banner,
.jestarter-badges-bottom-left .jestarter-badge-banner {
    clip-path: polygon(0% 0%, 100% 0%, 95% 50%, 100% 100%, 0% 100%);
    margin-left: -10px;
    padding-left: 15px;
}

.jestarter-badges-top-right .jestarter-badge-banner,
.jestarter-badges-bottom-right .jestarter-badge-banner {
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 5% 50%);
    margin-right: -10px;
    padding-right: 15px;
}

/* Ribbon scaling for large images */
.single-product .jestarter-badge-ribbon,
.single-product .woocommerce-product-gallery .jestarter-badge-ribbon,
ul.products.columns-1 .jestarter-badge-ribbon,
ul.products.columns-2 .jestarter-badge-ribbon {
    padding: 8px 20px 8px 16px;
    margin-right: -12px;
}

.single-product .jestarter-badges-top-left .jestarter-badge-ribbon,
.single-product .jestarter-badges-bottom-left .jestarter-badge-ribbon,
ul.products.columns-1 .jestarter-badges-top-left .jestarter-badge-ribbon,
ul.products.columns-1 .jestarter-badges-bottom-left .jestarter-badge-ribbon,
ul.products.columns-2 .jestarter-badges-top-left .jestarter-badge-ribbon,
ul.products.columns-2 .jestarter-badges-bottom-left .jestarter-badge-ribbon {
    padding: 8px 16px 8px 20px;
    margin-left: -12px;
    margin-right: 0;
}

/* Banner scaling for large images */
.single-product .jestarter-badge-banner,
.single-product .woocommerce-product-gallery .jestarter-badge-banner,
ul.products.columns-1 .jestarter-badge-banner,
ul.products.columns-2 .jestarter-badge-banner {
    padding: 10px 24px;
}

/* Single Product Page Specific */
.woocommerce div.product div.images .jestarter-badges-container {
    z-index: 100;
}

/* Widget and Slider Specific Styles */
.jestarter-badge-wrapper {
    position: relative !important;
    display: inline-block;
}

.jestarter-badge-wrapper .jestarter-badges-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
}

/* Make sure badge wrapper works in slick/swiper sliders */
.slick-slide .jestarter-badge-wrapper,
.swiper-slide .jestarter-badge-wrapper,
[class*="slider"] .jestarter-badge-wrapper,
[class*="carousel"] .jestarter-badge-wrapper {
    position: relative !important;
    display: block;
    width: 100%;
}

/* Ensure images inside badge wrapper display properly */
.jestarter-badge-wrapper img {
    display: block;
    width: 100%;
    height: auto;
}

/* Astra Theme Overrides */
.ast-woo-product-category .jestarter-badges-container,
.astra-shop-thumbnail-wrap .jestarter-badges-container {
    z-index: 100;
}

/* Astra Single Product Gallery */
.ast-product-gallery-layout-vertical .jestarter-badges-container,
.ast-product-gallery-layout-horizontal .jestarter-badges-container,
.ast-product-gallery-layout-first-image-large .jestarter-badges-container {
    z-index: 100;
}

.ast-woocommerce-product-gallery .jestarter-badges-container {
    z-index: 100;
}

/* Ensure Astra gallery wrapper has proper positioning */
.ast-woocommerce-product-gallery,
.ast-product-gallery-layout-vertical,
.ast-product-gallery-layout-horizontal,
.ast-product-gallery-layout-first-image-large {
    position: relative !important;
}

/* For Astra's flex image gallery */
.flex-viewport {
    position: relative !important;
}

.flex-viewport .jestarter-badges-container {
    z-index: 100;
}

/* Hide default WooCommerce sale badge */
.jestarter-badges-container ~ .onsale,
.onsale.jestarter-hidden {
    display: none !important;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .jestarter-badge {
        padding: 4px 8px;
        font-size: 10px !important;
    }
    
    .jestarter-badge-round {
        min-width: 40px;
        min-height: 40px;
        padding: 8px;
    }
    
    .jestarter-badges-top-right,
    .jestarter-badges-top-left,
    .jestarter-badges-bottom-right,
    .jestarter-badges-bottom-left {
        top: 5px;
        right: 5px;
        left: auto;
        bottom: auto;
    }
    
    .jestarter-badges-top-left {
        left: 5px;
        right: auto;
    }
    
    .jestarter-badges-bottom-right {
        top: auto;
        bottom: 5px;
        right: 5px;
    }
    
    .jestarter-badges-bottom-left {
        top: auto;
        bottom: 5px;
        left: 5px;
        right: auto;
    }
}

/* Animation on hover */
.jestarter-badge {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.product:hover .jestarter-badge,
.woocommerce-product-gallery:hover .jestarter-badge {
    transform: scale(1.05);
}

/* Ensure badges appear above Astra elements */
.ast-onsale-card {
    display: none !important;
}

/* Quick view and lightbox compatibility */
.pswp .jestarter-badges-container {
    display: none;
}
