/**
 * 图片优化相关样式
 */

/* 懒加载图片基础样式 */
.lazy-image {
    transition: opacity 0.3s ease-in-out;
    opacity: 0;
}

.lazy-image.loading {
    opacity: 0.5;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
}

.lazy-image.loaded {
    opacity: 1;
}

.lazy-image.error {
    opacity: 0.7;
    background: #f5f5f5;
    position: relative;
}

.lazy-image.error::after {
    content: "📷";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: #ccc;
}

/* 加载动画 */
@keyframes loading-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* 圆形头像样式 */
.circle-avatar {
    border-radius: 50%;
    object-fit: cover;
    aspect-ratio: 1;
}

/* 响应式图片容器 */
.responsive-image-container {
    position: relative;
    overflow: hidden;
    background: #f8f9fa;
}

.responsive-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 占卜师卡片图片优化 */
.reader-card .reader-photo img,
.reader-circle-card .reader-circle-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.reader-card:hover .reader-photo img,
.reader-circle-card:hover .reader-circle-photo img {
    transform: scale(1.05);
}

/* 详情页大图优化 */
.reader-detail .reader-photo img {
    width: 100%;
    max-width: 400px;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* 图片加载占位符 */
.image-placeholder {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 1.2rem;
    min-height: 200px;
}

/* 图片网格布局优化 */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    padding: 1rem 0;
}

.image-grid-item {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 8px;
    background: #f8f9fa;
}

/* 移动端优化 */
@media (max-width: 768px) {
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.5rem;
    }
    
    .reader-detail .reader-photo img {
        max-width: 100%;
        border-radius: 8px;
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .lazy-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* 图片上传预览样式 */
.image-upload-preview {
    position: relative;
    display: inline-block;
    margin: 10px;
}

.image-upload-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.image-upload-preview .remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 图片压缩质量指示器 */
.image-quality-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
}

.image-quality-indicator.high {
    background: rgba(40, 167, 69, 0.8);
}

.image-quality-indicator.medium {
    background: rgba(255, 193, 7, 0.8);
}

.image-quality-indicator.low {
    background: rgba(220, 53, 69, 0.8);
}

/* WebP支持指示器 */
.webp-supported::after {
    content: "WebP";
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0, 123, 255, 0.8);
    color: white;
    padding: 1px 4px;
    border-radius: 2px;
    font-size: 8px;
    font-weight: bold;
}

/* 图片加载进度条 */
.image-loading-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.image-loading-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, #007bff, transparent);
    animation: loading-progress 1.5s infinite;
}

@keyframes loading-progress {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* 图片错误状态样式 */
.image-error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    color: #6c757d;
}

.image-error-state .error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.image-error-state .error-message {
    font-size: 0.9rem;
    text-align: center;
}

/* 图片优化统计信息 */
.image-optimization-stats {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.image-optimization-stats .stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.image-optimization-stats .stat-value {
    font-weight: bold;
    color: #007bff;
}
