/* ============ 加入页面 ============ */
#joinPage {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.join-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #F8F8F8;
    padding: 20px 20px 20px;
    text-align: center;
    transition: background 0.3s;
    position: relative;
}

.header-right {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
}

.gear-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.gear-btn:hover {
    background: rgba(0,0,0,0.05);
}

body.dark .gear-btn:hover {
    background: rgba(255,255,255,0.1);
}

.gear-btn svg {
    width: 24px;
    height: 24px;
    fill: #666;
    transition: fill 0.3s;
}

body.dark .gear-btn svg {
    fill: #AAA;
}

body.dark .join-header { background: #333; }

.join-title {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    transition: color 0.3s;
}

body.dark .join-title { color: #E0E0E0; }

.join-subtitle {
    font-size: 14px;
    color: #999;
    margin-top: 8px;
    transition: color 0.3s;
}

body.dark .join-subtitle { color: #AAA; }

.join-form-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 20px 60px;
}

.join-form {
    width: 100%;
    max-width: 340px;
}

.join-input {
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 14px;
    border: 1px solid #E0E0E0;
    border-radius: 10px;
    font-size: 16px;
    background: #fff;
    color: #333;
    outline: none;
    transition: all 0.3s;
}

body.dark .join-input {
    background: #444;
    color: #E0E0E0;
    border-color: #555;
}

.join-input:focus { border-color: #07C160; }

.join-input::placeholder { color: #BBB; }

body.dark .join-input::placeholder { color: #777; }

.btn-join {
    width: 100%;
    padding: 14px;
    background: #07C160;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 17px;
    font-weight: 500;
    cursor: pointer;
}

.btn-join:active { background: #06AD56; }

/* ============ 设置面板 ============ */
.settings-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding-top: 80px;
}

.settings-overlay.show { display: flex; }

.settings-modal {
    background: #FFF;
    border-radius: 16px;
    width: 90%;
    max-width: 320px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    transition: background 0.3s;
}

body.dark .settings-modal { background: #2C2C2C; }

.settings-modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
    transition: color 0.3s;
}

body.dark .settings-modal-title { color: #E0E0E0; }

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.settings-row:last-child { margin-bottom: 0; }

.settings-label {
    font-size: 15px;
    color: #333;
    transition: color 0.3s;
}

body.dark .settings-label { color: #E0E0E0; }

.settings-select {
    padding: 8px 12px;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    font-size: 14px;
    background: #FFF;
    color: #333;
    outline: none;
    cursor: pointer;
    transition: all 0.3s;
}

body.dark .settings-select {
    background: #444;
    color: #E0E0E0;
    border-color: #555;
}

.theme-toggle {
    width: 50px;
    height: 28px;
    background: #CCC;
    border-radius: 14px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
}

.theme-toggle.active { background: #07C160; }

.theme-toggle-knob {
    width: 24px;
    height: 24px;
    background: #FFF;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: left 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.theme-toggle.active .theme-toggle-knob { left: 24px; }

/* ============ 管理员登录页面 ============ */
#adminLoginPage {
    display: none;
    flex-direction: column;
    height: 100%;
}

.admin-header {
    background: #F8F8F8;
    padding: 50px 20px 25px;
    text-align: center;
    transition: background 0.3s;
}

body.dark .admin-header { background: #333; }

.admin-title {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    transition: color 0.3s;
}

body.dark .admin-title { color: #E0E0E0; }

.admin-form-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 20px 60px;
}

.admin-form {
    width: 100%;
    max-width: 340px;
}

.admin-input {
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 14px;
    border: 1px solid #E0E0E0;
    border-radius: 10px;
    font-size: 16px;
    background: #fff;
    color: #333;
    outline: none;
    transition: all 0.3s;
}

body.dark .admin-input {
    background: #444;
    color: #E0E0E0;
    border-color: #555;
}

.admin-input:focus { border-color: #07C160; }

.admin-input::placeholder { color: #BBB; }

body.dark .admin-input::placeholder { color: #777; }

.btn-admin-login {
    width: 100%;
    padding: 14px;
    background: #07C160;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 17px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 12px;
}

.btn-back-join {
    width: 100%;
    padding: 12px;
    background: none;
    border: 1px solid #E0E0E0;
    border-radius: 10px;
    font-size: 15px;
    color: #666;
    cursor: pointer;
    transition: all 0.3s;
}

body.dark .btn-back-join {
    color: #AAA;
    border-color: #555;
}

/* ============ 消息列表页面 ============ */
#messageListPage {
    display: none;
    flex-direction: column;
    height: 100%;
}

.header {
    background: #F8F8F8;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #E0E0E0;
    flex-shrink: 0;
    transition: all 0.3s;
    position: relative;
}

body.dark .header {
    background: #333;
    border-bottom-color: #444;
}

.header-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    transition: color 0.3s;
}

body.dark .header-title { color: #E0E0E0; }

.header-btn {
    background: none;
    border: none;
    font-size: 15px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 5px;
    color: #333;
    transition: all 0.3s;
}

body.dark .header-btn { color: #E0E0E0; }

.header-btn:active { background: rgba(0,0,0,0.05); }

.message-list {
    flex: 1;
    overflow-y: auto;
}

.message-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #E0E0E0;
    cursor: pointer;
    transition: background 0.2s, border-color 0.3s;
}

body.dark .message-item { border-bottom-color: #444; }

.message-item:active { background: #F5F5F5; }

body.dark .message-item:active { background: #333; }

.message-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #07C160;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    font-weight: 600;
    margin-right: 15px;
    flex-shrink: 0;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.message-name {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.3s;
}

body.dark .message-name { color: #E0E0E0; }

.message-time {
    font-size: 12px;
    color: #999;
    flex-shrink: 0;
    margin-left: 10px;
    transition: color 0.3s;
}

body.dark .message-time { color: #AAA; }

.message-preview {
    font-size: 14px;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.3s;
}

body.dark .message-preview { color: #AAA; }

.message-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
    padding-left: 10px;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

.action-btn:hover { background: rgba(0,0,0,0.1); }
.action-btn.delete:hover { background: rgba(255,59,48,0.1); }

body.dark .action-btn:hover { background: rgba(255,255,255,0.1); }
body.dark .action-btn.delete:hover { background: rgba(255,59,48,0.2); }

/* ============ 房间管理页面 ============ */
#roomManagementPage {
    display: none;
    flex-direction: column;
    height: 100%;
}

.room-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.room-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: #FFFFFF;
    border: 1px solid #E0E0E0;
    border-radius: 10px;
    margin-bottom: 12px;
    transition: all 0.3s;
}

body.dark .room-item {
    background: #3A3A3A;
    border-color: #444;
}

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

.room-code {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    transition: color 0.3s;
}

body.dark .room-code { color: #E0E0E0; }

.room-name {
    font-size: 14px;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.3s;
}

body.dark .room-name { color: #AAA; }

.room-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    margin-left: 10px;
}

.room-btn {
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: white;
}

.room-btn:active { opacity: 0.8; }

.room-btn-copy { background: #07C160; }

.room-btn-delete { background: #FF3B30; }

.add-room-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #07C160;
    color: white;
    border: none;
    font-size: 32px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.add-room-btn:active { background: #06AD56; }

/* ============ 聊天页面 ============ */
#chatPage {
    display: none;
    flex-direction: column;
    height: 100%;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #F5F5F5;
    transition: background 0.3s;
}

body.dark .chat-messages { background: #1A1A1A; }

/* ============ 消息气泡 ============ */
.message-bubble {
    max-width: 70%;
    margin-bottom: 15px;
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
    color: #333;
    font-size: 15px;
    line-height: 1.5;
    transition: color 0.3s;
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.message-bubble .message-text {
    flex: 1;
    white-space: pre-wrap; /* 修复：保留换行符 */
}

.message-status {
    font-size: 11px;
    color: #999;
    white-space: nowrap;
}

.message-status.read {
    color: #07C160;
}

body.dark .message-bubble { color: #E0E0E0; }

.message-mine {
    background: var(--bg-my-message);
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

body.dark .message-mine { background: var(--bg-my-message); }

.message-theirs {
    background: var(--bg-their-message);
    margin-right: auto;
    border-bottom-left-radius: 5px;
    border: 1px solid var(--border-color);
    transition: all 0.3s;
}

body.dark .message-theirs {
    background: var(--bg-their-message);
    border-color: var(--border-color);
}

/* ============ 聊天输入区域 ============ */
.chat-input-area {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-top: 1px solid #E0E0E0;
    background: #F8F8F8;
    transition: all 0.3s;
}

body.dark .chat-input-area {
    background: #333;
    border-top-color: #444;
}

.chat-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #E0E0E0;
    border-radius: 20px;
    font-size: 16px;
    background: #fff;
    color: #333;
    outline: none;
    transition: all 0.3s;
}

body.dark .chat-input {
    background: #444;
    color: #E0E0E0;
    border-color: #555;
}

.chat-input:focus { border-color: #07C160; }

.chat-input::placeholder { color: #BBB; }

body.dark .chat-input::placeholder { color: #777; }

.input-icon-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 6px 8px;
    margin-right: 4px;
    border-radius: 6px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.input-icon-btn:hover { background: rgba(0,0,0,0.1); }
body.dark .input-icon-btn:hover { background: rgba(255,255,255,0.1); }

.chat-send-btn {
    padding: 10px 20px;
    margin-left: 10px;
    background: #07C160;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 15px;
    flex-shrink: 0;
    white-space: nowrap;
}

.chat-send-btn:active { background: #06AD56; }

/* ============ 表情面板 ============ */
.emoji-panel {
    display: none;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    max-height: 200px;
    overflow: hidden;
    transition: background 0.3s;
}

.emoji-panel.show { display: block; }
body.dark .emoji-panel { background: var(--bg-secondary); border-color: var(--border-color); }

.emoji-tabs {
    display: flex;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}
body.dark .emoji-tabs { border-color: var(--border-color); }

.emoji-tab {
    padding: 4px 10px;
    font-size: 16px;
    cursor: pointer;
    border-radius: 4px;
    white-space: nowrap;
}
.emoji-tab:hover { background: #F0F0F0; }
body.dark .emoji-tab:hover { background: #444; }
.emoji-tab.active { background: #E8F5E9; }
body.dark .emoji-tab.active { background: #1B5E20; }

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 8px;
    max-height: 140px;
    overflow-y: auto;
}

.emoji-item {
    font-size: 22px;
    padding: 4px;
    text-align: center;
    cursor: pointer;
    border-radius: 4px;
}
.emoji-item:hover { background: #F0F0F0; transform: scale(1.2); }
body.dark .emoji-item:hover { background: #444; }

/* ============ 图片预览 ============ */
.image-preview-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}
.image-preview-overlay.show { display: flex; }
.image-preview-overlay img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
}
.preview-close {
    position: absolute;
    top: 20px; right: 20px;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 24px;
    width: 40px; height: 40px;
    border-radius: 50%;
    cursor: pointer;
}
.preview-close:hover { background: rgba(255,255,255,0.3); }

/* ============ 图片消息 ============ */
.message-image {
    max-width: 200px;
    border-radius: 12px;
    cursor: pointer;
    margin-top: 4px;
}
.message-mine .message-image { border-bottom-right-radius: 4px; }
.message-theirs .message-image { border-bottom-left-radius: 4px; }

/* ============ 回复引用样式 ============ */
.reply-quote {
    background: rgba(0, 0, 0, 0.05);
    border-left: 3px solid var(--accent-color);
    padding: 6px 10px;
    margin-bottom: 6px;
    border-radius: 0 4px 4px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

body.dark .reply-quote {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}

.reply-quote .reply-sender {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

body.dark .reply-quote .reply-sender { color: var(--text-primary); }

.reply-quote .reply-content {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 回复输入区域 */
.reply-preview {
    display: none;
    background: #F8F8F8;
    border-top: 1px solid #E0E0E0;
    padding: 8px 15px;
    font-size: 13px;
    align-items: center;
    gap: 8px;
}

body.dark .reply-preview { background: #333; border-top-color: #444; }

.reply-preview.show {
    display: flex;
}

.reply-preview .reply-info {
    flex: 1;
    overflow: hidden;
}

.reply-preview .reply-sender {
    font-weight: 600;
    color: #07C160;
}

.reply-preview .reply-content {
    color: #999;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.dark .reply-preview .reply-content { color: #AAA; }

.reply-preview .cancel-reply {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    color: #999;
}

body.dark .reply-preview .cancel-reply { color: #AAA; }

/* ============ 日期分隔线 ============ */
.date-separator {
    text-align: center;
    margin: 20px 0 10px;
    position: relative;
}

.date-separator span {
    background: #F5F5F5;
    padding: 0 10px;
    font-size: 12px;
    color: #999;
    position: relative;
    z-index: 1;
}

body.dark .date-separator span { background: #1A1A1A; color: #AAA; }

.date-separator::before {
    content: '';
    position: absolute;
    left: 10%;
    right: 10%;
    top: 50%;
    height: 1px;
    background: #E0E0E0;
    z-index: 0;
}

body.dark .date-separator::before { background: #444; }

/* ============ 消息操作菜单 ============ */
.message-action-menu {
    position: fixed;
    background: #FFF;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 6px 0;
    z-index: 1000;
    min-width: 140px;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

body.dark .message-action-menu { background: #2C2C2C; }

.message-action-menu.show {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.message-action-menu::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #FFF;
}

body.dark .message-action-menu::before { border-bottom-color: #2C2C2C; }

.message-action-menu-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 0.15s;
    font-size: 14px;
    color: #333;
    gap: 10px;
}

body.dark .message-action-menu-item { color: #E0E0E0; }

.message-action-menu-item:hover { background: rgba(0, 0, 0, 0.05); }

body.dark .message-action-menu-item:hover { background: rgba(255, 255, 255, 0.1); }

.message-action-menu-item .icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

/* ============ 输入状态提示 ============ */
.typing-indicator {
    padding: 10px 20px;
    font-size: 13px;
    color: #999;
    font-style: italic;
    min-height: 20px;
}

body.dark .typing-indicator { color: #AAA; }

/* ============ 系统消息 ============ */
.system-message {
    text-align: center;
    margin: 10px 0;
    color: #999;
    font-size: 13px;
}

/* ============ 加载状态 ============ */
.loading-indicator {
    text-align: center;
    padding: 15px;
    color: #999;
    font-size: 13px;
}

.loading-indicator.hidden { display: none; }

/* ============ 图片占位符（懒加载） ============ */
.image-placeholder {
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
    border-radius: 12px;
    padding: 30px 50px;
    cursor: pointer;
    text-align: center;
    color: #666;
    font-size: 13px;
    transition: background 0.2s;
    min-width: 120px;
}
.image-placeholder:hover { background: linear-gradient(135deg, #C8E6C9 0%, #A5D6A7 100%); }
.message-mine .image-placeholder { background: linear-gradient(135deg, #DCEDC8 0%, #C5E1A5 100%); }
.message-mine .image-placeholder:hover { background: linear-gradient(135deg, #C5E1A5 0%, #AED581 100%); }
.image-placeholder::before {
    content: '📷';
    display: block;
    font-size: 24px;
    margin-bottom: 5px;
}

.no-more-messages {
    text-align: center;
    padding: 15px;
    color: #999;
    font-size: 13px;
}

.no-more-messages.hidden { display: none; }
