/* Badge Module — Front Styles */

/* ===== Container ===== */
.product-badges {
    position: absolute;
    left: 0;
    z-index: 99;
    top: 0;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
}

/* ===== Badge Item ===== */
.product-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 6px;
    background: transparent;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.4;
    text-decoration: none;
    color: inherit;
    cursor: default;
}

a.product-badge {
    cursor: pointer;
    transition: opacity 0.2s;
}

a.product-badge:hover {
    opacity: 0.85;
    text-decoration: none;
}

/* ===== Icon ===== */
.product-badge__icon {
    display: inline-block;
    align-items: center;
    flex-shrink: 0;
    width: 35px;
    height: 35px;
}
.product_gallery_column .product-badge__icon{
    width: 50px;
    height: 50px;
}
.product-badge:has(svg){
    background-color: var(--white);
}
.product-badge__icon:has(svg){
    width: 20px;
    height: 20px;
}
.product-badge__icon img,
.product-badge__icon svg {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

/* ===== Title ===== */
.product-badge__title {
    white-space: nowrap;
}

/* ===== Tooltip ===== */
.product-badge__tooltip-text {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: calc( 100% + 6px );
    right: 50%;
    transform: translateX( 50% );
    min-width: 140px;
    max-width: 220px;
    background: #1d2327;
    color: #fff;
    font-size: 11px;
    line-height: 1.5;
    padding: 6px 10px;
    border-radius: 4px;
    text-align: center;
    white-space: normal;
    z-index: 99;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    word-break: break-word;
}
figcaption.product_card_badge .product-badge__tooltip-text {
    bottom: auto !important;
    top: calc(100% + 6px);
}
/* Arrow */
.product-badge__tooltip-text::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 50%;
    transform: translateX( 50% );
    border: 5px solid transparent;
    border-top-color: #1d2327;
}
figcaption.product_card_badge .product-badge__tooltip-text::after {
   top: auto;
   bottom: 100%;
   border-bottom-color: #1d2327;
   border-top-color: transparent;
}
.product-badge:hover .product-badge__tooltip-text,
.product-badge:focus-within .product-badge__tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Tooltip که روی body mount می‌شه — توسط JS ساخته می‌شه */
.badge-tooltip-global {
    position: fixed;
    z-index: 99999;
    background: #1d2327;
    color: #fff;
    font-size: 11px;
    line-height: 1.5;
    padding: 6px 10px;
    border-radius: 4px;
    text-align: center;
    white-space: normal;
    word-break: break-word;
    max-width: 220px;
    min-width: 100px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.badge-tooltip-global.is-visible {
    opacity: 1;
}

.badge-tooltip-global::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 50%;
    transform: translateX( 50% );
    border: 5px solid transparent;
    border-top-color: #1d2327;
}

/* وقتی tooltip زیر badge نشون داده می‌شه */
.badge-tooltip-global.is-below::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #1d2327;
}

/* ===== Loop context ===== */
.product-badges--loop {
    position: absolute;
    top: 8px;
    left: 0;
    z-index: 9;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
    margin: 0;
    justify-content: flex-start;
    overflow: visible;
}

.product-badges--loop .product-badge {
    font-size: 11px;
    padding: 3px 6px;
}

/* ===== Accessibility — keyboard focus ===== */
.product-badge:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}
