/* ============================================
   血糖健康管理小程序 · 自定义样式系统
   专业医疗风 · 移动端优先
   ============================================ */

:root {
  /* 主题色 */
  --brand: #1E88E5;
  --brand-dark: #1565C0;
  --accent: #00ACC1;
  /* 状态色 */
  --normal: #4CAF50;
  --warn: #FF9800;
  --low: #FFC107;
  --danger: #F44336;
  /* 中性色 */
  --ink: #263238;
  --ink-soft: #546E7A;
  --ink-muted: #90A4AE;
  --canvas: #F5F7FA;
  --card: #FFFFFF;
  --border: #ECEFF1;
}

* {
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  font-family: 'Noto Sans SC', system-ui, sans-serif;
  background: var(--canvas);
  color: var(--ink);
}

/* 数字使用等宽字体，保证对齐 */
.num {
  font-family: 'Roboto Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

/* ============================================
   卡片
   ============================================ */
.card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(38, 50, 56, 0.06);
  transition: box-shadow 0.2s, transform 0.2s;
}
.card-tappable:hover {
  box-shadow: 0 6px 20px rgba(38, 50, 56, 0.10);
}
.card-tappable:active {
  transform: scale(0.98);
}

/* ============================================
   按钮
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.18s;
  cursor: pointer;
  user-select: none;
}
.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 12px rgba(30, 136, 229, 0.30);
}
.btn-primary:hover {
  background: var(--brand-dark);
  box-shadow: 0 6px 16px rgba(30, 136, 229, 0.40);
}
.btn-primary:active {
  transform: translateY(1px);
}
.btn-ghost {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--brand);
}
.btn-ghost:hover {
  background: rgba(30, 136, 229, 0.08);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-soft {
  background: rgba(30, 136, 229, 0.10);
  color: var(--brand);
}

/* 涟漪效果 */
.ripple {
  position: relative;
  overflow: hidden;
}
.ripple::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.5) 0%, transparent 70%);
  opacity: 0;
  transform: scale(0);
  transition: transform 0.5s, opacity 0.5s;
  pointer-events: none;
}
.ripple:active::after {
  opacity: 1;
  transform: scale(2);
  transition: 0s;
}

/* ============================================
   输入控件
   ============================================ */
input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
}
.field {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.field:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.12);
}
.field-area {
  height: auto;
  min-height: 72px;
  padding: 10px 14px;
  resize: vertical;
  line-height: 1.5;
}
.field-num {
  font-family: 'Roboto Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  height: 60px;
}

/* ============================================
   状态徽章与色块
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.badge-normal { background: rgba(76, 175, 80, 0.12); color: var(--normal); }
.badge-warn { background: rgba(255, 152, 0, 0.12); color: var(--warn); }
.badge-low { background: rgba(255, 193, 7, 0.15); color: #F57F17; }
.badge-danger { background: rgba(244, 67, 54, 0.12); color: var(--danger); }

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.dot-normal { background: var(--normal); }
.dot-warn { background: var(--warn); }
.dot-low { background: var(--low); }
.dot-danger { background: var(--danger); }
.dot-empty { background: var(--border); }

/* ============================================
   Tab 指示器
   ============================================ */
.tab-btn {
  position: relative;
}
.tab-btn.active {
  color: var(--brand);
}
.tab-btn.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--brand);
}

/* ============================================
   测量点选择 Tab
   ============================================ */
.mp-tab {
  flex: 0 0 auto;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--ink-soft);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.mp-tab.active {
  background: var(--brand);
  color: #fff;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(30, 136, 229, 0.30);
}

/* ============================================
   日历热力图
   ============================================ */
.cal-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}
.cal-cell:active {
  transform: scale(0.92);
}
.cal-cell.today {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}
.cal-cell.selected {
  box-shadow: 0 0 0 2px var(--brand), 0 4px 10px rgba(30, 136, 229, 0.3);
}
.cal-cell.empty {
  cursor: default;
  color: transparent;
}

/* ============================================
   时间线
   ============================================ */
.timeline {
  position: relative;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding-left: 32px;
}
.timeline-dot {
  position: absolute;
  left: 6px;
  top: 14px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
}

/* ============================================
   动画
   ============================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes countUp {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}
.animate-fade-up { animation: fadeUp 0.4s ease-out both; }
.animate-slide-in { animation: slideIn 0.3s ease-out both; }
.animate-count { animation: countUp 0.5s ease-out both; }
.pulse { animation: pulse 2s infinite; }

/* 错峰入场 */
.stagger > * { animation: fadeUp 0.4s ease-out both; }
.stagger > *:nth-child(1) { animation-delay: 0.04s; }
.stagger > *:nth-child(2) { animation-delay: 0.08s; }
.stagger > *:nth-child(3) { animation-delay: 0.12s; }
.stagger > *:nth-child(4) { animation-delay: 0.16s; }
.stagger > *:nth-child(5) { animation-delay: 0.20s; }
.stagger > *:nth-child(6) { animation-delay: 0.24s; }
.stagger > *:nth-child(7) { animation-delay: 0.28s; }
.stagger > *:nth-child(8) { animation-delay: 0.32s; }

/* ============================================
   Toast
   ============================================ */
.toast {
  background: rgba(38, 50, 56, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(8px);
  animation: fadeUp 0.3s ease-out both;
  max-width: 90vw;
  text-align: center;
}
.toast-success { background: rgba(76, 175, 80, 0.95); }
.toast-warn { background: rgba(255, 152, 0, 0.95); }
.toast-danger { background: rgba(244, 67, 54, 0.95); }

/* ============================================
   模态框
   ============================================ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(38, 50, 56, 0.5);
  backdrop-filter: blur(4px);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeUp 0.2s ease-out;
}
.modal-sheet {
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 14px;
}

/* ============================================
   工具类
   ============================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  text-align: center;
  color: var(--ink-muted);
}
.empty-state .icon-wrap {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(30, 136, 229, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

/* 渐变背景：即时分析卡 */
.grade-bg-normal { background: linear-gradient(135deg, #4CAF50 0%, #66BB6A 100%); }
.grade-bg-warn { background: linear-gradient(135deg, #FF9800 0%, #FFA726 100%); }
.grade-bg-low { background: linear-gradient(135deg, #FFC107 0%, #FFCA28 100%); }
.grade-bg-danger { background: linear-gradient(135deg, #F44336 0%, #EF5350 100%); }
.grade-bg-empty { background: linear-gradient(135deg, #1E88E5 0%, #00ACC1 100%); }

/* 进度环 */
.ring-track { stroke: rgba(0, 0, 0, 0.06); }

/* 滚动条隐藏（移动端体验） */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* 安全区适配 */
.safe-bottom { padding-bottom: env(safe-area-inset-bottom); }
