/* Mobile layout corrections for retail and wholesale storefronts */
@media (max-width: 767.98px) {
    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Retail: category cards and carousels should not widen the page */
    .find-what-you-need .d-flex.justify-content-between {
        align-items: flex-start !important;
        flex-wrap: wrap;
        gap: 8px !important;
    }

    .find-what-you-need .swiper-slide,
    .find-what-you-need .swiper-wrapper {
        max-width: 100%;
    }

    .find-what-you-need .find-what-you-need-items {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 10px 8px;
        overflow: visible;
    }

    .find-what-you-need .find-what-you-need-items > a,
    .find-what-you-need .find-what-you-need-items > a:not(:last-child),
    .find-what-you-need .find-what-you-need-items > a:last-child {
        width: 100%;
        min-width: 0;
        max-width: none;
        flex: 0 0 auto !important;
    }

    .find-what-you-need .find-what-you-need-items > a .w-80px {
        width: 100%;
    }

    .banner .owl-item img,
    .banner img,
    .main_banners_wrapper-thumb .owl-item img {
        width: 100% !important;
        height: auto !important;
        object-fit: cover;
    }

    /* Wholesale: hero content must wrap inside the screen */
    .wholesale-aster-hero .row,
    .wholesale-aster-hero [class*="col-"],
    .wholesale-aster-hero__content {
        min-width: 0;
        max-width: 100%;
    }

    .wholesale-aster-hero .wholesale-aster-hero__title,
    .wholesale-aster-hero .wholesale-aster-hero__subtitle {
        max-width: 100%;
        white-space: normal !important;
        overflow-wrap: anywhere;
        text-wrap: wrap !important;
    }

    .wholesale-aster-hero .wholesale-aster-hero__tabs {
        flex-wrap: wrap;
        margin-bottom: 18px;
    }

    .wholesale-aster-hero .wholesale-aster-hero__search-pill,
    .wholesale-aster-hero .wholesale-aster-hero__field {
        min-width: 0;
    }

    /* Wholesale shop header: stats must fit four cells */
    .wholesale-shop__stats {
        grid-auto-flow: row !important;
        grid-auto-columns: unset !important;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px !important;
    }

    .wholesale-shop__stats > li,
    .wholesale-shop__stats > li + li {
        min-width: 0;
        padding-inline: 2px !important;
        border-inline-start: 0 !important;
    }

    .wholesale-shop__stat-value {
        font-size: 0.875rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .wholesale-shop__stat-label {
        display: block;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .wholesale-shop__banner img {
        width: 100% !important;
        max-height: 170px;
        object-fit: cover;
    }

    .wholesale-shop__bottom-banner img {
        width: 100% !important;
        max-height: 150px;
        object-fit: cover;
    }

    .wholesale-shop__body {
        grid-template-columns: minmax(0, 1fr) !important;
        grid-template-areas: "identity" "stats" "actions" !important;
    }

    .wholesale-shop__actions {
        min-width: 0;
    }

    /* Wholesale section headers: never overlap arrows */
    .wholesale-aster-panel-head,
    .wholesale-aster-product-carousel__head {
        align-items: flex-start !important;
        flex-wrap: wrap;
        gap: 8px;
    }

    .wholesale-aster-panel-head__actions,
    .wholesale-aster-product-carousel__head .wholesale-aster-view-all {
        flex-shrink: 0;
    }

    .wholesale-aster-panel-head__actions {
        gap: 8px;
        flex-wrap: wrap;
    }

    .wholesale-aster-section-title,
    .wholesale-aster-panel-head .wholesale-aster-section-title {
        min-width: 0;
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .wholesale-aster-product-carousel__title {
        max-width: 100%;
        min-width: 0;
    }

    /* Product cards should not be wider than their column */
    .wholesale-product-list__cards {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    .wholesale-product-card,
    .wholesale-aster-card,
    .wholesale-aster-demand-card {
        min-width: 0;
        max-width: 100%;
    }

    .wholesale-aster-card__name,
    .wholesale-aster-price-card__name {
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

@media (max-width: 767.98px) {
    .find-what-you-need {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .find-what-you-need .d-flex.justify-content-between {
        flex-wrap: wrap !important;
    }

    .find-what-you-need .find-what-you-need-items {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 10px 8px !important;
        overflow: visible !important;
    }

    .find-what-you-need .find-what-you-need-items > a,
    .find-what-you-need .find-what-you-need-items > a:not(:last-child),
    .find-what-you-need .find-what-you-need-items > a:last-child {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        flex: 0 0 auto !important;
    }

    .wholesale-aster-hero {
        overflow: hidden;
    }

    .wholesale-aster-hero > .container,
    .wholesale-aster-hero .container,
    .wholesale-aster-hero .row,
    .wholesale-aster-hero [class*="col-"],
    .wholesale-aster-hero .hero-product__content,
    .wholesale-aster-hero .wholesale-aster-hero__content {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin-left: 0;
        margin-right: 0;
    }

    .wholesale-aster-hero .wholesale-aster-hero__title,
    .wholesale-aster-hero .wholesale-aster-hero__subtitle {
        width: 100% !important;
        max-width: 100% !important;
        white-space: normal !important;
        text-wrap: wrap !important;
        overflow-wrap: anywhere;
        word-break: normal;
    }

    .wholesale-aster-hero .wholesale-aster-hero__title {
        font-size: 20px;
        line-height: 1.25;
    }

    .wholesale-aster-trust-bar__track,
    .wholesale-aster-trust-bar {
        max-width: 100%;
        overflow-x: auto;
    }
}

/* Mobile/tablet carousel arrows must stay inside the viewport, not half off-screen. */
@media (max-width: 991.98px) {
    .owl-carousel .owl-nav .owl-prev,
    .wholesale-aster-product-carousel .owl-nav .owl-prev,
    .recently-viewed-product .owl-prev {
        left: auto !important;
        right: auto !important;
        inset-inline-start: 6px !important;
        inset-inline-end: auto !important;
    }

    .owl-carousel .owl-nav .owl-next,
    .wholesale-aster-product-carousel .owl-nav .owl-next,
    .recently-viewed-product .owl-next {
        left: auto !important;
        right: auto !important;
        inset-inline-start: auto !important;
        inset-inline-end: 6px !important;
    }

    .swiper-button-prev {
        inset-inline-start: 4px !important;
        inset-inline-end: auto !important;
    }

    .swiper-button-next {
        inset-inline-start: auto !important;
        inset-inline-end: 4px !important;
    }
}
