*{box-sizing:border-box}
body{margin:0;background:#f5f5f5;font-family:Arial,"Microsoft YaHei",sans-serif;color:#222}
.chatim-user{height:100vh;display:flex;flex-direction:column;background:#f7f7f7}

.chat-header{height:56px;background:#fff;border-bottom:1px solid #eee;padding:8px 12px;display:flex;align-items:center;justify-content:space-between}
.title{font-size:16px;font-weight:bold}
.status{font-size:12px;color:#888;margin-top:3px}
.small-btn{border:0;background:#1677ff;color:#fff;border-radius:5px;padding:6px 10px}

.typing-bar{height:24px;line-height:24px;font-size:12px;color:#1677ff;padding:0 12px;background:#eef6ff;display:none}

.chat-body{flex:1;overflow-y:auto;padding:12px 14px}

/* 时间 */
.msg-time{text-align:center;color:#999;font-size:12px;margin:10px 0}

/* 每一行消息 */
.msg-row{
    display:flex;
    margin-bottom:12px;
    align-items:flex-start;
    gap:8px;
}

/* 用户自己的消息：右边 */
.msg-row.user{
    justify-content:flex-end;
}

/* 客服消息：左边 */
.msg-row.admin{
    justify-content:flex-start;
}

/* 头像 */
.msg-avatar{
    width:38px;
    height:38px;
    min-width:38px;
    border-radius:50%;
    object-fit:cover;
    background:#fff;
    border:1px solid #eee;
    box-shadow:0 1px 3px rgba(0,0,0,.05);
}

/* 消息主体区域 */
.msg-main{
    display:flex;
    flex-direction:column;
    max-width:76%;
}

.msg-row.user .msg-main{
    align-items:flex-end;
}

.msg-row.admin .msg-main{
    align-items:flex-start;
}

/* 气泡 */
.msg-bubble{
    padding:9px 11px;
    border-radius:9px;
    background:#fff;
    line-height:1.5;
    word-break:break-all;
    font-size:14px;
    box-shadow:0 1px 2px rgba(0,0,0,.03);
}

/* 用户消息绿色 */
.msg-row.user .msg-bubble{
    background:#d9f7be;
}

/* 撤回 */
.msg-bubble.recalled{
    background:#eee!important;
    color:#999;
    font-style:italic;
}

/* 气泡下方状态栏 */
.msg-meta{
    margin-top:4px;
    display:flex;
    gap:7px;
    align-items:center;
    min-height:16px;
}

.msg-row.user .msg-meta{
    justify-content:flex-end;
}

.msg-row.admin .msg-meta{
    justify-content:flex-start;
}

.msg-action{
    font-size:12px;
    color:#999;
    cursor:pointer;
    display:none;
}

.msg-row:hover .msg-action{
    display:inline-block;
}

.msg-action:hover{
    color:#f5222d;
}

.msg-read-status{
    font-size:12px;
    color:#999;
}

/* 图片 */
.chat-img{
    max-width:180px;
    max-height:180px;
    border-radius:6px;
    display:block;
    cursor:pointer;
}

/* 文件 */
.file-card{
    display:flex;
    align-items:center;
    gap:10px;
    text-decoration:none;
    color:#333;
    min-width:180px;
    max-width:260px;
}

.file-icon{
    font-size:28px;
}

.file-info{
    overflow:hidden;
}

.file-name{
    font-size:14px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    max-width:200px;
}

.file-size{
    font-size:12px;
    color:#999;
    margin-top:4px;
}

/* 底部 */
.chat-tools{height:42px;background:#fff;border-top:1px solid #eee;padding:6px 8px;display:flex;gap:8px}
.chat-tools button{height:30px;border:0;border-radius:5px;background:#f0f0f0;padding:0 12px}

.chat-footer{height:78px;background:#fff;border-top:1px solid #eee;padding:8px;display:flex;gap:8px}
#messageInput{flex:1;border:1px solid #ddd;border-radius:6px;padding:8px;resize:none;outline:none}
#sendBtn{width:64px;border:0;border-radius:6px;background:#1677ff;color:#fff}

/* 手机端稍微缩小头像 */
@media (max-width: 480px){
    .chat-body{padding:10px}
    .msg-avatar{
        width:34px;
        height:34px;
        min-width:34px;
    }
    .msg-main{
        max-width:78%;
    }
}
