/* ============================================
   荆工智匠 - H5前端样式
   移动端优先，兼容PC
   ============================================ */

:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-dark: #1d4ed8;
  --accent: #f59e0b;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
}

/* ============ 页面切换 ============ */

.page {
  display: none;
  min-height: 100vh;
  padding: 0 16px 32px;
  animation: fadeIn 0.3s ease;
}

.page.active { display: block; }

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

/* ============ 首页 ============ */

.hero {
  text-align: center;
  padding: 48px 0 32px;
}

.logo { font-size: 48px; margin-bottom: 12px; }

.hero h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.desc {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 8px 16px;
  background: #eff6ff;
  border-radius: 20px;
  display: inline-block;
}

.card-group { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }

.action-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  gap: 16px;
}

.action-card:active { transform: scale(0.98); }
.action-card:hover { box-shadow: var(--shadow-lg); }

.card-icon { font-size: 32px; flex-shrink: 0; }

.action-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.action-card p { font-size: 13px; color: var(--text-secondary); }

.footer-info {
  text-align: center;
  margin-top: 32px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ============ 页面头部 ============ */

.page-header {
  display: flex;
  align-items: center;
  padding: 16px 0;
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.page-header h2 { font-size: 18px; flex: 1; }

.btn-back {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-text { font-size: 14px; color: var(--text-secondary); }

.chat-hint { font-size: 12px; color: var(--accent); }

/* ============ 表单 ============ */

.form-container { padding-bottom: 32px; }

.form-group { margin-bottom: 20px; }

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.form-group input[type="text"],
.form-group input[type="tel"],
.form-group input[type="email"],
.form-group input[type="number"] {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus { border-color: var(--primary); }

.select-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.select-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.select-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.select-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--card-bg);
}

.select-item:active { transform: scale(0.97); }

.select-item.selected {
  border-color: var(--primary);
  background: #eff6ff;
  color: var(--primary);
  font-weight: 600;
}

/* ============ 按钮 ============ */

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  transition: background 0.2s;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; }

.btn-secondary {
  width: 100%;
  padding: 12px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
}

.btn-end {
  padding: 6px 14px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

/* ============ 测评题目 ============ */

.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 20px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

.question-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow);
}

.question-dim {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 8px;
  padding: 2px 8px;
  background: #eff6ff;
  border-radius: 4px;
  display: inline-block;
}

.question-text {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 16px;
  line-height: 1.5;
}

.options { display: flex; flex-direction: column; gap: 10px; }

.option-item {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
  transition: all 0.2s;
}

.option-item:active { transform: scale(0.98); }

.option-item.selected {
  border-color: var(--primary);
  background: #eff6ff;
}

.option-item:hover { border-color: var(--primary-light); }

/* ============ 测评结果 ============ */

.result-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
}

.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.3);
}

.score-number { font-size: 36px; font-weight: 700; line-height: 1; }
.score-label { font-size: 12px; opacity: 0.9; }

#radar-chart { margin-bottom: 20px; }

#score-bars {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.score-bar-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bar-label { font-size: 13px; width: 64px; text-align: right; flex-shrink: 0; }

.bar-track {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s ease;
}

.bar-score { font-size: 13px; font-weight: 600; width: 30px; }

.weak-hint {
  width: 100%;
  padding: 12px 16px;
  background: #fef3c7;
  border-radius: 8px;
  font-size: 13px;
  color: #92400e;
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ============ 对话界面 ============ */

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  min-height: calc(100vh - 180px);
  max-height: calc(100vh - 180px);
}

.message {
  display: flex;
  margin-bottom: 16px;
  animation: messageIn 0.3s ease;
}

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

.message.bot { justify-content: flex-start; }
.message.user { justify-content: flex-end; }

.message-content {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.bot .message-content {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message.user .message-content {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 0;
  position: sticky;
  bottom: 0;
  background: var(--bg);
}

.chat-input-area textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  resize: none;
  font-family: inherit;
  line-height: 1.4;
}

.chat-input-area textarea:focus { border-color: var(--primary); }

.btn-send {
  padding: 10px 18px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  align-self: flex-end;
}

.btn-send:disabled { background: #94a3b8; cursor: not-allowed; }

/* ============ 报告 ============ */

.report-container {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}

.report-container h3 { font-size: 16px; margin: 16px 0 8px; color: var(--primary); }
.report-container h4 { font-size: 15px; margin: 12px 0 6px; }

.report-actions { display: flex; flex-direction: column; gap: 8px; }

.loading-spinner {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
  font-size: 15px;
}

.loading-spinner::before {
  content: "";
  display: block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

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

/* ============ 响应式 ============ */

@media (min-width: 480px) {
  body { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

/* ============ 留资弹窗 ============ */

.lead-modal-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.25s ease;
}

.lead-modal-mask.show { display: flex; }

.lead-modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 24px 20px 18px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  animation: leadPop 0.3s ease;
}

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

.lead-modal-header {
  text-align: center;
  margin-bottom: 16px;
}

.lead-modal-icon {
  font-size: 38px;
  margin-bottom: 6px;
}

.lead-modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.lead-modal-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.lead-modal-benefits {
  background: #f0f9ff;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.benefit-item {
  font-size: 12px;
  color: #0369a1;
  padding: 3px 0;
  line-height: 1.5;
}

.lead-form {
  display: flex;
  flex-direction: column;
}

.lead-phone-input {
  width: 100%;
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  letter-spacing: 1px;
  font-family: inherit;
}

.lead-phone-input:focus {
  border-color: var(--primary);
}

.lead-error {
  min-height: 16px;
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
  line-height: 1.4;
}

.lead-consent {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 4px 0 12px;
  cursor: pointer;
}

.lead-consent input[type="checkbox"] {
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
  width: 14px;
  height: 14px;
}

.lead-consent span {
  flex: 1;
}

.lead-form .btn-primary {
  margin-top: 0;
}

.lead-modal-footer {
  text-align: center;
  font-size: 11px;
  color: #94a3b8;
  margin-top: 12px;
}
