/* 微信风格 + 移动端优化 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}

body {
    background-color: #f5f5f5;
    height: 100vh;
    overflow: hidden; /* 防止滚动条 */
    -webkit-text-size-adjust: 100%; /* 防止 iOS Safari 缩放文字 */
}

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: white; /* 恢复背景色 */
}

/* 认证区域 */
.auth-section {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    background-color: white;
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-radius: 10px;
    background-color: white;
}

.auth-title {
    text-align: center;
    margin-bottom: 20px;
    font-size: 24px;
    color: #333;
}

.tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 20px;
}

.tab {
    flex: 1;
    padding: 15px;
    text-align: center;
    border: none;
    background: none;
    font-size: 16px;
    cursor: pointer;
    color: #999;
    border-bottom: 2px solid transparent;
}

.tab.active {
    color: #07c160;
    border-bottom-color: #07c160;
}

.form {
    display: none;
}

.form.active {
    display: block;
}

input[type="text"],
input[type="password"],
input[type="url"] {
    width: 100%;
    padding: 12px 15px; /* 增加内边距，便于触摸 */
    margin-bottom: 15px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    font-size: 16px;
    /* 移动端优化 */
    -webkit-appearance: none; /* 移除默认样式 */
    -moz-appearance: textfield; /* Firefox */
}

input[type="url"] {
    font-size: 14px; /* URL 输入框字体稍小 */
}

button {
    width: 100%;
    padding: 12px; /* 增加内边距，便于触摸 */
    background-color: #07c160;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    min-height: 44px; /* iOS 推荐的最小触摸目标 */
}

button:hover {
    background-color: #06ad56;
}

.error-message {
    color: #fa5151;
    font-size: 14px;
    text-align: center;
    margin-top: 10px;
    min-height: 20px;
}

.hidden {
    display: none !important;
}

/* 主界面 */
.main-section {
    display: flex;
    height: 100vh;
    overflow: hidden; /* 防止滚动条 */
}

/* 侧边栏 */
.sidebar {
    width: 300px;
    background-color: white;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* 防止滚动条 */
}

.user-info {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-right: 10px;
    object-fit: cover; /* 保持头像比例 */
}

.user-details {
    flex: 1;
    overflow: hidden; /* 防止文本溢出 */
}

.user-details span {
    display: block;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap; /* 昵称过长时省略 */
}

#current-user-nickname {
    font-weight: bold;
    color: #333;
}

.username {
    color: #999;
    font-size: 12px;
}

.logout-btn {
    background-color: #fa5151;
    padding: 8px 15px; /* 调整登出按钮大小 */
    font-size: 14px;
    width: auto;
    min-height: 36px; /* 调整最小高度 */
}

.settings-section {
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.settings-btn {
    width: 100%;
    margin-bottom: 10px;
    background-color: #f0f0f0;
    color: #333;
    font-size: 14px;
    min-height: 40px; /* 设置最小高度 */
}

/* 管理员面板 */
.admin-panel {
    flex: 1;
    overflow-y: auto; /* 侧边栏可滚动 */
    padding: 15px;
}

.admin-panel h3 {
    color: #333;
    margin-bottom: 15px;
}

.admin-controls {
    margin-bottom: 20px;
}

.search-box {
    display: flex;
    margin-bottom: 10px;
}

.search-box input {
    flex: 1;
    margin-right: 5px;
}

.search-box button {
    width: auto;
    padding: 8px 15px;
    margin-left: 5px;
    min-height: 36px; /* 调整按钮最小高度 */
}

.clear-time-section {
    margin-bottom: 10px;
}

.clear-time-section label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
}

.clear-time-section select {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    min-height: 36px; /* 调整下拉框最小高度 */
}

.clear-time-section button,
#clear-all-messages-btn {
    width: 100%;
    background-color: #fa5151;
    margin-bottom: 10px;
    min-height: 40px; /* 设置最小高度 */
}

.user-list-container h4 {
    margin-bottom: 10px;
    color: #666;
}

#user-list {
    list-style: none;
}

#user-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.user-actions button {
    padding: 6px 12px; /* 调整按钮内边距 */
    font-size: 12px;
    margin-left: 5px;
    border-radius: 3px;
    min-height: 32px; /* 设置最小高度 */
}

.user-actions .mute-btn {
    background-color: #fa5151;
}

.user-actions .unmute-btn {
    background-color: #07c160;
}

.user-actions .remove-btn {
    background-color: #999;
}

/* 聊天区域 */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #f5f5f5;
    overflow: hidden; /* 防止滚动条 */
}

.chat-header {
    padding: 15px 20px;
    background-color: white;
    border-bottom: 1px solid #e0e0e0;
    font-size: 18px;
    font-weight: bold;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1); /* 添加轻微阴影 */
}

.messages-container {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px; /* 消息间距 */
}

/* 消息气泡布局 */
.message {
    display: flex;
    align-items: flex-end;
    margin-bottom: 10px;
    max-width: 85%; /* 限制最大宽度 */
}

.message.own {
    align-self: flex-end;
    flex-direction: row-reverse; /* 自己的消息头像在右侧 */
}

.message .avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    margin: 0 5px; /* 调整头像与气泡间距 */
    object-fit: cover; /* 保持头像比例 */
    flex-shrink: 0; /* 防止头像被挤压 */
}

.message .content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.message.own .content-wrapper {
    align-items: flex-end;
}

.message .sender-name { /* 新增：发送者昵称 */
    font-size: 12px;
    color: #999;
    margin-bottom: 3px;
    align-self: flex-start; /* 昵称对齐到气泡开始 */
}

.message.own .sender-name {
    align-self: flex-end; /* 自己的昵称对齐到气泡末端 */
}

.message .content {
    padding: 10px 15px;
    border-radius: 10px;
    word-wrap: break-word;
    font-size: 14px;
    max-width: 100%; /* 防止超长文本撑破 */
    box-shadow: 0 1px 2px rgba(0,0,0,0.1); /* 添加轻微阴影 */
}

.message.own .content {
    background-color: #bfe6cf;
    border-bottom-right-radius: 2px; /* 自己的消息右下角尖角 */
}

.message:not(.own) .content {
    background-color: white;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 2px; /* 他人的消息左下角尖角 */
}

.message .info {
    font-size: 10px;
    color: #999;
    margin-top: 3px;
    align-self: flex-end; /* 时间戳对齐到气泡末端 */
}

.input-area {
    padding: 10px 15px;
    background-color: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    box-shadow: 0 -1px 2px rgba(0,0,0,0.1); /* 输入框阴影 */
}

#message-input {
    flex: 1;
    padding: 12px 15px; /* 增加内边距，便于触摸 */
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    margin-right: 10px;
    font-size: 14px;
    outline: none; /* 移除默认聚焦边框 */
}

#message-input:focus {
    border-color: #07c160; /* 聚焦时边框颜色 */
}

#send-btn {
    width: auto;
    padding: 12px 20px; /* 增加内边距，便于触摸 */
    border-radius: 20px;
    min-width: 60px; /* 设置最小宽度 */
}

/* 模态框 */
.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;
}

.modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
}

.modal-content h3 {
    margin-bottom: 15px;
    color: #333;
}

.modal-content input {
    margin-bottom: 10px;
}

.modal-content button {
    width: 48%;
    margin: 0 1% 0 1%;
    min-height: 40px; /* 设置最小高度 */
}

.modal-content button:nth-child(3) {
    margin-right: 0;
}

.modal-content button:nth-child(4) {
    margin-left: 0;
}

/* 移动端优化 */
@media (max-width: 768px) {
    .main-section {
        flex-direction: column; /* 移动端垂直布局 */
    }

    .sidebar {
        width: 100%;
        height: auto; /* 高度自适应 */
        max-height: 40vh; /* 限制最大高度 */
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }

    .chat-area {
        height: 100%;
    }

    .messages-container {
        padding: 10px; /* 减少内边距 */
    }

    .message {
        max-width: 90%; /* 移动端消息更窄 */
    }

    .message .avatar {
        width: 30px; /* 移动端头像更小 */
        height: 30px;
    }

    .message .content {
        font-size: 13px; /* 移动端字体稍小 */
        padding: 8px 12px; /* 移动端气泡更紧凑 */
    }

    .input-area {
        padding: 10px; /* 减少输入框区域内边距 */
    }

    #message-input {
        padding: 10px 12px; /* 减少输入框内边距 */
    }

    #send-btn {
        padding: 10px 15px; /* 减少发送按钮内边距 */
    }
}