/* Chat Window */
.chat-window {
    height:100vh; display:flex; flex-direction:column; background:#ebebeb;
}

.chat-header {
    display:flex; align-items:center; padding:10px 16px;
    background:var(--bg-white); border-bottom:1px solid var(--border);
    min-height:56px; flex-shrink:0;
}
.chat-header-info { flex:1; min-width:0; }
.chat-header-info h3 {
    font-size:16px; font-weight:600; white-space:nowrap;
    overflow:hidden; text-overflow:ellipsis;
}
.chat-status { font-size:12px; color:var(--text-muted); }
.chat-header-actions { display:flex; gap:4px; }

/* Messages container */
.chat-messages {
    flex:1; overflow-y:auto; padding:16px; display:flex;
    flex-direction:column; gap:4px;
    background:linear-gradient(180deg,#ebebeb 0%,#e8e8e8 100%);
}

.load-more {
    text-align:center; padding:12px; color:var(--text-muted);
    font-size:13px; cursor:pointer; transition:var(--transition);
}
.load-more:hover { color:var(--primary); }

/* Message item */
.msg-item {
    display:flex; gap:10px; max-width:75%; animation:msgIn 0.2s ease;
}
@keyframes msgIn { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }

.msg-item.self { flex-direction:row-reverse; margin-left:auto; }

.msg-avatar {
    width:40px; height:40px; border-radius:6px; overflow:hidden; flex-shrink:0;
    cursor:pointer;
}
.msg-avatar img { width:100%; height:100%; object-fit:cover; }

.msg-body { display:flex; flex-direction:column; }

.msg-nickname {
    font-size:12px; color:var(--text-muted); margin-bottom:2px;
    max-width:200px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.msg-item.self .msg-nickname { text-align:right; }

.msg-bubble {
    position:relative; background:#fff; border-radius:6px; padding:10px 14px;
    font-size:15px; line-height:1.5; word-break:break-word;
    box-shadow:0 1px 2px rgba(0,0,0,0.06);
}
.msg-item.self .msg-bubble {
    background:#95ec69;
}

/* Bubble arrows */
.msg-bubble::before {
    content:''; position:absolute; top:12px; width:0; height:0;
    border:6px solid transparent;
}
.msg-item:not(.self) .msg-bubble::before {
    left:-11px; border-right-color:#fff;
}
.msg-item.self .msg-bubble::before {
    right:-11px; border-left-color:#95ec69;
}

.msg-time {
    font-size:11px; color:var(--text-muted); margin-top:4px;
}
.msg-item.self .msg-time { text-align:right; }

/* Image message */
.msg-image {
    max-width:240px; border-radius:6px; overflow:hidden; cursor:pointer;
}
.msg-image img { width:100%; display:block; }

/* Video message */
.msg-video {
    max-width:240px; border-radius:6px; overflow:hidden; cursor:pointer;
    background:#000;
}
.msg-video video { width:100%; display:block; max-height:300px; }

/* Voice message */
.msg-voice {
    display:flex; align-items:center; gap:6px; min-width:80px;
    cursor:pointer; padding:2px 0;
}
.msg-voice i { font-size:20px; }
.msg-voice .duration { font-size:13px; }
.msg-item.self .msg-voice { flex-direction:row-reverse; }

.msg-voice.playing .voice-bars {
    display:flex; gap:2px; align-items:center; height:16px;
}
.msg-voice .voice-bars { display:none; }
.msg-voice.playing i { display:none; }

.voice-bar {
    width:3px; background:var(--primary); border-radius:2px;
    animation:voiceBar 0.6s ease-in-out infinite alternate;
}
.voice-bar:nth-child(1) { height:6px; animation-delay:0s; }
.voice-bar:nth-child(2) { height:10px; animation-delay:0.15s; }
.voice-bar:nth-child(3) { height:14px; animation-delay:0.3s; }
.voice-bar:nth-child(4) { height:8px; animation-delay:0.45s; }
@keyframes voiceBar { to{height:4px} }

/* File message */
.msg-file {
    display:flex; align-items:center; gap:10px; padding:8px;
    background:var(--bg-gray); border-radius:6px; min-width:200px;
    cursor:pointer;
}
.msg-file i { font-size:32px; color:var(--info); }
.msg-file .file-info { flex:1; min-width:0; }
.msg-file .file-name { font-size:14px; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.msg-file .file-size { font-size:12px; color:var(--text-muted); margin-top:2px; }

/* Red packet message */
.msg-redpacket {
    display:flex; align-items:center; gap:8px; background:#fa9d3b;
    border-radius:6px; padding:10px 14px; min-width:200px; cursor:pointer;
    color:#fff; position:relative; overflow:hidden;
}
.msg-redpacket::after {
    content:''; position:absolute; top:-10px; right:-10px;
    width:40px; height:40px; background:rgba(255,255,255,0.15);
    border-radius:50%;
}
.msg-redpacket i { font-size:28px; z-index:1; }
.msg-redpacket .rp-info { z-index:1; }
.msg-redpacket .rp-wish { font-size:14px; font-weight:500; }
.msg-redpacket .rp-tag { font-size:11px; opacity:0.8; margin-top:2px; }
.msg-redpacket.claimed { background: linear-gradient(135deg, #ffe281, #ffb800); color:#5b3e00; }

/* System message */
.msg-system {
    text-align:center; padding:8px 16px; max-width:100%;
}
.msg-system span {
    font-size:12px; color:var(--text-muted); background:rgba(0,0,0,0.04);
    padding:4px 12px; border-radius:4px; display:inline-block;
}

/* Typing indicator */
.typing-indicator {
    padding:4px 16px; font-size:12px; color:var(--text-muted);
    display:flex; align-items:center; gap:4px;
}
.typing-indicator span {
    width:4px; height:4px; background:var(--text-muted); border-radius:50%;
    animation:typingDot 1.4s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay:0.2s; }
.typing-indicator span:nth-child(3) { animation-delay:0.4s; }
@keyframes typingDot { 0%,60%,100%{opacity:0.3} 30%{opacity:1} }

/* Chat input area */
.chat-input-area {
    background:var(--bg-gray); border-top:1px solid var(--border);
    flex-shrink:0;
}

.chat-toolbar {
    display:flex; padding:6px 10px; gap:2px;
    border-bottom:1px solid rgba(0,0,0,0.04);
}
.chat-toolbar .icon-btn { font-size:24px; padding:6px 8px; }

.chat-input-row {
    display:flex; align-items:flex-end; padding:8px 10px; gap:8px;
}

.chat-input-row textarea {
    flex:1; border:none; background:#fff; border-radius:6px; padding:8px 12px;
    font-size:15px; resize:none; max-height:120px; outline:none;
    line-height:1.4; min-height:36px;
}

.send-btn {
    width:36px; height:36px; background:var(--primary); color:#fff;
    border:none; border-radius:50%; cursor:pointer; display:flex;
    align-items:center; justify-content:center; font-size:18px;
    transition:var(--transition); flex-shrink:0;
}
.send-btn:hover { background:var(--primary-dark); }
.send-btn:disabled { background:#ccc; cursor:not-allowed; }

/* Voice record */
.voice-record {
    display:flex; align-items:center; justify-content:center;
    padding:16px; gap:16px; background:var(--bg-gray);
}
.voice-btn {
    width:80px; height:80px; border-radius:50%; background:var(--primary);
    color:#fff; border:none; cursor:pointer; font-size:16px;
    display:flex; flex-direction:column; align-items:center; justify-content:center;
    gap:4px; transition:var(--transition); user-select:none;
}
.voice-btn:active { transform:scale(0.9); background:var(--primary-dark); }
.voice-btn i { font-size:24px; }
.voice-btn span { font-size:11px; }
#voiceTimer { font-size:14px; color:var(--text-muted); min-width:40px; text-align:center; }

/* Emoji panel */
.emoji-panel {
    background:var(--bg-white); border-top:1px solid var(--border);
    padding:10px; max-height:200px; overflow-y:auto;
    display:grid; grid-template-columns:repeat(8,1fr); gap:4px;
}
.emoji-panel .emoji {
    font-size:24px; text-align:center; padding:6px; cursor:pointer;
    border-radius:6px; transition:var(--transition);
}
.emoji-panel .emoji:hover { background:var(--bg-gray); }

/* Red packet form */
.red-packet-modal .modal-card { border:2px solid #fa9d3b; }

/* Notification dot for new messages */
.msg-item.new-msg {
    animation:msgIn 0.3s ease;
}

/* Red packet opened animation */
@keyframes rpOpen {
    0%{transform:scale(0.5);opacity:0}
    50%{transform:scale(1.1)}
    100%{transform:scale(1);opacity:1}
}
.rp-opened { animation:rpOpen 0.4s ease; }

/* Group member mention */
.msg-mention {
    color:var(--primary); font-weight:500;
}
