/* ===== 全局重置 ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f0f2f5;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

/* ===== 主容器 ===== */
.chat-container {
  width: 100%;
  max-width: 780px;
  height: 92vh;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== 顶部标题栏 ===== */
.chat-header {
  padding: 18px 24px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chat-header .avatar {
  width: 38px;
  height: 38px;
  background: rgba(255,255,255,0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.chat-header .info h1 {
  font-size: 16px;
  font-weight: 600;
}

.chat-header .info span {
  font-size: 12px;
  opacity: 0.8;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  margin-left: auto;
  box-shadow: 0 0 6px #4ade80;
}

/* ===== 消息区域 ===== */
.chat-box {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* 滚动条美化 */
.chat-box::-webkit-scrollbar {
  width: 5px;
}
.chat-box::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 10px;
}

/* ===== 消息气泡通用 ===== */
.message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 75%;
  animation: fadeUp 0.25s ease;
}

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

.message .bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.message .msg-time {
  font-size: 10px;
  color: #9ca3af;
  white-space: nowrap;
  margin-bottom: 2px;
}

/* ===== 用户消息（右对齐）===== */
.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.user .bubble {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.user .msg-avatar {
  font-size: 22px;
}

/* ===== AI 消息（左对齐）===== */
.message.bot {
  align-self: flex-start;
}

.message.bot .bubble {
  background: #f3f4f6;
  color: #1f2937;
  border-bottom-left-radius: 4px;
}

.message.bot .msg-avatar {
  font-size: 22px;
}

/* ===== 思考中动画 ===== */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
}

.typing-indicator .bubble {
  background: #f3f4f6;
  padding: 14px 18px;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 5px;
}

.typing-indicator .dot {
  width: 7px;
  height: 7px;
  background: #9ca3af;
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}
.typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-6px); }
}

/* ===== 输入区域 ===== */
.chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: #fff;
  flex-shrink: 0;
}

.chat-input-area textarea {
  flex: 1;
  resize: none;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  outline: none;
  transition: border-color 0.2s;
  color: #1f2937;
}

.chat-input-area textarea:focus {
  border-color: #7c3aed;
}

.chat-input-area textarea::placeholder {
  color: #9ca3af;
}

/* ===== 发送按钮 ===== */
.send-btn {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.1s;
  flex-shrink: 0;
}

.send-btn:hover  { opacity: 0.88; }
.send-btn:active { transform: scale(0.95); }
.send-btn:disabled { background: #d1d5db; cursor: not-allowed; }

.send-btn svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

/* ===== 清空按钮 ===== */
.clear-btn {
  font-size: 12px;
  color: #9ca3af;
  background: none;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.2s;
}
.clear-btn:hover { color: #ef4444; border-color: #ef4444; }

/* ===== 欢迎提示 ===== */
.welcome-msg {
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
  margin: auto;
  padding: 40px 0;
}

/* ===== 手机适配 ===== */
@media (max-width: 600px) {
  .chat-container {
    height: 100vh;
    border-radius: 0;
  }
  .message { max-width: 88%; }
}
/* ========================================
   登录 / 注册页面样式
   ======================================== */

.auth-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #ede9fe, #dbeafe);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 12px 40px rgba(79, 70, 229, 0.15);
  padding: 40px 36px 36px;
  animation: fadeUp 0.3s ease;
}

/* ===== Logo 区域 ===== */
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo .icon {
  font-size: 48px;
  display: block;
  margin-bottom: 8px;
}

.auth-logo h1 {
  font-size: 20px;
  font-weight: 700;
  color: #1f2937;
}

.auth-logo p {
  font-size: 13px;
  color: #6b7280;
  margin-top: 4px;
}

/* ===== Tab 切换 ===== */
.auth-tabs {
  display: flex;
  background: #f3f4f6;
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 28px;
}

.auth-tab {
  flex: 1;
  text-align: center;
  padding: 9px 0;
  font-size: 14px;
  font-weight: 500;
  color: #6b7280;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: none;
}

.auth-tab.active {
  background: #fff;
  color: #4f46e5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  font-weight: 600;
}

/* ===== 表单 ===== */
.auth-form {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.auth-form.active {
  display: flex;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: #374151;
}

.form-group input {
  padding: 11px 14px;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  color: #1f2937;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.form-group input:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.form-group input::placeholder {
  color: #9ca3af;
}

/* ===== 提交按钮 ===== */
.auth-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity 0.2s, transform 0.1s;
  font-family: inherit;
}

.auth-btn:hover   { opacity: 0.88; }
.auth-btn:active  { transform: scale(0.98); }
.auth-btn:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}

/* ===== 提示消息 ===== */
.auth-msg {
  font-size: 13px;
  text-align: center;
  padding: 10px 14px;
  border-radius: 8px;
  display: none;
}

.auth-msg.success {
  display: block;
  background: #d1fae5;
  color: #065f46;
}

.auth-msg.error {
  display: block;
  background: #fee2e2;
  color: #991b1b;
}

.auth-msg.loading {
  display: block;
  background: #ede9fe;
  color: #5b21b6;
}

/* ===== 底部说明 ===== */
.auth-footer {
  text-align: center;
  font-size: 12px;
  color: #9ca3af;
  margin-top: 20px;
}

/* ===== 聊天页顶栏新增：用户信息 + 登出 ===== */
.header-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-user span {
  font-size: 13px;
  opacity: 0.9;
}

.logout-btn {
  font-size: 12px;
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.logout-btn:hover {
  background: rgba(255,255,255,0.35);
}

/* ===== 手机适配补充 ===== */
@media (max-width: 480px) {
  .auth-card {
    margin: 16px;
    padding: 32px 24px 28px;
  }
}
