/* 商品图片画廊样式 */

:root {
    --product-gallery-bg: #f8f8f8;
}

[data-theme="dark"] {
    --product-gallery-bg: #2a3140;
}

.product-detail {
    display: flex;
    gap: 2%;
    align-items: flex-start;
    max-width: 1200px;
    margin: 0 auto;
}

/* 缩略图区域 */
.product-thumbnails-container {
    width: 100px;
    flex-shrink: 0;
    overflow: hidden;
}

.product-thumbnails {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 8px;
    max-height: 500px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 5px;
}

.product-thumbnails::-webkit-scrollbar {
    width: 4px;
}

.product-thumbnails::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

.product-thumbnails::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.product-thumbnails::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.product-thumbnail-wrapper {
    width: 80px;
    height: 80px;
    position: relative;
    flex-shrink: 0;
}

.product-thumbnail {
    width: 80px;
    height: 80px;
    object-fit: contain;
    cursor: pointer;
    border: 2px solid transparent;
    background-color: var(--product-gallery-bg);
    padding: 4px;
    box-sizing: border-box;
}

.product-thumbnail.active {
    border-color: #ff5000;
}

.thumbnail-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

.thumbnail-loading.active {
    display: block;
}

/* 主图区域 */
.product-main-image-container {
    position: relative;
    width: 45%;
    max-width: 500px;
    flex-shrink: 0;
    aspect-ratio: 1;
    background-color: var(--product-gallery-bg);
}

.gallery-slider-wrapper {
    width: 100%;
    height: 100%;
    min-height: 400px;
    overflow: hidden;
    position: relative;
}

.gallery-slider-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    display: none;
}

.gallery-slider-loading.active {
    display: block;
}

.gallery-slider {
    display: flex;
    height: 100%;
    transition: transform 0.3s ease-out;
    will-change: transform;
}

.gallery-slide {
    flex-shrink: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: zoom-in;
}

/* 商品信息 */
.product-info {
    flex: 1;
    min-width: 280px;
}

/* 主图导航按钮 */
.gallery-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background-color: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 10;
}

.gallery-nav-btn:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.gallery-nav-btn:focus {
    outline: 2px solid #fff;
}

.gallery-prev-btn {
    left: 10px;
}

.gallery-next-btn {
    right: 10px;
}

.product-main-image-container:hover .gallery-nav-btn {
    opacity: 1;
}

/* 灯箱遮罩层 */
.gallery-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.gallery-overlay.active {
    display: flex;
}

.gallery-drag-container {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease-out;
    will-change: transform;
    cursor: grab;
}

.gallery-drag-container:active {
    cursor: grabbing;
}

.gallery-container {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    cursor: zoom-out;
}

/* 灯箱导航按钮 */
.gallery-overlay-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
    z-index: 10000;
}

.gallery-overlay-nav:hover {
    background-color: rgba(255, 255, 255, 0.4);
}

.gallery-overlay-nav:focus {
    outline: 2px solid #fff;
}

.gallery-overlay-prev {
    left: 20px;
}

.gallery-overlay-next {
    right: 20px;
}

/* 关闭按钮 */
.gallery-close-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
    z-index: 10000;
}

.gallery-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.4);
}

.gallery-close-btn:focus {
    outline: 2px solid #fff;
}

/* 图片计数器 */
.gallery-counter {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 8px 16px;
    font-size: 14px;
    z-index: 10000;
}

/* 加载指示器 */
.gallery-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    z-index: 10000;
}

.gallery-loading.active {
    display: block;
}

.gallery-loading article,
.gallery-slider-loading article,
.thumbnail-loading article {
    background:none;
    margin-bottom: 0;
    box-shadow: none;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .product-detail {
        flex-direction: column;
        gap: 40px;
    }

    .product-thumbnails-container {
        width: 100%;
    }

    .product-thumbnails {
        flex-direction: row;
        flex-wrap: nowrap;
        max-height: 90px;
        overflow-x: auto;
        overflow-y: hidden;
        padding-right: 0;
        padding-bottom: 10px;
        gap: 8px;
        scrollbar-width: thin;
        scrollbar-color: #ccc #f1f1f1;
    }

    .product-thumbnail-wrapper {
        width: 80px;
        height: 80px;
        flex-shrink: 0;
    }

    .product-thumbnail {
        width: 80px;
        height: 80px;
        flex-shrink: 0;
    }

    .product-main-image-container {
        width: 100%;
        max-width: 400px;
        margin: 0 auto;
    }

    .gallery-slider-wrapper {
        min-height: 300px;
    }

    .product-info {
        min-width: auto;
        width: 100%;
    }

    .gallery-overlay-nav {
        display: none;
    }

    .gallery-drag-container {
        width: 100%;
        height: 100%;
        cursor: grab;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .gallery-drag-container:active {
        cursor: grabbing;
    }

    .gallery-container {
        width: 100%;
        height: 80vh;
        max-width: 100%;
        max-height: 100%;
        position: relative;
    }

    .gallery-image {
        max-width: 100%;
        max-height: 80vh;
        object-fit: contain;
    }

    .gallery-nav-btn {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }

    .gallery-prev-btn {
        left: 10px;
    }

    .gallery-next-btn {
        right: 10px;
    }
}
