/* ═══════════════ 全局变量与基础 ═══════════════ */
:root {
  --primary: #1a3a5c;
  --primary-light: #2d5f8a;
  --gold: #b8943e;
  --gold-light: #f5f0e6;
  --bg: #f7f6f3;
  --white: #ffffff;
  --text: #2c2c2c;
  --text-light: #666;
  --border: #e0dcd4;
  --danger: #c0392b;
  --success: #27ae60;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  max-width: 750px;
  margin: 0 auto;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ═══════════════ 顶部：律师品牌 ═══════════════ */
.header {
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.lawyer-info { display: flex; align-items: center; gap: 10px; }
.lawyer-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--gold);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
  flex-shrink: 0;
}
.lawyer-name { font-size: 15px; font-weight: 600; }
.lawyer-license { font-size: 11px; opacity: 0.8; margin-top: 1px; }
.header-link {
  color: var(--gold-light);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
}

/* ═══════════════ 主容器 ═══════════════ */
.main-container {
  padding: 20px 16px 80px;
}

/* ═══════════════ Step 1: 选择页 ═══════════════ */
.step-header { text-align: center; padding: 20px 0 24px; }
.page-title { font-size: 24px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.page-subtitle { color: var(--text-light); font-size: 14px; line-height: 1.6; }

.category-section { margin-bottom: 24px; }
.category-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-light);
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

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

.type-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  text-align: center;
  border: 2px solid transparent;
}
.type-card:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}
.type-icon { font-size: 32px; margin-bottom: 8px; }
.type-name { font-size: 15px; font-weight: 600; color: var(--primary); margin-bottom: 4px; }
.type-desc { font-size: 12px; color: var(--text-light); line-height: 1.4; }

.trust-bar {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 24px;
  padding: 16px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.trust-item { font-size: 13px; color: var(--text-light); font-weight: 500; }

/* ═══════════════ Step 2: 表单页 ═══════════════ */
.btn-back {
  background: none;
  border: none;
  color: var(--primary-light);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: 12px;
}
.form-title { font-size: 20px; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.form-desc { color: var(--text-light); font-size: 13px; margin-bottom: 20px; }

.questions-container { margin-bottom: 24px; }

.form-field {
  margin-bottom: 18px;
  background: var(--white);
  padding: 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}
.field-num {
  display: inline-block;
  width: 22px; height: 22px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  text-align: center;
  font-size: 12px;
  line-height: 22px;
  margin-right: 6px;
}
.field-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #fafaf8;
  transition: border-color 0.2s;
  outline: none;
}
.field-input:focus { border-color: var(--primary-light); background: #fff; }
.field-input::placeholder { color: #bbb; }
.field-textarea { resize: vertical; min-height: 80px; }

.form-note { text-align: center; font-size: 12px; color: #999; margin-top: 12px; }

/* ═══════════════ 按钮 ═══════════════ */
.btn-primary {
  display: inline-block;
  padding: 14px 32px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s;
  text-decoration: none;
}
.btn-primary:active { background: var(--primary-light); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { display: block; width: 100%; }

.btn-outline {
  display: inline-block;
  padding: 14px 24px;
  background: var(--white);
  color: var(--primary);
  font-size: 15px;
  font-weight: 500;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
}
.btn-text {
  display: block;
  width: 100%;
  padding: 12px;
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 14px;
  cursor: pointer;
  margin-top: 16px;
}

/* ═══════════════ Step 3: 生成中 ═══════════════ */
.loading-container {
  text-align: center;
  padding: 80px 20px;
}
.spinner {
  width: 48px; height: 48px;
  margin: 0 auto 24px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-title { font-size: 18px; color: var(--primary); margin-bottom: 8px; }
#loading-sub { color: var(--text-light); font-size: 14px; }

/* ═══════════════ Step 4: 预览页 ═══════════════ */
.preview-title { font-size: 18px; text-align: center; color: var(--primary); margin-bottom: 16px; }

.preview-paper {
  background: #fff;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  padding: 20px 16px;
  border-radius: 4px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 2;
  position: relative;
  overflow: auto;
  max-height: 60vh;
  -webkit-overflow-scrolling: touch;
}

/* 水印 */
.watermarked {
  position: relative;
}
.watermarked::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 100px,
    rgba(0,0,0,0.04) 100px,
    rgba(0,0,0,0.04) 102px
  );
  pointer-events: none;
}

/* 预览区内的标题修正 */
.preview-content h1 { font-size: 18px !important; }
.preview-content h3 { font-size: 15px !important; }
.preview-content table { font-size: 12px !important; width: 100% !important; }
.preview-content table td, .preview-content table th {
  padding: 4px 6px !important;
}
.preview-content p { margin: 4px 0 !important; }

.preview-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}
.preview-actions .btn-outline { flex: 1; }
.preview-actions .btn-primary { flex: 2; }

.download-area {
  background: #f0f9f4;
  border: 2px solid var(--success);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin-bottom: 12px;
}
.download-success { color: var(--success); font-weight: 600; font-size: 16px; margin-bottom: 12px; }

/* 知识库入口 */
.baike-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
  box-shadow: var(--shadow);
  text-decoration: none;
}
.baike-icon { font-size: 28px; }
.baike-text { flex: 1; display: flex; flex-direction: column; }
.baike-text strong { font-size: 15px; color: var(--primary); }
.baike-text span { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.baike-link {
  font-size: 13px;
  color: var(--primary-light);
  text-decoration: none;
  white-space: nowrap;
  font-weight: 500;
}

/* 分享区 */
.share-section {
  text-align: center;
  padding: 16px;
  margin-bottom: 8px;
}
.share-hint { font-size: 13px; color: var(--text-light); margin-bottom: 10px; }
.share-buttons { display: flex; gap: 10px; justify-content: center; }
.share-btn {
  padding: 10px 20px;
  border-radius: 20px;
  border: none;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}
.wechat-btn { background: #07c160; color: #fff; }
.copy-btn { background: var(--white); color: var(--text); border: 1px solid var(--border); }
.share-btn:active { opacity: 0.8; }
.copy-toast {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: 20px;
  font-size: 13px;
}

/* ═══════════════ Step 5: 支付页 ═══════════════ */
.payment-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  margin: 20px 0;
}
.payment-item {
  display: flex;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.payment-price {
  text-align: center;
  padding: 24px 20px;
  color: var(--danger);
}
.price-symbol { font-size: 20px; }
.price-num { font-size: 48px; font-weight: 700; }
.payment-features { padding: 16px 20px; border-top: 1px solid var(--border); }
.feature-item { font-size: 13px; color: var(--text-light); padding: 6px 0; }

.payment-success { text-align: center; padding: 40px 20px; }
.success-icon {
  width: 64px; height: 64px;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin: 0 auto 20px;
}
.payment-success h3 { font-size: 20px; margin-bottom: 8px; }
.payment-success p { color: var(--text-light); margin-bottom: 24px; }

/* 收款二维码 */
.qr-section {
  text-align: center;
  padding: 16px;
  margin: 16px 0;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.qr-title { font-size: 15px; font-weight: 600; color: var(--primary); margin-bottom: 12px; }
.qr-image { max-width: 220px; border-radius: 8px; margin: 0 auto; display: block; }
.qr-loading { color: #999; font-size: 13px; padding: 30px 0; }
.qr-hint { font-size: 12px; color: #999; margin-top: 12px; line-height: 1.8; }

/* 付款验证码 */
.verify-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
  box-shadow: var(--shadow);
  text-align: center;
}
.verify-label { font-size: 14px; font-weight: 600; color: var(--primary); display: block; margin-bottom: 10px; }
.verify-input {
  width: 180px;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  text-align: center;
  outline: none;
}
.verify-input:focus { border-color: var(--primary-light); }
.verify-hint { font-size: 11px; color: #999; margin-top: 6px; }

/* ═══════════════ 底部 ═══════════════ */
.footer {
  background: var(--primary);
  color: rgba(255,255,255,0.8);
  padding: 20px 16px;
  text-align: center;
}
.footer-brand { font-size: 13px; margin-bottom: 8px; }
.footer-disclaimer { font-size: 11px; opacity: 0.6; line-height: 1.6; }

/* ═══════════════ 响应式 ═══════════════ */
@media (min-width: 500px) {
  .type-grid { grid-template-columns: repeat(3, 1fr); }
  .preview-paper { padding: 32px 24px; }
}
@media (min-width: 750px) {
  body { padding: 0; }
  .main-container { padding: 28px 0 100px; }
  .type-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .preview-paper { padding: 40px 36px; }
}
