/* ===========================================================
 * 寄居蟹 H5 v2.0 · 共用样式
 * 移动端优先 · 4 入口差异化 · 多轮对话 UI
 * =========================================================== */

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

:root {
  --primary: #667eea;
  --primary-dark: #5568d3;
  --secondary: #764ba2;
  --owner-color: #ff6b6b;
  --agent-color: #4ecdc4;
  --foreman-color: #ffa726;
  --designer-color: #ab47bc;
  --bg: #f7f8fc;
  --card-bg: #ffffff;
  --text: #2d3436;
  --text-soft: #636e72;
  --border: #e0e6ed;
  --success: #00b894;
  --danger: #d63031;
  --warning: #fdcb6e;
  --info: #74b9ff;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

body {
  padding: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  min-height: 100vh;
  box-shadow: 0 0 40px rgba(0,0,0,0.05);
}

/* ========== 顶部导航 ========== */
.top-nav {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.top-nav .logo {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.top-nav .nav-actions {
  display: flex;
  gap: 8px;
}

.top-nav .icon-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.top-nav .icon-btn:active { transform: scale(0.9); }

/* ========== 入口切换条 ========== */
.entry-switch {
  display: flex;
  gap: 4px;
  padding: 8px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.entry-btn {
  flex: 1;
  min-width: 70px;
  padding: 8px 4px;
  background: #f5f6fa;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-soft);
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  transition: all 0.2s;
}

.entry-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.entry-btn[data-entry="owner"].active { background: var(--owner-color); border-color: var(--owner-color); }
.entry-btn[data-entry="agent"].active { background: var(--agent-color); border-color: var(--agent-color); }
.entry-btn[data-entry="foreman"].active { background: var(--foreman-color); border-color: var(--foreman-color); }
.entry-btn[data-entry="designer"].active { background: var(--designer-color); border-color: var(--designer-color); }

/* ========== 英雄区（差异化价值主张）========== */
.hero {
  padding: 20px 16px;
  color: #fff;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero.owner    { background: linear-gradient(135deg, var(--owner-color), #ff8e53); }
.hero.agent    { background: linear-gradient(135deg, var(--agent-color), #44a3aa); }
.hero.foreman  { background: linear-gradient(135deg, var(--foreman-color), #ff7043); }
.hero.designer { background: linear-gradient(135deg, var(--designer-color), #7e57c2); }

.hero h1 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.hero p {
  font-size: 13px;
  opacity: 0.95;
}

.hero .price-tag {
  display: inline-block;
  background: rgba(255,255,255,0.25);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  margin-top: 8px;
}

/* ========== 表单卡片 ========== */
.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px;
  margin: 12px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-title::before {
  content: '';
  width: 3px;
  height: 14px;
  background: var(--primary);
  border-radius: 2px;
}

.input-group { margin-bottom: 12px; }
.input-group:last-child { margin-bottom: 0; }

.input-label {
  display: block;
  font-size: 12px;
  color: var(--text-soft);
  margin-bottom: 5px;
}
.input-label .hint { color: #aaa; font-size: 11px; font-weight: normal; }
.dims-subtitle {
  font-size: 11px;
  color: #888;
  margin: 8px 0 4px 0;
  padding: 6px 10px;
  background: #f5f7fa;
  border-radius: 6px;
  border-left: 3px solid var(--primary, #ff6b6b);
}

.input-field {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  transition: border-color 0.2s;
}

.input-field:focus {
  outline: none;
  border-color: var(--primary);
}

textarea.input-field {
  resize: vertical;
  min-height: 70px;
  font-family: inherit;
}

select.input-field {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23636e72' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 32px;
}

/* ========== 按钮 ========== */
.btn-primary {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin: 16px;
  width: calc(100% - 32px);
  transition: transform 0.1s;
}

.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  padding: 6px 12px;
  background: #f5f6fa;
  color: var(--text-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  margin: 2px;
}

.btn-secondary.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.severity-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ========== 多轮对话区 ========== */
.chat-area {
  margin: 12px 16px;
  display: none;
}

.chat-area.show { display: block; }

.chat-list {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 12px;
  max-height: 480px;
  overflow-y: auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.chat-msg {
  margin-bottom: 14px;
  display: flex;
  gap: 8px;
  animation: fadeIn 0.3s ease;
}

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

.chat-msg.user { flex-direction: row-reverse; }

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.chat-msg.user .chat-avatar { background: var(--primary); }
.chat-msg.ai .chat-avatar { background: linear-gradient(135deg, var(--primary), var(--secondary)); }

.chat-bubble {
  max-width: 78%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  word-wrap: break-word;
}

.chat-msg.user .chat-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 2px;
}

.chat-msg.ai .chat-bubble {
  background: #f5f6fa;
  color: var(--text);
  border-bottom-left-radius: 2px;
}

.chat-bubble h1, .chat-bubble h2, .chat-bubble h3 {
  margin: 8px 0 4px;
  font-size: 14px;
  font-weight: 600;
}

.chat-bubble p { margin: 4px 0; }
.chat-bubble ul, .chat-bubble ol { margin: 4px 0 4px 18px; }
.chat-bubble code { background: rgba(0,0,0,0.06); padding: 1px 4px; border-radius: 3px; font-size: 12px; }
.chat-bubble pre { background: #2d3436; color: #fff; padding: 8px; border-radius: 6px; overflow-x: auto; font-size: 12px; }
.chat-bubble table { border-collapse: collapse; margin: 6px 0; font-size: 12px; }
.chat-bubble table th, .chat-bubble table td { border: 1px solid var(--border); padding: 4px 6px; }
.chat-bubble blockquote { border-left: 3px solid var(--primary); padding-left: 8px; color: var(--text-soft); margin: 4px 0; }

/* ========== 反馈按钮 ========== */
.feedback-row {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.fb-btn {
  padding: 4px 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-soft);
  transition: all 0.2s;
}

.fb-btn:active { transform: scale(0.95); }
.fb-btn.accept.active { background: var(--success); color: #fff; border-color: var(--success); }
.fb-btn.reject.active { background: var(--danger); color: #fff; border-color: var(--danger); }
.fb-btn.tweak.active { background: var(--warning); color: #fff; border-color: var(--warning); }
.fb-btn.rate.active { background: var(--info); color: #fff; border-color: var(--info); }

.fb-status {
  font-size: 11px;
  color: var(--success);
  margin-top: 4px;
  display: none;
}

.fb-status.show { display: block; }

/* ========== 5 维评分柱状图 ========== */
.score-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 12px 16px;
  margin: 12px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.score-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.score-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}

.score-bar-label {
  width: 60px;
  color: var(--text-soft);
  flex-shrink: 0;
}

.score-bar-track {
  flex: 1;
  height: 8px;
  background: #f0f2f5;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.score-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 4px;
  transition: width 0.6s ease;
}

.score-bar-value {
  width: 32px;
  text-align: right;
  font-weight: 600;
  color: var(--text);
}

/* ========== 决策门状态徽章 ========== */
.gate-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.gate-badge.calculated {
  background: #e8f5e9;
  color: #2e7d32;
}

.gate-badge.rendered {
  background: #e3f2fd;
  color: #1565c0;
}

.gate-badge.gated {
  background: #fff3e0;
  color: #ef6c00;
}

/* ========== 追问输入框 ========== */
.followup-box {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 12px;
  margin: 12px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.followup-input-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}

.followup-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  max-height: 80px;
  min-height: 36px;
}

.followup-input:focus { outline: none; border-color: var(--primary); }

.followup-send {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.followup-send:active { transform: scale(0.92); }

.quick-questions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.quick-q {
  padding: 4px 8px;
  background: #f5f6fa;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 11px;
  color: var(--text-soft);
  cursor: pointer;
}

.quick-q:active { background: var(--primary); color: #fff; }

/* ========== 支付引导 ========== */
.pay-card {
  background: linear-gradient(135deg, #fff5f5, #fff);
  border: 1px solid #ffd6d6;
  border-radius: 12px;
  padding: 14px 16px;
  margin: 12px 16px;
}

.pay-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--owner-color);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.pay-desc {
  font-size: 12px;
  color: var(--text-soft);
  margin-bottom: 10px;
}

.pay-actions {
  display: flex;
  gap: 8px;
}

.pay-btn {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.pay-btn.l2 { background: var(--owner-color); color: #fff; }
.pay-btn.l3 { background: linear-gradient(135deg, #ffd700, #ff8c00); color: #fff; }

.pay-btn:active { transform: scale(0.97); }

/* ========== 历史会话列表 ========== */
.history-panel {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
}

.history-panel.show { display: block; }

.history-sheet {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 86%;
  max-width: 380px;
  background: #fff;
  box-shadow: -2px 0 12px rgba(0,0,0,0.1);
  overflow-y: auto;
  padding: 16px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.history-header h3 { font-size: 16px; font-weight: 600; }

.history-item {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.history-item:active { background: #f5f6fa; }

.history-item-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.history-item-meta {
  font-size: 11px;
  color: var(--text-soft);
  display: flex;
  justify-content: space-between;
}

/* ========== 底部 footer ========== */
.footer {
  text-align: center;
  padding: 20px 16px 30px;
  font-size: 11px;
  color: var(--text-soft);
  line-height: 1.6;
}

/* ========== 浮动语音按钮 ========== */
.voice-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  border: none;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(102,126,234,0.4);
  cursor: pointer;
  z-index: 80;
}

.voice-fab:active { transform: scale(0.95); }
.voice-fab.recording { background: var(--danger); animation: pulse 1.2s infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 12px rgba(214,48,49,0.4); }
  50% { box-shadow: 0 4px 20px rgba(214,48,49,0.8); }
}

/* ========== 加载态 ========== */
.loading {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Toast 提示 ========== */
.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(45,52,54,0.92);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.toast.show { opacity: 1; }

/* ========== 响应式（手机以下）========== */
@media (max-width: 360px) {
  .hero h1 { font-size: 18px; }
  .chat-bubble { font-size: 12px; }
  .entry-btn { font-size: 11px; min-width: 60px; }
}
