/* ==========================================
   江河智序 · 管理诊断 H5
   视觉关键词：学术感 + 温暖 + 不装
   ========================================== */

/* --- CSS Variables --- */
:root {
  --deep-blue: #1a365d;
  --deep-blue-light: #2a4a7f;
  --warm-white: #fafaf9;
  --gold: #c9a94e;
  --gold-light: #e0c878;
  --text-primary: #1a1a1a;
  --text-secondary: #5a5a5a;
  --text-muted: #8a8a8a;
  --border-color: #e8e6e1;
  --card-bg: #ffffff;
  --bubble-bg: #f3f2ee;
  --danger: #c44;
  --success: #3a8;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, sans-serif;
  --font-mono: "SF Mono", "Menlo", "Courier New", monospace;
}

/* --- Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--warm-white);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* --- App Container --- */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* --- Page System --- */
.page {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 20px 32px;
  animation: fadeIn 0.3s ease;
}

.page.active {
  display: block;
}

.page-inner {
  max-width: 420px;
  margin: 0 auto;
}

.page-center {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

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

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

@keyframes progressPulse {
  0%   { width: 0%; }
  30%  { width: 35%; }
  60%  { width: 65%; }
  85%  { width: 90%; }
  100% { width: 100%; }
}

/* --- Header --- */
.page-header {
  margin-bottom: 28px;
}

.brand-tag {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold);
  background: rgba(201, 169, 78, 0.1);
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.step-indicator {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--deep-blue);
  line-height: 1.35;
  margin-bottom: 8px;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* --- Textarea --- */
.input-area {
  position: relative;
  margin-bottom: 20px;
}

.pain-textarea {
  width: 100%;
  padding: 16px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  resize: none;
  outline: none;
  background: var(--card-bg);
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.pain-textarea:focus {
  border-color: var(--deep-blue);
}

.pain-textarea::placeholder {
  color: var(--text-muted);
}

.char-count {
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Quick Tags --- */
.quick-tags {
  margin-bottom: 24px;
}

.tags-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.tags-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-block;
  padding: 8px 16px;
  font-size: 0.88rem;
  font-family: var(--font-sans);
  color: var(--deep-blue);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.tag:active {
  transform: scale(0.96);
}

.tag.selected {
  background: var(--deep-blue);
  color: #fff;
  border-color: var(--deep-blue);
}

.tag-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 6px 0 0;
}

/* --- Option Buttons --- */
.select-group {
  margin-bottom: 24px;
}

.select-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.option-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-grid.cols-2 .option-btn {
  flex: 0 0 calc(50% - 4px);
}

.option-btn {
  padding: 10px 20px;
  font-size: 0.9rem;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.option-btn:active {
  transform: scale(0.96);
}

.option-btn.selected {
  background: var(--deep-blue);
  color: #fff;
  border-color: var(--deep-blue);
}

.other-input {
  width: 100%;
  margin-top: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.2s;
}

.other-input:focus {
  border-color: var(--deep-blue);
}

/* --- Buttons --- */
.page-actions {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.followup-actions {
  margin-top: 32px;
  text-align: center;
}

.btn {
  display: inline-block;
  padding: 12px 28px;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

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

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

.btn:disabled:active {
  transform: none;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--deep-blue);
  color: #fff;
}

.btn-primary:not(:disabled):hover {
  background: var(--deep-blue-light);
}

.btn-secondary {
  background: var(--card-bg);
  color: var(--deep-blue);
  border: 1.5px solid var(--deep-blue);
}

.btn-outline {
  background: transparent;
  color: var(--deep-blue);
  border: 1.5px solid var(--deep-blue);
}

.btn-text {
  background: transparent;
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.85rem;
  padding: 8px 16px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.85rem;
}

/* --- Chat / Follow-up --- */
.chat-area {
  margin-top: 16px;
}

.chat-bubble {
  margin-bottom: 24px;
}

.ai-bubble {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.bubble-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--deep-blue);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bubble-content {
  background: var(--bubble-bg);
  border-radius: var(--radius-md);
  border-top-left-radius: 4px;
  padding: 14px 16px;
  max-width: 85%;
}

.bubble-content p {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-primary);
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-left: 46px;
}

.option-btn.followup-option {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.option-btn.followup-option.selected {
  background: var(--deep-blue);
  color: #fff;
  border-color: var(--deep-blue);
}

/* --- Generating --- */
.generating-container {
  padding: 40px 20px;
}

.brain-icon {
  font-size: 3rem;
  margin-bottom: 20px;
  animation: pulse 2s infinite;
}

.generating-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--deep-blue);
  margin-bottom: 24px;
}

.progress-bar {
  width: 100%;
  max-width: 280px;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  margin: 0 auto 16px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--deep-blue);
  border-radius: 2px;
  width: 0%;
  animation: progressPulse 4s ease-in-out infinite;
}

.generating-status {
  font-size: 0.85rem;
  color: var(--text-muted);
  animation: pulse 2.5s infinite;
}

/* --- Report --- */
.report-header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.report-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--deep-blue);
}

.report-meta {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.report-meta .meta-item {
  margin-bottom: 6px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.report-meta .meta-label {
  font-weight: 600;
  color: var(--deep-blue);
}

.report-meta .framework-tag {
  display: inline-block;
  background: rgba(201, 169, 78, 0.12);
  color: var(--gold);
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  margin: 2px 4px 2px 0;
}

.report-section {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--deep-blue);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1.5px solid var(--border-color);
}

.report-section p {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.report-section p:last-child {
  margin-bottom: 0;
}

.suggestion-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-num {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  background: var(--deep-blue);
  color: #fff;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 8px;
  flex-shrink: 0;
}

.suggestion-title {
  font-weight: 600;
  color: var(--deep-blue);
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.suggestion-detail {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.academic-ref {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 10px;
  background: var(--bubble-bg);
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

/* --- Lead Capture --- */
.lead-capture {
  border: 1px dashed var(--gold);
  background: rgba(201, 169, 78, 0.04);
}

.lead-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.lead-form {
  display: flex;
  gap: 8px;
}

.lead-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font-sans);
  outline: none;
}

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

.lead-confirm {
  color: var(--success) !important;
  font-size: 0.85rem !important;
  margin-top: 8px;
}

.lead-benefits {
  text-align: left;
  margin: 10px 0;
  padding-left: 20px;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.8;
}

/* QR Code */
.qr-section {
  text-align: center;
  margin: 16px 0;
}
.qr-code {
  width: 180px;
  height: 180px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.qr-hint {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.lead-form-alt {
  border-top: 1px solid #e5e7eb;
  margin-top: 12px;
  padding-top: 4px;
}

/* --- Radar Chart --- */
.radar-container {
  max-width: 300px;
  margin: 0 auto;
}

/* --- Footer --- */
.report-footer {
  text-align: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.report-footer p {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.footer-disclaimer {
  font-size: 0.72rem !important;
  margin-top: 4px;
}

/* --- Error / Offline Banner --- */
.offline-banner {
  background: #fff8e6;
  border: 1px solid #e6c878;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: #8a6d20;
  line-height: 1.5;
}

/* --- Restart Link --- */
.restart-link {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  margin-top: 12px;
  text-align: center;
}

/* --- Responsive: iPad / larger screens --- */
@media (min-width: 600px) {
  #app {
    max-width: 520px;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
  }

  .page {
    padding: 32px 28px 40px;
  }

  .page-title {
    font-size: 1.6rem;
  }
}

@media (min-width: 768px) {
  #app {
    max-width: 600px;
  }

  .page {
    padding: 40px 36px 48px;
  }

  .page-title {
    font-size: 1.7rem;
  }

  .options-list {
    max-width: 80%;
  }
}

/* --- Utility --- */
.text-center { text-align: center; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
