/* ==========================================================================
   聊天区域
   ========================================================================== */
/**
 * 微信风格聊天区域样式
 * @selector #right - 右侧聊天区域
 * @selector #title - 聊天标题栏
 * @selector .menu-btn - 菜单按钮
 * @selector .chat-title - 聊天标题
 * @selector .window-controls - 窗口控制按钮容器
 * @selector .control-btn - 控制按钮
 */

#right {
    flex: 1;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f7f7f7;
    overflow: hidden;
}

/* 移动端聊天区域调整 */
@media (max-width: 768px) {
    #right {
        width: 100vw;
        height: 100vh;
        position: relative;
        z-index: 1;
    }
}

/* 聊天标题栏 */
#title {
    height: 56px;
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
    z-index: 5;
    flex-shrink: 0;
}

.menu-btn {
    width: 32px;
    height: 32px;
    display: none;  /* 桌面端隐藏 */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.menu-btn:hover {
    background: var(--bg-hover);
}

.menu-btn span {
    width: 18px;
    height: 2px;
    background: var(--text-primary);
    margin: 2px 0;
    transition: all 0.3s ease;
}

.chat-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
    text-align: center;
}

.window-controls {
    display: flex;
    gap: 12px;
}

.control-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
    position: relative;
}

.control-btn:hover {
    background: var(--bg-hover);
}

.control-btn:active {
    transform: scale(0.9);
}

.refresh-btn::before {
    content: "";
    display: block;
    width: 12px;
    height: 12px;
    border: 2px solid #666;
    border-top-color: transparent;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    position: absolute;
    top: 50%;
    left: 50%;
}

.refresh-btn::after {
    content: "";
    display: block;
    width: 0;
    height: 0;
    border: 4px solid transparent;
    border-bottom-color: #666;
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
}

.minimize-btn::before {
    content: "";
    display: block;
    width: 12px;
    height: 2px;
    background: #666;
}

.close-btn::before,
.close-btn::after {
    content: "";
    display: block;
    width: 14px;
    height: 2px;
    background: #666;
    position: absolute;
}

.close-btn::before {
    transform: rotate(45deg);
}

.close-btn::after {
    transform: rotate(-45deg);
}

/* ==========================================================================
   消息显示区域
   ========================================================================== */
/**
 * 微信风格消息显示区域
 * @selector #msg - 消息容器
 * @selector .message-item - 消息项容器
 * @selector .avatar - 消息头像
 * @selector .message-content - 消息内容容器
 * @selector .message-bubble - 消息气泡
 * @selector .message-time - 消息时间
 * @selector .message-status - 消息状态指示器
 * @selector .file-message - 文件消息样式
 * @selector .file-container - 文件容器
 * @selector .file-header - 文件头部
 * @selector .file-icon - 文件图标
 * @selector .file-name - 文件名
 * @selector .file-size - 文件大小
 * @selector .file-download-btn - 文件下载按钮
 * @selector .image-preview-container - 图片预览容器
 * @selector .image-thumbnail - 图片缩略图
 * @selector .file-action-container - 文件操作按钮容器
 * @selector .file-action-btn - 文件操作按钮
 * @selector .center-text-gray - 空状态提示
 */

#msg {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 20px;
    background: #f7f7f7;
    display: flex;
    flex-direction: column;
}

/* 自定义滚动条 */
#msg::-webkit-scrollbar {
    width: 6px;
}

#msg::-webkit-scrollbar-track {
    background: transparent;
}

#msg::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

#msg::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* 消息项容器 */
.message-item {
    display: flex;
    margin-bottom: 16px;
    max-width: 100%;
    align-items: flex-start;
    animation: messageSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.message-item.me {
    justify-content: flex-end;
}

.message-item.other {
    justify-content: flex-start;
}

/* 头像 */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    margin: 0 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-gray);
}

/* 消息内容区 */
.message-content {
    max-width: 60%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.message-item.me .message-content {
    align-items: flex-end;
}

.message-item.other .message-content {
    align-items: flex-start;
}

/* 消息气泡 - 微信风格 */
.message-bubble {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 15px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    max-width: 100%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* 接收消息气泡 */
.message-item.other .message-bubble {
    background: white;
    color: var(--text-primary);
    border-radius: 0 6px 6px 6px;
}

/* 发送消息气泡 - 微信绿 */
.message-item.me .message-bubble {
    background: #95ec69;
    color: var(--text-primary);
    border-radius: 6px 0 6px 6px;
    align-self: flex-end;
}

/* 消息时间 */
.message-time {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
    padding: 0 4px;
}

.message-item.me .message-time {
    text-align: right;
}

.message-item.other .message-time {
    text-align: left;
}

/* 消息状态指示器 */
.message-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.message-item.me .message-status {
    margin-left: 4px;
    margin-right: 0;
}

.message-item.other .message-status {
    margin-left: 0;
    margin-right: 4px;
}

/* 消息状态样式 */
.message-item.pending .message-status {
    color: #999;
}

.message-item.pending .message-status i {
    animation: pulse 1.5s infinite ease-in-out;
}

.message-item.confirmed .message-status {
    color: #07c160;
}

.message-item.failed .message-status {
    color: #fa5151;
}

.message-item.retrying .message-status {
    color: #ff9500;
}

.message-item.retrying .message-status i {
    animation: spin 1s infinite linear;
}

/* 图片消息 */
.message-bubble img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 4px;
    cursor: pointer;
    display: block;
    transition: transform 0.2s ease;
}

.message-bubble img:hover {
    transform: scale(1.02);
}

/* 文件消息样式 */
.file-message {
    padding: 12px 16px !important;
    min-width: 280px;
    max-width: 320px;
}

.file-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.file-size {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: 28px;
}

.file-download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 4px;
    align-self: flex-start;
}

.file-download-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.file-download-btn:active {
    transform: translateY(0);
}

/* 图片文件消息特殊样式 */
.file-message.image-file {
    max-width: 280px;
    min-width: 200px;
}

/* 图片预览容器 */
.image-preview-container {
    margin-bottom: 8px;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.05);
    position: relative;
}

.image-thumbnail {
    width: 100%;
    height: 180px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s ease;
    display: block;
}

.image-thumbnail:hover {
    transform: scale(1.02);
}

.image-error-placeholder {
    width: 100%;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-secondary);
    font-size: 14px;
    text-align: center;
    border-radius: 8px;
}

/* 文件信息容器 */
.file-info-container {
    padding: 8px 12px;
}

/* 文件操作按钮容器 */
.file-action-container {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    justify-content: flex-end;
}

.file-action-btn {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--primary-color);
    color: white;
    font-weight: 500;
}

.file-action-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.file-action-btn.download-btn {
    background: var(--success-color, #07c160);
}

.file-action-btn.download-btn:hover {
    background: var(--success-hover, #06ad56);
}

.file-action-btn.preview-btn {
    background: var(--info-color, #10aeff);
}

.file-action-btn.preview-btn:hover {
    background: var(--info-hover, #0996e6);
}

/* 空状态提示 */
.center-text-gray {
    text-align: center;
    color: var(--text-light);
    padding: 60px 20px;
    align-self: center;
    font-size: 14px;
}