:root {
    --danger: #d63031;
    --success: #00b894;
    --info: #0984e3;
    --warning: #f39c12;
    --chat-me: var(--primary);
    --chat-me-text: #ffffff;
    --chat-other: var(--surface);
}

.msg-main-container { display: flex; flex: 1; min-height: 0; max-width: 1200px; margin: 0 auto; width: 100%; background: var(--surface); box-shadow: 0 0 20px rgba(0,0,0,0.02); }

.msg-sidebar { width: 220px; background: var(--bg-color); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.menu-item { padding: 18px 20px; cursor: pointer; transition: 0.2s; font-size: 15px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.menu-item:hover { background: rgba(230, 126, 34, 0.05); color: var(--primary); }
.menu-item.active { background: var(--surface); color: var(--primary); border-left: 4px solid var(--primary); font-weight: bold; border-right: 1px solid transparent; margin-right: -1px; }

.menu-item.disabled { opacity: 0.5; cursor: not-allowed; }
.menu-item.disabled:hover { background: transparent; color: var(--text-main); }

.badge { background: var(--danger); color: white; font-size: 12px; padding: 2px 6px; border-radius: 10px; font-weight: bold; display: none; }
.badge.show { display: inline-block; }

.content-area { flex: 1; display: flex; flex-direction: column; position: relative; background: var(--surface); min-width: 0; min-height: 0; }
.tab-pane { display: none; flex: 1; overflow-y: auto; padding: 20px; animation: fadeIn 0.3s; min-height: 0; }
.tab-pane.active { display: flex; flex-direction: column; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.section-title { margin-top: 0; border-bottom: 2px dashed var(--border); padding-bottom: 10px; margin-bottom: 20px; font-size: 18px; color: var(--text-main); display: flex; justify-content: space-between; flex-shrink: 0; }

.item-card { border: 1px solid var(--border); border-radius: 8px; padding: 15px; margin-bottom: 15px; transition: 0.2s; }
.item-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.05); border-color: var(--primary); }
.item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.item-title { font-weight: bold; font-size: 16px; color: var(--text-main); display: flex; align-items: center; }
.item-date { font-size: 12px; color: var(--text-sub); }
.item-body { font-size: 14px; color: var(--text-main); line-height: 1.6; word-break: break-word; }
.unread-dot { display: inline-block; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; margin-right: 8px; }

/* ======== 微信风格聊天布局 ======== */
.chat-layout { display: flex; height: 100%; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; min-height: 0; }

.contacts-panel { width: 280px; background: var(--bg-color); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; min-height: 0; }
.search-wrap { padding: 15px; border-bottom: 1px solid var(--border); position: relative; background: var(--surface); flex-shrink: 0; }
.search-wrap input { width: 100%; padding: 10px 15px; border: 1px solid var(--border); border-radius: 20px; outline: none; font-size: 13px; background: var(--bg-color); color: var(--text-main); }
.search-wrap input:focus { border-color: var(--primary); background: var(--surface); }

.autocomplete-dropdown { position: absolute; top: 55px; left: 15px; right: 15px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.1); z-index: 100; max-height: 250px; overflow-y: auto; display: none; flex-direction: column; }
.autocomplete-item { padding: 10px 15px; display: flex; align-items: center; gap: 10px; cursor: pointer; border-bottom: 1px solid var(--border); }
.autocomplete-item:hover { background: rgba(230,126,34,0.05); }
.autocomplete-item img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }

.contacts-list { flex: 1; overflow-y: auto; min-height: 0; }
.contact-item { padding: 12px 15px; display: flex; align-items: center; gap: 10px; cursor: pointer; border-bottom: 1px solid var(--border); transition: 0.2s; position: relative; }
.contact-item:hover { background: rgba(0,0,0,0.02); }
.contact-item.active { background: var(--primary); color: white; border-color: var(--primary); }
.contact-avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: var(--bg-color); flex-shrink: 0; border: 1px solid rgba(0,0,0,0.05); }
.contact-info { flex: 1; min-width: 0; }
.contact-name { font-weight: bold; font-size: 14px; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.contact-msg { font-size: 12px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-item.active .contact-name { color: white; }
.contact-item.active .contact-msg { color: rgba(255,255,255,0.8); }
.contact-unread { position: absolute; right: 15px; top: 15px; background: var(--danger); color: white; font-size: 10px; font-weight: bold; padding: 2px 6px; border-radius: 10px; }

.chat-panel { flex: 1; display: flex; flex-direction: column; background: var(--bg-color); min-width: 0; min-height: 0; }
.chat-header { padding: 15px; background: var(--surface); border-bottom: 1px solid var(--border); font-weight: bold; color: var(--text-main); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }

.mobile-back-btn { display: none; margin-right: 10px; font-size: 18px; cursor: pointer; color: var(--primary); text-decoration: none; user-select: none; }
.chat-title-wrap { display: flex; align-items: center; }

/* ======== 全新设计的聊天气泡样�?(支持头像与一左一右排�? ======== */
.chat-history { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; min-height: 0; }

.msg-row { display: flex; width: 100%; gap: 10px; }
.msg-row.me { flex-direction: row-reverse; }
.msg-row.other { flex-direction: row; }

.msg-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--bg-color); flex-shrink: 0; border: 1px solid var(--border); }

.msg-content-wrapper { display: flex; flex-direction: column; max-width: 70%; }
.msg-row.me .msg-content-wrapper { align-items: flex-end; }
.msg-row.other .msg-content-wrapper { align-items: flex-start; }

.msg-name { font-size: 12px; color: var(--text-sub); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.msg-row.me .msg-name { flex-direction: row-reverse; }

.msg-bubble { padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.5; word-break: break-word; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border: 1px solid var(--border); }
.msg-row.me .msg-bubble { background: var(--primary); color: #ffffff; border-top-right-radius: 2px; border-color: var(--primary); }
.msg-row.other .msg-bubble { background: var(--surface); color: var(--text-main); border-top-left-radius: 2px; border-color: var(--border); }
/* ============================================================== */

.chat-input-area { display: flex; border-top: 1px solid var(--border); background: var(--surface); padding: 12px 15px; gap: 10px; align-items: flex-end; flex-shrink: 0; }
.chat-input-area textarea { flex: 1; padding: 10px; border: 1px solid var(--border); border-radius: 6px; resize: none; outline: none; font-family: inherit; height: 44px; background: var(--bg-color); color: var(--text-main); }
.chat-input-area textarea:focus { border-color: var(--primary); background: var(--surface); }
.chat-input-area button { background: var(--success); color: white; border: none; border-radius: 6px; padding: 0 20px; height: 44px; cursor: pointer; font-weight: bold; transition: 0.2s; white-space: nowrap; flex-shrink: 0; }
.chat-input-area button:hover { background: #00a884; }
.chat-input-area button:disabled { opacity: 0.6; cursor: not-allowed; }

.empty-state { text-align: center; color: var(--text-sub); margin-top: 40px; font-size: 14px; padding: 0 20px; }

/* 移动端深度适配 */
@media (max-width: 768px) {
    .msg-main-container { flex-direction: column; }
    .msg-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); flex-direction: row; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
    .menu-item { padding: 12px 15px; border-bottom: none; border-bottom-width: 3px; border-bottom-style: solid; border-bottom-color: transparent; }
    .menu-item.active { border-bottom-color: var(--primary); border-left: none; margin-right: 0; }
    
    .tab-pane { padding: 10px; }
    .chat-layout { border: none; border-radius: 0; }
    
    .contacts-panel { width: 100%; border-right: none; }
    .chat-panel { width: 100%; display: none; } 
    
    .chat-layout.mobile-chat-active .contacts-panel { display: none; }
    .chat-layout.mobile-chat-active .chat-panel { display: flex; }
    .chat-layout.mobile-chat-active #chatPlaceholder { display: none; }
    
    .mobile-back-btn { display: inline-block; }
    
    .msg-content-wrapper { max-width: 80%; }
    .msg-avatar { width: 32px; height: 32px; }
    .chat-history { padding: 10px; gap: 10px; }
}
