/**
 * 云信IM - 图片消息样式
 * 遵循微信设计最佳实践
 */

/* 图片消息容器 */
.yunxin-message-image-wrapper {
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    background: #F0F0F0;
    max-width: 240px;
}

/* 单张图片 */
.yunxin-message-image {
    display: block;
    max-width: 240px;
    max-height: 240px;
    width: auto;
    height: auto;
    border-radius: 4px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.yunxin-message-image:hover {
    opacity: 0.9;
}

/* 长图样式 */
.yunxin-message-image.long-image {
    max-height: 400px;
}

/* 原图标识 */
.yunxin-message-image-original {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: #FFFFFF;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
}

/* 图片加载状态 */
.yunxin-message-image-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 3px solid #E5E5E5;
    border-top-color: #07C160;
    border-radius: 50%;
    animation: yunxin-spin 0.8s linear infinite;
}

/* 图片加载失败 */
.yunxin-message-image-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    padding: 20px;
    background: #F7F7F7;
    color: #999999;
    font-size: 13px;
}

.yunxin-message-image-error-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.yunxin-message-image-reload {
    margin-top: 8px;
    padding: 4px 12px;
    background: #07C160;
    color: #FFFFFF;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.yunxin-message-image-reload:hover {
    background: #06AD56;
}

/* 多图网格 */
.yunxin-message-images-grid {
    display: grid;
    gap: 4px;
}

/* 2张图片 */
.yunxin-message-images-grid.count-2 {
    grid-template-columns: repeat(2, 120px);
}

.yunxin-message-images-grid.count-2 .yunxin-message-image {
    width: 120px;
    height: 120px;
    object-fit: cover;
}

/* 3张图片 */
.yunxin-message-images-grid.count-3 {
    grid-template-columns: 240px;
}

.yunxin-message-images-grid.count-3 .yunxin-message-image:first-child {
    width: 240px;
    max-height: 240px;
}

.yunxin-message-images-grid.count-3 .yunxin-message-image:not(:first-child) {
    width: 118px;
    height: 118px;
    object-fit: cover;
}

.yunxin-message-images-grid.count-3 .yunxin-message-image-row {
    display: grid;
    grid-template-columns: repeat(2, 118px);
    gap: 4px;
}

/* 4张图片 */
.yunxin-message-images-grid.count-4 {
    grid-template-columns: repeat(2, 120px);
}

.yunxin-message-images-grid.count-4 .yunxin-message-image {
    width: 120px;
    height: 120px;
    object-fit: cover;
}

/* 5-6张图片 */
.yunxin-message-images-grid.count-5,
.yunxin-message-images-grid.count-6 {
    grid-template-columns: repeat(3, 80px);
}

.yunxin-message-images-grid.count-5 .yunxin-message-image,
.yunxin-message-images-grid.count-6 .yunxin-message-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
}

/* 7-9张图片 */
.yunxin-message-images-grid.count-7,
.yunxin-message-images-grid.count-8,
.yunxin-message-images-grid.count-9 {
    grid-template-columns: repeat(3, 80px);
}

.yunxin-message-images-grid.count-7 .yunxin-message-image,
.yunxin-message-images-grid.count-8 .yunxin-message-image,
.yunxin-message-images-grid.count-9 .yunxin-message-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
}

/* 图片项 */
.yunxin-message-image-item {
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    background: #F0F0F0;
}

/* 懒加载占位符 */
.yunxin-message-image.lazy {
    opacity: 0;
    transition: opacity 0.3s;
}

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

/* 长图提示 */
.yunxin-message-long-image-tip {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    color: #FFFFFF;
    padding: 8px;
    text-align: center;
    font-size: 12px;
}

/* 动画 */
@keyframes yunxin-spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 移动端适配 */
@media (max-width: 768px) {
    .yunxin-message-image-wrapper {
        max-width: 200px;
    }

    .yunxin-message-image {
        max-width: 200px;
        max-height: 200px;
    }

    .yunxin-message-images-grid.count-2 {
        grid-template-columns: repeat(2, 100px);
    }

    .yunxin-message-images-grid.count-2 .yunxin-message-image {
        width: 100px;
        height: 100px;
    }

    .yunxin-message-images-grid.count-3 {
        grid-template-columns: 200px;
    }

    .yunxin-message-images-grid.count-3 .yunxin-message-image:first-child {
        width: 200px;
    }

    .yunxin-message-images-grid.count-3 .yunxin-message-image:not(:first-child) {
        width: 98px;
        height: 98px;
    }

    .yunxin-message-images-grid.count-3 .yunxin-message-image-row {
        grid-template-columns: repeat(2, 98px);
    }

    .yunxin-message-images-grid.count-4 {
        grid-template-columns: repeat(2, 100px);
    }

    .yunxin-message-images-grid.count-4 .yunxin-message-image {
        width: 100px;
        height: 100px;
    }

    .yunxin-message-images-grid.count-5,
    .yunxin-message-images-grid.count-6,
    .yunxin-message-images-grid.count-7,
    .yunxin-message-images-grid.count-8,
    .yunxin-message-images-grid.count-9 {
        grid-template-columns: repeat(3, 65px);
    }

    .yunxin-message-images-grid.count-5 .yunxin-message-image,
    .yunxin-message-images-grid.count-6 .yunxin-message-image,
    .yunxin-message-images-grid.count-7 .yunxin-message-image,
    .yunxin-message-images-grid.count-8 .yunxin-message-image,
    .yunxin-message-images-grid.count-9 .yunxin-message-image {
        width: 65px;
        height: 65px;
    }
}

