/* 主图库容器 */
.woocommerce div.product div.images.woocommerce-product-gallery {
    position: relative;
    margin-bottom: 40px;
    max-width: 100%;
    opacity: 1 !important;
}

/* 主图片包装器 */
.woocommerce div.product div.images .woocommerce-product-gallery__wrapper {
    margin: 0;
    padding: 0 10px;
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 20px;
    min-height: 0; /* 重要：允许网格项目收缩 */
}

/* 主图片样式 */
.woocommerce div.product div.images .woocommerce-product-gallery__image.main-image {
    grid-column: 2;
    grid-row: 1;
    width: 100% !important;
    margin: 0;
}

.woocommerce div.product div.images .woocommerce-product-gallery__image.main-image img {
    width: 100%;
    height: auto;
    display: block;
}

/* 缩略图外层容器 */
.thumbnails-container {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    height: 100%;
    min-height: 0;
    padding: 24px 0; /* 为按钮留出空间 */
}

/* 缩略图滚动容器 */
.thumbnails-wrapper {
    position: absolute;
    top: 24px; /* 为上按钮留出空间 */
    left: 0;
    right: 0;
    bottom: 24px; /* 为下按钮留出空间 */
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-right: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 滚动按钮样式 */
.thumbnail-scroll-button {
    position: absolute;
    height: 24px;
    width: 100%;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: all 0.2s ease;
    padding: 0;
    color: #666;
    font-size: 16px;
}

/* 上下按钮位置 */
.thumbnail-scroll-button.scroll-up {
    /* top: 0; */
    border-bottom: 1px solid #eee;
}

.thumbnail-scroll-button.scroll-down {
    bottom: 0;
    border-top: 1px solid #eee;
}

/* SVG 图标样式 */
.thumbnail-scroll-button svg {
    width: 16px;
    height: 16px;
    fill: #666;
    transition: fill 0.2s ease;
}

/* 按钮悬停效果 */
.thumbnail-scroll-button:hover {
    background: rgba(245, 245, 245, 0.95);
}

.thumbnail-scroll-button:hover svg {
    fill: #0602f3;
}

/* 禁用状态 */
.thumbnail-scroll-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.thumbnail-scroll-button.disabled svg {
    fill: #999;
}

/* 只在有滚动内容时显示按钮 */
.thumbnails-container.has-scroll .thumbnail-scroll-button {
    display: flex;
}

/* 缩略图样式 */
.woocommerce div.product div.images .woocommerce-product-gallery__image:not(.main-image) {
    cursor: pointer;
    overflow: hidden;
    position: relative;
    width: 100px !important;
    height: 133px !important;
    margin: 0;
    flex: 0 0 auto;
}

.woocommerce div.product div.images .woocommerce-product-gallery__image:not(.main-image) img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 6px !important;
    border: 2px solid transparent;
    transition: all 0.3s ease-in-out !important;
    opacity: 0.7;
    padding: 0 !important;
}

/* 缩略图悬停效果 */
.woocommerce div.product div.images .woocommerce-product-gallery__image:not(.main-image):hover img {
    opacity: 1;
    transform: translateY(-2px);
    border-color: #0602f3;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* 缩略图激活状态 */
.woocommerce div.product div.images .woocommerce-product-gallery__image:not(.main-image).active img,
.woocommerce div.product div.images .woocommerce-product-gallery__image:not(.main-image) img.flex-active {
    opacity: 1;
    border: 2px solid #0602f3 !important;
    box-shadow: 0 0 0 1px #fff, 0 0 0 3px #0602f3 !important;
}

/* 添加悬停时的光效 */
.woocommerce div.product div.images .woocommerce-product-gallery__image:not(.main-image)::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.1) 50%,
            rgba(255, 255, 255, 0) 100%);
    transform: rotate(45deg);
    transition: all 0.5s ease-in-out;
    z-index: 1;
    opacity: 0;
}

.woocommerce div.product div.images .woocommerce-product-gallery__image:not(.main-image):hover::before {
    opacity: 1;
    transform: rotate(45deg) translate(50%, 50%);
}

/* 放大镜提示 - 只在主图上显示 */
.woocommerce div.product div.images .woocommerce-product-gallery__image.main-image a::after {
    content: '🔍';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: rgba(255, 255, 255, 0.9);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    text-align: center;
    line-height: 50px;
    font-size: 20px;
    opacity: 0;
    transition: all 0.3s ease;
}

.woocommerce div.product div.images .woocommerce-product-gallery__image.main-image a:hover::after {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* 覆盖可能的内联样式 */
.woocommerce-product-gallery__image img[style],
.flex-control-nav li img[style],
.flex-control-thumbs li img[style] {
    width: 100% !important;
    height: auto !important;
    max-width: none !important;
}

@media (min-width: 769px) {
    .thumbnail-scroll-button.scroll-up {
        top: 0;
    }
}

/* 响应式调整 */
@media (max-width: 768px) {
    .woocommerce div.product div.images .woocommerce-product-gallery__wrapper {
        display: flex;
        flex-direction: column;
        gap: 15px;
        min-height: auto;
        padding: 0;
    }
    
    .woocommerce div.product div.images .woocommerce-product-gallery__image.main-image {
        order: 0; /* 确保主图在最上方 */
        width: 100% !important;
    }
    
    .thumbnails-container {
        order: 1; /* 确保缩略图在主图下方 */
        position: relative;
        width: 100%;
        height: auto;
        margin-top: 15px;
        padding: 0 24px; /* 为左右按钮留出空间 */
    }
    
    .thumbnails-wrapper {
        position: relative;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: auto;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 10px 0;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .thumbnails-wrapper::-webkit-scrollbar {
        display: none;
    }

    /* 移动端滚动按钮样式 */
    .thumbnail-scroll-button {
        top: 50%;
        transform: translateY(-50%);
        width: 24px;
        height: 100%;
        background: rgba(255, 255, 255, 0.9);
    }

    .thumbnail-scroll-button.scroll-up {
        left: 0;
        border: none;
        border-right: 1px solid #eee;
    }

    .thumbnail-scroll-button.scroll-down {
        right: 0;
        border: none;
        border-left: 1px solid #eee;
    }

    /* 移动端箭头方向 */
    /* .thumbnail-scroll-button.scroll-up svg {
        transform: rotate(0);
    }

    .thumbnail-scroll-button.scroll-down svg {
        transform: rotate(180deg);
    } */

    /* 显示移动端滚动按钮 */
    .thumbnails-container.has-scroll .thumbnail-scroll-button {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .woocommerce div.product div.images .woocommerce-product-gallery__image:not(.main-image) {
        width: calc(25% - 8px) !important;
        height: auto !important;
        aspect-ratio: 3/4;
        margin: 0;
        flex: 0 0 auto;
    }
}

@media (max-width: 480px) {
    .woocommerce div.product div.images .woocommerce-product-gallery__wrapper {
        gap: 10px;
    }

    .thumbnails-container {
        padding: 0 20px; /* 稍微减小按钮区域 */
    }

    .thumbnail-scroll-button {
        width: 20px; /* 稍微减小按钮宽度 */
    }

    .woocommerce div.product div.images .woocommerce-product-gallery__image:not(.main-image) {
        width: calc(33.33% - 7px) !important;
    }
}

/* 图片加载动画 */
.woocommerce div.product div.images .woocommerce-product-gallery__wrapper {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.woocommerce div.product div.images .woocommerce-product-gallery__wrapper.is-loaded {
    opacity: 1;
}

.woocommerce-breadcrumb {
    margin: 0 0 20px;
    padding: 10px 0;
    font-size: 14px;
    color: #777;
}

.woocommerce-breadcrumb a {
    color: #333;
    text-decoration: none;
}

.woocommerce-breadcrumb a:hover {
    color: #666;
    text-decoration: underline;
}

/* 尺码选择器样式 */
.body-size-wrapper {
    margin: 20px 0;
}

.body-size-wrapper label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
}

#body_size {
    min-width: 150px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
}

#body_size option {
    padding: 5px;
}

/* 错误状态样式 */
#body_size.error {
    border-color: #dc3545;
    box-shadow: 0 0 0 1px #dc3545;
}

.body-size-error {
    color: #dc3545;
    font-size: 0.875em;
    margin-top: 5px;
    animation: shake 0.5s ease-in-out;
}

/* 错误提示动画 */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

/* 尺码选择器悬停状态 */
#body_size:hover {
    border-color: #666;
}

/* 尺码选择器焦点状态 */
#body_size:focus {
    border-color: #333;
    outline: none;
    box-shadow: 0 0 0 1px #333;
}