/* 聊天界面样式 */
.chat-section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f5f5f5;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    will-change: transform; /* 优化变换性能 */
}

/* 消息区域 */
.message-area {
    flex: 1;
    overflow-y: auto;
    padding: 10px 15px;
    background-color: #f5f7fa;
    position: relative;
}

.message-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 消息项 */
.message-item {
    display: flex;
    gap: 8px;
    max-width: 80%;
}

.message-item.own-message {
    align-self: flex-end;
    flex-direction: row; /* 改为row，让头像在右侧 */
}

/* 消息头像 */
.message-avatar {
    flex-shrink: 0;
}

/* 消息内容 */
.message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-item.own-message .message-content {
    align-items: flex-end;
}

/* 消息气泡 */
.message-bubble {
    background-color: #F5F5F5;
    color: #303133;
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 100%;
    word-wrap: break-word;
    position: relative;
    font-size: 14px;
    line-height: 1.4;
}

.message-bubble::before {
    content: '';
    position: absolute;
    bottom: 6px;
    left: -6px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 6px 6px 0;
    border-color: transparent #F5F5F5 transparent transparent;
}

.message-item.own-message .message-bubble {
    background-color: #E8F3FF;
    color: #303133;
}

.message-item.own-message .message-bubble::before {
    left: auto;
    right: -6px;
    border-width: 0 0 6px 6px;
    border-color: transparent transparent transparent #E8F3FF;
}

/* 输入区最大高度限制为屏幕的 1/3，高度溢出滚动 */
.input-area .el-textarea__inner {
    max-height: 33vh;
    overflow-y: auto;
}

/* 顶部“联系人”按钮上的总未读角标样式 */
.switch-btn { position: relative; }
.total-unread-badge {
    position: absolute;
    top: -2px;
    right: -6px;
    background: #ff4757;
    color: #fff;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 12px;
    text-align: center;
    border: 2px solid #fff;
}


/* 消息内容类型 */
.image-message {
    display: flex;
    justify-content: flex-start;
}

.image-message .el-image {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.image-message .el-image:hover {
    transform: scale(1.02);
}

.image-slot {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    background: #f5f7fa;
    color: #909399;
    font-size: 14px;
}

.image-slot i {
    font-size: 24px;
    margin-bottom: 8px;
}

.message-audio {
    width: 200px;
    height: 40px;
}

/* 消息状态 */
.message-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #909399;
    margin-top: 2px;
}

.message-status i {
    font-size: 14px;
}

.message-status .message-read {
    color: #409eff;
}

.message-status .message-failed {
    color: #f56c6c;
    cursor: pointer;
}

/* 消息时间显示 */
.message-time {
    font-size: 11px;
    color: #909399;
    text-align: center;
    margin-top: 4px;
    padding: 2px 6px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    display: inline-block;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 底部输入区 */
.input-area {
    background-color: #fff;
    border-top: 1px solid #e4e7ed;
    padding: 10px 15px;
    position: relative; /* 为表情面板提供定位基准 */
}

/* 输入工具栏 */
.input-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.input-toolbar .el-button {
    padding: 8px;
    min-width: 40px;
    min-height: 40px;
}

.voice-btn,
.emoji-btn,.picture-btn {
    font-size: 20px;
}

/* 语音按钮激活状态 */
.voice-btn.active {
    color: #409eff;
    background-color: rgba(64, 158, 255, 0.1);
}

.voice-btn.active:hover {
    background-color: rgba(64, 158, 255, 0.2);
}

.upload-btn {
    display: inline-block;
}

.upload-btn .el-button {
    margin: 0;
    padding: 8px;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 输入框区域优化 */
.input-box {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.text-input-mode {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    width: 100%;
}

.text-input-mode .el-textarea {
    flex: 1;
}

.text-input-mode .el-textarea__inner {
    border-radius: 20px;
    border: 1px solid #dcdfe6;
    padding: 10px 15px;
    resize: none;
    font-size: 15px;
    line-height: 1.5;
    min-height: 40px;
    max-height: 33vh;
}

.text-input-mode .el-textarea__inner:focus {
    border-color: #409eff;
    box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.1);
}

/* 发送按钮 */
.send-btn {
    border-radius: 20px;
    padding: 10px 20px;
    font-size: 14px;
    height: 40px;
    flex-shrink: 0;
}

/* 语音输入模式 */
.voice-input-mode {
    width: 100%;
}

.voice-record-btn {
    width: 100%;
    height: 50px;
    border-radius: 25px;
    border: none;
    background: linear-gradient(135deg, #409eff 0%, #66b3ff 100%);
    color: white;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    outline: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.voice-record-btn .record-text {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 1px;
}

.voice-record-btn .record-duration {
    font-size: 12px;
    opacity: 0.9;
    font-weight: normal;
}

/* 录音中的状态 */
.voice-record-btn.recording {
    background: linear-gradient(135deg, #f56c6c 0%, #ff8a8a 100%) !important;
    border-color: #f56c6c !important;
    box-shadow: 0 0 0 0 rgba(245, 108, 108, 0.7);
    animation: recording-pulse 1.5s infinite, recording-scale 0.3s ease-out;
    transform: scale(1.02);
}

/* 脉冲动画 */
@keyframes recording-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(245, 108, 108, 0.7);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(245, 108, 108, 0.3);
    }
    100% {
        box-shadow: 0 0 0 20px rgba(245, 108, 108, 0);
    }
}

/* 缩放动画 */
@keyframes recording-scale {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1.02);
    }
}

/* 按下效果 */
.voice-record-btn:active {
    transform: scale(0.98);
}

.voice-record-btn.recording:active {
    transform: scale(1.00);
}

/* 波纹效果 */
.voice-record-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.voice-record-btn.recording::before {
    width: 200%;
    height: 200%;
    opacity: 0;
}

/* 表情面板 */
.emoji-panel {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

/* 表情面板动效 */
.emoji-fade-enter-active, .emoji-fade-leave-active {
    transition: all 0.3s ease;
    transform-origin: bottom center;
}

.emoji-fade-enter {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
}

.emoji-fade-leave-to {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
}

.emoji-item {
    padding: 8px;
    text-align: center;
    cursor: pointer;
    border-radius: 4px;
    font-size: 20px;
    transition: background-color 0.2s;
    user-select: none;
}

.emoji-item:hover {
    background-color: #f5f5f5;
    transform: scale(1.1);
}

.emoji-item:active {
    transform: scale(0.95);
}

/* 表情消息样式 */
.message-content.emoji-message {
    font-size: 32px;
    line-height: 1;
    padding: 8px 12px;
    background: transparent !important;
}

.message-content.emoji-message::before,
.message-content.emoji-message::after {
    display: none;
}

/* 滚动条样式 */
.message-area::-webkit-scrollbar {
    width: 4px;
}

.message-area::-webkit-scrollbar-track {
    background: transparent;
}

.message-area::-webkit-scrollbar-thumb {
    background: #c0c4cc;
    border-radius: 2px;
}

.message-area::-webkit-scrollbar-thumb:hover {
    background: #909399;
}

.emoji-panel::-webkit-scrollbar {
    width: 4px;
}

.emoji-panel::-webkit-scrollbar-track {
    background: transparent;
}

.emoji-panel::-webkit-scrollbar-thumb {
    background: #c0c4cc;
    border-radius: 2px;
}

/* 消息加载更多 */
.load-more {
    text-align: center;
    padding: 10px;
    color: #909399;
    font-size: 14px;
    cursor: pointer;
}

.load-more:hover {
    color: #409eff;
}

/* 时间分隔符样式优化 */
.time-separator {
    text-align: center;
    margin: 15px 0;
    font-size: 12px;
    color: #909399;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 消息时间分隔 */
.message-time-divider {
    text-align: center;
    margin: 15px 0;
    position: relative;
}

.message-time-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: #e4e7ed;
}

.message-time-divider span {
    background-color: #f5f7fa;
    padding: 0 15px;
    color: #909399;
    font-size: 12px;
    position: relative;
    z-index: 1;
}

/* 响应式设计 */
@media (max-width: 480px) {
    .message-item {
        max-width: 85%;
    }
    
    .image-message .el-image {
        width: 120px !important;
        height: 120px !important;
    }
    
    .emoji-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .emoji-item {
        font-size: 20px;
        padding: 6px;
    }
    
    /* 移动端语音按钮优化 */
    .voice-record-btn {
        height: 55px;
        font-size: 17px;
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }
    
    .voice-record-btn .record-text {
        font-size: 16px;
    }
    
    .voice-record-btn .record-duration {
        font-size: 13px;
    }
}