* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f0f2f5;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.chat-container {
    max-width: 1200px;
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chat-header {
    background-color: #ffffff;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h1 {
    font-size: 1.5rem;
    color: #333;
    display: flex;
    align-items: center;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    padding-bottom: calc(140px + 2rem);
    background-color: #fff;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: auto;
    position: relative;
    z-index: 1;
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.chat-input-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #ffffff;
    padding: 1rem;
    border-top: 1px solid #e0e0e0;
    z-index: 100;
    margin: 0 auto;
}

.input-controls {
    margin-bottom: 0.5rem;
    position: relative;
}

.control-btn {
    padding: 0.5rem 1rem;
    margin-right: 0.5rem;
    border: none;
    background-color: #f0f2f5;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.control-btn:hover {
    background-color: #e4e6e9;
}

.message-input-wrapper {
    display: flex;
    gap: 0.5rem;
    position: relative;
    z-index: 1;
}

#messageInput {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    resize: none;
    height: 40px;
}

#sendBtn {
    padding: 0.5rem 1rem;
    background-color: #0084ff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.message {
    margin-bottom: 1.5rem;
    max-width: 80%;
    display: flex;
    flex-direction: column;
    will-change: transform;
    transform: translateZ(0);
}

.message-time {
    font-size: 0.8rem;
    color: #999;
    margin: 0.2rem 0;
}

.message-text {
    background-color: #e9ecef;
    padding: 0.8rem 1rem;
    border-radius: 4px 16px 16px 16px;
    margin-left: 32px;
    max-width: fit-content;
}

.message-image {
    margin-left: 32px;
    max-width: 300px;
    border-radius: 8px;
    will-change: transform;
    transform: translateZ(0);
}

.message-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
    display: block;
}

.message-image:hover {
    transform: scale(1.02);
}

.emoji-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 8px;
    display: none;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.emoji-picker span {
    cursor: pointer;
    font-size: 1.5rem;
    text-align: center;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s, transform 0.2s;
}

.emoji-picker span:hover {
    background-color: #f0f2f5;
    transform: scale(1.2);
}

/* 加载提示样式 */
.loading-message {
    display: flex;
    align-items: center;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 10px;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

.loading-text {
    color: #666;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 图片预览模态 */
.image-preview-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.image-preview-modal img {
    max-width: 90%;
    max-height: 90vh;
    object-fit: contain;
}

.image-preview-modal.active {
    display: flex;
}

/* 录音按钮样式 */
.control-btn.recording {
    background-color: #ff4444;
    color: white;
}

/* 录音指示器样式 */
.recording-indicator {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
}

.recording-dot {
    width: 8px;
    height: 8px;
    background-color: #ff4444;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.3; }
    100% { opacity: 1; }
}

/* 音频消息样式 */
.message audio {
    display: none;
}

.audio-player {
    margin-left: 32px;
    display: flex;
    align-items: center;
    background-color: #95ec69;
    padding: 8px 16px;
    border-radius: 4px 18px 18px 18px;
    gap: 8px;
    width: 200px;
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s;
    word-break: keep-all;
    flex-shrink: 0;
}

.audio-player:hover {
    background-color: #88d863;
}

.audio-play-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2e3238;
    padding: 0;
}

.audio-play-btn i {
    font-size: 16px;
}

.audio-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 语音波形动画 */
.audio-wave {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 16px;
    margin-right: 4px;
}

.audio-wave span {
    display: inline-block;
    width: 3px;
    height: 8px;
    background-color: #2e3238;
    border-radius: 1px;
}

/* 播放状态样式 */
.audio-player.playing .audio-wave span {
    animation: waveform 1s ease infinite;
}

.audio-player:not(.playing) .audio-wave span {
    animation: none;
    height: 4px;
}

.audio-player:not(.playing) .audio-wave span:nth-child(2) { height: 6px; }
.audio-player:not(.playing) .audio-wave span:nth-child(3) { height: 8px; }
.audio-player:not(.playing) .audio-wave span:nth-child(4) { height: 6px; }
.audio-player:not(.playing) .audio-wave span:nth-child(5) { height: 4px; }

@keyframes waveform {
    0% { height: 4px; }
    50% { height: 12px; }
    100% { height: 4px; }
}

/* 为每个波形条添加不同的动画延迟 */
.audio-player.playing .audio-wave span:nth-child(1) { animation-delay: 0s; }
.audio-player.playing .audio-wave span:nth-child(2) { animation-delay: 0.1s; }
.audio-player.playing .audio-wave span:nth-child(3) { animation-delay: 0.2s; }
.audio-player.playing .audio-wave span:nth-child(4) { animation-delay: 0.3s; }
.audio-player.playing .audio-wave span:nth-child(5) { animation-delay: 0.4s; }

/* 响应式设计 */
@media (max-width: 768px) {
    body {
        position: fixed;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }
    
    .chat-container {
        height: 100%;
        max-height: 100vh;
        width: 100%;
    }
    
    .chat-messages {
        height: calc(100vh - 60px);
        padding-bottom: calc(140px + 1rem);
    }
    
    .chat-input-container {
        background: #fff;
        padding: 0.5rem;
        max-height: 140px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .message-text {
        font-size: 0.95rem;
    }
    
    .message-time {
        font-size: 0.75rem;
    }
    
    #messageInput {
        font-size: 16px; /* 防止iOS自动大 */
        max-height: 100px;
    }
    
    .input-controls {
        margin-bottom: 0.3rem;
    }
    
    .control-btn {
        padding: 0.4rem 0.8rem;
    }
}

/* iOS设备的特殊处理 */
@supports (-webkit-touch-callout: none) {
    .chat-messages {
        padding-bottom: calc(140px + 1rem + env(safe-area-inset-bottom));
    }
    
    .chat-input-container {
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    }
}

.online-count {
    font-size: 14px;
    color: #666;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 4px 8px;
    border-radius: 12px;
    margin-left: 1rem;
    display: inline-block;
}

/* 添加日期分隔线样式 */
.message-date-divider {
    text-align: center;
    margin: 1rem 0;
    position: relative;
}

.message-date-divider::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background-color: #e0e0e0;
}

.message-date-divider span {
    background-color: #fff;
    padding: 0 1rem;
    color: #999;
    font-size: 0.8rem;
    position: relative;
}

/* 新消息提示样式 */
.new-messages-alert {
    position: fixed;
    bottom: 160px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 132, 255, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    display: none;
    animation: bounceIn 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    user-select: none;
    white-space: nowrap;
}

.new-messages-alert:hover {
    background-color: rgba(0, 132, 255, 1);
    transform: translateX(-50%) scale(1.05);
    transition: all 0.2s ease;
}

.new-messages-alert i {
    display: inline-block;
    vertical-align: middle;
}

@keyframes bounceIn {
    0% { 
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    50% {
        transform: translate(-50%, -5px);
    }
    100% { 
        opacity: 1;
        transform: translate(-50%, 0);
    }
} 

/* 头部控制区域 */
.header-controls {
    display: flex;
    align-items: center;
}

.settings-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* 设置模态框 */
.settings-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.settings-modal.active {
    display: flex;
}

.settings-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    position: relative;
}

.settings-close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

.settings-item {
    margin-bottom: 1.5rem;
}

.settings-item label {
    display: block;
    margin-bottom: 0.5rem;
    color: #666;
}

.avatar-upload {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#currentAvatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
}

#changeAvatarBtn {
    padding: 0.5rem 1rem;
    background-color: #f0f2f5;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#nicknameInput {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.save-settings-btn {
    width: 100%;
    padding: 0.8rem;
    background-color: #0084ff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 1rem;
}

.save-settings-btn:hover {
    background-color: #0073e6;
} 

.avatar-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.preset-avatars {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-top: 1rem;
    max-height: 200px;
    overflow-y: auto;
}

.preset-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.preset-avatar:hover {
    transform: scale(1.1);
}

.preset-avatar.selected {
    border-color: #0084ff;
    transform: scale(1.1);
}

/* 消息用户信息样式 */
.message-user-info {
    display: flex;
    align-items: flex-start;
    margin-bottom: 0.3rem;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 0.5rem;
    object-fit: cover;
    will-change: transform;
    transform: translateZ(0);
}

/* 用户文本信息容器 */
.user-text-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.message-nickname {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

.message-time {
    font-size: 0.8rem;
    color: #999;
}

/* 自己发送的消息靠右 */
.message[data-self="true"] {
    margin-left: auto;
}

/* 自己发送的消息用户信息靠右 */
.message[data-self="true"] .message-user-info {
    flex-direction: row-reverse;
}

/* 自己发送的消息头像在右边 */
.message[data-self="true"] .message-avatar {
    margin-right: 0;
    margin-left: 0.5rem;
}

/* 自己发送的消息内容样式 */
.message[data-self="true"] .message-text {
    background-color: #0084ff;
    color: white;
    border-radius: 16px 4px 16px 16px;
    margin-left: 0;
    margin-right: 32px;
}

/* 自己发送的图片消息样式 */
.message[data-self="true"] .message-image {
    margin-left: 0;
    margin-right: 32px;
}

/* 自己发送的音频消息样式 */
.message[data-self="true"] .audio-player {
    margin-left: 0;
    margin-right: 32px;
    background-color: #0084ff;
    border-radius: 16px 4px 16px 16px;
    color: white;
}

/* 自己发送的消息用户信息靠右 */
.message[data-self="true"] .user-text-info {
    flex-direction: row-reverse;
}

/* 消息文本容器 */
.message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* 自己发送的消息内容靠右 */
.message[data-self="true"] .message-content {
    align-items: flex-end;
}

/* 消息文本样式 */
.message-text {
    background-color: #e9ecef;
    padding: 0.8rem 1rem;
    border-radius: 4px 16px 16px 16px;
    margin-left: 32px;
    max-width: fit-content;
}

/* 自己发送的消息靠右 */
.message[data-self="true"] {
    margin-left: auto;
}

/* 自己发送的消息内容样式 */
.message[data-self="true"] .message-text {
    background-color: #0084ff;
    color: white;
    border-radius: 16px 4px 16px 16px;
    margin-left: 0;
    margin-right: 32px;
}

/* 系统消息样式 */
.message-system {
    text-align: center;
    color: #666;
    font-size: 0.9rem;
    margin: 1rem 0;
    background-color: rgba(0, 0, 0, 0.03);
    padding: 0.5rem 1rem;
    border-radius: 16px;
    max-width: fit-content;
    margin-left: auto;
    margin-right: auto;
}