/* ==========================================================================
   Shared product card design (tablet / desktop, 768px and up).
   Applies to every product grid on the user side: any ".row" whose direct
   children are columns holding an ".ast_product_section" card
   (home, all-products, shop, wishlist, collection-details, checkout upsell).
   Mobile (< 768px) keeps the original list-style cards from redesign.min.css.
   ========================================================================== */
@media (min-width: 768px) {

    /* ----- Grid: fills the available width, cards wrap by width ----- */
    .row:has(> [class*="col-"] > .ast_product_section) {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
        gap: 16px;
        margin: 0;
        --bs-gutter-x: 0;
        padding-left: 0;
        list-style: none;
        --bs-gutter-y: 0;
    }

    .row:has(> [class*="col-"] > .ast_product_section) > [class*="col-"] {
        display: flex;
        width: auto !important;
        max-width: none !important;
        min-width: 0;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* ----- Card ----- */
    :is(.row:has(> [class*="col-"] > .ast_product_section), .swiper-wrapper:has(> .swiper-slide > .ast_product_section), .stack-page:has(> .stack-item > .ast_product_section)) .ast_product_section {
        display: flex;
        flex-direction: column;
        width: 100%;
        min-width: 0;
        margin: 0 !important;
        overflow: hidden;
        border-radius: 12px;
        border: 1px solid rgba(0, 0, 0, .06);
        background: #fff;
        box-shadow: 0 4px 14px rgba(0, 0, 0, .08);
        transition: transform .25s ease, box-shadow .25s ease;
    }

    :is(.row:has(> [class*="col-"] > .ast_product_section), .swiper-wrapper:has(> .swiper-slide > .ast_product_section), .stack-page:has(> .stack-item > .ast_product_section)) .ast_product_section:hover {
        transform: translateY(-4px);
        box-shadow: 0 10px 24px rgba(0, 0, 0, .14);
    }

    /* ----- Image: fills the whole frame (redesign.min.css forces contain + 180px) ----- */
    :is(.row:has(> [class*="col-"] > .ast_product_section), .swiper-wrapper:has(> .swiper-slide > .ast_product_section), .stack-page:has(> .stack-item > .ast_product_section)) .ast_product_section .ast_product_image {
        position: relative;
        display: block !important;
        flex: 0 0 auto !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        aspect-ratio: 5 / 4;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: #faf6ef !important;
    }

    :is(.row:has(> [class*="col-"] > .ast_product_section), .swiper-wrapper:has(> .swiper-slide > .ast_product_section), .stack-page:has(> .stack-item > .ast_product_section)) .ast_product_section .ast_product_image a {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
    }

    :is(.row:has(> [class*="col-"] > .ast_product_section), .swiper-wrapper:has(> .swiper-slide > .ast_product_section), .stack-page:has(> .stack-item > .ast_product_section)) .ast_product_section .ast_product_image img.product-img {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        margin: 0 !important;
        object-fit: cover !important;
        object-position: center;
    }

    /* ----- Body ----- */
    :is(.row:has(> [class*="col-"] > .ast_product_section), .swiper-wrapper:has(> .swiper-slide > .ast_product_section), .stack-page:has(> .stack-item > .ast_product_section)) .ast_product_section .ast_product_info {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        gap: 2px;
        min-width: 0;
        padding: 8px 10px 10px !important;
        text-align: center;
    }

    :is(.row:has(> [class*="col-"] > .ast_product_section), .swiper-wrapper:has(> .swiper-slide > .ast_product_section), .stack-page:has(> .stack-item > .ast_product_section)) .ast_product_section .ast_shop_title {
        min-height: 2.6em;
        margin: 0 !important;
        font-size: .95rem !important;
        line-height: 1.3;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow-wrap: anywhere;
    }

    :is(.row:has(> [class*="col-"] > .ast_product_section), .swiper-wrapper:has(> .swiper-slide > .ast_product_section), .stack-page:has(> .stack-item > .ast_product_section)) .ast_product_section .ast_shop_title a {
        color: inherit;
    }

    :is(.row:has(> [class*="col-"] > .ast_product_section), .swiper-wrapper:has(> .swiper-slide > .ast_product_section), .stack-page:has(> .stack-item > .ast_product_section)) .ast_product_section .product_description {
        margin: 0 auto !important;
    }

    :is(.row:has(> [class*="col-"] > .ast_product_section), .swiper-wrapper:has(> .swiper-slide > .ast_product_section), .stack-page:has(> .stack-item > .ast_product_section)) .ast_product_section .price2 {
        margin: 0 !important;
        font-size: 1.05rem !important;
    }

    :is(.row:has(> [class*="col-"] > .ast_product_section), .swiper-wrapper:has(> .swiper-slide > .ast_product_section), .stack-page:has(> .stack-item > .ast_product_section)) .ast_product_section .fixed-add-to-cart {
        flex-wrap: wrap;
        justify-content: center !important;
        margin-top: auto;
        padding-top: 6px;
    }

    :is(.row:has(> [class*="col-"] > .ast_product_section), .swiper-wrapper:has(> .swiper-slide > .ast_product_section), .stack-page:has(> .stack-item > .ast_product_section)) .ast_product_section .fixed-add-to-cart .btn {
        padding: 6px 10px;
        font-size: .8rem;
    }

    /* ----- Home page "Astro Shopping" section ----- */
    .ast_shop_wrapper {
        float: none;
        clear: both;
        overflow: hidden;
        background-size: cover;
        background-position: center;
    }

    .ast_shop_wrapper.ast_toppadder70.ast_bottompadder70 {
        padding-top: 16px !important;
        padding-bottom: 16px !important;
    }

    /* full width instead of the 10/12 column that left empty side space */
    .ast_shop_wrapper > .container-fluid {
        max-width: 1920px;
        padding-left: clamp(8px, 2vw, 32px);
        padding-right: clamp(8px, 2vw, 32px);
    }

    .ast_shop_wrapper > .container-fluid > .row > [class*="col-xl-10"] {
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
    }

    .ast_shop_wrapper .ast_shop_main {
        float: none;
        clear: both;
    }

    .ast_shop_wrapper .premium-section-header {
        margin-bottom: 12px !important;
    }

    .ast_shop_wrapper .premium-section-header .premium-headline {
        margin-bottom: 4px;
    }

    .ast_shop_wrapper .premium-section-header .header-divider {
        margin: 4px auto;
    }

    .ast_shop_wrapper .premium-section-header .premium-subline {
        margin-bottom: 0;
    }

    .ast_shop_wrapper .ast_shop_main > .col-12.mt-md-5 {
        margin-top: 6px !important;
    }

    .ast_shop_wrapper .ast_shop_main .btn-primary.rounded-pill {
        margin-top: 12px !important;
    }

    /* home keeps an even 4 per row so the 8 products fill two full rows */
    .ast_shop_wrapper .row:has(> [class*="col-"] > .ast_product_section) {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 14px;
    }
}

@media (min-width: 992px) {
    .ast_shop_wrapper .row:has(> [class*="col-"] > .ast_product_section) {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 16px;
    }
}

@media (min-width: 1700px) {
    .ast_shop_wrapper .row:has(> [class*="col-"] > .ast_product_section) {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

/* ----- Wishlist page: use the full width like the other grids ----- */
@media (min-width: 768px) {
    .row > [class*="col-"]:has(> .Wishlist_Section) {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ----- Wishlist card: discount chip and remove button sit in the card body (all screen sizes),
         so nothing is layered over the image, the title or each other ----- */
.Wishlist_Section .ast_product_section .price2 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px 8px;
}

.Wishlist_Section .wishlist-off-chip {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    background: #e8f7ec;
    color: #168b2b;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.5;
    white-space: nowrap;
}

.Wishlist_Section .wishlist-remove-btn {
    align-self: center;
    margin-top: 4px;
    padding: 2px 10px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #b3261e;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.6;
}

.Wishlist_Section .wishlist-remove-btn:hover {
    background: #fdecec;
}

/* ----- Wishlist card on phones: the list-style card in redesign.min.css is capped at 140px high and
         centres its content, which pushed the product name out of view once the price, stock line and
         buttons were added. Let the card grow with its content and keep the name at the top. ----- */
@media (max-width: 767.98px) {
    .redesign-v4 .Wishlist_Section .ast_product_section {
        align-items: flex-start !important;
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
    }

    .redesign-v4 .Wishlist_Section .ast_product_section .ast_product_image {
        align-self: flex-start !important;
    }

    .redesign-v4 .Wishlist_Section .ast_product_section .ast_product_info {
        min-width: 0;
        height: auto !important;
        gap: 2px;
        justify-content: flex-start !important;
    }

    .redesign-v4 .Wishlist_Section .ast_product_section .ast_product_info .ast_shop_title {
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        max-height: none !important;
        height: auto !important;
        min-height: 0 !important;
        margin-bottom: 2px !important;
        overflow: hidden !important;
        overflow-wrap: anywhere;
        white-space: normal !important;
    }

    .redesign-v4 .Wishlist_Section .ast_product_section .ast_product_info .price2 {
        margin-bottom: 2px !important;
        justify-content: flex-start !important;
    }

    .Wishlist_Section .ast_product_section .ast_product_info > .small {
        margin: 0 0 4px !important;
        font-size: 11px;
        line-height: 1.3;
        text-align: left !important;
    }

    .redesign-v4 .Wishlist_Section .ast_product_section .ast_product_info .fixed-add-to-cart {
        margin-top: 2px !important;
    }

    .Wishlist_Section .wishlist-remove-btn {
        align-self: flex-start;
        margin-top: 2px;
        padding-left: 0;
    }
}

/* ----- Wishlist: tighter spacing between cards (all screen sizes) ----- */
.Wishlist_Section {
    --bs-gutter-y: 0;
    row-gap: 8px;
    margin-bottom: 0 !important;
}

.Wishlist_Section > li {
    margin: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.redesign-v4 .Wishlist_Section .ast_product_section {
    margin: 0 !important;
}

@media (min-width: 768px) {
    .Wishlist_Section.row:has(> [class*="col-"] > .ast_product_section) {
        gap: 10px;
    }
}

/* ==========================================================================
   Common fixes for every product grid (all screen sizes)
   1. Product name: small and semi-bold, not large/bold (beats fs-4 / fw-bold utility classes).
   2. Phone list card: no wasted space on the left of the image.
   ========================================================================== */
:is(.row:has(> [class*="col-"] > .ast_product_section), .swiper-wrapper:has(> .swiper-slide > .ast_product_section), .stack-page:has(> .stack-item > .ast_product_section)) .ast_product_section .ast_product_info .ast_shop_title,
:is(.row:has(> [class*="col-"] > .ast_product_section), .swiper-wrapper:has(> .swiper-slide > .ast_product_section), .stack-page:has(> .stack-item > .ast_product_section)) .ast_product_section .ast_product_info .ast_shop_title a {
    font-size: .88rem !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
}

@media (max-width: 767.98px) {
    :is(.row:has(> [class*="col-"] > .ast_product_section), .swiper-wrapper:has(> .swiper-slide > .ast_product_section), .stack-page:has(> .stack-item > .ast_product_section)) .ast_product_section .ast_product_info .ast_shop_title,
    :is(.row:has(> [class*="col-"] > .ast_product_section), .swiper-wrapper:has(> .swiper-slide > .ast_product_section), .stack-page:has(> .stack-item > .ast_product_section)) .ast_product_section .ast_product_info .ast_shop_title a {
        font-size: .70rem !important;
    }

    /* image sits flush with the card's left edge; the card keeps a little room on the other sides */
    :is(.row:has(> [class*="col-"] > .ast_product_section), .swiper-wrapper:has(> .swiper-slide > .ast_product_section), .stack-page:has(> .stack-item > .ast_product_section)) .ast_product_section {
        padding: 6px 8px 6px 0 !important;
    }

    :is(.row:has(> [class*="col-"] > .ast_product_section), .swiper-wrapper:has(> .swiper-slide > .ast_product_section), .stack-page:has(> .stack-item > .ast_product_section)) .ast_product_section .ast_product_image {
        border-radius: 0 10px 10px 0 !important;
    }

    :is(.row:has(> [class*="col-"] > .ast_product_section), .swiper-wrapper:has(> .swiper-slide > .ast_product_section), .stack-page:has(> .stack-item > .ast_product_section)) .ast_product_section .ast_product_info {
        padding-left: 10px !important;
    }
}

/* ----- "View all ..." buttons under product sections: compact pill, never full width ----- */
.shop-viewall-wrap {
    margin-top: 10px;
}

.shop-viewall-wrap .btn-viewall {
    width: auto;
    gap: 6px;
    padding: 6px 18px;
    font-size: .82rem;
    font-weight: 600;
    line-height: 1.4;
    box-shadow: 0 4px 10px rgba(113, 0, 0, .2);
}

.shop-viewall-wrap .btn-viewall:hover {
    gap: 9px;
}

.shop-viewall-wrap .btn-viewall i {
    font-size: .7rem;
}

.shop-viewall-wrap {
    margin-bottom: 20px;
}
