/* Frontend Badge Styles */

.wcb-sale-badge-wrapper {
    position: absolute;
    z-index: 10;
    pointer-events: none;
}

/* O z-index acima serve para o badge ficar sobre a foto e vale so dentro do card.
   Sem isolar o container, ele sobe para o contexto da pagina e passa por cima do
   submenu do cabecalho, que o WordPress entrega com z-index 2.
   Os dois seletores cobrem os dois lugares onde o badge nasce hoje: a vitrine
   (bloco product-image) e a pagina do produto (galeria). Em tema classico o badge
   nasce em outro pai, que nao casa aqui: segue como esta hoje, sem regressao. */
.wc-block-components-product-image__inner-container:has(> .wcb-sale-badge-wrapper) {
    isolation: isolate;
}

/* Na galeria do produto a propria <img> tem z-index 1. So isolar faria o badge
   afundar atras da foto, entao o container empata em 1 e desempata pela ordem do
   DOM, ficando visivel e ainda abaixo do submenu. */
.wc-block-product-gallery-large-image__inner-blocks:has(> .wcb-sale-badge-wrapper) {
    isolation: isolate;
    z-index: 1;
}

.wcb-sale-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    line-height: 1;
    position: absolute;
    white-space: nowrap;
    animation: wcb-badge-entrance 0.3s ease-out;
}

@keyframes wcb-badge-entrance {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.wcb-badge-text {
    position: relative;
    z-index: 1;
}

/* Badge vertical layout */
.wcb-badge-percentage {
    line-height: 1.1;
}

.wcb-badge-text-label {
    line-height: 1.1;
    margin-top: 2px;
}

/* Position Classes */
.wcb-position-top-left .wcb-sale-badge {
    left: 0;
    top: 0;
}

.wcb-position-top-right .wcb-sale-badge {
    right: 0;
    top: 0;
}

/* Posicao e escala dos badges especiais.
   As distancias vem de variaveis inline (--wcb-top/--wcb-left/--wcb-right) em vez de
   propriedades inline, porque estilo inline vence media query e impedia qualquer
   ajuste separado para celular. */
.wcb-sale-badge-wrapper .wcb-special-badge {
    top: var(--wcb-top, 0);
    left: var(--wcb-left, auto);
    right: var(--wcb-right, auto);
}

.wcb-sale-badge-wrapper .wcb-special-badge .wcb-badge-text {
    font-size: var(--wcb-fs, 10px);
}

/* Default Badge (Rectangle).
   Posicao, fonte, padding e tamanho vem de variaveis inline, pelo mesmo motivo
   do badge especial: propriedade inline vence media query e impediria o ajuste
   de celular. O valor padrao de cada var e o que o badge tinha antes. */
.wcb-sale-badge-wrapper .wcb-sale-badge-default {
    top: var(--wcb-top, 0);
    left: var(--wcb-left, auto);
    right: var(--wcb-right, auto);
    font-size: var(--wcb-fs, 14px);
    padding: var(--wcb-pv, 8px) var(--wcb-ph, 8px);
    width: var(--wcb-w, auto);
    height: var(--wcb-h, auto);
}

/* Special Badge Shapes */

/* Star Shape */
.wcb-shape-star {
    width: var(--wcb-w, 90px) !important;
    height: var(--wcb-h, 90px) !important;
    position: relative;
    clip-path: polygon(50% 0%,
            61% 35%,
            98% 35%,
            68% 57%,
            79% 91%,
            50% 70%,
            21% 91%,
            32% 57%,
            2% 35%,
            39% 35%) !important;
}

.wcb-shape-star .wcb-badge-text {
    font-size: 10px;
    font-weight: 700;
    padding: var(--wcb-pv, 20px) var(--wcb-ph, 10px);
    text-align: center;
    z-index: 10;
    position: relative;
    line-height: 1.2;
    word-break: break-word;
    max-width: var(--wcb-tw, 50px);
}

/* Burst/Explosion Shape - CENTRO MAIOR */
.wcb-shape-burst {
    width: var(--wcb-w, 100px) !important;
    height: var(--wcb-h, 100px) !important;
    position: relative;
    background: transparent !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wcb-shape-burst::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: currentColor;
    /* Clip-path modificado para centro maior */
    clip-path: polygon(50% 0%,
            58% 30%,
            95% 30%,
            70% 50%,
            80% 88%,
            50% 70%,
            20% 88%,
            30% 50%,
            5% 30%,
            42% 30%);
    z-index: 0;
}

.wcb-shape-burst::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: currentColor;
    /* Clip-path modificado para centro maior */
    clip-path: polygon(50% 0%,
            58% 30%,
            95% 30%,
            70% 50%,
            80% 88%,
            50% 70%,
            20% 88%,
            30% 50%,
            5% 30%,
            42% 30%);
    transform: rotate(22.5deg);
    opacity: 0.8;
    z-index: 0;
}

.wcb-shape-burst .wcb-badge-text {
    font-size: 10px;
    font-weight: 700;
    padding: var(--wcb-pv, 5px) var(--wcb-ph, 5px);
    text-align: center;
    position: relative;
    z-index: 10;
    line-height: 1.3;
    word-break: break-word;
    max-width: var(--wcb-tw, 55px);
    /* Permitir quebra de linha */
    white-space: normal !important;
}

/* Hexagon Shape */
.wcb-shape-hexagon {
    width: var(--wcb-w, 90px) !important;
    height: var(--wcb-h, 80px) !important;
    position: relative;
    clip-path: polygon(30% 0%,
            70% 0%,
            100% 50%,
            70% 100%,
            30% 100%,
            0% 50%) !important;
}

.wcb-shape-hexagon .wcb-badge-text {
    font-size: 12px;
    padding: var(--wcb-pv, 5px) var(--wcb-ph, 5px);
    text-align: center;
    z-index: 10;
    position: relative;
}

/* Circle Shape */
.wcb-shape-circle {
    width: var(--wcb-w, 80px) !important;
    height: var(--wcb-h, 80px) !important;
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wcb-shape-circle .wcb-badge-text {
    font-size: 11px;
    text-align: center;
    padding: var(--wcb-pv, 10px) var(--wcb-ph, 10px);
    line-height: 1.2;
    z-index: 10;
    position: relative;
    /* Permitir quebra de linha */
    white-space: normal !important;
}

/* Square Shape */
.wcb-shape-square {
    width: var(--wcb-w, 80px) !important;
    height: var(--wcb-h, 80px) !important;
    /* zera o arredondamento que vem das configuracoes do badge padrao: quadrado e quadrado */
    border-radius: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wcb-shape-square .wcb-badge-text {
    font-size: 11px;
    text-align: center;
    padding: var(--wcb-pv, 10px) var(--wcb-ph, 10px);
    line-height: 1.2;
    z-index: 10;
    position: relative;
    /* Permitir quebra de linha */
    white-space: normal !important;
}

/* Ribbon Shape */
.wcb-shape-ribbon {
    position: relative;
    padding: var(--wcb-pv, 12px) var(--wcb-ph, 25px);
    min-width: var(--wcb-minw, 90px);
    text-align: center;
    overflow: visible;
    border-radius: 0 !important;
}

.wcb-shape-ribbon::before,
.wcb-shape-ribbon::after {
    content: '';
    position: absolute;
    top: 100%;
    width: 0;
    height: 0;
    border-style: solid;
}

.wcb-shape-ribbon::before {
    left: 0;
    border-width: 12px 12px 0 0;
    border-color: inherit;
    border-right-color: transparent;
    border-bottom-color: transparent;
    filter: brightness(0.7);
}

.wcb-shape-ribbon::after {
    right: 0;
    border-width: 12px 0 0 12px;
    border-color: inherit;
    border-left-color: transparent;
    border-bottom-color: transparent;
    filter: brightness(0.7);
}

.wcb-shape-ribbon .wcb-badge-text {
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
    /* Permitir quebra de linha */
    white-space: normal !important;
}

/* Permitir quebra de linha em TODOS os badges especiais */
.wcb-special-badge .wcb-badge-text {
    white-space: normal !important;
}

/* Star também permite quebra de linha */
.wcb-shape-star .wcb-badge-text {
    white-space: normal !important;
}

/* Hexagon também permite quebra de linha */
.wcb-shape-hexagon .wcb-badge-text {
    white-space: normal !important;
}

/* WooCommerce Blocks Integration */
.wp-block-woocommerce-product-image {
    position: relative;
}

.wc-block-grid__product {
    position: relative;
}

/* Hide original WooCommerce sale badge when our plugin is active */
.wc-block-components-product-sale-badge {
    display: none !important;
}

/* WooCommerce Traditional Templates */
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product {
    position: relative;
}

.woocommerce div.product div.images,
.woocommerce-page div.product div.images {
    position: relative;
}

.woocommerce div.product .woocommerce-product-gallery {
    position: relative;
}

/* Ensure badge is above product image */
.wcb-sale-badge-wrapper {
    z-index: 10 !important;
    pointer-events: none;
}

/* Ajustes de celular (ate 768px).
   Cada variavel cai para a do desktop quando o badge nao tem ajuste de celular. */
@media (max-width: 768px) {

    .wcb-sale-badge-wrapper .wcb-special-badge {
        top: var(--wcb-top-m, var(--wcb-top, 0));
        left: var(--wcb-left-m, var(--wcb-left, auto));
        right: var(--wcb-right-m, var(--wcb-right, auto));
    }

    .wcb-sale-badge-wrapper .wcb-special-badge .wcb-badge-text {
        font-size: var(--wcb-fs-m, var(--wcb-fs, 10px));
    }

    /* Cada formato mantem, como padrao do celular, exatamente a medida que tem
       no desktop: badge sem ajuste de celular continua igual ao que era. */
    .wcb-special-badge.wcb-shape-star {
        width: var(--wcb-w-m, var(--wcb-w, 90px)) !important;
        height: var(--wcb-h-m, var(--wcb-h, 90px)) !important;
    }

    .wcb-special-badge.wcb-shape-star .wcb-badge-text {
        padding: var(--wcb-pv-m, var(--wcb-pv, 20px)) var(--wcb-ph-m, var(--wcb-ph, 10px));
        max-width: var(--wcb-tw-m, var(--wcb-tw, 50px));
    }

    .wcb-special-badge.wcb-shape-burst {
        width: var(--wcb-w-m, var(--wcb-w, 100px)) !important;
        height: var(--wcb-h-m, var(--wcb-h, 100px)) !important;
    }

    .wcb-special-badge.wcb-shape-burst .wcb-badge-text {
        padding: var(--wcb-pv-m, var(--wcb-pv, 5px)) var(--wcb-ph-m, var(--wcb-ph, 5px));
        max-width: var(--wcb-tw-m, var(--wcb-tw, 55px));
    }

    .wcb-special-badge.wcb-shape-hexagon {
        width: var(--wcb-w-m, var(--wcb-w, 90px)) !important;
        height: var(--wcb-h-m, var(--wcb-h, 80px)) !important;
    }

    .wcb-special-badge.wcb-shape-hexagon .wcb-badge-text {
        padding: var(--wcb-pv-m, var(--wcb-pv, 5px)) var(--wcb-ph-m, var(--wcb-ph, 5px));
    }

    .wcb-special-badge.wcb-shape-circle {
        width: var(--wcb-w-m, var(--wcb-w, 80px)) !important;
        height: var(--wcb-h-m, var(--wcb-h, 80px)) !important;
    }

    .wcb-special-badge.wcb-shape-circle .wcb-badge-text {
        padding: var(--wcb-pv-m, var(--wcb-pv, 10px)) var(--wcb-ph-m, var(--wcb-ph, 10px));
    }

    .wcb-special-badge.wcb-shape-square {
        width: var(--wcb-w-m, var(--wcb-w, 80px)) !important;
        height: var(--wcb-h-m, var(--wcb-h, 80px)) !important;
    }

    .wcb-special-badge.wcb-shape-square .wcb-badge-text {
        padding: var(--wcb-pv-m, var(--wcb-pv, 10px)) var(--wcb-ph-m, var(--wcb-ph, 10px));
    }

    .wcb-shape-ribbon {
        padding: var(--wcb-pv-m, 8px) var(--wcb-ph-m, 15px);
        min-width: var(--wcb-minw-m, 80px);
    }

    /* Badge normal (promocional): mesma regra de queda do especial. Sem ajuste
       de celular configurado, cada var cai para a do desktop e nada muda. */
    .wcb-sale-badge-wrapper .wcb-sale-badge-default {
        top: var(--wcb-top-m, var(--wcb-top, 0));
        left: var(--wcb-left-m, var(--wcb-left, auto));
        right: var(--wcb-right-m, var(--wcb-right, auto));
        font-size: var(--wcb-fs-m, var(--wcb-fs, 14px));
        padding: var(--wcb-pv-m, var(--wcb-pv, 8px)) var(--wcb-ph-m, var(--wcb-ph, 8px));
        width: var(--wcb-w-m, var(--wcb-w, auto));
        height: var(--wcb-h-m, var(--wcb-h, auto));
    }
}

/* Hover effect for special badges */
.wcb-special-badge {
    transition: transform 0.2s ease;
}

.wcb-sale-badge-wrapper:hover .wcb-special-badge {
    transform: scale(1.05);
}