/* ============================================================
   戒烟打卡系统 - 全局样式 v1.1
   PC端：标准桌面布局（顶部导航 + 居中内容）
   移动端：APP样式（底部Tab导航 + 卡片 + 悬浮打卡按钮）
   ============================================================ */

:root {
  --primary: #16a34a;
  --primary-dark: #15803d;
  --primary-light: #dcfce7;
  --primary-bg: #f0fdf4;
  --danger: #dc2626;
  --warning: #f59e0b;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --bg: #f8fafc;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========== 顶部导航（PC端） ========== */
.topnav {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.topnav .logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.topnav .logo .icon { font-size: 24px; }
.topnav .nav-links {
  display: flex;
  gap: 8px;
  align-items: center;
}
.topnav .nav-links a {
  padding: 8px 16px;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}
.topnav .nav-links a:hover,
.topnav .nav-links a.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  text-decoration: none;
}
.topnav .user-area {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
.topnav .user-area .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

/* ========== 主内容区 ========== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}
.page-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

/* ========== 卡片 ========== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ========== 统计卡片网格 ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
  transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card .num {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}
.stat-card .num.danger { color: var(--danger); }
.stat-card .num.warning { color: var(--warning); }
.stat-card .label {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
}

/* ========== 表单 ========== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22,163,74,0.15);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-hint {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; opacity: 0.9; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========== 表格 ========== */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-light);
  font-size: 13px;
}
tr:hover td { background: var(--primary-bg); }

/* ========== 标签 ========== */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.badge-success { background: var(--primary-light); color: var(--primary-dark); }
.badge-danger { background: #fee2e2; color: var(--danger); }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* ========== 进度条 ========== */
.progress {
  background: var(--border);
  border-radius: 20px;
  height: 12px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #4ade80);
  border-radius: 20px;
  transition: width 0.5s ease;
}
.progress-bar.danger { background: linear-gradient(90deg, var(--danger), #f87171); }

/* ========== 登录/注册页 ========== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #16a34a 0%, #059669 50%, #0d9488 100%);
  padding: 20px;
}
.auth-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 36px;
  width: 100%;
  max-width: 420px;
}
.auth-card .auth-logo {
  text-align: center;
  font-size: 28px;
  margin-bottom: 8px;
}
.auth-card h2 {
  text-align: center;
  font-size: 22px;
  margin-bottom: 6px;
}
.auth-card .auth-sub {
  text-align: center;
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 24px;
}
.auth-card .auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-light);
}

/* 验证码 */
.captcha-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.captcha-row input { flex: 1; }
.captcha-img {
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}

/* ========== 打卡步进器 ========== */
.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 16px 0;
}
.stepper button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: #fff;
  color: var(--primary);
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.stepper button:active { transform: scale(0.92); background: var(--primary-light); }
.stepper .count {
  font-size: 40px;
  font-weight: 700;
  color: var(--primary);
  min-width: 60px;
  text-align: center;
}

/* ========== 底部Tab导航（移动端APP样式） ========== */
.bottom-tab {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
}
.bottom-tab .tab-inner {
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.bottom-tab a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  color: var(--text-light);
  font-size: 11px;
  text-decoration: none;
  transition: color 0.2s;
}
.bottom-tab a .tab-icon {
  font-size: 22px;
  line-height: 1;
}
.bottom-tab a.active {
  color: var(--primary);
  font-weight: 600;
}

/* ========== 悬浮打卡按钮（移动端） ========== */
.fab-record {
  display: none;
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 28px;
  box-shadow: 0 4px 16px rgba(22,163,74,0.4);
  cursor: pointer;
  z-index: 99;
  transition: transform 0.2s;
  align-items: center;
  justify-content: center;
}
.fab-record:active { transform: scale(0.9); }

/* ========== 移动端顶部标题栏 ========== */
.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  background: var(--primary);
  color: #fff;
  padding: 14px 20px;
  font-size: 18px;
  font-weight: 600;
  z-index: 50;
  box-shadow: var(--shadow);
}

/* ========== 健康时间线 ========== */
.timeline {
  position: relative;
  padding-left: 30px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding-bottom: 24px;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -25px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid #fff;
}
.timeline-item.done::before {
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.timeline-item .tl-title {
  font-weight: 600;
  font-size: 15px;
}
.timeline-item.done .tl-title { color: var(--primary-dark); }
.timeline-item .tl-desc {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 2px;
}
.timeline-item.done .tl-desc { color: var(--text); }

/* ========== 成就徽章 ========== */
.achievements {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
}
.achievement {
  text-align: center;
  padding: 16px 8px;
  border-radius: 12px;
  background: var(--bg);
  opacity: 0.4;
}
.achievement.unlocked {
  background: var(--primary-light);
  opacity: 1;
}
.achievement .ach-icon { font-size: 32px; }
.achievement .ach-name {
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
}

/* ========== 日历热力图 ========== */
.calendar-heatmap {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.heat-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  background: var(--border);
  position: relative;
}
.heat-cell.level-1 { background: #bbf7d0; }
.heat-cell.level-2 { background: #4ade80; }
.heat-cell.level-3 { background: #22c55e; }
.heat-cell.level-4 { background: #15803d; }

/* ========== 开关 ========== */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #ccc;
  border-radius: 26px;
  transition: 0.3s;
}
.switch .slider::before {
  content: '';
  position: absolute;
  height: 20px; width: 20px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(22px); }

/* ========== 提示消息 ========== */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
.alert-success { background: var(--primary-light); color: var(--primary-dark); }
.alert-danger { background: #fee2e2; color: var(--danger); }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* ========== 空状态 ========== */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}
.empty .empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ========== 分页 ========== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}
.pagination button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.pagination button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ========== 图表容器 ========== */
.chart-container {
  position: relative;
  height: 300px;
  margin: 16px 0;
}

/* ========== 品牌选择器 ========== */
.brand-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.brand-chip {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  background: #fff;
  transition: all 0.2s;
}
.brand-chip:hover { border-color: var(--primary); }
.brand-chip.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ============================================================
   移动端适配（max-width: 768px）→ APP样式
   ============================================================ */
@media (max-width: 768px) {
  .topnav { display: none; }
  .mobile-header { display: block; }
  .bottom-tab { display: block; }
  .fab-record { display: flex; }

  .container {
    padding: 16px 16px 90px;
    max-width: 100%;
  }
  .page-title { font-size: 20px; margin-bottom: 16px; }
  .card { padding: 16px; border-radius: 14px; margin-bottom: 12px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 16px 10px; }
  .stat-card .num { font-size: 26px; }
  .stat-card .label { font-size: 12px; }
  .form-row { grid-template-columns: 1fr; }
  .form-group input,
  .form-group select,
  .form-group textarea { padding: 12px 14px; font-size: 16px; }
  .btn { padding: 12px 20px; font-size: 15px; }
  .auth-card { padding: 28px 24px; border-radius: 20px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .chart-container { height: 250px; }
  .stepper .count { font-size: 36px; }
  .stepper button { width: 44px; height: 44px; font-size: 22px; }
}

@media (max-width: 380px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card .num { font-size: 22px; }
}
