/* 移动端产品图片Gallery优化 */

/* 基础移动端图片容器 */
@media (max-width: 768px) {
    .product-images {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }
    
    .main-image-container {
        width: 100%;
        max-width: 100%;
        aspect-ratio: 1;
        border: 1px solid #ddd;
        border-radius: 8px;
        overflow: hidden;
        background: #f8f9fa;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        position: relative;
    }
    
    .main-image {
        width: 100%;
        height: 100%;
        object-fit: contain;
        transition: none; /* 移动端取消hover效果 */
    }
    
    /* 移动端缩略图容器 - 水平滚动 */
    .image-gallery {
        display: flex;
        gap: 0.5rem;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0.5rem 0;
        margin: 0;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }
    
    .image-gallery::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }
    
    /* 缩略图样式 */
    .gallery-thumb {
        flex-shrink: 0;
        width: 60px;
        height: 60px;
        border: 2px solid #ddd;
        border-radius: 6px;
        cursor: pointer;
        object-fit: contain;
        background: white;
        transition: border-color 0.2s ease;
    }
    
    .gallery-thumb:hover,
    .gallery-thumb.active {
        border-color: #ff9900;
    }
    
    /* 当缩略图很多时的优化 */
    .image-gallery.many-images {
        justify-content: flex-start;
    }
    
    .image-gallery.many-images .gallery-thumb {
        width: 50px;
        height: 50px;
    }
}

/* 超小屏幕优化 */
@media (max-width: 480px) {
    .product-images {
        gap: 0.75rem;
    }
    
    .main-image-container {
        border-radius: 6px;
    }
    
    .image-gallery {
        gap: 0.375rem;
        padding: 0.375rem 0;
    }
    
    .gallery-thumb {
        width: 45px;
        height: 45px;
        border-radius: 4px;
    }
    
    .image-gallery.many-images .gallery-thumb {
        width: 40px;
        height: 40px;
    }
}

/* 当有很多图片时的特殊处理 */
@media (max-width: 768px) {
    /* 超过6张图片时的样式 */
    .image-gallery[data-count="7"] .gallery-thumb,
    .image-gallery[data-count="8"] .gallery-thumb,
    .image-gallery[data-count="9"] .gallery-thumb,
    .image-gallery[data-count="10"] .gallery-thumb {
        width: 45px;
        height: 45px;
    }
    
    /* 超过10张图片时的样式 */
    .image-gallery[data-count="11"] .gallery-thumb,
    .image-gallery[data-count="12"] .gallery-thumb,
    .image-gallery[data-count="13"] .gallery-thumb,
    .image-gallery[data-count="14"] .gallery-thumb,
    .image-gallery[data-count="15"] .gallery-thumb {
        width: 40px;
        height: 40px;
    }
}

/* 滚动指示器 */
@media (max-width: 768px) {
    .gallery-scroll-indicator {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 0.25rem;
        margin-top: 0.5rem;
    }
    
    .scroll-dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #ddd;
        transition: background 0.2s ease;
    }
    
    .scroll-dot.active {
        background: #ff9900;
    }
}

/* 图片计数显示 */
@media (max-width: 768px) {
    .image-counter {
        position: absolute;
        top: 10px;
        right: 10px;
        background: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 4px 8px;
        border-radius: 12px;
        font-size: 12px;
        font-weight: 500;
        z-index: 10;
    }
}

/* 图片gallery的左右滚动按钮 */
@media (max-width: 768px) {
    .gallery-container {
        position: relative;
    }
    
    .gallery-scroll-btn {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 32px;
        height: 32px;
        background: rgba(255, 255, 255, 0.9);
        border: 1px solid #ddd;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 10;
        transition: all 0.2s ease;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .gallery-scroll-btn:hover {
        background: white;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    }
    
    .gallery-scroll-btn.prev {
        left: -16px;
    }
    
    .gallery-scroll-btn.next {
        right: -16px;
    }
    
    .gallery-scroll-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }
    
    .gallery-scroll-btn svg {
        width: 16px;
        height: 16px;
        fill: #333;
    }
}

/* 触摸滑动指示 */
@media (max-width: 768px) {
    .gallery-touch-hint {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        margin-top: 0.5rem;
        font-size: 12px;
        color: #666;
        opacity: 0.7;
    }
    
    .gallery-touch-hint svg {
        width: 14px;
        height: 14px;
        fill: currentColor;
    }
}

/* 图片加载状态 */
@media (max-width: 768px) {
    .gallery-thumb.loading {
        background: #f0f0f0;
        position: relative;
        overflow: hidden;
    }
    
    .gallery-thumb.loading::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
        animation: loading-shimmer 1.5s infinite;
    }
    
    @keyframes loading-shimmer {
        0% {
            left: -100%;
        }
        100% {
            left: 100%;
        }
    }
}

/* 图片错误状态 */
@media (max-width: 768px) {
    .gallery-thumb.error {
        background: #f8f9fa;
        border-color: #e9ecef;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #6c757d;
        font-size: 10px;
    }
    
    .gallery-thumb.error::before {
        content: '📷';
        font-size: 16px;
    }
}

/* 全屏查看模式的移动端优化 */
@media (max-width: 768px) {
    .modal {
        padding: 0;
    }
    
    .modal-content {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
        object-fit: contain;
    }
    
    .modal-nav {
        width: 44px;
        height: 44px;
        background: rgba(0, 0, 0, 0.7);
        border: none;
        border-radius: 50%;
        color: white;
        font-size: 18px;
    }
    
    .modal-nav.prev {
        left: 20px;
    }
    
    .modal-nav.next {
        right: 20px;
    }
    
    .close {
        top: 20px;
        right: 20px;
        width: 44px;
        height: 44px;
        background: rgba(0, 0, 0, 0.7);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        color: white;
    }
    
    .modal-counter {
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 8px 16px;
        border-radius: 16px;
        font-size: 14px;
    }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .product-container {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }
    
    .main-image-container {
        aspect-ratio: 4/3;
    }
    
    .image-gallery {
        justify-content: center;
    }
    
    .gallery-thumb {
        width: 35px;
        height: 35px;
    }
}

/* 移动端全屏模态框样式 */
.mobile-gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-gallery-modal .modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
}

.mobile-gallery-modal .modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-gallery-modal img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    user-select: none;
    -webkit-user-select: none;
}

.mobile-gallery-modal .modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.mobile-gallery-modal .modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    width: 100%;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
}

.mobile-gallery-modal .modal-prev,
.mobile-gallery-modal .modal-next {
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    transition: background 0.2s ease;
}

.mobile-gallery-modal .modal-prev:hover,
.mobile-gallery-modal .modal-next:hover {
    background: rgba(0, 0, 0, 0.9);
}

.mobile-gallery-modal .modal-prev:disabled,
.mobile-gallery-modal .modal-next:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mobile-gallery-modal .modal-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 500;
}

/* 移动端模态框动画 */
.mobile-gallery-modal {
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.mobile-gallery-modal img {
    animation: modalImageZoomIn 0.3s ease-out;
}

@keyframes modalImageZoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
} 