/* ========== 聊天室 暗色主题 ========== */

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #0f1117;
  color: #d1d5db;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
input, textarea, select { font-family: inherit; }

/* ========== Toast ========== */
.toast-box { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 18px; border-radius: 8px; font-size: 14px; color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4); animation: toastIn 0.3s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast-ok { background: #1e3a5f; }
.toast-err { background: #991b1b; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }

/* ========== 登录页 ========== */
.auth-overlay {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: #0f1117;
  background-image: radial-gradient(ellipse at 30% 20%, rgba(15,52,96,0.4) 0%, transparent 60%),
                    radial-gradient(ellipse at 70% 80%, rgba(88,28,135,0.2) 0%, transparent 60%);
  padding: 16px;
}
.auth-card {
  background: #1a1d28; border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px; padding: 40px 32px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.auth-card h1 { text-align: center; font-size: 1.75rem; color: #fff; margin-bottom: 4px; }
.auth-subtitle { text-align: center; color: #6b7280; font-size: 14px; margin-bottom: 28px; }
.auth-tabs { display: flex; gap: 0; margin-bottom: 24px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.auth-tab {
  flex: 1; padding: 10px 0; text-align: center; font-size: 14px; color: #6b7280;
  border-bottom: 2px solid transparent; transition: all 0.2s;
}
.auth-tab:hover { color: #d1d5db; }
.auth-tab.active { color: #60a5fa; border-bottom-color: #60a5fa; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13px; color: #9ca3af; }
.captcha-ref { color: #60a5fa; cursor: pointer; float: right; }
.captcha-ref:hover { color: #93c5fd; }
.captcha-q {
  background: #0f1724; border: 1px solid #374151; border-radius: 6px;
  padding: 10px; text-align: center; font-size: 18px; font-weight: 700;
  color: #fff; font-family: monospace; letter-spacing: 2px; margin-bottom: 4px;
}
.field input {
  padding: 10px 12px; background: #0f1724; border: 1px solid #374151;
  border-radius: 6px; color: #fff; font-size: 14px; outline: none;
  transition: border-color 0.2s;
}
.field input:focus { border-color: #60a5fa; }
.field input::placeholder { color: #4b5563; }
.btn-primary {
  padding: 10px; background: #1e40af; color: #fff; border-radius: 6px;
  font-size: 15px; font-weight: 600; transition: background 0.2s;
}
.btn-primary:hover { background: #1e3a8a; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========== 主界面布局 ========== */
.app { flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  height: 52px; background: #1a1d28; border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0; z-index: 10;
}
.topbar-inner {
  max-width: 1400px; margin: 0 auto; padding: 0 12px; height: 100%;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.sidebar-toggle { color: #9ca3af; padding: 4px; display: flex; }
.sidebar-toggle:hover { color: #fff; }
.topbar-title { font-size: 1rem; color: #fff; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.online-badge { font-size: 12px; color: #34d399; background: rgba(52,211,153,0.1); padding: 3px 10px; border-radius: 12px; }
.user-badge { font-size: 13px; color: #d1d5db; }
.btn-logout { color: #6b7280; padding: 4px; display: flex; transition: color 0.2s; }
.btn-logout:hover { color: #f87171; }
.btn-icon { color: #6b7280; padding: 4px; border-radius: 4px; display: flex; transition: all 0.2s; }
.btn-icon:hover { color: #fff; background: rgba(255,255,255,0.08); }

.app-body { flex: 1; display: flex; max-width: 1400px; margin: 0 auto; width: 100%; }

/* ========== 侧边栏 ========== */
.sidebar {
  width: 260px; background: #161922; border-right: 1px solid rgba(255,255,255,0.06);
  display: flex; flex-direction: column; flex-shrink: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.sidebar.hidden { transform: translateX(-100%); position: absolute; opacity: 0; pointer-events: none; }
.sidebar-header { padding: 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,0.06); }
.sidebar-header h2 { font-size: 14px; color: #9ca3af; text-transform: uppercase; letter-spacing: 1px; }
.room-list { flex: 1; overflow-y: auto; padding: 8px; }
.room-item {
  padding: 12px 14px; border-radius: 8px; cursor: pointer;
  transition: background 0.15s; margin-bottom: 2px;
}
.room-item:hover { background: rgba(255,255,255,0.04); }
.room-item.active { background: rgba(96,165,250,0.12); }
.room-item-name { font-size: 14px; font-weight: 600; color: #e5e7eb; margin-bottom: 2px; display: flex; align-items: center; gap: 6px; }
.room-item.active .room-item-name { color: #60a5fa; }
.room-item-desc { font-size: 12px; color: #6b7280; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-item-meta { font-size: 11px; color: #4b5563; margin-top: 4px; display: flex; gap: 8px; }
.room-item .room-del-btn { display: none; margin-left: auto; color: #6b7280; font-size: 12px; padding: 2px 6px; border-radius: 3px; }
.room-item .room-del-btn:hover { color: #f87171; background: rgba(248,113,113,0.1); }
.room-item:hover .room-del-btn { display: inline-block; }

/* 在线用户 */
.online-section { border-top: 1px solid rgba(255,255,255,0.06); padding: 12px 16px; max-height: 200px; overflow-y: auto; }
.online-section h3 { font-size: 12px; color: #6b7280; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.online-list { display: flex; flex-wrap: wrap; gap: 4px; }
.online-user {
  font-size: 12px; color: #34d399; background: rgba(52,211,153,0.08);
  padding: 2px 8px; border-radius: 10px; display: flex; align-items: center; gap: 4px;
}
.online-dot { width: 6px; height: 6px; border-radius: 50%; background: #34d399; flex-shrink: 0; }
.online-empty { font-size: 12px; color: #4b5563; }

/* ========== 聊天区 ========== */
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header {
  padding: 14px 20px; border-bottom: 1px solid rgba(255,255,255,0.06);
  background: #1a1d28; flex-shrink: 0;
}
.chat-header h2 { font-size: 16px; color: #fff; font-weight: 600; }
.chat-header p { font-size: 13px; color: #6b7280; margin-top: 2px; }

.messages {
  flex: 1; overflow-y: auto; padding: 16px 20px; display: flex;
  flex-direction: column; gap: 6px; background: #0f1117;
}
.welcome-hint {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: #4b5563; font-size: 15px;
}
.msg { display: flex; gap: 10px; max-width: 80%; animation: msgIn 0.2s ease; }
.msg-self { align-self: flex-end; flex-direction: row-reverse; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
}
.msg-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.msg-self .msg-body { align-items: flex-end; }
.msg-header { display: flex; align-items: center; gap: 8px; }
.msg-name { font-size: 12px; font-weight: 600; }
.msg-self .msg-name { order: 1; }
.msg-time { font-size: 11px; color: #4b5563; }
.msg-bubble {
  padding: 8px 14px; border-radius: 12px; font-size: 14px;
  line-height: 1.5; word-break: break-word; white-space: pre-wrap;
  position: relative;
}
.msg-other .msg-bubble { background: #1e2233; border-bottom-left-radius: 4px; }
.msg-self .msg-bubble { background: #1e3a5f; border-bottom-right-radius: 4px; }
.msg-admin .msg-name { color: #fbbf24; }
.msg-bubble .msg-del {
  display: none; position: absolute; top: 4px; right: 4px;
  color: #6b7280; font-size: 11px; padding: 1px 6px; border-radius: 3px;
  background: rgba(0,0,0,0.3); cursor: pointer;
}
.msg-bubble:hover .msg-del { display: inline-block; }
.msg-bubble .msg-del:hover { color: #f87171; }

.date-divider {
  text-align: center; font-size: 12px; color: #4b5563; padding: 8px 0;
  position: relative; align-self: center;
}
.date-divider span { background: #0f1117; padding: 0 12px; position: relative; z-index: 1; }
.date-divider::before {
  content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px;
  background: rgba(255,255,255,0.04);
}

/* ========== 输入栏 ========== */
.input-bar {
  padding: 12px 20px 14px; background: #1a1d28;
  border-top: 1px solid rgba(255,255,255,0.06); flex-shrink: 0;
}
.input-bar-inner { display: flex; gap: 10px; align-items: center; }
.input-bar input {
  flex: 1; padding: 10px 14px; background: #0f1724; border: 1px solid #374151;
  border-radius: 8px; color: #fff; font-size: 14px; outline: none;
  transition: border-color 0.2s;
}
.input-bar input:focus { border-color: #60a5fa; }
.input-bar input::placeholder { color: #4b5563; }
.btn-send {
  width: 40px; height: 40px; border-radius: 8px; background: #1e40af;
  color: #fff; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s; flex-shrink: 0;
}
.btn-send:hover { background: #1e3a8a; }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }
.input-hint { text-align: right; font-size: 11px; color: #374151; margin-top: 6px; }

/* ========== 弹窗 ========== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #1a1d28; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; padding: 28px; width: 90%; max-width: 420px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.modal h2 { text-align: center; font-size: 1.125rem; color: #fff; margin-bottom: 20px; }
.modal p { color: #9ca3af; font-size: 14px; margin-bottom: 20px; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn-cancel { padding: 8px 18px; border: 1px solid #374151; color: #d1d5db; border-radius: 6px; font-size: 14px; transition: all 0.2s; }
.btn-cancel:hover { color: #fff; border-color: #6b7280; }
.btn-danger { padding: 8px 18px; background: #991b1b; color: #fff; border-radius: 6px; font-size: 14px; transition: background 0.2s; }
.btn-danger:hover { background: #7f1d1d; }

/* ========== 响应式 ========== */
@media (max-width: 640px) {
  .sidebar { position: fixed; left: 0; top: 52px; bottom: 0; z-index: 20; width: 280px; transform: translateX(-100%); opacity: 0; pointer-events: none; }
  .sidebar.show { transform: translateX(0); opacity: 1; pointer-events: auto; }
  .sidebar-toggle { display: flex !important; }
  .msg { max-width: 90%; }
}
@media (min-width: 641px) {
  .sidebar-toggle { display: none; }
}

/* 滚动条 */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #374151; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4b5563; }
