/* Custom Product Gallery Styles - Responsive Fix Version */
/* 基于用户提供的类名进行响应式优化 */

.custom-product-gallery {
    position: relative;
}

.custom-gallery-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    justify-content: flex-end;
}

.custom-gallery-thumbnails {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 600px !important;
    min-height: 600px !important;
    overflow-y: auto;
    width: 100px !important;
    flex-shrink: 0;
    scrollbar-width: thin;
    scrollbar-color: #ddd transparent;
    padding: 10px;
    background: rgba(248, 248, 248, 0.5);
    border-radius: 12px;
}

.custom-gallery-thumbnails::-webkit-scrollbar {
    width: 8px;
}

.custom-gallery-thumbnails::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 4px;
}

.custom-gallery-thumbnails::-webkit-scrollbar-thumb {
    background-color: #ddd;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.custom-gallery-thumbnails::-webkit-scrollbar-thumb:hover {
    background-color: #bbb;
}

.custom-gallery-thumbnails .thumbnail-item {
    cursor: pointer;
    border: 3px solid transparent;
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
    width: 80px !important;
    height: 80px !important;
    flex-shrink: 0;
}

.custom-gallery-thumbnails .thumbnail-item:hover {
    border-color: #ed0677;
    transform: scale(1.03);
    box-shadow: 0 6px 20px rgba(237, 6, 119, 0.25);
}

.custom-gallery-thumbnails .thumbnail-item.active {
    border-color: #ed0677;
    transform: scale(1.03);
    box-shadow: 0 6px 20px rgba(237, 6, 119, 0.35);
}

.custom-gallery-thumbnails .thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.3s ease;
}

.custom-gallery-thumbnails .thumbnail-item:hover img {
    opacity: 0.9;
}

.custom-gallery-main-image {
    width: 600px;
    height: 600px;
    min-width: 400px;
    /* align-items: center; */
    /* justify-content: center; */
}

.custom-gallery-main-image img {
    width: 600px;
    height: 600px;
    min-width: 400px;
    object-fit: cover;
    border-radius: 12px;
    transition: opacity 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Sale badge positioning */
.custom-product-gallery .onsale {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10;
    background-color: #ed0677;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(237, 6, 119, 0.3);
}

/* Loading state */
.custom-gallery-main-image.loading img {
    opacity: 0.5;
}

/* Enhanced hover effects */
.custom-gallery-thumbnails .thumbnail-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(237, 6, 119, 0.1), rgba(237, 6, 119, 0.05));
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    border-radius: 7px;
}

.custom-gallery-thumbnails .thumbnail-item:hover::before,
.custom-gallery-thumbnails .thumbnail-item.active::before {
    opacity: 1;
}

/* 滚动指示器 */
.custom-gallery-thumbnails::after {
    content: '';
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 3px;
    background: linear-gradient(90deg, transparent, #ed0677, transparent);
    border-radius: 2px;
    opacity: 0.6;
}

/* ===== 改进的响应式设计 ===== */

/* 大屏幕桌面 (1200px+) */
@media (min-width: 1200px) {
    .custom-gallery-main-image {
        width: 600px;
        height: 600px;
        min-width: 500px;
        flex: none !important;
    }

    .custom-gallery-main-image img {
        width: 600px;
        height: 600px;
        min-width: 500px;
    }

    .custom-gallery-thumbnails {
        width: 140px;
        height: 600px;
        min-height: 600px;
    }

    .custom-gallery-thumbnails .thumbnail-item {
        width: 100px;
        height: 100px;
    }
}

/* 大屏幕桌面 (1921px+) */
@media (min-width: 1921px) {
    .custom-gallery-main-image {
        width: 800px;
        height: 800px;
        min-width: 500px;
        flex: none !important;
    }

    .custom-gallery-main-image img {
        width: 800px !important;
        height: 800px !important;
        max-height: 800px !important;
        min-width: 800px !important;
    }

    .custom-gallery-thumbnails {
        width: 140px !important;
        height: 800px !important;
        min-height: 800px !important;
    }

    .custom-gallery-thumbnails .thumbnail-item {
        width: 120px !important;
        height: 120px !important;
    }
}

/* 中等桌面屏幕 (992px - 1199px) */
@media (max-width: 1199px) and (min-width: 992px) {
    .custom-gallery-main-image {
        width: 500px;
        height: 500px;
        min-width: 350px;
    }

    .custom-gallery-main-image img {
        width: 500px;
        height: 500px;
        min-width: 350px;
    }

    .custom-gallery-thumbnails {
        width: 100px;
        height: 500px;
        min-height: 500px;
    }

    .custom-gallery-thumbnails .thumbnail-item {
        width: 70px;
        height: 70px;
    }
}

/* 平板设备 (768px - 991px) */
@media (max-width: 991px) and (min-width: 769px) {
    .custom-gallery-container {
        gap: 15px;
    }

    .custom-gallery-main-image {
        width: 400px;
        height: 400px;
        min-width: 300px;
    }

    .custom-gallery-main-image img {
        width: 400px;
        height: 400px;
        min-width: 300px;
    }

    .custom-gallery-thumbnails {
        width: 90px;
        height: 400px;
        min-height: 400px;
        gap: 10px;
    }

    .custom-gallery-thumbnails .thumbnail-item {
        width: 65px;
        height: 65px;
    }
}

/* 小平板和大手机 (768px及以下) - 垂直布局 */
@media (max-width: 768px) {
    .custom-gallery-container {
        flex-direction: column;
        gap: 15px;
    }

    .custom-gallery-thumbnails {
        flex-direction: row;
        width: 100%;
        height: 120px;
        min-height: 120px;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 10px;
        gap: 10px;
    }

    .custom-gallery-thumbnails .thumbnail-item {
        min-width: 100px;
        width: 100px;
        height: 100px;
        flex-shrink: 0;
    }

    .custom-gallery-main-image {
        /* width: 100%; */
        height: auto;
        min-width: auto;
        max-width: 400px;
        margin: 0;
    }

    .custom-gallery-main-image img {
        /* width: 100%; */
        height: auto;
        min-width: auto;
        max-width: 400px;
        aspect-ratio: 1;
    }

    .custom-gallery-thumbnails::after {
        display: none;
    }
}

/* 中等手机 (481px - 767px) */
@media (max-width: 767px) and (min-width: 481px) {
    .custom-gallery-main-image {
        max-width: 350px;
    }

    .custom-gallery-main-image img {
        max-width: 350px;
    }

    .custom-gallery-thumbnails .thumbnail-item {
        min-width: 90px;
        width: 90px;
        height: 90px;
    }
}

/* 小手机 (480px及以下) */
@media (max-width: 480px) {
    .custom-gallery-container {
        gap: 12px;
    }

    .custom-gallery-thumbnails {
        gap: 8px;
        height: 100px;
        min-height: 100px;
        padding: 8px;
    }

    .custom-gallery-thumbnails .thumbnail-item {
        min-width: 80px;
        width: 80px;
        height: 80px;
    }

    .custom-gallery-main-image {
        max-width: 300px;
    }

    .custom-gallery-main-image img {
        max-width: 300px;
    }
}

/* 超小手机 (360px及以下) */
@media (max-width: 360px) {
    .custom-gallery-container {
        gap: 10px;
    }

    .custom-gallery-thumbnails {
        gap: 6px;
        height: 90px;
        min-height: 90px;
        padding: 6px;
    }

    .custom-gallery-thumbnails .thumbnail-item {
        min-width: 70px;
        width: 70px;
        height: 70px;
    }

    .custom-gallery-main-image {
        max-width: 280px;
    }

    .custom-gallery-main-image img {
        max-width: 280px;
    }
}

/* Animation for image transitions */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.custom-gallery-main-image img.fade-in {
    animation: fadeIn 0.4s ease-in-out;
}

/* Focus styles for accessibility */
.custom-gallery-thumbnails .thumbnail-item:focus {
    outline: 3px solid #ed0677;
    outline-offset: 2px;
}

/* Smooth scrolling for thumbnail container */
.custom-gallery-thumbnails {
    scroll-behavior: smooth;
}

/* 缩略图数量指示器 */
.custom-gallery-thumbnails-counter {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ed0677;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(237, 6, 119, 0.3);
}

/* 优化滚动条在不同浏览器中的表现 */
.custom-gallery-thumbnails {
    -webkit-overflow-scrolling: touch;
}

/* 活跃缩略图的特殊效果 */
.custom-gallery-thumbnails .thumbnail-item.active::after {
    content: '✓';
    position: absolute;
    top: 5px;
    right: 5px;
    background: #ed0677;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* 确保在所有设备上图片都能正确显示 */
.custom-gallery-main-image img {
    /* max-width: 100%; */
    height: auto;
    display: block;
}

/* 针对高DPI屏幕的优化 */
/* @media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    .custom-gallery-main-image img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
} */

/* ===== 额外的布局保护措施 ===== */

/* 确保自定义模块不会被其他元素覆盖 */
.custom-product-gallery {
    z-index: 1;
    position: relative;
}

/* 在小屏幕下确保容器占满宽度 */
@media (max-width: 768px) {
    .custom-product-gallery {
        width: 100% !important;
        max-width: 100% !important;
    }

    .custom-gallery-container {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* 防止容器被压缩 */
.custom-gallery-container {
    min-width: 0;
    flex: 1;
}

/* 确保图片容器在移动端的正确显示 */
@media (max-width: 768px) {
    .custom-gallery-main-image {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        min-width: auto !important;
        min-height: auto !important;
    }

    .custom-gallery-main-image img {
        width: 100% !important;
        height: auto !important;
        min-width: auto !important;
        max-height: none !important;
    }
}
