/* health-tracker — 性冷淡风 */

:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --text-muted: #999;
  --border: #e8e8e8;
  --accent: #eef1f5;
  --accent-hover: #e2e6ec;
  --chip-active: #2c3e50;
  --chip-text: #fff;
  --danger: #c0392b;
  --danger-bg: #fdf0ef;
  --success: #27ae60;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Noto Serif SC', 'Songti SC', 'SimSun', serif;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
}

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

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* 导航 */
.nav {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-btn {
  flex: 1;
  min-width: fit-content;
  padding: 12px 8px;
  border: none;
  background: none;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.nav-btn.active {
  color: var(--text);
  border-bottom-color: var(--text);
  font-weight: 500;
}

/* 内容区 */
.content {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

/* 卡片 */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card-ghost {
  border-style: dashed;
  background: #fafafa;
}

.card-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

/* 表单字段 */
.field {
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.2s;
}

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

.field-textarea {
  resize: vertical;
  min-height: 60px;
}

.date-input {
  border: none;
  font-size: 20px;
  font-family: var(--font-serif);
  font-weight: 500;
  padding: 4px 0;
  flex: 1;
}

.date-input:focus { outline: none; }

/* Chip 选择器 */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-sans);
}

.chip:hover { background: var(--accent); }

.chip.active {
  background: var(--chip-active);
  color: var(--chip-text);
  border-color: var(--chip-active);
}

.chip-toggle.active {
  background: var(--chip-active);
  color: var(--chip-text);
  border-color: var(--chip-active);
}

/* 按钮 */
.btn {
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  background: var(--bg);
  color: var(--text);
  transition: all 0.2s;
  font-family: var(--font-sans);
}

.btn:hover { background: var(--accent); }

.btn-primary {
  background: var(--chip-active);
  color: var(--chip-text);
  border-color: var(--chip-active);
}

.btn-primary:hover { opacity: 0.9; }

.btn-ghost {
  border: none;
  background: none;
  color: var(--text-muted);
}

.btn-ghost:hover { color: var(--text); background: none; }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-bg);
}

.btn-danger:hover { opacity: 0.8; }

/* 保存状态 */
.save-status {
  font-size: 12px;
  color: var(--success);
  opacity: 0;
  transition: opacity 0.3s;
}

.save-status.visible { opacity: 1; }

/* 预览行 */
.preview-row {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.preview-label {
  color: var(--text-muted);
  font-size: 11px;
}

.preview-val {
  font-weight: 500;
  margin-right: 12px;
}

/* 图表 */
.chart-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 8px;
}

.chart-month {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 500;
  min-width: 120px;
  text-align: center;
}

.chart-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.chart-wrap canvas {
  max-height: 280px;
}

.chart-legend {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.legend-item { display: flex; align-items: center; gap: 4px; }

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-fmt1 { background: #f1c40f; }
.dot-fmt2 { background: #e67e22; }
.dot-dqt { background: #9b59b6; }

/* 药物色条 */
.medicine-strip {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 2px;
}

.medicine-strip .seg-fmt1 { background: #f1c40f; }
.medicine-strip .seg-fmt2 { background: #e67e22; }
.medicine-strip .seg-dqt { background: #9b59b6; }

/* 时间轴 */
.timeline {
  margin-top: 20px;
  position: relative;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-left: 24px;
  margin-bottom: 24px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--chip-active);
}

.timeline-date {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
}

.timeline-memo {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.5;
}

.timeline-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.timeline-check-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--text-muted);
}

.timeline-photos {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.timeline-photos img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border);
}

.timeline-actions {
  margin-top: 8px;
}

.timeline-actions .btn {
  font-size: 11px;
  padding: 4px 10px;
}

/* 检查数值卡片 */
.exam-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  background: var(--bg);
}

.exam-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  cursor: pointer;
}

.exam-card-date {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 500;
}

.exam-card-toggle {
  font-size: 12px;
  color: var(--text-muted);
}

.exam-indicator-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #f5f5f5;
  font-size: 13px;
}

.exam-indicator-name { color: var(--text-muted); }

.exam-indicator-val { font-weight: 500; }

.exam-indicator-val.abnormal { color: var(--danger); }

.exam-indicator-ref {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 6px;
}

/* 弹窗 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal {
  background: var(--bg);
  border-radius: 12px 12px 0 0;
  padding: 24px 20px 32px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
}

.modal-wide { max-width: 720px; }

.modal h3 {
  font-family: var(--font-serif);
  font-size: 17px;
  margin-bottom: 20px;
}

/* 照片预览 */
.photo-previews {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.photo-previews .preview-img-wrap {
  position: relative;
  width: 80px;
  height: 80px;
}

.photo-previews img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.photo-previews .remove-photo {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  border: none;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 导出 */
.export-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

/* 打印样式 */
@media print {
  body {
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .nav, .btn, .card-actions, .modal-overlay, .chart-controls, .export-actions,
  .timeline-actions, #import-file, #import-preview, .exam-card-toggle,
  .exam-card-header { display: none !important; }
  .content { max-width: 100%; padding: 0; }
  .card { border: none; box-shadow: none; padding: 10px 0; }
  .chart-wrap canvas { max-height: 400px; }
  .field-input { border: none; padding: 4px 0; }
  .chip.active { background: #333 !important; color: #fff !important; }
}

/* 导入预览 */
.import-preview-section {
  margin: 16px 0;
}

.import-preview-section h4 {
  font-family: var(--font-serif);
  font-size: 14px;
  margin-bottom: 8px;
}

.import-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.import-preview-table th,
.import-preview-table td {
  padding: 6px 8px;
  border: 1px solid var(--border);
  text-align: left;
}

.import-preview-table th {
  background: #fafafa;
  font-weight: 500;
}

/* 通用 */
.muted { color: var(--text-muted); font-size: 14px; }

h3 {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
}

/* 服药色条 */
.med-strips {
  margin-top: 8px;
  padding: 0 4px;
}

.med-strip-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 1px 0;
}

.med-strip-label {
  font-size: 10px;
  color: var(--text-muted);
  min-width: 44px;
  text-align: right;
}

.timeline-followup {
  font-size: 13px;
  color: #2c3e50;
  background: #eef1f5;
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 6px;
}

/* 移动端适配 */
@media (max-width: 480px) {
  .content { padding: 16px 12px 60px; }
  .nav-btn { font-size: 12px; padding: 10px 6px; }
  .card { padding: 16px; }
  .modal { padding: 20px 16px 28px; }
  .chart-wrap canvas { max-height: 220px; }
}

/* 照片大图 */
.photo-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.photo-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
}
