/* ===== 古风梦幻 · 灵境 AI 平台样式 ===== */

:root {
  --purple-deep: #5B21B6;
  --purple-mid: #7C3AED;
  --purple-light: #A78BFA;
  --purple-soft: #DDD6FE;
  --purple-bg: #F5F0FF;
  --warm: #C8A992;
  --warm-light: #F5EFE8;
  --cream: #FEFAF5;
  --gold: #D4A853;
  --text-dark: #2D1B69;
  --text-mid: #6B5A8C;
  --text-light: #9B8CB5;
  --white: #FFFFFF;
  --shadow: 0 4px 24px rgba(124, 58, 237, 0.10);
  --shadow-hover: 0 8px 32px rgba(124, 58, 237, 0.16);
  --radius: 16px;
  --radius-sm: 10px;
}

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

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", -apple-system, sans-serif;
  background: linear-gradient(135deg, #FEFAF5 0%, #F5F0FF 30%, #FDF2F8 60%, #FEFAF5 100%);
  background-attachment: fixed;
  color: var(--text-dark);
  min-height: 100vh;
  line-height: 1.6;
}

/* 背景装饰 */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  right: -20%;
  width: 60%;
  height: 100%;
  background: radial-gradient(ellipse, rgba(167, 139, 250, 0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: -30%;
  left: -10%;
  width: 50%;
  height: 80%;
  background: radial-gradient(ellipse, rgba(200, 169, 146, 0.10) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ===== 通用容器 ===== */
.container {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 20px;
}

/* ===== 顶部品牌区 ===== */
.brand {
  text-align: center;
  padding: 60px 0 30px;
}

.brand-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--purple-mid), var(--purple-deep));
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.25);
}

.brand-logo svg {
  width: 32px;
  height: 32px;
  fill: white;
}

.brand h1 {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--purple-deep), var(--purple-mid));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
}

.brand p {
  color: var(--text-light);
  font-size: 14px;
  margin-top: 6px;
  letter-spacing: 1px;
}

/* ===== 卡片 ===== */
.card {
  background: rgba(255, 255, 255, 0.80);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(167, 139, 250, 0.15);
  margin-bottom: 20px;
  transition: box-shadow 0.3s;
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

/* ===== 表单 ===== */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-mid);
  margin-bottom: 8px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--purple-soft);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text-dark);
  background: rgba(255, 255, 255, 0.6);
  transition: all 0.3s;
  outline: none;
  font-family: inherit;
}

.form-input:focus {
  border-color: var(--purple-mid);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.10);
  background: white;
}

.form-input::placeholder {
  color: var(--text-light);
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  letter-spacing: 0.5px;
  font-family: inherit;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--purple-mid), var(--purple-deep));
  color: white;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.30);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(124, 58, 237, 0.40);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-outline {
  background: transparent;
  color: var(--purple-mid);
  border: 1.5px solid var(--purple-light);
}

.btn-outline:hover {
  background: var(--purple-bg);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-danger {
  background: #FEF2F2;
  color: #DC2626;
  border: 1px solid #FECACA;
}

.btn-danger:hover {
  background: #FEE2E2;
}

/* ===== Toast 提示 ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  animation: slideDown 0.3s ease-out;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.toast-success {
  background: #ECFDF5;
  color: #065F46;
  border: 1px solid #A7F3D0;
}

.toast-error {
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== 加载 ===== */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--purple-soft);
  border-top-color: var(--purple-mid);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 登录页专属 ===== */
.login-tabs {
  display: flex;
  margin-bottom: 24px;
  background: var(--purple-bg);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.login-tab {
  flex: 1;
  padding: 10px 0;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-mid);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.3s;
  background: transparent;
  border: none;
  font-family: inherit;
}

.login-tab.active {
  background: white;
  color: var(--purple-deep);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.12);
}

/* ===== 聊天气泡 ===== */
.chat-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.80);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--purple-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header h2 {
  font-size: 17px;
  color: var(--text-dark);
  font-weight: 600;
}

.chat-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0 120px;
}

.message {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  animation: fadeIn 0.3s ease-out;
}

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

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.message.assistant .message-avatar {
  background: linear-gradient(135deg, var(--purple-mid), var(--purple-deep));
}

.message.user .message-avatar {
  background: linear-gradient(135deg, var(--warm), #B8956E);
}

.message-bubble {
  max-width: 75%;
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.7;
  word-wrap: break-word;
}

.message.assistant .message-bubble {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(167, 139, 250, 0.15);
  border-bottom-left-radius: 4px;
}

.message.user .message-bubble {
  background: linear-gradient(135deg, var(--purple-mid), var(--purple-deep));
  color: white;
  border-bottom-right-radius: 4px;
}

.message-bubble p { margin-bottom: 8px; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble pre {
  background: rgba(0,0,0,0.05);
  padding: 12px 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 13px;
  margin: 8px 0;
}
.message-bubble code {
  font-family: "SFMono-Regular", "Consolas", monospace;
  font-size: 13px;
}

.message.user .message-bubble pre {
  background: rgba(255,255,255,0.15);
}

/* 流式输出光标 */
.streaming-cursor::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 16px;
  background: var(--purple-mid);
  margin-left: 2px;
  animation: blink 0.8s infinite;
  vertical-align: text-bottom;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ===== 输入区 ===== */
.chat-input-area {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 800px;
  padding: 16px 20px 24px;
  background: linear-gradient(to top, rgba(254, 250, 245, 0.98) 60%, rgba(254, 250, 245, 0) 100%);
}

.chat-input-wrapper {
  background: rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(20px);
  border-radius: var(--radius);
  border: 1.5px solid var(--purple-soft);
  padding: 10px 16px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  box-shadow: var(--shadow);
  transition: border-color 0.3s;
}

.chat-input-wrapper:focus-within {
  border-color: var(--purple-mid);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.10);
}

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  color: var(--text-dark);
  resize: none;
  font-family: inherit;
  max-height: 120px;
  line-height: 1.5;
}

.chat-input::placeholder {
  color: var(--text-light);
}

.btn-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple-mid), var(--purple-deep));
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.3s;
}

.btn-send:hover {
  transform: scale(1.05);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-light);
}

.empty-state svg {
  width: 80px;
  height: 80px;
  margin-bottom: 20px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text-mid);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
}

/* 新对话按钮 */
.new-chat-btn {
  background: linear-gradient(135deg, var(--purple-mid), var(--purple-deep));
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.3s;
}

.new-chat-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.30);
}

/* ===== 管理后台 ===== */
.admin-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.admin-header h2 {
  font-size: 24px;
  color: var(--text-dark);
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.80);
  backdrop-filter: blur(20px);
  border-radius: var(--radius);
  padding: 20px 24px;
  border: 1px solid rgba(167, 139, 250, 0.15);
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--purple-deep), var(--purple-mid));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
}

/* 用户表格 */
.user-table {
  width: 100%;
  background: rgba(255, 255, 255, 0.80);
  backdrop-filter: blur(20px);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(167, 139, 250, 0.15);
}

.user-table th, .user-table td {
  padding: 14px 20px;
  text-align: left;
  font-size: 14px;
}

.user-table th {
  background: var(--purple-bg);
  color: var(--text-mid);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.5px;
}

.user-table td {
  border-top: 1px solid var(--purple-soft);
  color: var(--text-dark);
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge.active {
  background: #ECFDF5;
  color: #065F46;
}

.status-badge.disabled {
  background: #FEF2F2;
  color: #991B1B;
}

/* 弹窗 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  animation: fadeIn 0.2s;
}

.modal {
  background: white;
  border-radius: var(--radius);
  padding: 32px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal h3 {
  font-size: 20px;
  color: var(--text-dark);
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .container { padding: 16px; }
  .brand { padding: 40px 0 20px; }
  .chat-messages { padding: 16px 0 100px; }
  .message-bubble { max-width: 85%; }
  .admin-stats { grid-template-columns: 1fr 1fr; }
}
