/* ═══════════════════════════════════════════════════════
   缘AI - 纯消息流聊天界面 样式表
   ═══════════════════════════════════════════════════════ */

:root {
  --primary: #FF4B6E;
  --primary-light: #FF8FA3;
  --primary-pale: #FFE0E6;
  --bg: #FFF5F7;
  --bg-white: #FFFFFF;
  --text: #2D2D2D;
  --text-light: #6B6B6B;
  --text-lighter: #999;
  --border: #F0E0E5;
  --shadow: 0 2px 16px rgba(255, 75, 110, 0.08);
  --shadow-lg: 0 8px 32px rgba(255, 75, 110, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ═══ 主应用 ═══ */
.main-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-white);
  box-shadow: var(--shadow-lg);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* 阶段徽章 */
.phase-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.55rem;
  border-radius: 1rem;
  font-weight: 600;
  margin-left: 0.5rem;
}
.phase-badge.phase-asking {
  background: #FFF3E0;
  color: #E65100;
}
.phase-badge.phase-done {
  background: #E8F5E9;
  color: #2E7D32;
}
.phase-badge.phase-matching {
  background: #E3F2FD;
  color: #1565C0;
}

/* 快速测试按钮 */
.btn-quick-test {
  font-size: 0.75rem;
  padding: 0.3rem 0.8rem;
  border-radius: 1rem;
  border: 1px dashed var(--primary-light);
  background: white;
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-quick-test:hover {
  background: var(--primary-pale);
  border-color: var(--primary);
}
.btn-quick-test:active { transform: scale(0.95); }

/* ═══ 问答进度条 ═══ */
.progress-bar-wrap {
  padding: 0.5rem 1.25rem;
  background: white;
  border-bottom: 1px solid var(--border);
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}
.progress-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}
.progress-text {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
}
.progress-bar {
  height: 6px;
  background: #F0E0E5;
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 3px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ═══ 聊天区域 ═══ */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar { width: 4px; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── 消息气泡 ── */
.message {
  display: flex;
  gap: 0.6rem;
  animation: msgIn 0.35s ease-out;
  max-width: 95%;
}

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

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

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  background: var(--bg);
}

.message.ai .msg-avatar { background: var(--primary-pale); }
.message.user .msg-avatar { background: #E8F5E9; }

.msg-bubble {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  line-height: 1.65;
  font-size: 0.92rem;
}

.message.ai .msg-bubble {
  border-bottom-left-radius: 4px;
  background: white;
}

.message.user .msg-bubble {
  border-bottom-right-radius: 4px;
  background: linear-gradient(135deg, var(--primary-pale), #FFF0F3);
  border-color: transparent;
}

.msg-bubble p { margin-bottom: 0.5rem; }
.msg-bubble p:last-child { margin-bottom: 0; }

/* ── 打字指示器 ── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1rem;
  animation: msgIn 0.3s ease-out;
}

.typing-dots { display: flex; gap: 4px; }
.typing-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--primary-light);
  animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-8px); opacity: 1; }
}

/* ═══ 内联档案卡片（嵌入聊天流） ═══ */
.profile-card-inline {
  background: linear-gradient(135deg, #FFF, #FFF5F7);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 0.5rem 0;
  box-shadow: var(--shadow);
}

.profile-card-inline .profile-card-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.profile-card-inline .profile-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: white;
  flex-shrink: 0;
}

.profile-card-inline .profile-name {
  font-size: 1.25rem;
  font-weight: 700;
}

.profile-card-inline .profile-basic {
  font-size: 0.85rem;
  color: var(--text-light);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ═══ 内联匹配卡片（嵌入聊天流） ═══ */
.match-card-inline {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin: 0.5rem 0;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.match-card-inline:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary-light);
}

.match-card-inline.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-pale);
}

.match-score {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: linear-gradient(135deg, var(--primary), #FF6B8A);
  color: white;
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
}

.match-score small {
  font-size: 0.6rem;
  font-weight: 400;
  opacity: 0.8;
}

.match-card-inline .match-card-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-right: 3rem;
}

.match-card-inline .match-card-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.match-card-inline .match-card-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.match-card-inline .match-card-info {
  font-size: 0.82rem;
  color: var(--text-light);
}

/* ═══ 性格+星座标签 ═══ */
.destiny-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  margin-right: 4px;
  margin-bottom: 4px;
  font-weight: 500;
}
.zodiac-tag {
  background: #EDE7F6;
  color: #5E35B1;
}
.mbti-tag {
  background: #E3F2FD;
  color: #1565C0;
}
.element-tag {
  background: #E8F5E9;
  color: #2E7D32;
}
.lovelang-tag {
  background: #FCE4EC;
  color: #C2185B;
}
.values-tag {
  background: #FFF8E1;
  color: #F57F17;
}

/* ═══ 通���标签 ═══ */
.profile-tag {
  background: var(--primary-pale);
  color: var(--primary);
  padding: 0.25rem 0.7rem;
  border-radius: 1rem;
  font-size: 0.82rem;
  font-weight: 500;
  display: inline-block;
  margin: 0.15rem;
}

.profile-tag.green { background: #E8F5E9; color: #2E7D32; }
.profile-tag.blue { background: #E3F2FD; color: #1565C0; }
.profile-tag.purple { background: #F3E5F5; color: #7B1FA2; }

.profile-section-title {
  font-size: 0.85rem;
  color: var(--primary);
  margin: 0.6rem 0 0.35rem;
}

/* ═══ 消息内按钮 ═══ */
.msg-btn {
  display: inline-block;
  background: linear-gradient(135deg, var(--primary), #FF6B8A);
  color: white;
  border: none;
  padding: 0.5rem 1.2rem;
  border-radius: 1.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0.35rem 0.35rem 0 0;
  transition: all var(--transition);
}

.msg-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(255,75,110,0.3); }
.msg-btn:active { transform: scale(0.96); }

.msg-btn-outline {
  background: white;
  color: var(--primary);
  border: 1.5px solid var(--primary-light);
}

.msg-btn-outline:hover {
  background: var(--primary-pale);
  box-shadow: none;
}

/* 小号按钮(匹配卡片内) */
.msg-btn-small {
  padding: 0.35rem 0.8rem;
  font-size: 0.78rem;
  border-radius: 1.2rem;
}

.msg-btn-exchange {
  background: linear-gradient(135deg, #FF6B8A, var(--primary));
}

.msg-btn-exchange:hover {
  background: linear-gradient(135deg, var(--primary), #E0405B);
}

.msg-btn-done {
  background: #E8F5E9;
  color: #2E7D32;
  cursor: default;
}

.msg-btn-done:hover {
  transform: none;
  box-shadow: none;
}

/* 邮箱展示区 */
.email-reveal {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: linear-gradient(135deg, #E8F5E9, #F1F8E9);
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
  color: #2E7D32;
  animation: fadeIn 0.4s ease;
}
.email-reveal strong {
  color: #1B5E20;
}

/* ═══ 输入区域 ═══ */
.input-area {
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem;
  background: white;
}

.input-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.user-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 1.5rem;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  font-family: var(--font);
  resize: none;
  outline: none;
  transition: border-color var(--transition);
  min-height: 40px;
  max-height: 120px;
  line-height: 1.5;
}
.user-input:focus { border-color: var(--primary-light); }

.btn-send {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary), #FF6B8A);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.btn-send:hover { transform: scale(1.05); }
.btn-send:active { transform: scale(0.95); }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ═══ 加载遮罩 ═══ */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(2px);
}

.loading-dots {
  display: flex;
  gap: 6px;
  margin-bottom: 0.75rem;
}
.loading-dots span {
  width: 10px; height: 10px;
  background: var(--primary);
  border-radius: 50%;
  animation: loadingDot 1.4s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes loadingDot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.loading-overlay p {
  color: var(--text-light);
  font-size: 0.9rem;
}

/* ═══ 模态弹窗 ═══ */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: var(--radius);
  max-width: 550px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,0.15);
  animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
  from { transform: translateY(20px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 1.15rem; color: var(--text); }

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-lighter);
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 1.25rem; line-height: 1.8; font-size: 0.92rem; white-space: pre-wrap; }

/* ═══ 响应式 ═══ */
@media (max-width: 600px) {
  .main-app { height: 100dvh; border-radius: 0; }
  .chat-area { padding: 0.75rem; }
}

@media (min-width: 601px) {
  .main-app {
    margin-top: 20px;
    border-radius: var(--radius);
    height: calc(100vh - 40px);
    max-height: 900px;
  }
}
