/* 聊天区域 */
#chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

/* 聊天头部 */
#chat-header {
    background: white;
    border-bottom: 1px solid #e0e0e0;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.chat-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-details {
    flex: 1;
}

.chat-name {
    font-weight: 600;
    color: #333;
    font-size: 1.1rem;
}

.chat-status {
    color: #666;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.chat-actions {
    display: flex;
    gap: 0.5rem;
}

/* 消息容器 */
#messages-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* 空状态 */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #999;
    text-align: center;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #ddd;
}

.empty-state p {
    font-size: 1rem;
}

/* 消息项 */
.message {
    display: flex;
    gap: 0.75rem;
    max-width: 70%;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.received {
    align-self: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    max-width: 100%;
}

.message.sent .message-bubble {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.message-text {
    line-height: 1.4;
    white-space: pre-wrap;
}

.message-image {
    max-width: 300px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s;
}

.message-image:hover {
    transform: scale(1.02);
}

.message-file {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    margin-top: 0.5rem;
}

.message-file-icon {
    font-size: 2rem;
    color: #666;
}

.message-file-info {
    flex: 1;
}

.message-file-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
}

.message-file-size {
    font-size: 0.85rem;
    color: #666;
}

.message-file-download {
    padding: 0.25rem 0.75rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 15px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

.message-file-download:hover {
    background: #5a6fd8;
}

.message-emoji {
    font-size: 1.5rem;
    line-height: 1;
}

.message-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: #999;
}

.message.sent .message-info {
    justify-content: flex-end;
}

.message-status {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.message-status i {
    font-size: 0.75rem;
}

.message-status.sent {
    color: #999;
}

.message-status.delivered {
    color: #4caf50;
}

.message-status.read {
    color: #2196f3;
}

/* 系统消息 */
.system-message {
    align-self: center;
    background: rgba(0, 0, 0, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 15px;
    font-size: 0.85rem;
    color: #666;
    max-width: 80%;
    text-align: center;
}

.message-divider {
    align-self: center;
    background: transparent;
    padding: 1rem;
    font-size: 0.85rem;
    color: #999;
    position: relative;
    text-align: center;
    margin: 1rem 0;
}

.message-divider::before,
.message-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 80px;
    height: 1px;
    background: #e0e0e0;
}

.message-divider::before {
    left: -100px;
}

.message-divider::after {
    right: -100px;
}

/* 日期分隔符 */
.date-divider {
    align-self: center;
    background: #e8eaf6;
    color: #667eea;
    padding: 0.5rem 1rem;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 600;
    margin: 1rem 0;
}

/* 撤回消息 */
.revoked-message {
    align-self: center;
    background: #fff3e0;
    padding: 0.5rem 1rem;
    border-radius: 15px;
    font-size: 0.85rem;
    color: #f57c00;
    max-width: 80%;
    text-align: center;
    font-style: italic;
}

/* 输入区域 */
#input-area {
    background: white;
    border-top: 1px solid #e0e0e0;
    padding: 1rem;
}

.input-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.input-box {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

#message-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    resize: none;
    font-size: 1rem;
    line-height: 1.4;
    max-height: 120px;
    min-height: 44px;
    font-family: inherit;
}

#message-input:focus {
    outline: none;
    border-color: #667eea;
}

#send-btn {
    background: #667eea;
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}

#send-btn:hover {
    background: #5a6fd8;
    transform: scale(1.05);
}

#send-btn:active {
    transform: scale(0.95);
}

/* 表情选择器 */
.emoji-picker {
    position: absolute;
    bottom: 80px;
    left: 20px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: none;
    width: 320px;
    max-height: 300px;
}

.emoji-tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
}

.emoji-tab {
    flex: 1;
    padding: 0.75rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background-color 0.3s;
}

.emoji-tab.active {
    background: #f8f9fa;
    border-bottom: 2px solid #667eea;
}

.emoji-tab:hover {
    background: #f8f9fa;
}

.emoji-content {
    padding: 0.75rem;
    max-height: 200px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.25rem;
}

.emoji-item {
    padding: 0.5rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1.5rem;
    border-radius: 4px;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-item:hover {
    background: #f8f9fa;
}

/* 输入状态 */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: #666;
    font-size: 0.85rem;
    font-style: italic;
}

.typing-dots {
    display: flex;
    gap: 0.25rem;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #666;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 图片预览 */
.image-preview {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.image-preview img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
}

.image-preview-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    background: none;
    border: none;
}

/* 消息搜索 */
.search-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    display: none;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
}

.search-modal-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.search-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.search-input-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.search-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 1rem;
}

.search-results {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.search-result-item {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.3s;
}

.search-result-item:hover {
    background: #f8f9fa;
}

.search-result-message {
    color: #333;
    margin-bottom: 0.5rem;
}

.search-result-meta {
    color: #666;
    font-size: 0.85rem;
}

/* 引用消息 */
.message-quote {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.5rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    border-left: 3px solid #667eea;
}

.quote-content {
    color: #666;
    font-size: 0.85rem;
    font-style: italic;
}

.quote-author {
    font-weight: 600;
    color: #667eea;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

/* 语音消息 */
.message-voice {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 18px;
    min-width: 120px;
}

.voice-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s;
}

.voice-play-btn:hover {
    background: #5a6fd8;
}

.voice-duration {
    font-size: 0.85rem;
    color: #666;
}

.voice-waveform {
    flex: 1;
    height: 20px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.voice-bar {
    flex: 1;
    background: #667eea;
    border-radius: 1px;
    transition: height 0.3s;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .message {
        max-width: 85%;
    }
    
    .emoji-picker {
        width: 280px;
        left: 10px;
        bottom: 70px;
    }
    
    .emoji-content {
        grid-template-columns: repeat(7, 1fr);
    }
    
    .search-modal {
        width: 95%;
        max-height: 90vh;
    }
}

@media (max-width: 480px) {
    #chat-header {
        padding: 0.75rem;
        height: 60px;
    }
    
    .chat-avatar {
        width: 40px;
        height: 40px;
    }
    
    .chat-name {
        font-size: 1rem;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
    }
    
    .message-bubble {
        padding: 0.5rem 0.75rem;
    }
    
    #input-area {
        padding: 0.75rem;
    }
    
    .emoji-picker {
        width: calc(100vw - 20px);
        left: 10px;
    }
    
    .emoji-content {
        grid-template-columns: repeat(10, 1fr);
    }
}