/**
 * tree.css — 对话式决策树 UI
 * AI 自由收入规划师 · 动态问题收集样式
 */

/* ============ 对话容器 ============ */
.chat-container {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 120px);
  padding-bottom: 24px;
}

/* ============ 问题气泡 ============ */
.question-wrap {
  animation: fadeUp .4s ease;
  margin-bottom: 20px;
}

.question-bubble {
  background: linear-gradient(135deg, rgba(99,102,241,.15), rgba(245,158,11,.1));
  border: 1px solid rgba(99,102,241,.25);
  border-radius: 16px;
  padding: 18px 20px;
  position: relative;
}

.question-bubble .q-num {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.question-bubble .q-text {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--text);
}

.question-bubble .q-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.5;
}

.question-bubble .q-note {
  font-size: 12px;
  color: var(--accent);
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(245,158,11,.08);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}

/* ============ 选项按钮 ============ */
.options-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
  animation: fadeUp .35s ease .1s both;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  transition: all .2s;
  text-align: left;
  width: 100%;
}

.option-btn:hover {
  border-color: var(--primary);
  background: rgba(99,102,241,.08);
  transform: translateX(4px);
}

.option-btn:active {
  transform: translateX(2px) scale(.99);
}

.option-btn .opt-icon {
  font-size: 20px;
  flex-shrink: 0;
}

/* 多选状态 */
.option-btn.multichoice {
  position: relative;
  padding-left: 48px;
}

.option-btn.multichoice::before {
  content: '';
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 6px;
  transition: all .2s;
}

.option-btn.multichoice.checked {
  border-color: var(--primary);
  background: rgba(99,102,241,.1);
}

.option-btn.multichoice.checked::before {
  background: var(--primary);
  border-color: var(--primary);
}

.option-btn.multichoice.checked::after {
  content: '✓';
  position: absolute;
  left: 19px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: #fff;
  font-weight: 700;
}

/* ============ 数字输入 ============ */
.number-wrap {
  animation: fadeUp .35s ease .1s both;
  margin-bottom: 20px;
}

.number-wrap input[type="number"] {
  width: 100%;
  padding: 16px 18px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  outline: none;
  transition: border .2s;
  text-align: center;
}

.number-wrap input[type="number"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

.number-wrap input[type="number"]::-webkit-outer-spin-button,
.number-wrap input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.number-wrap .num-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.number-wrap .num-actions .btn {
  flex: 1;
  max-width: none;
}

/* ============ 已回答问题（历史气泡） ============ */
.history-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.history-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: fadeUp .3s ease;
}

.history-item .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.history-item .answer-bubble {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-2);
}

/* ============ 底部控制栏 ============ */
.chat-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.chat-footer .progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--muted);
}

.chat-footer .back-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 0;
}

.chat-footer .back-btn:hover {
  color: var(--text);
}

/* ============ 完成状态 ============ */
.complete-wrap {
  text-align: center;
  padding: 40px 20px;
  animation: fadeUp .5s ease;
}

.complete-wrap .complete-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.complete-wrap .complete-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.complete-wrap .complete-desc {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 24px;
  line-height: 1.6;
}

/* ============ v3 新增样式 ============ */

/* 进度条 */
.chat-progress-wrap { margin-bottom: 20px; }
.chat-progress-bar {
  height: 4px; background: var(--bg-2); border-radius: 2px; overflow: hidden;
  margin-bottom: 8px;
}
.chat-progress-fill {
  height: 100%; background: var(--grad); border-radius: 2px;
  transition: width .4s ease;
}
.chat-progress-text {
  font-size: 12px; color: var(--muted); text-align: center;
}

/* 题目气泡（新版） */
.question-bubble {
  background: linear-gradient(135deg, rgba(99,102,241,.15), rgba(245,158,11,.1));
  border: 1px solid rgba(99,102,241,.25);
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 16px;
  animation: fadeUp .4s ease;
}
.question-subtitle {
  font-size: 12px; color: var(--muted); margin-bottom: 8px;
  padding: 3px 10px; background: rgba(99,102,241,.1);
  border-radius: 6px; display: inline-block;
}
.question-text {
  font-size: 17px; font-weight: 700; line-height: 1.45;
  color: var(--text); margin-bottom: 8px;
}
.question-note {
  font-size: 12px; color: var(--accent); margin-top: 6px;
  padding: 6px 10px; background: rgba(245,158,11,.08);
  border-radius: 8px; border-left: 3px solid var(--accent);
}
.question-input-area {
  margin-top: 14px; display: flex; flex-direction: column; gap: 10px;
  animation: fadeUp .35s ease .1s both;
}

/* 选项按钮（新版） */
.option-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; background: var(--card);
  border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); font-size: 15px; cursor: pointer;
  transition: all .2s; text-align: left; width: 100%;
  font-family: inherit;
}
.option-btn:hover {
  border-color: var(--primary); background: rgba(99,102,241,.08);
  transform: translateX(3px);
}
.option-btn:active { transform: translateX(1px) scale(.99); }
.option-btn.selected {
  border-color: var(--primary); background: rgba(99,102,241,.12);
}
.option-btn.confirm-btn {
  background: var(--grad); color: #fff; border: none;
  font-weight: 600; justify-content: center; margin-top: 6px;
}
.option-btn.confirm-btn:hover { opacity: .9; transform: none; }

/* 多选提示 */
.multi-hint {
  font-size: 12px; color: var(--muted); text-align: center;
  min-height: 16px; transition: color .2s;
}
.multi-hint.show { color: var(--accent); }

/* 数字输入（新版） */
.number-input {
  width: 100%; padding: 14px 16px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text); font-size: 18px;
  font-weight: 600; outline: none; transition: border .2s;
  text-align: center; font-family: inherit;
}
.number-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

/* 量表题 */
.scale-wrap {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.scale-btn {
  flex: 1; min-width: 60px; padding: 12px 8px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 13px;
  cursor: pointer; transition: all .2s; text-align: center;
  font-family: inherit;
}
.scale-btn:hover {
  border-color: var(--primary); background: rgba(99,102,241,.08);
}
.scale-btn.selected {
  background: var(--grad); color: #fff; border-color: transparent;
  font-weight: 600; transform: scale(1.05);
}

/* 开放题 */
.text-input {
  width: 100%; padding: 14px 16px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text); font-size: 15px;
  outline: none; transition: border .2s; resize: vertical;
  font-family: inherit; line-height: 1.5;
}
.text-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

/* 历史气泡（新版） */
.history-bubble {
  align-self: flex-end; max-width: 80%;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 14px 14px 4px 14px;
  padding: 10px 16px; font-size: 14px; color: var(--text);
  margin-bottom: 12px; margin-left: auto;
  animation: fadeUp .3s ease;
}

/* ============ 结果页 ============ */
.result-section { margin-bottom: 24px; }
.result-section h3 {
  font-size: 18px; font-weight: 700; margin-bottom: 14px;
  color: var(--text);
}

/* 画像速写 */
.profile-section { }
.profile-loading {
  padding: 20px; text-align: center; color: var(--muted);
  font-size: 14px; background: var(--card); border-radius: 12px;
}
.profile-desc {
  padding: 18px 20px; background: var(--card);
  border: 1px solid var(--border); border-radius: 12px;
  font-size: 15px; line-height: 1.7; color: var(--text);
}
.profile-desc.fallback { opacity: .85; }

/* 画像详情网格 */
.profile-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px;
}
@media (max-width: 600px) { .profile-grid { grid-template-columns: 1fr; } }

.profile-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 18px;
}
.profile-card h4 {
  font-size: 14px; font-weight: 600; color: var(--muted);
  margin-bottom: 12px; text-transform: uppercase;
  letter-spacing: .5px; font-size: 12px;
}

/* RIASEC 条 */
.riasec-bar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px; font-size: 13px;
}
.riasec-bar.top3 .riasec-name { color: var(--accent); font-weight: 600; }
.riasec-icon { font-size: 16px; width: 20px; }
.riasec-name { flex-shrink: 0; width: 80px; color: var(--text); font-size: 12px; }
.riasec-track {
  flex: 1; height: 6px; background: var(--bg-2);
  border-radius: 3px; overflow: hidden;
}
.riasec-fill {
  height: 100%; background: var(--grad); border-radius: 3px;
  transition: width .6s ease;
}
.riasec-score { font-size: 11px; color: var(--muted); width: 32px; text-align: right; }

/* Ikigai 网格 */
.ikigai-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.ikigai-item {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px; background: var(--bg-2);
  border-radius: 8px; border: 1px solid var(--border);
}
.ikigai-label { font-size: 11px; color: var(--muted); }
.ikigai-value { font-size: 13px; color: var(--text); font-weight: 500; }

/* Big Five 条 */
.bigfive-bar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.bf-name { font-size: 12px; width: 60px; color: var(--text); flex-shrink: 0; }
.bf-track { flex: 1; height: 6px; background: var(--bg-2); border-radius: 3px; overflow: hidden; }
.bf-fill { height: 100%; background: #06b6d4; border-radius: 3px; transition: width .6s ease; }
.bf-score { font-size: 11px; color: var(--muted); width: 32px; text-align: right; }

/* 技能条 */
.skill-bar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.skill-name { font-size: 12px; width: 60px; color: var(--text); flex-shrink: 0; }
.skill-track { flex: 1; height: 6px; background: var(--bg-2); border-radius: 3px; overflow: hidden; }
.skill-fill { height: 100%; background: #8b5cf6; border-radius: 3px; transition: width .6s ease; }
.skill-score { font-size: 11px; color: var(--muted); width: 32px; text-align: right; }

/* 实践条件 */
.constraints-list { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.constraints-list strong { color: var(--text); }

/* 平台标签 */
.platform-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.platform-tag {
  padding: 4px 12px; background: rgba(99,102,241,.12);
  border: 1px solid rgba(99,102,241,.25); border-radius: 20px;
  font-size: 12px; color: #818cf8;
}

/* 承诺 */
.pledge-text {
  padding: 12px 16px; background: rgba(245,158,11,.08);
  border-left: 3px solid var(--accent); border-radius: 8px;
  font-size: 14px; color: var(--text); font-style: italic;
}

/* 路径卡片 */
.path-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px 20px; margin-bottom: 14px;
  transition: border .2s;
}
.path-card.top-match {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(99,102,241,.2);
}
.path-header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.path-icon { font-size: 28px; }
.path-title h4 { font-size: 16px; font-weight: 700; color: var(--text); }
.path-score { font-size: 13px; color: var(--accent); font-weight: 600; }
.path-desc { font-size: 14px; color: var(--muted); line-height: 1.5; margin-bottom: 10px; }
.path-meta {
  display: flex; gap: 16px; font-size: 12px; color: var(--muted);
  margin-bottom: 8px; flex-wrap: wrap;
}
.path-scores {
  display: flex; gap: 12px; font-size: 11px; color: var(--muted);
  margin-bottom: 8px; flex-wrap: wrap;
}
.path-scores span {
  padding: 2px 8px; background: var(--bg-2); border-radius: 4px;
}
.path-gates { margin-bottom: 8px; }
.gate-tag {
  display: inline-block; padding: 3px 8px; margin-right: 4px;
  background: rgba(239,68,68,.1); color: var(--bad);
  border-radius: 4px; font-size: 11px;
}
.path-reason {
  font-size: 13px; color: var(--text); line-height: 1.6;
  padding-top: 8px; border-top: 1px solid var(--border);
}

/* 矛盾提示 */
.contradiction-warn {
  padding: 14px 18px; background: rgba(245,158,11,.08);
  border: 1px solid rgba(245,158,11,.2); border-radius: 12px;
  font-size: 13px; color: var(--text); margin-bottom: 20px;
}
.contradiction-warn strong { color: var(--accent); }

/* 结果页行动 */
.result-actions { text-align: center; margin-top: 24px; }

/* ============ 动画 ============ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ 响应式 ============ */
@media (max-width: 360px) {
  .question-text { font-size: 15px; }
  .option-btn { padding: 12px 14px; font-size: 14px; }
  .scale-btn { min-width: 50px; font-size: 12px; }
  .profile-grid { grid-template-columns: 1fr; }
}

/* ============ 已回答题目冻结样式（已废弃，保留以便参考）============
.question-bubble.answered {
  opacity: 0.55;
  border-color: rgba(99, 102, 241, 0.12);
}
*/

/* ============ 改题高亮动画 ============ */
@keyframes questionChanged {
  0%   { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); border-color: rgba(245, 158, 11, 0.7); }
  50%  { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0.3); border-color: rgba(245, 158, 11, 1); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); border-color: rgba(99, 102, 241, 0.25); }
}

.question-bubble.changed {
  animation: questionChanged 1.5s ease-out;
}

/* 旧题被点击时按钮短暂高亮 */
.question-bubble .option-btn.flash,
.question-bubble .scale-btn.flash {
  animation: btnFlash 0.6s ease-out;
}

@keyframes btnFlash {
  0%   { background: rgba(245, 158, 11, 0.3); }
  100% { background: transparent; }
}

/* ============ 路径骨架屏加载态 ============ */
.path-skeleton-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.path-skeleton {
  height: 180px;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(99,102,241,0.08) 25%, rgba(99,102,241,0.15) 50%, rgba(99,102,241,0.08) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  border: 1px solid rgba(99,102,241,0.1);
}

.path-skeleton.strategy-safe { border-left: 4px solid rgba(34,197,94,0.3); }
.path-skeleton.strategy-passion { border-left: 4px solid rgba(249,115,22,0.3); }
.path-skeleton.strategy-future { border-left: 4px solid rgba(59,130,246,0.3); }

@keyframes skeletonShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.path-loading-text {
  text-align: center;
  color: var(--muted, #94a3b8);
  font-size: 14px;
  margin-top: 16px;
  padding: 8px;
}

.path-source-notice {
  color: var(--muted, #94a3b8);
  font-size: 13px;
  margin: 4px 0 12px;
}

/* ============ 路径卡片 V2（5 段式）============ */
.path-card-v2 {
  background: var(--bg2, #1e293b);
  border: 1px solid rgba(99,102,241,0.15);
  border-radius: 14px;
  padding: 18px 16px;
  margin-bottom: 14px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.path-card-v2.top-match {
  border-width: 2px;
}

/* 3 种策略主题色 */
.path-card-v2.strategy-safe {
  border-left: 4px solid #22c55e;
  background: linear-gradient(135deg, rgba(34,197,94,0.05) 0%, transparent 60%);
}
.path-card-v2.strategy-passion {
  border-left: 4px solid #f97316;
  background: linear-gradient(135deg, rgba(249,115,22,0.05) 0%, transparent 60%);
}
.path-card-v2.strategy-future {
  border-left: 4px solid #3b82f6;
  background: linear-gradient(135deg, rgba(59,130,246,0.05) 0%, transparent 60%);
}

.path-card-v2:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

/* 1. 标题栏 */
.path-v2-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.path-v2-icon {
  font-size: 28px;
  line-height: 1;
}

.path-v2-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.path-v2-title h4 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink, #e2e8f0);
}

.strategy-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
}

.strategy-tag.strategy-safe {
  background: rgba(34,197,94,0.15);
  color: #4ade80;
}
.strategy-tag.strategy-passion {
  background: rgba(249,115,22,0.15);
  color: #fb923c;
}
.strategy-tag.strategy-future {
  background: rgba(59,130,246,0.15);
  color: #60a5fa;
}

/* 2. 一句话定位 */
.path-v2-liner {
  font-size: 14px;
  color: var(--muted, #94a3b8);
  margin: 0 0 12px;
  line-height: 1.5;
}

/* 3. 适合 + 注意 */
.path-v2-fit {
  margin-bottom: 12px;
}

.fit-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 13px;
  line-height: 1.5;
  padding: 4px 0;
}

.fit-good { color: #4ade80; }
.fit-warn { color: #fbbf24; }

/* 4. 第一步动作（高亮） */
.path-v2-first-action {
  background: rgba(99,102,241,0.1);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.first-action-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent, #818cf8);
  background: rgba(99,102,241,0.15);
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.first-action-text {
  font-size: 14px;
  color: var(--ink, #e2e8f0);
  line-height: 1.5;
}

/* 5. 元信息 */
.path-v2-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 12px;
  color: var(--muted, #94a3b8);
  margin-bottom: 10px;
}

.meta-item {
  white-space: nowrap;
}

/* 推荐理由折叠 */
.path-v2-reason {
  border-top: 1px solid rgba(99,102,241,0.1);
  padding-top: 8px;
}

.path-v2-reason summary {
  font-size: 13px;
  color: var(--accent, #818cf8);
  cursor: pointer;
  user-select: none;
}

.path-v2-reason p {
  font-size: 13px;
  color: var(--muted, #94a3b8);
  line-height: 1.6;
  margin: 8px 0 0;
}

/* ============ 响应式补充 ============ */
@media (max-width: 600px) {
  .path-v2-title h4 { font-size: 15px; }
  .path-v2-liner { font-size: 13px; }
  .first-action-text { font-size: 13px; }
  .path-v2-meta { font-size: 11px; }
}

/* ============ 字数提示 ============ */
.char-count {
  text-align: right;
  font-size: 12px;
  color: var(--muted, #94a3b8);
  margin-top: 4px;
}

.char-count.maxed {
  color: #f87171;
}
