/* 营养素服用计划 H5 · 极简骨架样式 */

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; background: #f7f8fa; color: #1f2329; -webkit-font-smoothing: antialiased; }
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; background: #fff; }

/* ============ 进度条 ============ */
.progress-header {
  position: sticky; top: 0; z-index: 10;
  background: #fff; padding: 12px 20px; border-bottom: 1px solid #eaecf0;
}
.progress-bar { height: 6px; background: #eaecf0; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #ff9500, #ff6b35); transition: width 0.3s; }
.progress-text { margin-top: 8px; font-size: 13px; color: #6b7280; }

/* ============ Step ============ */
.step { display: none; }
.step.active { display: block; }
.step-content { padding: 24px 20px 40px; }

h1 { font-size: 24px; font-weight: 600; margin-bottom: 8px; }
h2 { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
h3 { font-size: 16px; font-weight: 600; margin: 16px 0 8px; }
h4 { font-size: 14px; font-weight: 600; margin: 12px 0 6px; }
.lead { font-size: 14px; color: #4b5563; line-height: 1.6; margin-bottom: 24px; }
.hint { font-size: 12px; color: #9ca3af; margin-top: 6px; line-height: 1.5; }

/* ============ 表单 ============ */
.form-group { margin-bottom: 24px; }
.form-label-question { display: block; font-size: 15px; font-weight: 500; margin-bottom: 10px; line-height: 1.5; }
.form-label-question small { display: block; font-size: 12px; color: #9ca3af; font-weight: 400; margin-top: 4px; }
.form-label-section { display: block; font-size: 14px; font-weight: 500; color: #374151; margin-bottom: 10px; }

.radio-group { display: flex; gap: 16px; }
.radio-group label { display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 8px 16px; border: 1px solid #e5e7eb; border-radius: 8px; }
.radio-group input { margin: 0; }

.time-input, .text-input {
  width: 100%; padding: 12px 16px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 16px;
  font-family: inherit; background: #fff;
}
.time-input:focus, .text-input:focus { outline: 2px solid #ff9500; border-color: transparent; }

/* ============ Chip 多选 ============ */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  display: inline-block; padding: 8px 16px; background: #f3f4f6; border-radius: 999px;
  font-size: 14px; color: #4b5563; cursor: pointer; user-select: none;
  transition: all 0.15s;
}
.chip:active { transform: scale(0.96); }
.chip.active { background: #ff9500; color: #fff; }

/* ============ SKU 折叠列表 ============ */
.sku-category {
  margin-bottom: 8px; border: 1px solid #e5e7eb; border-radius: 8px; padding: 0;
  background: #fafbfc;
}
.sku-category summary {
  padding: 12px 16px; font-weight: 500; cursor: pointer; user-select: none;
  display: flex; align-items: center;
}
.sku-category summary::-webkit-details-marker { display: none; }
.sku-category summary::before {
  content: "▸"; margin-right: 8px; transition: transform 0.2s;
}
.sku-category[open] summary::before { transform: rotate(90deg); }
.sku-list { padding: 0 16px 12px; }
.sku-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-top: 1px solid #f3f4f6; cursor: pointer;
}
.sku-item input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; flex-shrink: 0; }
.sku-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sku-line1 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sku-name { font-size: 14px; color: #111; }
.sku-en { font-size: 12px; color: #9ca3af; font-style: italic; }
.sku-brand { font-size: 12px; color: #9ca3af; }
.sku-item.out-of-stock { opacity: 0.5; }
.badge { font-size: 11px; padding: 2px 6px; background: #fee2e2; color: #991b1b; border-radius: 4px; flex-shrink: 0; }

/* ============ 外购品 ============ */
.external-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.external-row .text-input { flex: 1; padding: 10px 12px; }

/* SKU 搜索框 */
#sku-search {
  margin-bottom: 12px;
  padding: 10px 14px;
  font-size: 14px;
  background: #f9fafb;
}
#sku-search:focus { background: #fff; }
.slot-select { padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; background: #fff; }
.btn-icon {
  width: 32px; height: 32px; border-radius: 16px; border: 1px solid #d1d5db;
  background: #fff; cursor: pointer; font-size: 16px; line-height: 1;
}

/* ============ 按钮 ============ */
.actions { margin-top: 32px; display: flex; gap: 12px; }
.btn-primary, .btn-secondary, .btn-link {
  flex: 1; padding: 14px 24px; border-radius: 8px; font-size: 16px; font-weight: 500;
  border: none; cursor: pointer; font-family: inherit;
}
.btn-primary { background: linear-gradient(90deg, #ff9500, #ff6b35); color: #fff; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary { background: #f3f4f6; color: #374151; }
.btn-link {
  flex: none; padding: 8px 0; background: transparent; color: #ff6b35;
  text-align: left; font-size: 14px; font-weight: normal;
}

/* ============ 固定底部步骤导航（微信端核心体验） ============ */
.step-nav-sticky {
  position: sticky; bottom: 0; left: 0; right: 0;
  display: flex; gap: 12px;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
  z-index: 50;
}
.step-nav-sticky .btn-primary,
.step-nav-sticky .btn-secondary {
  flex: 1; padding: 12px 16px; font-size: 15px;
}
/* 占位避免内容被固定按钮挡住 */
.sticky-spacer { height: 80px; }

/* ============ 搜索框 + 清空按钮 ============ */
.search-wrapper { position: relative; }
.search-wrapper .text-input { padding-right: 40px; }
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 14px; border: none;
  background: #d1d5db; color: #fff; font-size: 18px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.search-clear:active { background: #9ca3af; }

/* ============ 已选 N 项胶囊（顶部固定） ============ */
.selected-summary {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; margin: 0 0 12px;
  background: linear-gradient(90deg, #fff7ed, #fef3c7);
  border-radius: 24px;
  border: 1px solid #fbbf24;
  cursor: pointer;
  font-size: 14px;
  color: #92400e;
  box-shadow: 0 2px 6px rgba(251, 191, 36, 0.2);
}
.selected-summary-count strong { font-size: 18px; color: #d97706; margin: 0 4px; }
.selected-summary-arrow { font-size: 16px; transition: transform 0.2s; }
.selected-summary.expanded .selected-summary-arrow { transform: rotate(180deg); }
.selected-list {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 8px 12px; margin-bottom: 12px;
}
.selected-list-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-top: 1px solid #f3f4f6; font-size: 14px;
}
.selected-list-item:first-child { border-top: none; }
.selected-list-item .name { flex: 1; color: #111; }
.selected-list-item .remove {
  color: #dc2626; background: none; border: none; cursor: pointer;
  font-size: 14px; padding: 4px 8px;
}
.selected-list-empty { color: #9ca3af; text-align: center; padding: 12px; font-size: 14px; }

/* ============ 锌摄入实时计数（Step 4） ============ */
.zinc-meter {
  padding: 12px 14px; border-radius: 8px; margin: 8px 0 16px; font-size: 13px;
  border: 1px solid; line-height: 1.5;
}
.zinc-meter-head { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.zinc-meter-head strong { font-size: 16px; }
.zinc-meter-sources { color: #555; margin-top: 4px; font-size: 12px; }
.zinc-meter-hint { color: #6b7280; margin-top: 6px; font-size: 12px; }
.zinc-meter-notice {
  background: #eff6ff; border-color: #bfdbfe; color: #1e3a8a;
}
.zinc-meter-warning {
  background: #fffbeb; border-color: #fcd34d; color: #92400e;
}
.zinc-meter-warning .zinc-meter-hint { color: #b45309; }
.zinc-meter-danger {
  background: #fef2f2; border-color: #fca5a5; color: #7f1d1d;
}
.zinc-meter-danger .zinc-meter-hint { color: #b91c1c; }

/* ============ 警示框 ============ */
.warning-box-red {
  background: #fef2f2; border-left: 4px solid #dc2626; padding: 16px;
  border-radius: 6px; margin: 16px 0; color: #7f1d1d;
}
.warning-box-yellow {
  background: #fffbeb; border-left: 4px solid #f59e0b; padding: 16px;
  border-radius: 6px; margin: 16px 0; color: #78350f;
}
.hint-box {
  background: #eff6ff; border-left: 4px solid #3b82f6; padding: 16px;
  border-radius: 6px; margin: 16px 0; color: #1e40af;
}
.notice-card {
  background: #f0fdf4; border: 1px solid #bbf7d0; padding: 12px 16px;
  border-radius: 6px; color: #166534; font-size: 13px; line-height: 1.6;
}

.warning-box-red p, .warning-box-yellow p, .hint-box p { margin: 4px 0; line-height: 1.5; font-size: 14px; }

/* ============ 时间表（4 列：时间节点 / 营养素 / 剂量 / 注意事项） ============ */
/* 微信 WebView 在 border-collapse:collapse + rowspan 下会漏画竖向 border。
   改用 separate + 给每个单元格画上下左右四边的方案最稳。 */
.schedule {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 16px 0;
  font-size: 13px;
  table-layout: fixed;
  border-top: 1px solid #d1d5db;
  border-left: 1px solid #d1d5db;
}
.schedule th, .schedule td {
  padding: 8px 6px;
  text-align: left;
  vertical-align: middle;
  border-right: 1px solid #d1d5db;
  border-bottom: 1px solid #d1d5db;
  word-wrap: break-word;
  overflow: hidden;
}
.schedule th {
  background: #f9fafb;
  font-weight: 600;
  font-size: 12px;
  color: #4b5563;
}
/* rowspan 合并的"时段"格背景浅灰，强化分组视觉。v4 列宽：时段+剂量再压缩，把空间留给营养素+注意事项 */
.col-timing {
  width: 10%;
  font-weight: 500;
  color: #1f2937;
  background: #fafbfc;
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
  padding: 8px 2px;
}
.col-name {
  width: 30%;
  color: #1f2937;
  vertical-align: top;
  white-space: normal;
  word-break: break-all;
  line-height: 1.4;
}
.col-dose {
  width: 13%;
  color: #4b5563;
  vertical-align: top;
  font-size: 12px;
  text-align: center;
  padding: 8px 2px;
}
.col-note {
  width: 47%;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.5;
  vertical-align: top;
  white-space: normal;
  word-break: break-word;
}

/* ============ 时间表（子时段卡片版） ============ */
.schedule-cards { margin: 16px 0; }
.meal-block {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
}
.meal-head {
  background: #f9fafb;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 15px;
  color: #1f2937;
  border-bottom: 1px solid #e5e7eb;
}
.meal-time { color: #6b7280; font-weight: 500; font-variant-numeric: tabular-nums; }
.sub-block {
  display: flex;
  padding: 10px 14px;
  border-bottom: 1px solid #f3f4f6;
  align-items: flex-start;
}
.sub-block:last-child { border-bottom: none; }
.sub-label {
  flex: 0 0 48px;
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
  padding-top: 2px;
}
.sub-items {
  flex: 1;
  font-size: 14px;
  line-height: 1.7;
  color: #1f2937;
}
.sku-line {
  display: inline-block;
  margin-right: 8px;
}
.sku-line + .sku-line::before {
  content: " · ";
  color: #d1d5db;
  margin-right: 4px;
}
.badge-topical {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  font-size: 11px;
  background: #fef3c7;
  color: #92400e;
  border-radius: 4px;
  vertical-align: middle;
}

/* ============ 行动指南 & CTA ============ */
.action-tips { background: #fafbfc; padding: 16px; border-radius: 8px; margin: 24px 0; }
.action-tips ol { padding-left: 20px; line-height: 1.8; font-size: 14px; }

.upgrade-cta {
  margin-top: 32px; padding: 20px; border-radius: 12px;
  background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%);
  border: 1px solid #fde68a;
}
.upgrade-cta h3 { color: #78350f; }
.upgrade-cta p { font-size: 14px; line-height: 1.7; color: #5b3408; margin: 8px 0 16px; }

/* ============ 加载 / 错误 ============ */
.loading-wrapper, .error-wrapper { text-align: center; padding: 48px 20px; }
.spinner {
  width: 32px; height: 32px; margin: 0 auto 16px;
  border: 3px solid #f3f4f6; border-top-color: #ff9500; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
.text-center { text-align: center; }
.big-icon { font-size: 56px; margin-bottom: 16px; }

/* ============ Toast ============ */
.global-toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  padding: 12px 20px; border-radius: 8px;
  background: rgba(220, 38, 38, 0.92); color: #fff; font-size: 14px;
  max-width: 90vw; z-index: 100; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.global-toast[data-type="success"] { background: rgba(34, 197, 94, 0.92); }
.global-toast[data-type="info"] { background: rgba(59, 130, 246, 0.92); }

/* ============ 截图 footer ============ */
.snapshot-footer {
  text-align: center; padding: 16px 0 8px;
  color: #9ca3af; font-size: 11px; letter-spacing: 0.5px;
  border-top: 1px dashed #e5e7eb; margin-top: 24px;
}

/* ============ 移动端微调 ============ */
@media (max-width: 480px) {
  .step-content { padding: 20px 16px 32px; }
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
  .chip { padding: 7px 14px; font-size: 13px; }
  .schedule { font-size: 13px; }
  .schedule th, .schedule td { padding: 8px 6px; }
}
