/* ========================================
   Telegram 风格聊天平台 - 全局样式
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 15px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --sidebar-width: 320px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;  /* 回退：不支持 dvh 的浏览器使用 vh */
    min-height: 100dvh;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ============ 通用组件 ============ */

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    display: -webkit-inline-flex;
    display: inline-flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    /* iOS 修复：确保在 -webkit-overflow-scrolling 容器内可点击 */
    position: relative;
    z-index: 1;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-text { background: none; color: var(--primary); padding: 8px 16px; }
.btn-text:hover { background: var(--primary-light); }

.btn-small { padding: 6px 14px; font-size: 13px; }
.btn-full { width: 100%; }
.btn-disabled { opacity: 0.5; cursor: not-allowed; background: var(--border); color: var(--text-secondary); }

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background: none;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    color: var(--text-secondary);
}

.icon-btn svg { display: block; }

.icon-btn:hover { background: var(--border); }

.back-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--primary);
    padding: 8px;
    border-radius: 8px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.back-btn:hover { background: var(--primary-light); }

input[type="text"],
input[type="tel"],
input[type="password"] {
    padding: 10px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    background: var(--card-bg);
    color: var(--text);
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
input:disabled, input.disabled { background: var(--bg); color: var(--text-secondary); }

.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* 密码输入框包裹器 */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 6px;
    background: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
}

.password-toggle:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.loading { text-align: center; padding: 20px; color: var(--text-muted); }
.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }

/* ============ 头像 ============ */

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--primary);
}

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

.avatar-small { width: 32px; height: 32px; font-size: 13px; }
.avatar-large { width: 80px; height: 80px; font-size: 32px; }
.avatar-room { background: #0891b2; }

/* 群组默认头像：使用明亮渐变底色 + 白色 SVG 图标，与普通用户区分 */
.avatar.avatar-group {
    background: linear-gradient(135deg, #38bdf8, #0ea5e9) !important;
}

.avatar.avatar-group .group-avatar-icon {
    width: 18px;
    height: 18px;
    display: block;
    opacity: 0.95;
}

.avatar.avatar-group.avatar-small .group-avatar-icon {
    width: 16px;
    height: 16px;
}

.avatar.avatar-group.avatar-large .group-avatar-icon {
    width: 36px;
    height: 36px;
}

/* ============ Toast 通知 ============ */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: white;
    animation: slideIn 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.toast-info { background: var(--primary); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }

.toast-hide { opacity: 0; transform: translateX(100%); transition: all 0.3s; }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

/* ============ 登录页面 ============ */

.login-container {
    min-height: 100vh;  /* 回退：不支持 dvh 的浏览器使用 vh */
    min-height: 100dvh;  /* 动态视口高度，适配移动端键盘 */
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: flex-start;
    justify-content: flex-start;  /* 改为顶部对齐，允许滚动 */
    padding: 20px;
    padding-top: 10vh;  /* 顶部留白 */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow-y: auto;  /* 允许滚动，防止键盘遮挡 */
    -webkit-overflow-scrolling: touch;
}

.login-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 20vh;  /* 底部留白，确保键盘弹出时内容可滚动到可见 */
    -webkit-overflow-scrolling: touch;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    font-size: 48px;
    margin-bottom: 16px;
}

.login-header h1 {
    font-size: 24px;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-step { margin-bottom: 16px; }

.phone-input-wrapper {
    display: flex;
    align-items: center;
    border: 2px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.phone-input-wrapper:focus-within { border-color: var(--primary); }

.phone-prefix {
    padding: 10px 12px;
    background: var(--bg);
    font-weight: 600;
    color: var(--text-secondary);
    border-right: 1px solid var(--border);
}

.phone-input-wrapper input {
    border: none;
    flex: 1;
}

.phone-input-wrapper input:focus { border: none; }

.error-msg {
    color: var(--danger);
    font-size: 13px;
    text-align: center;
    padding: 8px;
    background: #fef2f2;
    border-radius: 8px;
    margin-top: 12px;
}

/* 登录页邀请提示已迁至 login.html 内联样式，此处不再保留 */

.login-footer {
    margin-top: 16px;
    text-align: center;
    font-size: 13px;
}
.login-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;  /* iOS WebKit 必需：无 cursor:pointer 的元素不触发 click */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.login-footer a:hover {
    text-decoration: underline;
}

/* ============ 主界面布局 ============ */

.app-container {
    display: -webkit-flex;
    display: flex;
    height: 100vh;  /* 回退 */
    height: 100dvh; /* 动态视口高度，适配移动端浏览器 UI */
    overflow: hidden;
}

/* ============ 侧边栏 ============ */

.sidebar {
    width: var(--sidebar-width);
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.2s;
    flex: 1;
    min-width: 0;
}

.user-info:hover { background: var(--bg); }

.user-name {
    font-weight: 600;
    font-size: 15px;
}

/* 用户名 + 积分徽章组合 */
.user-name-points {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.coin-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px 4px 6px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    color: #92400e;
    font-weight: 700;
    align-self: flex-start;
    min-height: 28px;
}

.coin-badge:hover {
    background: linear-gradient(135deg, #fde68a, #fcd34d);
    transform: scale(1.05);
}

.coin-badge-icon {
    position: relative;
    display: flex;
    align-items: center;
    line-height: 0;
}

.coin-badge-value {
    font-weight: 700;
    font-size: 13px;
    line-height: 1;
}

.sidebar-actions {
    display: flex;
    gap: 4px;
}

.search-box {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.search-box input {
    background: var(--bg);
    border: none;
    padding: 10px 36px 10px 16px;
    border-radius: 20px;
    font-size: 14px;
    width: 100%;
}

.search-box input:focus { background: var(--border); }

/* 搜索清除按钮 */
.search-clear-btn {
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: var(--text-muted);
    color: white;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: background 0.15s;
}

.search-clear-btn:hover { background: var(--text-secondary); }
.search-clear-btn.hidden { display: none !important; }

/* ============ 聊天列表 ============ */

.chat-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0; /* 允许 flex 收缩，为搜索结果腾出空间 */
}

/* 侧边栏内的搜索结果容器 */
#chatSearchResults {
    flex-shrink: 0;
    max-height: 50%;
    overflow-y: auto;
    border-top: 1px solid var(--border);
}

/* 左滑删除容器 */
.chat-item-wrapper {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}

.chat-item-delete {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 80px;
    background: var(--danger);
    color: white;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: transform 0.3s ease, background 0.15s;
    background: var(--card-bg);
    position: relative;
    z-index: 1;
}

.chat-item:hover { background: var(--bg); }
.chat-item.active { background: var(--primary-light); }
.chat-item.swiping { transition: none; }

.chat-item-avatar {
    position: relative;
    flex-shrink: 0;
}

/* 在线状态指示点（绿点=在线，灰点=离线） */
.status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border: 2px solid var(--card-bg);
    border-radius: 50%;
}

.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--text-muted); }

.chat-item-info {
    flex: 1;
    min-width: 0;
    position: relative;
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.chat-item-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-time {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.chat-item-last-msg {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 未读消息数量徽章 */
.unread-badge {
    min-width: 18px;
    height: 18px;
    background: var(--danger);
    color: white;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    flex-shrink: 0;
    line-height: 1;
}

.room-tag {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    margin-right: 4px;
    font-weight: 600;
}

/* ============ 编辑模式 & 批量操作 ============ */

/* 编辑模式按钮激活态 */
#editBtn.active {
    background: var(--primary-light);
    color: var(--primary);
}

/* 编辑模式下聊天项左侧显示复选框 */
.chat-item-checkbox {
    display: none;
    width: 20px;
    height: 20px;
    margin-right: 8px;
    flex-shrink: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

/* 编辑模式下显示复选框 */
.edit-mode .chat-item-checkbox {
    display: block;
}

/* 编辑模式下禁用左滑删除 */
.edit-mode .chat-item-wrapper {
    pointer-events: none;
}

.edit-mode .chat-item {
    pointer-events: auto;
}

/* 编辑模式下点击项高亮选中 */
.chat-item.selected {
    background: var(--primary-light);
}

/* 批量操作栏 */
.batch-action-bar {
    padding: 12px 16px;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.batch-select-all {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    flex: 1;
    user-select: none;
}

.batch-select-all input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ============ 搜索分区标题 ============ */

.search-section-header {
    padding: 8px 20px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

/* ============ 面板 ============ */

.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.panel-header h3 { font-size: 18px; }

.form-content {
    padding: 24px;
}

.search-results {
    flex: 1;
    overflow-y: auto;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
}

.search-result-item:hover { background: var(--bg); }

.result-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.result-name { font-weight: 600; font-size: 14px; }
.result-hint { font-size: 12px; color: var(--text-muted); }

/* ============ 聊天详情 ============ */

.info-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.info-section {
    margin-bottom: 24px;
}

.info-section h4 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.member-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.member-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
}

.member-item:hover { background: var(--bg); }

.user-profile-info {
    text-align: center;
    padding: 20px;
}

.user-profile-info h3 { margin-top: 12px; font-size: 20px; }
.user-profile-info .bio { color: var(--text-secondary); margin-top: 8px; }

.invite-section {
    background: var(--bg);
    padding: 16px;
    border-radius: 12px;
}

/* ============ 个人资料页 ============ */

.profile-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    overflow-y: auto;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.profile-header h2 { font-size: 20px; }

.profile-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.profile-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.profile-form { margin-bottom: 16px; }

.profile-actions { margin-top: 8px; }

.profile-display-field {
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    border-radius: 8px;
}

/* ============ 邀请好友弹窗 ============ */

.invite-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

/* 用 ::before 伪元素代替 overlay div，彻底避免拦截子元素点击事件 */
.invite-modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 0;
    pointer-events: none;
}

.invite-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.invite-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.invite-modal-box {
    position: relative;
    background: var(--card-bg);
    border-radius: 20px;
    padding: 28px;
    width: 90%;
    max-width: 380px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: modalEnter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1;
}

@keyframes modalEnter {
    from { transform: scale(0.92) translateY(12px); opacity: 0; }
    to   { transform: scale(1) translateY(0);    opacity: 1; }
}

.invite-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.invite-modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.invite-modal-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.invite-link-box {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.invite-link-box input {
    flex: 1;
    font-size: 12px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    outline: none;
}

.invite-link-box input:focus {
    border-color: var(--primary);
}

.invite-qr-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

/* 系统分享按钮区域 */
.native-share-section {
    margin-bottom: 16px;
}

.native-share-section.hidden {
    display: none !important;
}

.invite-qr-wrapper {
    background: white;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
}

.invite-qr-wrapper img {
    width: 180px;
    height: 180px;
    display: block;
}

/* 登录页邀请提示样式由 login.html 内联样式提供 */

/* ============ 登录页 Tab 切换 ============ */

.tab-switch {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border);
}

.tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab:hover {
    color: var(--primary);
}

/* ============ 后台管理页 ============ */

.admin-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

.admin-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.admin-header h2 { font-size: 20px; flex: 1; }

.admin-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logout-btn {
    padding: 5px 14px;
    border: 1px solid #ef4444;
    background: transparent;
    color: #ef4444;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.logout-btn:hover {
    background: #ef4444;
    color: white;
}

.admin-badge {
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.admin-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.admin-stats {
    display: flex;
    gap: 24px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.admin-search {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

.admin-search input {
    background: var(--bg);
    border: none;
    border-radius: 8px;
}

.admin-table-wrapper {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.admin-table td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.admin-table tr:hover {
    background: var(--bg);
}

.role-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: var(--bg);
    color: var(--text-secondary);
}

.role-badge.admin {
    background: var(--primary-light);
    color: var(--primary);
}

/* ============ 确认弹窗 ============ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-box {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 320px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.2s;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.modal-message {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 20px;
    word-break: break-word;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-actions .btn {
    flex: 1;
    max-width: 120px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.modal-btn-cancel {
    background: var(--bg);
    color: var(--text-secondary);
}

.modal-btn-cancel:hover {
    background: var(--border);
}

/* ============ 响应式 ============ */

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        z-index: 100;
        height: 100vh;  /* 回退 */
        height: 100dvh;
        background: var(--card-bg);
        /* 安全区域适配 */
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }

    .sidebar.hidden { display: none !important; }

    .main-content {
        width: 100%;
    }
    
    /* 侧边栏头部安全区域 */
    .sidebar-header {
        padding-top: calc(16px + env(safe-area-inset-top, 0px));
    }
    
    /* 批量操作栏安全区域 */
    .batch-action-bar {
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .message-wrapper {
        max-width: 85%;
    }

    .chat-header .back-btn {
        display: inline-flex;
    }
    
    /* 移动端面板全宽显示 */
    .panel {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 50;
    }
    
    /* 移动端输入区域优化 + 安全区域适配 */
    .chat-input-wrapper {
        /* 安全区域适配 */
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    
    .input-area {
        padding: 8px 12px;
        gap: 6px;
    }
    
    .input-area input {
        padding: 8px 14px;
        font-size: 16px; /* 防止 iOS 自动缩放 */
    }
    
    .attach-menu {
        padding: 16px 16px;
        gap: 10px;
    }
    
    .attach-item {
        padding: 10px 12px;
        min-width: 60px;
    }
    
    .attach-icon { font-size: 24px; }
    .attach-label { font-size: 11px; }
    
    .voice-panel {
        padding: 10px 12px;
        gap: 8px;
    }
    
    .voice-record-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    /* 移动端聊天头部安全区域 */
    .chat-header {
        padding-top: calc(12px + env(safe-area-inset-top, 0px));
    }
    
    /* 移动端消息列表安全区域 */
    .message-list {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    
    /* 登录卡片移动端适配 */
    .login-card {
        padding: 24px;
    }
    
    .login-logo {
        font-size: 36px;
    }
    
    .login-header h1 {
        font-size: 20px;
    }
}

@media (min-width: 769px) {
    .chat-header .back-btn {
        display: none;
    }
}


/* ============ 通知小红点 ============ */

.notification-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    border: 1.5px solid var(--card-bg);
}

/* 积分规则区域已移至 points.css */

/* ============ 系统通知弹窗内容 ============ */

.notification-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.notification-item.unread {
    background: var(--primary-light);
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.notification-body {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.notification-content {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    word-break: break-all;
}

.notification-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============ 备注样式 ============ */

.remark-badge {
    display: inline-block;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
    font-weight: normal;
}

.chat-item-name-row {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.chat-item-name-row .remark-badge {
    flex-shrink: 0;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 邀请关系 & 备注编辑样式已移至 profile.css */

/* ============ 管理后台入口按钮 ============ */

.admin-entry-btn {
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    position: relative;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.admin-entry-btn:hover {
    background: var(--primary-light);
}

/* 管理后台待审核小红点 */
.admin-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    border: 1.5px solid white;
    box-shadow: 0 0 0 1px #ef4444;
    animation: admin-dot-pulse 1.5s ease-in-out infinite;
}

@keyframes admin-dot-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

