/**
 * 图片懒加载样式
 * @version 1.0.0
 */

/* 加载中状态 */
.lazy-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* 已加载状态 */
.lazy-loaded {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* 加载失败状态 */
.lazy-error {
    background: #f8d7da;
    border: 1px dashed #f5c6cb;
}

/* 图片容器优化 */
img[data-src],
img[data-srcset] {
    display: block;
    width: 100%;
    height: auto;
}

/* 背景图片懒加载 */
[data-background-image] {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* 占位符样式 */
.lazy-placeholder {
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
}

.lazy-placeholder::before {
    content: '';
    display: block;
    padding-top: 75%; /* 4:3 比例 */
}

.lazy-placeholder.ratio-16-9::before {
    padding-top: 56.25%; /* 16:9 比例 */
}

.lazy-placeholder.ratio-1-1::before {
    padding-top: 100%; /* 1:1 比例 */
}

/* 加载图标 */
.lazy-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #f3f3f3;
    border-top-color: #3470ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 深色模式适配 */
.dark .lazy-loading {
    background: linear-gradient(90deg, #2d3748 25%, #1a202c 50%, #2d3748 75%);
    background-size: 200% 100%;
}

.dark .lazy-placeholder {
    background: #2d3748;
}

.dark .lazy-error {
    background: #7f1d1d;
    border-color: #991b1b;
}

/* 响应式优化 */
@media (max-width: 768px) {
    .lazy-loading::after {
        width: 30px;
        height: 30px;
        margin: -15px 0 0 -15px;
        border-width: 2px;
    }
}

/* 打印时显示所有图片 */
@media print {
    .lazy-loading,
    .lazy-loaded,
    .lazy-error {
        background: none !important;
        animation: none !important;
    }
    
    .lazy-loading::after {
        display: none !important;
    }
}

/* 无障碍优化 */
@media (prefers-reduced-motion: reduce) {
    .lazy-loading,
    .lazy-loaded {
        animation: none !important;
        transition: none !important;
    }
}

/* 产品卡片懒加载优化 */
.product-card img[data-src] {
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

/* 产品详情图片懒加载 */
.product-images img[data-src] {
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

/* 缩略图懒加载 */
.thumbnail img[data-src] {
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

/* Banner图片懒加载 */
.banner img[data-src] {
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

@media (max-width: 768px) {
    .banner img[data-src] {
        aspect-ratio: 4 / 3;
    }
}

