/**
 * Single product: WooCommerce Flexslider gallery + related products carousel.
 * Brand accents align with Elementor landing (e.g. post-18: #1D1A46 headers).
 *
 * Layout strategy:
 *   - .single-product div.product: max-width cap + auto margins (box model, not full-width)
 *   - Inner flex: 35 % gallery | 65 % summary side by side
 *   - Elementor templates and WooCommerce default templates get the same proportions
 *     without either layout taking over the full screen width.
 *   - Mobile: column stack.
 *
 * Flexslider base: Hello Elementor and similar themes don't ship it; WC still
 * inits the slider.  Without these rules slides/nav look like broken lists.
 */

/* -------------------------------------------------------------------------
   Product row: max-width box (matches Elementor's default behaviour)
   ------------------------------------------------------------------------- */
.single-product div.product {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
    box-sizing: border-box;
}

/* Inner split: gallery 35 % | summary 65 % */
.single-product div.product {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0;
}

/* Gallery column — 35 % */
.single-product div.product .woocommerce-product-gallery {
    flex: 0 0 35%;
    max-width: 35%;
    width: 35%;
    position: relative;
    border-radius: 2px;
    overflow: hidden;
    padding-right: 24px;
    box-sizing: border-box;
}

/* Summary / right column — 65 % */
.single-product div.product div.summary {
    flex: 1 1 65%;
    max-width: 65%;
    width: 65%;
    box-sizing: border-box;
    margin: 0;
}

/* Print config panel section */
.single-product div.product section.sp-wc-print-config-section {
    clear: both;
    margin-top: 1.5rem;
}

/* -------------------------------------------------------------------------
   Gallery: Flexslider base (adapted from FlexSlider 2 defaults)
   object-fit: cover fills the gallery column; use contain for letterboxing.
   ------------------------------------------------------------------------- */
.single-product div.product .woocommerce-product-gallery .flex-viewport {
    max-height: 100%;
    height: auto;
    transition: all 1s ease;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.single-product div.product .woocommerce-product-gallery.loading .flex-viewport {
    max-height: 400px;
}

.single-product div.product .woocommerce-product-gallery .woocommerce-product-gallery__wrapper {
    max-width: 100%;
    width: 100%;
    height: auto;
    overflow: hidden;
}

.single-product div.product .woocommerce-product-gallery .slides > li {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    text-align: center;
}

.single-product div.product .woocommerce-product-gallery .flexslider,
.single-product div.product .woocommerce-product-gallery.flexslider {
    margin: 0;
    padding: 0;
    position: relative;
}

.single-product div.product .woocommerce-product-gallery .slides,
.single-product div.product .woocommerce-product-gallery .flex-direction-nav,
.single-product div.product .woocommerce-product-gallery .flex-control-nav {
    margin: 0;
    padding: 0;
    list-style: none;
}

.single-product div.product .woocommerce-product-gallery .slides::after {
    content: "\0020";
    display: block;
    clear: both;
    visibility: hidden;
    line-height: 0;
    height: 0;
}

.single-product div.product .woocommerce-product-gallery .slides img {
    max-width: 100%;
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    object-position: center;
}

/* WC stylesheet makes 2nd+ images 25% wide before slider init; normalize only in non-slider fallback. */
.single-product div.product div.images.woocommerce-product-gallery:not(.flexslider) .woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image:nth-child(n + 2) {
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
}

/* Prev/next (only when spectra_printing_gallery_show_direction_nav is true) */
.single-product div.product .woocommerce-product-gallery .flex-direction-nav {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    pointer-events: none;
}

.single-product div.product .woocommerce-product-gallery .flex-direction-nav li {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    padding: 0;
    list-style: none;
    pointer-events: auto;
}

.single-product div.product .woocommerce-product-gallery .flex-direction-nav .flex-nav-prev {
    left: 8px;
}

.single-product div.product .woocommerce-product-gallery .flex-direction-nav .flex-nav-next {
    right: 8px;
}

.single-product div.product .woocommerce-product-gallery .flex-direction-nav a {
    display: block;
    width: 36px;
    height: 36px;
    line-height: 36px;
    margin-top: -18px;
    opacity: 0.9;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    background: rgba(29, 26, 70, 0.55);
    border-radius: 2px;
    text-decoration: none;
    overflow: hidden;
}

.single-product div.product .woocommerce-product-gallery .flex-direction-nav a:hover {
    background: rgba(29, 26, 70, 0.85);
}

.single-product div.product .woocommerce-product-gallery:hover .flex-direction-nav .flex-prev,
.single-product div.product .woocommerce-product-gallery:hover .flex-direction-nav .flex-next {
    opacity: 1;
}

/* Thumbnail strip: horizontal scrollable row below the main image */
.single-product div.product .woocommerce-product-gallery .flex-control-thumbs {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    padding: 8px 0 4px;
    margin: 0;
    list-style: none;
    width: 100%;
}

.single-product div.product .woocommerce-product-gallery .flex-control-thumbs li {
    float: none;
    width: auto;
    flex: 0 0 auto;
    scroll-snap-align: start;
    margin: 0;
}

.single-product div.product .woocommerce-product-gallery .flex-control-thumbs img {
    width: 72px;
    height: auto;
    display: block;
    border-radius: 2px;
    opacity: 0.85;
    transition: opacity 0.2s ease;
}

.single-product div.product .woocommerce-product-gallery .flex-control-thumbs li img:hover,
.single-product div.product .woocommerce-product-gallery .flex-control-thumbs li.flex-active-slide img {
    opacity: 1;
}

/* Fallback mode: if Flexslider layout breaks, force one active visible slide. */
.single-product div.product div.images.woocommerce-product-gallery.sp-gallery-fallback {
    padding-bottom: 0 !important;
}

.single-product div.product div.images.woocommerce-product-gallery.sp-gallery-fallback .flex-viewport {
    height: auto !important;
    max-height: none !important;
}

.single-product div.product div.images.woocommerce-product-gallery.sp-gallery-fallback .woocommerce-product-gallery__wrapper {
    width: 100% !important;
    transform: none !important;
    display: block !important;
    margin-bottom: 0 !important;
}

.single-product div.product div.images.woocommerce-product-gallery.sp-gallery-fallback .woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image {
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    position: absolute !important;
    top: 0;
    left: 0;
}

.single-product div.product div.images.woocommerce-product-gallery.sp-gallery-fallback .woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image:first-child {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    position: relative !important;
}

.single-product div.product div.images.woocommerce-product-gallery.sp-gallery-fallback .woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image.sp-gallery-active,
.single-product div.product div.images.woocommerce-product-gallery.sp-gallery-fallback .woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image.flex-active-slide {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    position: relative !important;
}

/* 确保缩略图仍然可以点击切换图片 */
.single-product div.product div.images.woocommerce-product-gallery.sp-gallery-fallback .flex-control-thumbs {
    pointer-events: auto !important;
    margin-top: 0 !important;
}

/* -------------------------------------------------------------------------
   Related products: carousel strip + nav
   ------------------------------------------------------------------------- */
.sp-related-wrap {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
    box-sizing: border-box;
    margin-top: 2.5rem;
    clear: both;
}

.sp-related-wrap section.related.products {
    position: relative;
    margin: 0;
    padding: 0;
}

.sp-related-wrap section.related.products > h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 1rem;
    letter-spacing: -0.02em;
    color: #1a1a1a;
}

.sp-related-nav {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    gap: 6px;
}

.sp-related-nav__btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 2px;
    background: #fff;
    color: #1a1a1a;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.sp-related-nav__btn:hover {
    background: #f4f4f5;
    border-color: rgba(0, 0, 0, 0.2);
}

.sp-related-nav__btn:focus {
    outline: 2px solid rgba(30, 41, 59, 0.35);
    outline-offset: 2px;
}

.sp-related-wrap .related.products ul.products {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    padding: 4px 2px 12px;
    margin: 0;
    list-style: none;
}

.sp-related-wrap .related.products ul.products::after {
    content: "";
    flex: 0 0 8px;
}

.sp-related-wrap .related.products ul.products li.product {
    flex: 0 0 min(240px, 78vw);
    max-width: min(240px, 78vw);
    scroll-snap-align: start;
    margin: 0;
}

/* Reuse loop card look inside related */
.sp-related-wrap .related.products ul.products li.product {
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.22s ease, border-color 0.22s ease;
}

.sp-related-wrap .related.products ul.products li.product:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06), 0 4px 14px rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.14);
}

/* Titles: black; prices: brand indigo (landing #1D1A46) */
.single-product .sp-related-wrap ul.products li.product .woocommerce-loop-product__title,
.single-product .sp-related-wrap ul.products li.product .woocommerce-loop-category__title,
.single-product .sp-related-wrap ul.products li.product h2.woocommerce-loop-product__title {
    color: #111111 !important;
}

.single-product .sp-related-wrap ul.products li.product .price,
.single-product .sp-related-wrap ul.products li.product .price .amount,
.single-product .sp-related-wrap ul.products li.product .price ins,
.single-product .sp-related-wrap ul.products li.product .price ins .amount {
    color: #1d1a46 !important;
}

.single-product .sp-related-wrap ul.products li.product .price del,
.single-product .sp-related-wrap ul.products li.product .price del .amount {
    color: #111111 !important;
    opacity: 0.55 !important;
}

/* -------------------------------------------------------------------------
   Responsive breakpoints
   ------------------------------------------------------------------------- */

/* Tablet: shift to 45 / 55 */
@media (max-width: 900px) {
    .single-product div.product {
        gap: 0;
    }

    .single-product div.product .woocommerce-product-gallery {
        flex: 0 0 45%;
        max-width: 45%;
        width: 45%;
    }

    .single-product div.product div.summary {
        flex: 1 1 55%;
        max-width: 55%;
        width: 55%;
    }
}

/* Mobile: stack — gallery full width on top, summary below */
@media (max-width: 600px) {
    .single-product div.product {
        flex-direction: column;
        padding-left: 0;
        padding-right: 0;
    }

    .single-product div.product .woocommerce-product-gallery {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
        padding-right: 0;
        padding-bottom: 16px;
    }

    .single-product div.product div.summary {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
    }

    .sp-related-nav {
        position: static;
        justify-content: flex-end;
        margin-bottom: 8px;
    }
}
