/* ========== Shared product carousel (Digikala-like related cards) ========== */

.single-row-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    flex-wrap: nowrap;
}

.single-row-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #212529;
    margin: 12px 0 14px;
    text-align: right;
    width: auto;
    position: relative;
}

.single-row-title::after {
    display: none;
}

@media (min-width: 992px) {
    .single-row-title {
        font-size: 1.5rem;
    }
}

.product-carousel-wrap {
    position: relative;
}

.product-carousel-wrap .desktop-nav-btn {
    display: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    border: 1px solid #e0e0e2;
    border-radius: 50%;
    background: #fff;
    color: #424750;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.product-carousel-wrap .desktop-nav-prev {
    right: 8px;
}

.product-carousel-wrap .desktop-nav-next {
    left: 8px;
}

.product-carousel-wrap .desktop-nav-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    display: block;
}

.product-carousel-wrap .desktop-nav-btn:disabled {
    display: none;
}

@media (min-width: 992px) {
    .product-carousel-wrap .desktop-nav-btn:not(:disabled) {
        display: flex;
    }
}

.product-carousel {
    --pc-card-w: 140px;
    --pc-card-h: 240px;
    --pc-img: 140px;
    --pc-gap: 8px;
    --pc-title-size: 0.75rem;
    --pc-price-size: 0.875rem;
    --pc-orig-size: 0.75rem;
    --pc-discount-size: 0.75rem;
    display: flex;
    flex-wrap: nowrap;
    gap: var(--pc-gap);
    padding: 0 var(--product-page-inset, 1rem) 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    overflow-anchor: none;
}

.product-carousel::-webkit-scrollbar {
    display: none;
}

.product-carousel > a {
    flex: 0 0 var(--pc-card-w);
    width: var(--pc-card-w);
    min-width: var(--pc-card-w);
    max-width: var(--pc-card-w);
    height: var(--pc-card-h);
    display: flex;
    align-items: stretch;
    text-decoration: none;
    color: inherit;
    box-sizing: border-box;
}

.product-carousel .product-card--related {
    width: 100%;
    height: 100%;
    padding: 0;
    gap: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    border: 1px solid #e0e0e2;
    border-radius: 8px;
    background: #fff;
    box-sizing: border-box;
}

.product-carousel .product-card--related .variant-image {
    position: relative;
    width: 100%;
    height: var(--pc-img);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: none;
    border-radius: 0;
    background: transparent;
}

.product-carousel .product-card--related .variant-image img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: var(--pc-img);
    max-height: var(--pc-img);
    object-fit: contain;
    mix-blend-mode: multiply;
    border-radius: 0;
}

.product-carousel .product-card--related .product-card-body {
    width: 100%;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    gap: 4px;
    min-height: 0;
    padding: 4px 8px 8px;
    box-sizing: border-box;
}

.product-carousel .product-card--related .product-name {
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    margin: 0;
    margin-bottom: 0;
    font-size: var(--pc-title-size);
    font-weight: 600;
    line-height: 1.6;
    color: #424750;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

/* Mobile: discount + strikethrough on top, final price below */
.product-carousel .product-info.product-info--related {
    width: 100%;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 2px;
    padding-top: 2px;
}

.product-carousel .product-price-top {
    display: contents;
}

.product-carousel .product-card-discount {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    height: 16px;
    padding: 0 4px;
    background: #d32f2f;
    color: #fff;
    border-radius: 16px;
    font-size: var(--pc-discount-size);
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    order: 1;
}

.product-carousel .product-card--related .variant-original-price {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
    font-size: var(--pc-orig-size);
    font-weight: 400;
    line-height: 16px;
    color: #c0c2c5;
    text-decoration: line-through;
    white-space: nowrap;
    order: 2;
}

.product-carousel .product-card--related .variant-discounted-price {
    display: flex;
    flex-direction: row;
    flex: 0 0 auto;
    width: auto;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    white-space: nowrap;
    color: #23254e;
    font-size: var(--pc-price-size);
    font-weight: 600;
    line-height: 24px;
    order: 3;
}

.product-carousel .product-card--related .toman {
    display: inline-flex;
    width: 14px;
    height: 14px;
    margin: 0;
    flex-shrink: 0;
    color: #424750;
    vertical-align: middle;
}

/* When discount exists on mobile, put discount+original on one visual row */
.product-carousel .product-info.product-info--related:has(.product-card-discount) {
    display: grid;
    grid-template-columns: auto auto;
    justify-content: end;
    align-items: center;
    column-gap: 4px;
    row-gap: 2px;
}

.product-carousel .product-info.product-info--related:has(.product-card-discount) .product-card-discount {
    grid-column: 1;
    grid-row: 1;
    order: unset;
}

.product-carousel .product-info.product-info--related:has(.product-card-discount) .variant-original-price {
    grid-column: 2;
    grid-row: 1;
    order: unset;
}

.product-carousel .product-info.product-info--related:has(.product-card-discount) .variant-discounted-price {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: end;
    order: unset;
}

@media (max-width: 991.98px) {
    .product-carousel-section .product-carousel-wrap {
        margin-inline: calc(var(--product-page-inset, 1rem) * -1);
    }
}

/* Desktop Digikala vertical card (192px) — keep full border, no left-only border */
@media (min-width: 992px) {
    .product-carousel {
        --pc-card-w: 192px;
        --pc-card-h: auto;
        --pc-img: 150px;
        --pc-gap: 24px;
        --pc-title-size: 0.75rem;
        --pc-price-size: 1rem;
        --pc-orig-size: 0.75rem;
        --pc-discount-size: 0.75rem;
        padding: 0 0 8px;
        scroll-padding-inline: 0;
        scroll-snap-type: x mandatory;
    }

    .product-carousel > a {
        height: auto;
        scroll-snap-align: start;
    }

    .product-carousel .product-card--related {
        border: 1px solid #e0e0e2;
        border-radius: 8px;
        padding: 12px 8px;
        justify-content: flex-start;
        gap: 4px;
    }

    .product-carousel .product-card--related .variant-image {
        height: var(--pc-img);
        margin-inline: auto;
        margin-bottom: 4px;
    }

    .product-carousel .product-card--related .variant-image img {
        border-radius: 8px;
    }

    .product-carousel .product-card--related .product-card-body {
        padding: 0;
        gap: 8px;
        justify-content: flex-start;
    }

    .product-carousel .product-card--related .product-name {
        color: #3f4064;
        font-weight: 600;
    }

    .product-carousel .product-info.product-info--related,
    .product-carousel .product-info.product-info--related:has(.product-card-discount) {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 0;
        padding-top: 4px;
        min-height: 0;
    }

    .product-carousel .product-price-top {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        gap: 4px;
    }

    .product-carousel .product-card-discount {
        order: unset;
        height: auto;
        min-height: 20px;
        padding: 0 4px;
    }

    .product-carousel .product-card--related .variant-discounted-price {
        order: unset;
        flex: 1 1 auto;
        justify-content: flex-end;
        gap: 4px;
        color: #3f4064;
        font-size: var(--pc-price-size);
        line-height: 1.4;
    }

    .product-carousel .product-card--related .variant-original-price {
        order: unset;
        align-self: flex-end;
        margin-inline-end: 20px;
        color: #c0c2c5;
        line-height: 1.4;
    }

    .product-carousel .product-card--related .toman {
        width: 14px;
        height: 14px;
    }

}
