* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Microsoft Yahei", sans-serif;
}

/* 登录弹窗样式 */
.login-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.login-box {
    width: 400px;
    padding: 30px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.2);
}

.login-title {
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #333;
}

.form-item {
    margin-bottom: 20px;
}

.form-item label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: #666;
}

.form-item input {
    width: 100%;
    height: 40px;
    padding: 0 15px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    font-size: 16px;
    outline: none;
}

.form-item input:focus {
    border-color: #0078ff;
}

.login-btn {
    width: 100%;
    height: 45px;
    background-color: #0078ff;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.login-btn:hover {
    background-color: #0066d0;
}

.login-error {
    color: #ff3b30;
    font-size: 14px;
    text-align: center;
    margin-top: 10px;
    display: none;
}

/* 整体容器 - 重构为左右布局 */
.chat-container {
    width: 100%;
    max-width: 1000px;
    height: 80vh;
    margin: 20px auto;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: none; /* 初始隐藏，登录成功后显示 */
    display: flex;
    flex-direction: row;
}

/* 好友列表区域 */
.friend-list-container {
    width: 280px;
    height: 100%;
    background-color: #f8f9fa;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
}

.friend-list-header {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    font-weight: bold;
    font-size: 16px;
    color: #333;
}

.friend-list-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.friend-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.friend-item:hover {
    background-color: #e9ecef;
}

.friend-item.active {
    background-color: #0078ff;
    color: white;
}

.friend-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 10px;
    flex-shrink: 0;
}

.friend-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background-color: #e0e0e0;
}

.friend-info {
    flex: 1;
    min-width: 0;
}

.friend-nickname {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-id {
    font-size: 12px;
    color: #666;
}

.friend-item.active .friend-id {
    color: rgba(255, 255, 255, 0.8);
}

.empty-friend-list {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 14px;
}

/* 聊天区域 */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* 聊天标题栏 */
.chat-header {
    padding: 15px;
    background-color: #0078ff;
    color: white;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 当前用户信息 */
.current-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-with-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-with-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    overflow: hidden;
}

.chat-with-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-with-name {
    font-size: 16px;
}

.user-id-tag {
    font-size: 12px;
    background-color: rgba(255,255,255,0.2);
    padding: 2px 6px;
    border-radius: 8px;
}

/* 连接状态提示 */
.connection-status {
    font-size: 14px;
    font-weight: normal;
    padding: 2px 8px;
    border-radius: 10px;
    background-color: rgba(255,255,255,0.2);
}

.status-connected {
    background-color: #4cd964;
}

.status-disconnected {
    background-color: #ff3b30;
}

/* 消息展示区域 */
.chat-messages {
    height: calc(100% - 120px);
    padding: 20px;
    overflow-y: auto;
    background-color: #f5f5f5;
    width: 100%;
    box-sizing: border-box;
}

/* 未选择好友提示 */
.no-friend-selected {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 16px;
}

/* 消息项通用样式 */
.message {
    margin-bottom: 20px;
    max-width: 70%;
    clear: both;
    display: flex;
    width: fit-content;
    max-width: 70%;
}

/* 接收的消息（对方） */
.message.receive {
    float: left;
    flex-direction: row;
    align-items: flex-start;
}

/* 发送的消息（自己） */
.message.send {
    float: right;
    flex-direction: row-reverse;
    align-items: flex-start;
}

/* 系统消息 */
.message.system {
    max-width: 100%;
    text-align: center;
    float: none;
    margin: 10px auto;
    display: block;
    width: 100%;
}

/* 头像样式 */
.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.receive .message-avatar {
    margin-right: 10px;
}

.send .message-avatar {
    margin-left: 10px;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background-color: #e0e0e0;
}

/* 消息内容容器 */
.message-content-wrapper {
    flex: 1;
    min-width: 0;
    max-width: calc(100% - 50px);
}

/* 消息头部（昵称） */
.message-header {
    font-size: 12px;
    color: #666;
    margin-bottom: 3px;
    padding-left: 5px;
    word-break: break-all;
    white-space: normal;
}

/* 消息内容 */
.message-content {
    padding: 10px 15px;
    border-radius: 18px;
    line-height: 1.4;
    word-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    hyphens: auto;
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
}

/* 接收消息样式 */
.receive .message-content {
    background-color: white;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 5px;
}

/* 发送消息样式 */
.send .message-content {
    background-color: #0078ff;
    color: white;
    border-bottom-right-radius: 5px;
}

/* 系统消息样式 */
.system .message-content {
    background-color: #e5e5ea;
    color: #666;
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 4px;
    max-width: 100%;
    width: auto;
    display: inline-block;
}

/* 消息时间 */
.message-time {
    font-size: 12px;
    color: #999;
    margin-top: 5px;
    text-align: right;
    padding-right: 5px;
    word-break: break-all;
}

/* 输入区域 */
.chat-input-area {
    height: 90px;
    padding: 10px;
    background-color: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 消息输入行 */
.message-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

/* 输入框 */
#message-input {
    flex: 1;
    height: 40px;
    padding: 0 15px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    outline: none;
    font-size: 16px;
    resize: none;
    word-wrap: break-word;
    word-break: break-word;
}

/* 发送按钮 */
#send-btn {
    width: 80px;
    height: 40px;
    background-color: #0078ff;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
}

#send-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

#send-btn:hover:not(:disabled) {
    background-color: #0066d0;
}

/* 滚动条美化 */
.chat-messages::-webkit-scrollbar,
.friend-list-content::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb,
.friend-list-content::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 3px;
}

/* 默认头像样式 */
.default-avatar {
    width: 100%;
    height: 100%;
    background-color: #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

/* 加载中提示 */
.loading-tips {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 14px;
}