/* ===== 小乐QQ 样式 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: linear-gradient(135deg, #0b1026 0%, #15204a 50%, #1e2f66 100%);
  color: #e2e8f0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: rgba(10, 15, 40, 0.9);
  border-bottom: 1px solid rgba(99, 102, 241, 0.35);
  position: sticky;
  top: 0;
  z-index: 20;
}
.nav-brand { font-size: 20px; font-weight: 700; color: #fff; text-decoration: none; letter-spacing: 1px; }
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-user { color: #a5b4fc; font-weight: 600; }
.nav-btn {
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(129, 140, 248, 0.5);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: all .2s;
}
.nav-btn:hover { background: rgba(99, 102, 241, 0.4); color: #fff; }

/* ===== 主聊天区 ===== */
.chat-wrap {
  flex: 1;
  display: flex;
  margin: 18px auto;
  width: min(1100px, 96vw);
  height: calc(100vh - 130px);
  min-height: 420px;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(17, 24, 54, 0.95);
  border: 1px solid rgba(99, 102, 241, 0.3);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

/* 左侧栏 */
.sidebar {
  width: 290px;
  min-width: 240px;
  border-right: 1px solid rgba(99, 102, 241, 0.25);
  display: flex;
  flex-direction: column;
  background: rgba(13, 19, 45, 0.9);
}
.add-box { padding: 14px; border-bottom: 1px solid rgba(99, 102, 241, 0.2); }
.add-box input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(129, 140, 248, 0.4);
  background: rgba(30, 41, 82, 0.8);
  color: #e2e8f0;
  font-size: 14px;
  outline: none;
}
.add-box input:focus { border-color: #818cf8; }
.add-btn {
  margin-top: 8px;
  width: 100%;
  padding: 8px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none;
  color: #fff;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}
.add-tip { margin-top: 8px; font-size: 13px; color: #c7d2fe; min-height: 18px; line-height: 1.5; }
.add-tip a { color: #fbbf24; }

.friend-head {
  padding: 10px 16px;
  font-size: 13px;
  color: #94a3b8;
  border-bottom: 1px solid rgba(99, 102, 241, 0.15);
}
.friend-list { list-style: none; flex: 1; overflow-y: auto; padding: 6px; }
.friend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  transition: background .15s;
}
.friend-item:hover { background: rgba(99, 102, 241, 0.15); }
.friend-item.active { background: rgba(99, 102, 241, 0.3); }
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #ec4899);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
}
.friend-info { flex: 1; min-width: 0; }
.friend-name { font-weight: 600; font-size: 14px; }
.friend-msg {
  font-size: 12px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.unread {
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  padding: 0 5px;
  position: absolute;
  right: 8px;
  top: 8px;
}
.friend-empty { padding: 20px; color: #64748b; font-size: 13px; text-align: center; list-style: none; }

/* 右侧聊天区 */
.chat-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-title {
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  border-bottom: 1px solid rgba(99, 102, 241, 0.2);
  color: #e0e7ff;
}
.chat-box {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(10, 15, 38, 0.6);
}
.chat-empty {
  margin: auto;
  color: #64748b;
  font-size: 14px;
}
.msg-row { display: flex; }
.msg-row.mine { justify-content: flex-end; }
.msg-row.theirs { justify-content: flex-start; }
.bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}
.msg-row.mine .bubble {
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-row.theirs .bubble {
  background: rgba(51, 65, 112, 0.85);
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
}

.chat-input-row {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid rgba(99, 102, 241, 0.2);
  background: rgba(13, 19, 45, 0.9);
}
.chat-input-row textarea {
  flex: 1;
  resize: none;
  height: 64px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(129, 140, 248, 0.4);
  background: rgba(30, 41, 82, 0.8);
  color: #e2e8f0;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.chat-input-row textarea:focus { border-color: #818cf8; }
.chat-input-row textarea:disabled { opacity: .5; }
.send-btn {
  width: 84px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.send-btn:hover { filter: brightness(1.15); }

.foot { text-align: center; padding: 14px; color: #64748b; font-size: 12px; }

/* ===== 登录注册弹窗 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.modal {
  width: min(400px, 92vw);
  background: linear-gradient(160deg, #1b2552, #101a3a);
  border: 1px solid rgba(129, 140, 248, 0.5);
  border-radius: 18px;
  padding: 26px 26px 20px;
  position: relative;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 22px;
  cursor: pointer;
}
.modal-title { font-size: 22px; font-weight: 700; color: #fff; }
.modal-sub { font-size: 13px; color: #a5b4fc; margin: 6px 0 16px; }
.modal input {
  width: 100%;
  padding: 11px 13px;
  margin-bottom: 10px;
  border-radius: 10px;
  border: 1px solid rgba(129, 140, 248, 0.4);
  background: rgba(30, 41, 82, 0.85);
  color: #e2e8f0;
  font-size: 14px;
  outline: none;
}
.modal input:focus { border-color: #818cf8; }
.code-row { display: flex; gap: 8px; margin-bottom: 10px; }
.code-row input { flex: 1; margin-bottom: 0; }
.code-row .send-btn {
  width: auto;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 13px;
  white-space: nowrap;
  background: rgba(99, 102, 241, 0.5);
}
.modal-err { min-height: 20px; font-size: 13px; color: #f87171; margin-bottom: 6px; }
.modal .btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.modal .btn:hover { filter: brightness(1.12); }
.modal-switch { text-align: center; font-size: 13px; color: #94a3b8; margin-top: 12px; }
.modal-switch a { color: #fbbf24; text-decoration: none; }

@media (max-width: 640px) {
  .chat-wrap { flex-direction: column; height: calc(100vh - 120px); }
  .sidebar { width: 100%; max-height: 34%; border-right: none; border-bottom: 1px solid rgba(99,102,241,.25); }
  .friend-list { max-height: 160px; }
}
