/* ===== 重置与全局设置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* 主体背景 + 动态星光装饰（核心） */
body {
    background: linear-gradient(135deg, #16213E, #0F3460);
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #e0e0e0;
    overflow: hidden;
    position: relative; /* 必须有这个，伪元素才能基于body定位 */
}

/* 动态星光粒子背景（关键：确保没被其他样式覆盖） */
body::before {
    content: "";
    position: absolute;
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0;
    z-index: 1; /* 低于所有内容，只做背景装饰 */
    background: 
        radial-gradient(2px 2px at 20px 30px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 40px 70px, #ff9a9e, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 50px 160px, #fbc2eb, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 90px 40px, #a18cd1, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 130px 80px, #fecfef, rgba(0,0,0,0));
    background-repeat: repeat;
    background-size: 200px 200px;
    opacity: 0.8; /* 调高透明度，更容易看到效果 */
    animation: float 20s linear infinite;
    pointer-events: none; /* 不影响点击 */
}

/* 粒子浮动动画 */
@keyframes float {
    0% { transform: translate(0, 0); }
    50% { transform: translate(-20px, -20px); }
    100% { transform: translate(0, 0); }
}

/* 全局标题（始终在最上层，进入聊天页也不被盖住） */
.global-title {
    position: fixed;
    top: 65px; /* 你要的位置 */
    left: 0;
    right: 0;
    text-align: center;
    z-index: 10006; /* 高于登录弹窗(10005)，始终可见 */
    pointer-events: none; /* 不拦截点击 */
}

.global-title h1 {
    font-size: 36px;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    margin: 0;
    padding: 0;
}

/* ===== 登录模态框 ===== */
.modal {
    position: fixed;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000; /* 低于标题，高于背景 */
}
/* 登录/注册弹窗始终在最上层，从切换账号进入时不被聊天界面挡住 */
#authModal {
    z-index: 10005 !important;
}

.modal-content {
    background: rgba(255, 255, 255, 0.15);
    padding: 40px;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    margin-top: 20px;
    z-index: 1001; /* 模态框内容层级更高 */
}

/* ===== 统一输入框样式 ===== */
.modal-content input,
.group-actions input {
    width: 100%;
    padding: 14px 16px;
    margin: 8px 0;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    outline: none;
    color: #ffffff;
    font-size: 15px;
    transition: all 0.3s ease;
}

.modal-content input:focus,
.group-actions input:focus {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 3px rgba(161, 140, 209, 0.3);
    border-color: rgba(161, 140, 209, 0.5);
}

input::placeholder {
    color: #9ca3af;
    opacity: 0.7;
}

/* 按钮通用样式 */
.modal-content button,
#sendBtn,
#createGroup,
#joinGroup {
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.42, 1.31);
    font-size: 16px;
    box-shadow: 0 6px 15px rgba(161, 140, 209, 0.3);
}

.modal-content button:active,
#sendBtn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(161, 140, 209, 0.2);
}

.primary-btn {
    background: linear-gradient(45deg, #a18cd1, #fbc2eb);
    color: #333;
}

/* 选项卡切换 */
.tabs {
    display: flex;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: transparent;
    color: white;
    cursor: pointer;
    border: none;
    font-size: 16px;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* ===== 主聊天容器 ===== */
#chatContainer {
    margin: 8vh auto 0 !important; /* 下移8vh */
    transform: scale(0.95) !important; /* 缩放95% */
    transform-origin: center top !important; /* 缩放中心 */
    display: none;
    flex-direction: column;
    width: 95%;
    max-width: 1300px;
    height: 90vh;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.8s ease-out forwards;
    margin-top: 20px;
    z-index: 10000; /* 高于全局标题(9999)，避免被挡 */
}

@keyframes slideIn {
    to { transform: translateY(0); opacity: 1; }
}

header.chat-header {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px 20px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    position: relative;
    z-index: 9999; /* 保证 header 内退出按钮在最上层可点 */
}

/* ===== 布局 ===== */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 左侧边栏 */
.sidebar {
    width: 280px;
    background: rgba(20, 30, 50, 0.6);
    padding: 20px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    overflow-y: auto;
}

.sidebar h3 {
    margin-bottom: 20px;
    color: #a18cd1;
    font-weight: 600;
    text-align: center;
}

/* 群组列表项 */
#groupList li {
    padding: 14px 15px;
    margin: 5px 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    border-left: 3px solid transparent;
}

#groupList li:hover {
    background: rgba(161, 140, 209, 0.2);
    border-left-color: #a18cd1;
    transform: translateX(5px);
}

#groupList li.active {
    background: rgba(161, 140, 209, 0.3);
    border-left-color: #a18cd1;
    font-weight: bold;
}

/* ===== 聊天区域 ===== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#chatBox {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* 保证群组列表、聊天区可接收右键/长按 */
#groupList,
#chatBox {
    pointer-events: auto;
}
#groupList li {
    pointer-events: auto;
}

/* 强制让创建群组按钮可点击，避免被遮挡 */
#createGroup {
    pointer-events: auto !important;
    z-index: 999 !important;
}

/* 消息气泡 */
.message {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: 18px;
    line-height: 1.5;
    position: relative;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.self {
    align-self: flex-end;
    background: linear-gradient(45deg, #6a11cb, #2575fc);
    color: white;
    border-bottom-right-radius: 5px;
}

.message.other {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    color: #e0e0e0;
    border-bottom-left-radius: 5px;
}

/* 打字机光标效果 */
.typing-animation {
    border-right: 2px solid #4ade80;
    animation: blink-caret 0.75s step-end infinite;
}

@keyframes blink-caret {
    from, to { border-color: transparent }
    50% { border-color: #4ade80 }
}

.message small {
    font-size: 11px;
    opacity: 0.7;
    margin-left: 10px;
}

/* ===== 输入区域 & 自定义控件 ===== */
#emojiSelect {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px 0 0 14px;
    padding: 14px 10px 14px 16px;
    color: white;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.3s ease;
    margin-right: -1px;
}

#emojiSelect:hover {
    background: rgba(255, 255, 255, 0.12);
}

#emojiSelect:focus {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 3px rgba(161, 140, 209, 0.3);
    border-color: rgba(161, 140, 209, 0.5);
}

#messageInput {
    flex: 1;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    outline: none;
    color: white;
    font-size: 15px;
}

#messageInput:focus {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 3px rgba(161, 140, 209, 0.3);
    border-color: rgba(161, 140, 209, 0.5);
}

#sendBtn {
    padding: 0 25px;
    border-radius: 0 14px 14px 0;
    background: linear-gradient(45deg, #ff8177, #ff867a);
    color: #333;
    font-weight: bold;
    box-shadow: 0 6px 15px rgba(255, 129, 119, 0.3);
}

/* ===== 退出按钮 ===== */
#logoutBtn {
    background: rgba(255, 255, 255, 0.05);
    color: #ef4444;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 14px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

#logoutBtn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

header .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 1. 修复退出按钮可点+动效（保留你原有样式，只加优先级） */
#logoutBtn {
    position: relative !important;
    z-index: 9999 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    /* 下面保留你自己的样式，我只加 !important 确保生效 */
    padding:8px 14px !important;
    background: rgba(255,255,255,0.05) !important;
    color:#ef4444 !important;
    border:1px solid rgba(255,255,255,0.2) !important;
    border-radius:12px !important;
    transition: all 0.2s ease !important;
}
#logoutBtn:hover {
    background: rgba(239,68,68,0.2) !important;
    transform: scale(1.05) !important;
    border-color: #ef4444 !important;
}

/* 终极强制样式：覆盖所有屎山代码的冲突，保证可点 */
#logoutBtn {
    position: relative !important;
    z-index: 9999 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    opacity: 1 !important;
    filter: none !important;
    visibility: visible !important;
}
header.chat-header .user-info {
    position: relative;
    z-index: 9999;
    pointer-events: auto;
}

#logoutBtn:hover {
    background: rgba(239,68,68,0.2) !important;
    transform: scale(1.05) !important;
    border-color: #ef4444 !important;
}

#chatContainer {
    margin-top: 8vh !important;
    transform: scale(0.95) !important;
    transform-origin: center top !important;
}

/* ===== 设置界面（修改个人信息） ===== */
.settings-modal {
    z-index: 10001 !important;
    background: rgba(0, 0, 0, 0.25);
}
.settings-content {
    max-width: 380px;
}
.settings-title {
    margin: 0 0 24px 0;
    font-size: 22px;
    color: #fff;
    text-align: center;
}
.settings-section {
    margin-bottom: 18px;
}
.settings-section label {
    display: block;
    margin-bottom: 6px;
    color: rgba(255,255,255,0.9);
    font-size: 14px;
}
.settings-value {
    padding: 10px 14px;
    background: rgba(255,255,255,0.08);
    border-radius: 10px;
    color: #fff;
    font-size: 15px;
}
.settings-input {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 10px;
    color: #fff;
    font-size: 15px;
    box-sizing: border-box;
}
.settings-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}
.settings-actions .btn-logout {
    width: 100%;
}
.settings-actions .primary-btn {
    width: 100%;
}

/* 侧栏「我的群组」底部：修改个人信息（与创建/加入群组同风格） */
.sidebar .sidebar-btn-settings {
    width: 100%;
    margin-top: 16px;
    padding: 12px 20px;
    background: linear-gradient(45deg, #a18cd1, #fbc2eb);
    color: #333;
    border: none;
    border-radius: 12px;
    font-weight: bold;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 6px 15px rgba(161, 140, 209, 0.3);
}
.sidebar .sidebar-btn-settings:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(161, 140, 209, 0.4);
}
.sidebar .sidebar-btn-settings:active {
    transform: scale(0.98);
}

/* 有 cookie 时登录框提示 */
.auth-cookie-hint {
    color: #fef08a;
    font-size: 14px;
    margin: 0 0 12px 0;
    text-align: center;
}

/* 账号选择界面 */
.account-select-modal {
    z-index: 10003 !important;
}
.account-select-content {
    max-width: 360px;
}
.account-select-title {
    margin: 0 0 12px 0;
    font-size: 20px;
    color: #fff;
    text-align: center;
}
.account-select-current {
    margin: 0 0 16px 0;
    color: rgba(255,255,255,0.9);
    font-size: 14px;
}
.account-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 240px;
    overflow-y: auto;
    margin-bottom: 20px;
}
.account-list .account-btn {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 12px;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}
.account-list .account-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.01);
}
.account-list .account-btn.current {
    background: rgba(161, 140, 209, 0.4);
    border-color: #a18cd1;
    font-weight: bold;
}
.account-select-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.account-select-actions .primary-btn {
    width: 100%;
}

/* 正在进入中... 遮罩 */
.entering-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10004;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    color: #fff;
    font-size: 18px;
    font-weight: 500;
}

/* 右键/长按菜单 */
.context-menu {
    position: fixed;
    z-index: 10010;
    min-width: 140px;
    padding: 6px 0;
    background: rgba(30, 30, 40, 0.98);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.context-menu-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    color: #e0e0e0;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}
.context-menu-item:hover {
    background: rgba(161, 140, 209, 0.35);
}
.context-menu-item:disabled {
    color: #666;
    cursor: not-allowed;
}
.context-menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.25);
}
