/* image_sizes.css - 修复版：确保占位符和生成图片尺寸完全一致 */

:root {
    /* ========== PC端基础尺寸 ========== */
    --pc-image-max-height: 280px;
    --pc-image-min-height: 200px;
    
    /* ========== 移动端尺寸 ========== */
    --mobile-image-max-height: 250px;
    --mobile-image-min-height: 250px;
    
    /* ========== 极小屏尺寸 ========== */
    --small-image-max-height: 180px;
    --small-image-min-height: 140px;
    
    /* ========== 通用样式变量 ========== */
    --image-border-radius: 12px;
    --image-box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --placeholder-bg-start: #f5f7fa;
    --placeholder-bg-end: #e4e8f0;
}


/* ========== 1. 通用图片容器样式（确保占位符和图片容器一致） ========== */
.message-image-container {
    position: relative;
    display: block;
    max-width: 100%;
    margin: 0;
    padding: 0;
    border-radius: var(--image-border-radius);
    overflow: hidden;
}

/* ========== 2. 生成图片样式 ========== */
.generated-image {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: var(--pc-image-max-height);
    min-height: var(--pc-image-min-height);
    object-fit: contain;
    border-radius: var(--image-border-radius);
    box-shadow: var(--image-box-shadow);
    cursor: zoom-in;
    display: block;
    transition: transform 0.3s ease;
    /* 关键：图片容器不设置固定宽高，由内容撑开 */
}

.generated-image:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}


/* ========== 3. 占位符样式 - 与图片使用相同的尺寸规则 ========== */
.dynamic-placeholder {
    position: relative;
    background: linear-gradient(135deg, var(--placeholder-bg-start) 0%, var(--placeholder-bg-end) 100%);
    border-radius: var(--image-border-radius);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    /* 关键修改：移除固定的 max-height 和 min-height，改用 max-width 限制宽度，高度由内容决定 */
    box-shadow: var(--image-box-shadow);
    transition: all 0.3s ease;
    /* 确保占位符不会太小 */
    min-width: 150px;
}

/* 根据不同比例设置最小宽度，确保占位符有足够大小 */
.dynamic-placeholder.ratio-1-1 {
    aspect-ratio: 1 / 1;
    max-height: var(--pc-image-max-height);
}

.dynamic-placeholder.ratio-4-3 {
    aspect-ratio: 4 / 3;
    max-height: var(--pc-image-max-height);
}

.dynamic-placeholder.ratio-3-4 {
    aspect-ratio: 3 / 4;
    max-height: var(--pc-image-max-height);
}

.dynamic-placeholder.ratio-16-9 {
    aspect-ratio: 16 / 9;
    max-height: var(--pc-image-max-height);
}

.dynamic-placeholder.ratio-9-16 {
    aspect-ratio: 9 / 16;
    max-height: var(--pc-image-max-height);
}

.dynamic-placeholder.ratio-3-2 {
    aspect-ratio: 3 / 2;
    max-height: var(--pc-image-max-height);
}

.dynamic-placeholder.ratio-2-3 {
    aspect-ratio: 2 / 3;
    max-height: var(--pc-image-max-height);
}

.dynamic-placeholder.ratio-21-9 {
    aspect-ratio: 21 / 9;
    max-height: var(--pc-image-max-height);
}

.dynamic-placeholder.ratio-2-1 {
    aspect-ratio: 2 / 1;
    max-height: var(--pc-image-max-height);
}

.dynamic-placeholder.ratio-1-2 {
    aspect-ratio: 1 / 2;
    max-height: var(--pc-image-max-height);
}

.dynamic-placeholder.ratio-4-5 {
    aspect-ratio: 4 / 5;
    max-height: var(--pc-image-max-height);
}

.dynamic-placeholder.ratio-5-4 {
    aspect-ratio: 5 / 4;
    max-height: var(--pc-image-max-height);
}

/* 闪烁动画效果 */
.dynamic-placeholder::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0) 0%, 
        rgba(255, 255, 255, 0.6) 50%, 
        rgba(255, 255, 255, 0) 100%);
    animation: shimmer 2s infinite;
    pointer-events: none;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}


/* ========== 4. 加载动画样式 ========== */
.modern-spinner {
    position: relative;
    width: 50px;
    height: 50px;
    z-index: 2;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top: 3px solid #18A058;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-ring:nth-child(2) {
    border: 3px solid rgba(24, 160, 88, 0.2);
    animation: spin 1.5s linear infinite reverse;
}

.spinner-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #18A058;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 0.8; }
}


/* ========== 5. 图片操作按钮 ========== */
.image-actions {
    position: absolute;
    right: 8px;
    bottom: 8px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    padding: 4px;
    display: flex;
    gap: 4px;
    z-index: 10;
    backdrop-filter: blur(4px);
}

.image-action {
    background: none;
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.image-action:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}


/* ========== 6. 详情弹窗图片 ========== */
.detail-image img {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--image-border-radius);
    box-shadow: var(--image-box-shadow);
    cursor: pointer;
    object-fit: contain;
}

.detail-image-placeholder {
    padding: 40px;
    text-align: center;
    background: #f8fafc;
    border-radius: var(--image-border-radius);
    color: #64748b;
}


/* ========== 7. 灵感画册/网格视图 ========== */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.image-card {
    background-color: white;
    border-radius: var(--image-border-radius);
    overflow: hidden;
    box-shadow: var(--image-box-shadow);
    transition: all 0.3s ease;
    cursor: pointer;
}

.image-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background: #f5f5f5;
}

.image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.image-card:hover .image-wrapper img {
    transform: scale(1.05);
}


/* ========== 8. 移动端适配 ========== */
@media (max-width: 767px) {
    .generated-image {
        max-height: var(--mobile-image-max-height);
        min-height: var(--mobile-image-min-height);
    }
    
    .dynamic-placeholder.ratio-1-1,
    .dynamic-placeholder.ratio-4-3,
    .dynamic-placeholder.ratio-3-4,
    .dynamic-placeholder.ratio-16-9,
    .dynamic-placeholder.ratio-9-16,
    .dynamic-placeholder.ratio-3-2,
    .dynamic-placeholder.ratio-2-3,
    .dynamic-placeholder.ratio-21-9,
    .dynamic-placeholder.ratio-2-1,
    .dynamic-placeholder.ratio-1-2,
    .dynamic-placeholder.ratio-4-5,
    .dynamic-placeholder.ratio-5-4 {
        max-height: var(--mobile-image-max-height);
    }
    
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }
    
    .detail-image img {
        max-height: 300px;
    }
    
    .image-action {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
    
    .modern-spinner {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    .generated-image {
        max-height: var(--small-image-max-height);
        min-height: var(--small-image-min-height);
    }
    
    .dynamic-placeholder.ratio-1-1,
    .dynamic-placeholder.ratio-4-3,
    .dynamic-placeholder.ratio-3-4,
    .dynamic-placeholder.ratio-16-9,
    .dynamic-placeholder.ratio-9-16,
    .dynamic-placeholder.ratio-3-2,
    .dynamic-placeholder.ratio-2-3,
    .dynamic-placeholder.ratio-21-9,
    .dynamic-placeholder.ratio-2-1,
    .dynamic-placeholder.ratio-1-2,
    .dynamic-placeholder.ratio-4-5,
    .dynamic-placeholder.ratio-5-4 {
        max-height: var(--small-image-max-height);
    }
    
    .image-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .detail-image img {
        max-height: 250px;
    }
    
    .modern-spinner {
        width: 36px;
        height: 36px;
    }
}

/* 平板端适配 */
@media (min-width: 768px) and (max-width: 1023px) {
    .image-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

/* 桌面端大屏优化 */
@media (min-width: 1024px) {
    .image-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 20px;
    }
}