/**
 * Web Price Badge — Onecode_WebPriceBadge
 */

/* Badge wrapper */
.web-price-badge {
    display: inline-flex;
    align-items: center;
    position: relative;
    cursor: pointer;
    vertical-align: middle;
}

/* Red pill label */
.web-price-badge__label {
    display: inline-block;
    background: #D32F2F;
    color: #ffffff;
    padding: 5px 13px;
    border-radius: 4px;
    font-size: 1.2rem;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.2px;
    line-height: 1.5;
}

/* Tooltip data — hidden, used only as JS data source */
.web-price-badge__tooltip,
.web-price-badge__tooltip-data {
    display: none !important;
}

/* Floating tooltip rendered by JS into <body> — fixed so it's never clipped */
.web-price-floating-tooltip {
    display: none;
    position: fixed;
    background: rgba(0, 0, 0, 0.87);
    color: #ffffff;
    padding: 18px 20px;
    border-radius: 12px;
    font-size: 1.4rem;
    font-weight: normal;
    width: 280px;
    z-index: 9999;
    line-height: 1.7;
    text-align: center;
    white-space: normal;
    pointer-events: none;
}

/* Arrow pointing DOWN (tooltip above badge — default) */
.web-price-floating-tooltip::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: var(--arrow-left, 50%);
    margin-left: -8px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid rgba(0, 0, 0, 0.87);
}

/* Arrow pointing UP (tooltip below badge — fallback) */
.web-price-floating-tooltip.tooltip-below::after {
    bottom: auto;
    top: -8px;
    border-top: none;
    border-bottom: 8px solid rgba(0, 0, 0, 0.87);
}

/* ── Product page ─────────────────────────────────────── */
/* Override theme: .page-main .columns .main .product-info-main .product-info-price has 5-class specificity.
   Prefix with body.catalog-product-view to win without touching theme files. */
body.catalog-product-view .page-main .columns .main .product-info-main .product-info-price {
    display: -webkit-inline-box !important;
    display: -ms-inline-flexbox !important;
    display: inline-flex !important;
    -webkit-box-align: center !important;
    -ms-flex-align: center !important;
    align-items: center !important;
    float: none !important;
    width: auto !important;
    margin-top: 0 !important;
    gap: 16px;
}

/* Reset vertical offset, keep 20px left spacing, center price text AND center box in container */
body.catalog-product-view .page-main .columns .main .product-info-main .product-info-price .price-box {
    -webkit-box-flex: 0;
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    -webkit-box-align: center !important;
    -ms-flex-align: center !important;
    align-items: center !important;
    position: static !important;
    left: 0 !important;
    top: 0 !important;
    margin-left: 20px;
    margin-top: auto !important;
    margin-bottom: auto !important;
}

body.catalog-product-view .page-main .columns .main .product-info-main .product-info-price .web-price-badge {
    -webkit-box-flex: 0;
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    position: static;
    margin-top: 0 !important;
    margin-bottom: auto !important;
}

/* Slightly larger badge on product page for readability, but still badge-sized */
body.catalog-product-view .product-info-main .product-info-price .web-price-badge__label {
    font-size: 1.3rem;
    padding: 6px 15px;
}

/* ── Catalog / category page ──────────────────────────── */
/* Bottom-right corner sticker — same pattern as .out-of-stock-sticker (position:absolute, top:0, right:0)
   but anchored to the bottom-right of the card.
   padding-bottom on details-grid-inner reserves space so the badge never overlaps the price. */
.details-grid-price-box .web-price-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    z-index: 9;
    display: block;
    margin: 0;
}

li.product-item .details-grid-inner {
    padding-bottom: 36px;
}

/* On hover the absolute badge is hidden — reset padding so hover overlay fits */
body #amasty-shopby-product-list.oc-view-mode--grid.ocjs-loaded li.product-item:hover .details-grid-inner {
    padding-bottom: 0 !important;
}

/* Badge shown inside the hover overlay */
.web-price-badge-hover-wrapper {
    text-align: center;
    padding: 2px 0 6px;
}

/* ── Desktop hover container: increase height to fit badge ─── */
@media (min-width: 768px) {
    /* Hide price-box badge when hover overlay is active (hover section has its own badge) */
    body #amasty-shopby-product-list.oc-view-mode--grid.ocjs-loaded li.product-item:hover .details-grid-price-box .web-price-badge {
        display: none !important;
    }

    body #amasty-shopby-product-list.oc-view-mode--grid.ocjs-loaded li.product-item:hover .product-item-details-grid.desktop {
        max-height: 165px !important;
        -webkit-transform: translateY(-130px) !important;
        -ms-transform: translateY(-130px) !important;
        transform: translateY(-130px) !important;
    }

    /* No-description products: inner section is 36px taller (padding-bottom for badge),
       so the overlay needs 36px more translation + extra max-height to fit badge+button. */
    body #amasty-shopby-product-list.oc-view-mode--grid.ocjs-loaded li.product-item:hover .product-item-details-grid.desktop[data-has-description="false"] {
        max-height: 201px !important;
        -webkit-transform: translateY(-136px) !important;
        -ms-transform: translateY(-136px) !important;
        transform: translateY(-136px) !important;
    }
}

/* ── Amasty related products slider ──────────────────── */
/* Both .price-box (right: 0, top: 36px) and .brand-data (bottom: 50px) are
   absolutely positioned inside .product-item-details.
   Move brand up to make room, then anchor the badge at the same spot. */
.onecode-related-products .product-item-details .brand-data {
    bottom: 85px !important;
}

.onecode-related-products .product-item-details .web-price-badge {
    position: absolute !important;
    right: 0;
    bottom: 50px;
    display: block;
    margin: 0;
    z-index: 10;
}

/* ── Mobile ───────────────────────────────────────────── */
@media (max-width: 799px) {
    /* Hide hover-wrapper badge (no hover on mobile) */
    .web-price-badge-hover-wrapper {
        display: none;
    }

    /* On mobile .details-grid-brand-price gets position:relative (theme CSS),
       which makes our absolute badge anchor to it instead of the card.
       Revert to static flow so it sits below the price, right-aligned. */
    .details-grid-price-box .web-price-badge {
        position: static !important;
        display: block;
        margin-top: 6px;
        text-align: right;
    }

    /* No padding-bottom needed when badge is in normal flow */
    li.product-item .details-grid-inner {
        padding-bottom: 0 !important;
    }
}

/* ── Mobile sticky bar (JS fires at max-width: 1024px) ── */
/* Theme bug: sets both width:100% AND left:12px/right:0 on .product-info-price.
   Over-constrained absolute: CSS honours left+width, recalculates right=-12px,
   pushing the element 12px past the viewport right edge. Fix: width:auto. */
#mobileStickyBar #product_addtocart_form .box-tocart .fieldset .actions .product-info-price {
    width: auto !important;
    display: -webkit-box !important;
    display: -ms-flexbox !important;
    display: flex !important;
    -webkit-box-orient: horizontal !important;
    -webkit-box-direction: normal !important;
    -ms-flex-direction: row !important;
    flex-direction: row !important;
    -webkit-box-pack: end !important;
    -ms-flex-pack: end !important;
    justify-content: flex-end !important;
    -webkit-box-align: center !important;
    -ms-flex-align: center !important;
    align-items: center !important;
    gap: 8px;
    padding-right: 14px !important;
}

#mobileStickyBar #product_addtocart_form .box-tocart .fieldset .actions .product-info-price .price-box {
    -webkit-box-orient: horizontal !important;
    -webkit-box-direction: normal !important;
    -ms-flex-direction: row !important;
    flex-direction: row !important;
    margin-right: 0 !important;
    -webkit-align-self: center !important;
    -ms-flex-item-align: center !important;
    align-self: center !important;
}

#mobileStickyBar #product_addtocart_form .box-tocart .fieldset .actions .product-info-price .web-price-badge {
    -webkit-align-self: center !important;
    -ms-flex-item-align: center !important;
    align-self: center !important;
    margin-top: 0 !important;
    margin-bottom: 18px !important;
}

#mobileStickyBar #product_addtocart_form .box-tocart .fieldset .actions .product-info-price .web-price-badge__label {
    font-size: 0.9rem !important;
    padding: 2px 8px !important;
    line-height: 1.2 !important;
    white-space: nowrap;
}
