/* 产品图库主容器 */
.woocommerce-product-gallery {
    position: relative;
    overflow: hidden;
}

/* 主图区域容器 */
.flex-viewport {
    position: relative !important;
    overflow: hidden !important;
    width: 100% !important;
    height: auto !important;
    min-height: 500px; /* 设置最小高度防止跳动 */
}

/* 图片包装器 */
.woocommerce-product-gallery__wrapper {
    display: flex !important;
    flex-wrap: nowrap !important;
    transition: transform 0.4s ease-in-out !important;
    width: auto !important;
}

/* 单张图片项 - 关键修复 */
.woocommerce-product-gallery__image {
    flex: 0 0 100% !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
    position: relative !important;
    overflow: hidden !important;
    min-height: 500px; /* 设置最小高度 */
    display: flex !important;
    align-items: center !important; /* 垂直居中 */
    justify-content: center !important; /* 水平居中 */
    background-color: #f8f8f8; /* 添加背景色 */
}

/* 确保图片充满容器 */
.woocommerce-product-gallery__image img {
    width: 100% !important;
    height: auto !important;
    max-height: 100% !important;
    object-fit: contain !important; /* 保持图片比例 */
    transition: none !important; /* 禁用所有过渡效果 */
    transform: none !important; /* 禁用变换效果 */
    position: static !important; /* 禁用绝对定位 */
}

/* 保留放大镜效果但防止位置跳动 */
.woocommerce-product-gallery__image .zoomImg {
    position: absolute !important;
    opacity: 0 !important; /* 默认隐藏 */
    transition: opacity 0.3s ease !important;
}

/* 放大镜激活时的样式 */
.woocommerce-product-gallery__image:hover .zoomImg {
    opacity: 1 !important; /* 显示放大镜 */
}

/* 自定义导航箭头 */
.custom-gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: all 0.3s ease;
}

.custom-gallery-arrow:hover {
    background: rgba(0, 0, 0, 0.9);
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

.custom-gallery-prev {
    left: 15px;
}

.custom-gallery-next {
    right: 15px;
}

/* 图片计数器 */
.custom-gallery-counter {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
    z-index: 90;
}

/* 确保缩略图显示 */
.flex-control-nav.flex-control-thumbs {
    display: flex !important;
    justify-content: center;
    margin: 15px 0 0 0;
    padding: 0;
    gap: 8px;
    flex-wrap: wrap;
    list-style: none;
}

.flex-control-thumbs li {
    list-style: none;
    margin: 0;
}

.flex-control-thumbs img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border: 2px solid #ddd;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.3s ease;
}

.flex-control-thumbs img:hover,
.flex-control-thumbs img.flex-active {
    opacity: 1;
    border-color: #333;
}

/* 修复图片高度不足时的悬停下移问题 */
.woocommerce-product-gallery__image a {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
}

/* 禁用可能导致移动的过渡效果 */
.woocommerce-product-gallery__image,
.woocommerce-product-gallery__image * {
    transition: none !important;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .custom-gallery-arrow {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .custom-gallery-prev {
        left: 10px;
    }
    
    .custom-gallery-next {
        right: 10px;
    }
    
    .flex-control-thumbs img {
        width: 50px;
        height: 50px;
    }
    
    .flex-viewport,
    .woocommerce-product-gallery__image {
        min-height: 400px !important;
    }
}

/* 防止放大镜导致的位置跳动 */
.woocommerce-product-gallery__image:hover img {
    transform: none !important;
    position: static !important;
}