* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  height: 100vh;
  overflow: hidden;
}
input, textarea, button { font-family: inherit; }

/* ====== 登录页 ====== */
.auth-page {
  display: flex; justify-content: center; align-items: center;
  height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}
.auth-box {
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 40px;
  width: 400px;
  max-width: 90%;
}
.auth-header { text-align: center; margin-bottom: 30px; }
.auth-header h1 { font-size: 28px; color: #fff; }
.auth-header p { color: #8899aa; margin-top: 5px; font-size: 14px; }
.auth-tabs { display: flex; gap: 0; margin-bottom: 24px; }
.tab-btn {
  flex: 1; padding: 10px; border: none; background: transparent;
  color: #8899aa; font-size: 15px; cursor: pointer;
  border-bottom: 2px solid transparent; transition: all 0.3s;
}
.tab-btn.active { color: #4fc3f7; border-bottom-color: #4fc3f7; }
.auth-form { display: none; }
.auth-form.active { display: block; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: #aabbcc; }
.form-group input, .form-group textarea {
  width: 100%; padding: 10px 14px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; color: #fff; font-size: 14px;
  outline: none; transition: border 0.3s;
}
.form-group input:focus, .form-group textarea:focus { border-color: #4fc3f7; }
.form-group textarea { resize: vertical; }
.btn-primary {
  width: 100%; padding: 12px;
  background: linear-gradient(135deg, #4fc3f7, #29b6f6);
  border: none; border-radius: 8px; color: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: opacity 0.3s;
}
.btn-primary:hover { opacity: 0.9; }
.form-error { color: #ff6b6b; font-size: 13px; margin-top: 10px; text-align: center; min-height: 20px; }

/* ====== 聊天主界面 ====== */
.chat-page { display: flex; flex-direction: column; height: 100vh; }

/* 头部 */
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; background: rgba(255,255,255,0.05);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(10px);
}
.chat-header h2 { font-size: 18px; color: #4fc3f7; }
.header-center { flex: 1; text-align: center; }
.header-center span { font-size: 15px; color: #ccc; }
.header-right { display: flex; align-items: center; gap: 15px; }
.online-badge { font-size: 13px; color: #66bb6a; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-display { font-size: 14px; color: #e0e0e0; }
.btn-sm {
  padding: 4px 12px; background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2); border-radius: 6px;
  color: #ccc; font-size: 12px; cursor: pointer; transition: all 0.3s;
}
.btn-sm:hover { background: rgba(255,255,255,0.2); }

/* 主布局 */
.chat-container {
  display: flex; flex: 1; overflow: hidden;
}

/* 左侧边栏 */
.sidebar-left {
  width: 260px; background: rgba(255,255,255,0.03);
  border-right: 1px solid rgba(255,255,255,0.08);
  display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar-section {
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 10px;
}
.section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.section-header h3 { font-size: 13px; color: #8899aa; text-transform: uppercase; }
.room-search input, .user-search input {
  width: 100%; padding: 6px 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 6px;
  color: #e0e0e0; font-size: 13px; outline: none;
  margin-bottom: 8px;
}
.room-search input:focus, .user-search input:focus { border-color: #4fc3f7; }

.room-list, .private-list, .online-users-list {
  list-style: none; max-height: 200px; overflow-y: auto;
}
.room-list li, .private-list li {
  padding: 8px 10px; cursor: pointer; border-radius: 6px;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; transition: background 0.2s;
}
.room-list li:hover, .private-list li:hover { background: rgba(255,255,255,0.08); }
.room-list li.active { background: rgba(79,195,247,0.2); color: #4fc3f7; }
.room-badge {
  background: rgba(79,195,247,0.2); color: #4fc3f7;
  font-size: 11px; padding: 1px 6px; border-radius: 10px;
  margin-left: auto;
}
.private-list .unread {
  background: rgba(255,107,107,0.2); color: #ff6b6b;
  font-size: 11px; padding: 1px 6px; border-radius: 10px;
  margin-left: auto;
}

/* 中间聊天区 */
.chat-main {
  flex: 1; display: flex; flex-direction: column;
  position: relative;
}
.message-area {
  flex: 1; overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 8px;
}
.welcome-placeholder {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100%;
  color: #556677;
}
.welcome-placeholder h2 { font-size: 24px; margin-bottom: 10px; color: #4fc3f7; }

/* 消息气泡 */
.message { display: flex; gap: 10px; max-width: 80%; animation: fadeIn 0.2s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.message.self { align-self: flex-end; flex-direction: row-reverse; }
.message-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }
.message-body { }
.message-header { font-size: 12px; color: #8899aa; margin-bottom: 3px; }
.message.self .message-header { text-align: right; }
.message-username { color: #4fc3f7; font-weight: 600; }
.message-time { margin-left: 8px; }
.message-content {
  background: rgba(255,255,255,0.08); padding: 8px 14px;
  border-radius: 12px; font-size: 14px; line-height: 1.5;
  word-break: break-word;
}
.message.self .message-content {
  background: rgba(79,195,247,0.25); color: #e0f7fa;
}
.message-content img {
  max-width: 300px; max-height: 200px; border-radius: 8px;
  cursor: pointer; display: block;
}
.message-content .file-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: #4fc3f7; text-decoration: none; padding: 4px 10px;
  background: rgba(79,195,247,0.1); border-radius: 6px;
  font-size: 13px;
}
.system-message {
  text-align: center; color: #667788; font-size: 12px;
  padding: 5px 0;
}

/* 输入区 */
.input-area {
  padding: 10px 20px; background: rgba(255,255,255,0.03);
  border-top: 1px solid rgba(255,255,255,0.08);
}
.input-toolbar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.btn-icon {
  cursor: pointer; font-size: 18px; padding: 4px;
  transition: transform 0.2s;
}
.btn-icon:hover { transform: scale(1.2); }
.typing-indicator {
  font-size: 12px; color: #8899aa; font-style: italic;
  min-height: 18px;
}
.input-row {
  display: flex; gap: 10px; align-items: flex-end;
}
.input-row textarea {
  flex: 1; padding: 10px 14px; max-height: 80px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12); border-radius: 8px;
  color: #e0e0e0; font-size: 14px; outline: none; resize: none;
}
.input-row textarea:focus { border-color: #4fc3f7; }
.btn-send {
  padding: 10px 24px; background: #4fc3f7; border: none;
  border-radius: 8px; color: #fff; font-size: 14px;
  font-weight: 600; cursor: pointer; transition: background 0.3s;
}
.btn-send:hover { background: #29b6f6; }

/* 右侧在线列表 */
.sidebar-right {
  width: 220px; background: rgba(255,255,255,0.03);
  border-left: 1px solid rgba(255,255,255,0.08);
  padding: 15px; overflow-y: auto;
}
.online-users-list { list-style: none; }
.online-users-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px; font-size: 13px;
}
.online-users-list li:hover { background: rgba(255,255,255,0.06); }
.online-dot {
  width: 8px; height: 8px; background: #66bb6a; border-radius: 50%;
  flex-shrink: 0;
}
.user-avatar-sm { width: 28px; height: 28px; border-radius: 50%; }

/* 弹窗 */
.modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); display: flex;
  justify-content: center; align-items: center; z-index: 1000;
}
.modal-content {
  background: #1e2a3a; border-radius: 12px; padding: 24px;
  width: 420px; max-width: 90%;
  border: 1px solid rgba(255,255,255,0.1);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.modal-header h3 { color: #e0e0e0; }
.close-btn {
  font-size: 24px; cursor: pointer; color: #8899aa;
  transition: color 0.2s;
}
.close-btn:hover { color: #fff; }
.image-preview-content {
  background: transparent; border: none; text-align: center;
  width: auto; max-width: 90%;
}
.image-preview-content img {
  max-width: 100%; max-height: 80vh; border-radius: 8px;
}

/* 滚动条美化 */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* 响应式 */
@media (max-width: 768px) {
  .sidebar-left { width: 200px; }
  .sidebar-right { display: none; }
}
