/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Microsoft YaHei", sans-serif;
}

/* 背景与布局 */
body {
    background: linear-gradient(135deg, #e0f7fa 0%, #f3e5f5 100%);
    background-attachment: fixed;
    min-height: 100vh;
}

/* 通用卡片样式 */
.card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}
.card:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* 按钮通用样式 */
.btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}
.btn-primary {
    background: #1677ff;
    color: white;
}
.btn-primary:hover {
    background: #0958d9;
    transform: translateY(-1px);
}
.btn-success {
    background: #52c41a;
    color: white;
}
.btn-success:hover {
    background: #389e0d;
}
.btn-danger {
    background: #ff4d4f;
    color: white;
}
.btn-danger:hover {
    background: #d9363e;
}
.btn-outline {
    background: transparent;
    border: 1px solid #1677ff;
    color: #1677ff;
}
.btn-outline:hover {
    background: #e6f7ff;
}
.btn:disabled {
    background: #f5f5f5;
    color: #cccccc;
    cursor: not-allowed;
    transform: none;
}

/* 输入框通用样式 */
.input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
}
.input:focus {
    outline: none;
    border-color: #1677ff;
    box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.2);
}
.input-error {
    border-color: #ff4d4f;
}
.input-success {
    border-color: #52c41a;
}

/* 提示文本 */
.tip {
    font-size: 12px;
    margin-top: 4px;
}
.tip-error {
    color: #ff4d4f;
}
.tip-success {
    color: #52c41a;
}
.tip-warning {
    color: #faad14;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 聊天主界面布局 */
.chat-layout {
    display: flex;
    width: 95%;
    max-width: 1400px;
    height: 90vh;
    margin: 20px auto;
    gap: 10px;
}

/* 侧边栏（联系人/群聊列表） */
.sidebar {
    width: 260px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.sidebar-header {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
}
.sidebar-tabs {
    display: flex;
    padding: 0 16px;
    border-bottom: 1px solid #f0f0f0;
}
.sidebar-tab {
    padding: 10px 0;
    width: 50%;
    text-align: center;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 2px solid transparent;
}
.sidebar-tab.active {
    color: #1677ff;
    border-bottom-color: #1677ff;
}
.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.contact-item {
    padding: 8px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    margin-bottom: 4px;
}
.contact-item:hover {
    background: #f5f5f5;
}
.contact-item.active {
    background: #e6f7ff;
}
.contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #1677ff;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
.contact-info {
    flex: 1;
    overflow: hidden;
}
.contact-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.contact-last-msg {
    font-size: 12px;
    color: #8c8c8c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 聊天区域 */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.chat-header {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
}
.chat-title {
    font-size: 16px;
    font-weight: 500;
}
.chat-actions {
    display: flex;
    gap: 8px;
}
.chat-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.message-item {
    display: flex;
    max-width: 70%;
}
.message-item.self {
    flex-direction: row-reverse;
    margin-left: auto;
}
.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1677ff;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.message-content {
    margin: 0 8px;
    padding: 8px 12px;
    border-radius: 10px;
    background: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}
.message-item.self .message-content {
    background: #1677ff;
    color: white;
}
.message-time {
    font-size: 10px;
    color: #8c8c8c;
    text-align: center;
    margin-top: 4px;
}
.message-item.self .message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* 聊天输入区域 */
.chat-input-area {
    padding: 16px;
    border-top: 1px solid #f0f0f0;
}
.chat-input-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.tool-icon {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.tool-icon:hover {
    background: #f5f5f5;
}
.chat-input-container {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.chat-input {
    flex: 1;
    min-height: 60px;
    max-height: 120px;
    resize: none;
    padding: 10px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    font-size: 14px;
}
.chat-input:focus {
    outline: none;
    border-color: #1677ff;
}
.send-btn {
    height: 60px;
    width: 80px;
}

/* 好友添加/管理弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-content {
    width: 90%;
    max-width: 500px;
    background: white;
    border-radius: 12px;
    padding: 20px;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.modal-title {
    font-size: 18px;
    font-weight: 500;
}
.modal-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
}
.modal-close:hover {
    background: #f5f5f5;
}
.modal-body {
    margin-bottom: 20px;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* 响应式适配 */
@media (max-width: 768px) {
    .chat-layout {
        flex-direction: column;
        height: auto;
    }
    .sidebar {
        width: 100%;
        height: 200px;
    }
}

/* 隐藏元素 */
.hidden {
    display: none !important;
}
/* 表情面板样式 */
#emoji-panel {
    position: absolute;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 8px;
    z-index: 100;
}

.emoji-item {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 4px;
    font-size: 20px;
    transition: all 0.2s ease;
}

.emoji-item:hover {
    background: #f5f5f5;
    transform: scale(1.1);
}

/* 设置页面样式 */
#avatar-preview {
    border: 2px solid #e0e0e0;
}

#avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}