.ap-ai-image {
    position: relative;
    display: inline-block;
    max-width: 100%;
    vertical-align: top;
    line-height: 0;
}

.ap-ai-image--block {
    display: block;
}

.ap-ai-image > img,
.ap-ai-image > picture,
.ap-ai-image > picture > img {
    max-width: 100%;
}

/* Žyma dedama į esamą nuotraukos konteinerį, o ne apgaubia img elementą.
 * Taip išlaikoma Flatsome „Equal Image Heights“ reikalaujama DOM struktūra. */
.ap-ai-image-host--positioned {
    position: relative !important;
}

.ap-ai-image__badge {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 50;
    display: block;
    width: clamp(58px, 24%, 116px);
    max-width: calc(100% - 16px);
    line-height: 0;
    cursor: help;
    outline: none;
}

/* Ikona sąmoningai nėra <img> elementas. Flatsome „Equal Image Heights“
 * apdoroja visus produkto vaizdo konteineryje esančius img elementus, todėl
 * papildomas žymos img galėjo būti palaikytas produkto nuotrauka ir ją paslėpti. */
.ap-ai-image__badge .ap-ai-image__icon {
    position: static !important;
    inset: auto !important;
    display: block !important;
    width: 100% !important;
    aspect-ratio: 60 / 13;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 999px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    transform: none !important;
    opacity: 1 !important;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.28);
}

/* Tekstas paliekamas prie žymos ekrano skaitytuvams. Matomas paaiškinimas
 * perkeltas į body lygmens elementą, todėl jo nebekarpo produktų kortelių
 * overflow: hidden taisyklės. */
.ap-ai-image__tooltip {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.ap-ai-image__floating-tooltip {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2147483000;
    box-sizing: border-box;
    width: max-content;
    max-width: min(300px, calc(100vw - 24px));
    padding: 9px 11px;
    border-radius: 5px;
    background: #111;
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.35;
    text-align: left;
    white-space: normal;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-3px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
}

.ap-ai-image__floating-tooltip.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.ap-ai-image__badge:focus-visible .ap-ai-image__icon {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

@media (max-width: 480px) {
    .ap-ai-image__badge {
        top: 6px;
        right: 6px;
        width: clamp(52px, 28%, 96px);
        max-width: calc(100% - 12px);
    }

    .ap-ai-image__floating-tooltip {
        font-size: 12px;
    }
}

/* Flatsome / WooCommerce produkto galerijoje žyma turi būti lygiuojama pagal
 * visą skaidrę, o ne pagal nuotrauką centruojančią nuorodą. */
.single-product .woocommerce-product-gallery__image > .ap-ai-image__badge,
.single-product .product-gallery .slide > .ap-ai-image__badge {
    top: 8px;
    right: 8px;
}

@media (max-width: 480px) {
    .single-product .woocommerce-product-gallery__image > .ap-ai-image__badge,
    .single-product .product-gallery .slide > .ap-ai-image__badge {
        top: 6px;
        right: 6px;
    }
}
