/* ============================================================
   style.css - 每日计划助手 (v2.0 Premium Edition)
   亮点：毛玻璃(Glassmorphism)、平滑动效、响应式增强、暖色调美学
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap');

:root {
  /* 调色盘 - 暖橙/米白/军绿 */
  --color-primary: #E8703A;
  --color-primary-rgb: 232, 112, 58;
  --color-primary-light: #F5A855;
  --color-primary-dark: #C8521A;
  --color-secondary: #4A9B8E;
  --color-accent: #E8A830;
  --color-success: #67C23A;
  --color-danger: #F56C6C;

  --bg-main: #FFF8F2;
  --bg-glass: rgba(255, 255, 255, 0.75);
  --bg-card: #FFFFFF;
  --bg-input: rgba(255, 255, 255, 0.9);
  
  --text-primary: #3D2B1E;
  --text-secondary: #7A5C45;
  --text-muted: #B0947A;
  --text-inverse: #FFFFFF;

  --border-color: rgba(232, 112, 58, 0.15);
  --shadow-soft: 0 8px 30px rgba(232, 112, 58, 0.08);
  --shadow-md: 0 12px 40px rgba(232, 112, 58, 0.12);
  --shadow-inner: inset 0 2px 4px rgba(0,0,0,0.02);

  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-full: 999px;

  --nav-height: 72px;
  --header-height: 64px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --safe-bottom: env(safe-area-inset-bottom);
}

/* 夜间模式 - 暖棕色 */
body.theme-night {
  --bg-main: #1D1610;
  --bg-glass: rgba(45, 34, 24, 0.85);
  --bg-card: #2D2218;
  --bg-input: #3D2B1E;
  --text-primary: #F5E8DC;
  --text-secondary: #C8B09A;
  --text-muted: #8A705A;
  --border-color: rgba(232, 112, 58, 0.2);
  --shadow-soft: 0 8px 30px rgba(0, 0, 0, 0.4);
}

/* ==================== 基础重置 ==================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Outfit', 'Noto Sans SC', sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none; /* 防止长按选中文本 */
}

/* ==================== 毛玻璃通用类 ==================== */
.glass {
  background: var(--bg-glass);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  border: 1px solid var(--border-color);
}

/* ==================== 布局 ==================== */
.app-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-height);
  padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  z-index: 1000;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 4px 20px rgba(0,0,0,0.02);
}

.header-title { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }
.header-date { font-size: 0.85rem; color: var(--text-secondary); opacity: 0.8; }

.main-content {
  padding: calc(var(--header-height) + 16px) 16px calc(var(--nav-height) + 30px + var(--safe-bottom));
  max-width: 540px; margin: 0 auto;
}

/* ==================== 底部导航 ==================== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex; align-items: center;
  z-index: 1000;
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -10px 40px rgba(0,0,0,0.04);
}

.nav-item {
  flex: 1; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 0.75rem; font-weight: 600;
  transition: all var(--transition);
  position: relative;
}

.nav-icon { font-size: 1.6rem; transform: translateY(0); transition: transform var(--transition); }
.nav-item.active { color: var(--color-primary); }
.nav-item.active .nav-icon { transform: translateY(-4px) scale(1.1); }
.nav-item.active::after {
  content: ''; position: absolute; bottom: 12px;
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--color-primary);
  box-shadow: 0 0 10px var(--color-primary);
}

.nav-badge {
  position: absolute; top: 12px; right: calc(50% - 20px);
  background: var(--color-danger); color: #fff;
  font-size: 0.65rem; min-width: 18px; padding: 0 4px;
  height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; border: 2px solid var(--bg-card);
}

/* ==================== FAB 悬浮按钮 ==================== */
.fab {
  position: fixed; right: 24px;
  bottom: calc(var(--nav-height) + 24px + var(--safe-bottom));
  width: 62px; height: 62px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: #fff; border-radius: 50%;
  box-shadow: 0 10px 30px rgba(var(--color-primary-rgb), 0.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; z-index: 900;
  border: 4px solid #fff;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.fab:active { transform: scale(0.85) rotate(90deg); }

/* ==================== 顶部卡片 & 问候 ==================== */
.today-header {
  background: linear-gradient(145deg, var(--color-primary), var(--color-primary-light));
  border-radius: var(--radius-lg);
  padding: 24px; color: #fff;
  margin-bottom: 20px; position: relative; overflow: hidden;
  box-shadow: 0 15px 40px rgba(var(--color-primary-rgb), 0.2);
}

.today-header::before {
  content: ''; position: absolute; top: -20%; right: -10%;
  width: 140px; height: 140px; border-radius: 50%;
  background: rgba(255,255,255,0.15); filter: blur(20px);
}

.today-greeting { font-size: 1.4rem; font-weight: 800; }
.today-date { font-size: 0.9rem; opacity: 0.85; margin-top: 4px; font-weight: 500; }

.today-progress-bar-wrap { margin-top: 20px; }
.today-progress-label { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 8px; font-weight: 600; }
.today-progress-bar { height: 10px; background: rgba(255,255,255,0.25); border-radius: 5px; overflow: hidden; }
.today-progress-fill { height: 100%; border-radius: 5px; background: #fff; transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1); }

/* ==================== 搜索 & 筛选 ==================== */
.search-bar { position: relative; margin-bottom: 18px; }
.search-input {
  width: 100%; padding: 14px 16px 14px 44px;
  background: var(--bg-card); border: 2px solid transparent;
  border-radius: var(--radius-md); font-size: 0.95rem;
  box-shadow: var(--shadow-soft); transition: all var(--transition);
}
.search-input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 4px rgba(var(--color-primary-rgb), 0.1); }
.search-icon { position: absolute; left: 16px; top: 16px; color: var(--text-muted); font-size: 1.1rem; }

.category-tabs {
  display: flex; gap: 10px; overflow-x: auto; padding: 4px 4px 16px;
  scrollbar-width: none; -ms-overflow-style: none;
}
.category-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
  flex-shrink: 0; padding: 10px 18px; border-radius: var(--radius-full);
  background: var(--bg-card); border: 1.5px solid var(--border-color);
  color: var(--text-secondary); font-size: 0.85rem; font-weight: 700;
  transition: all var(--transition); box-shadow: var(--shadow-soft);
}
.cat-tab.active {
  background: var(--color-primary); color: #fff; border-color: var(--color-primary);
  box-shadow: 0 8px 20px rgba(var(--color-primary-rgb), 0.3);
  transform: translateY(-2px);
}

/* ==================== 任务卡片 ==================== */
.task-item {
  background: var(--bg-card); border-radius: var(--radius-md);
  margin-bottom: 12px; padding: 16px;
  display: flex; align-items: flex-start; gap: 14px;
  box-shadow: var(--shadow-soft); border: 1.5px solid transparent;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.task-item:active { transform: scale(0.98); }
.task-item.completed { opacity: 0.7; background: var(--bg-main); border-color: transparent; }
.task-item.completed .task-title { text-decoration: line-through; color: var(--text-muted); }

.task-checkbox {
  width: 26px; height: 26px; border-radius: 8px;
  border: 2.5px solid var(--border-color);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px; transition: all var(--transition);
}
.task-checkbox.checked {
  background: var(--color-secondary); border-color: var(--color-secondary);
  color: #fff; animation: checkPulse 0.4s ease;
}
@keyframes checkPulse { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }

.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }
.task-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.task-tag {
  font-size: 0.7rem; font-weight: 800; padding: 3px 10px;
  border-radius: var(--radius-full); text-transform: uppercase;
}
.task-time { font-size: 0.75rem; color: var(--text-muted); display: flex; align-items: center; gap: 4px; font-weight: 600; }

/* ==================== 设置项优化 ==================== */
.settings-group { margin-bottom: 24px; }
.settings-section-title { font-size: 0.85rem; font-weight: 800; color: var(--text-muted); margin-bottom: 12px; margin-left: 4px; }

.settings-item {
  background: var(--bg-card); border-radius: var(--radius-md);
  padding: 18px; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow-soft);
}
.settings-item-label { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.settings-item-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* 开关组件 */
.switch {
  width: 50px; height: 28px; background: var(--border-color);
  border-radius: 14px; position: relative; transition: background 0.3s;
}
.switch::after {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 22px; height: 22px; background: #fff; border-radius: 50%;
  transition: left 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.switch.active { background: var(--color-success); }
.switch.active::after { left: 25px; }

/* ==================== 模态框 & 毛玻璃 ==================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(45, 34, 24, 0.4); backdrop-filter: blur(8px);
  animation: fadeIn 0.3s ease;
}

.modal-sheet {
  width: 100%; max-width: 500px;
  background: var(--bg-card); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px 24px calc(24px + var(--safe-bottom));
  box-shadow: 0 -10px 40px rgba(0,0,0,0.15);
  animation: slideUp 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

.modal-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 20px; text-align: center; }

/* ==================== 奖励弹窗 (Reward Popup) ==================== */
.reward-overlay {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle, rgba(var(--color-primary-rgb), 0.2), rgba(0,0,0,0.85));
  backdrop-filter: blur(10px);
  animation: rewardIn 0.5s ease-out;
}

.reward-card {
  text-align: center; padding: 40px;
  background: rgba(255, 255, 255, 0.1); border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-lg); backdrop-filter: blur(20px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  transform: scale(1); animation: cardPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.reward-icon { font-size: 5rem; margin-bottom: 15px; filter: drop-shadow(0 0 20px var(--color-accent)); }
.reward-name { font-size: 1.8rem; font-weight: 900; color: #fff; margin-bottom: 5px; }
.reward-desc { color: rgba(255,255,255,0.8); font-size: 1rem; margin-bottom: 25px; }

/* ==================== 动画定义 ==================== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes rewardIn { from { opacity: 0; backdrop-filter: blur(0); } to { opacity: 1; backdrop-filter: blur(10px); } }
@keyframes cardPop { from { transform: scale(0.5) translateY(50px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }

/* ==================== 辅助 UI ==================== */
.btn {
  width: 100%; padding: 16px; border-radius: var(--radius-md);
  font-size: 1.05rem; font-weight: 800; border: none; cursor: pointer;
  transition: all var(--transition); display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary { background: var(--color-primary); color: #fff; box-shadow: 0 8px 20px rgba(var(--color-primary-rgb), 0.3); }
.btn-primary:active { transform: scale(0.96); box-shadow: 0 4px 10px rgba(var(--color-primary-rgb), 0.2); }

.form-input {
  box-sizing: border-box; width: 100%; min-width: 0;
  border: 2px solid var(--border-color); border-radius: var(--radius-sm);
  padding: 14px; font-size: 1rem; background: var(--bg-input); color: var(--text-primary);
  transition: border-color 0.3s;
}
.form-input:focus { border-color: var(--color-primary); }

/* 周期选择器 */
.weekday-selector { display: flex; gap: 6px; justify-content: space-between; margin-top: 10px; }
.weekday-btn {
  flex: 1; aspect-ratio: 1; border-radius: 12px;
  background: var(--bg-card); border: 2px solid var(--border-color);
  font-size: 0.85rem; font-weight: 800; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
}
.weekday-btn.selected { background: var(--color-secondary); color: #fff; border-color: var(--color-secondary); transform: translateY(-4px); box-shadow: 0 4px 12px rgba(74, 155, 142, 0.3); }

/* ==================== 响应式优化 ==================== */
@media (max-width: 380px) {
  .today-greeting { font-size: 1.2rem; }
  .fab { width: 56px; height: 56px; right: 16px; bottom: calc(var(--nav-height) + 16px + var(--safe-bottom)); }
}

/* 针对 iOS 微信的特别处理 */
.ios-fix { padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom)); }

/* ==================== 工具类 ==================== */
.hidden { display: none !important; }
.flex-1 { flex: 1; }
.btn-w-full { width: 100%; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }

/* ==================== 空状态 ==================== */
.task-list-empty {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted); opacity: 0.7;
}
.task-list-empty .empty-icon {
  font-size: 3.5rem; margin-bottom: 12px; display: block;
}
.task-list-empty p { font-size: 0.95rem; font-weight: 600; }

/* ==================== 任务操作按钮 ==================== */
.task-action-btn {
  background: none; border: none; font-size: 1.1rem;
  color: var(--text-muted); padding: 4px 6px; border-radius: 8px;
  flex-shrink: 0; cursor: pointer; line-height: 1;
  transition: all var(--transition);
}
.task-action-btn:active { color: var(--color-danger); transform: scale(1.2); }

/* ==================== 模态弹窗抓手 ==================== */
.modal-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border-color); margin: 0 auto 16px;
}

/* ==================== 表单元素 ==================== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 0.85rem; font-weight: 700;
  color: var(--text-secondary); margin-bottom: 8px;
}
.form-row {
  display: flex; gap: 12px;
}
.form-row .form-group { flex: 1; }

/* ==================== 分类选择器 ==================== */
.cat-selector {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.cat-option {
  padding: 8px 14px; border-radius: var(--radius-full);
  border: 1.5px solid var(--border-color);
  background: var(--bg-card); color: var(--text-secondary);
  font-size: 0.85rem; font-weight: 700; cursor: pointer;
  transition: all var(--transition);
}
.cat-option.selected {
  background: var(--color-primary); color: #fff;
  border-color: var(--color-primary);
  box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.3);
}

/* ==================== 按钮变体 ==================== */
.btn-outline {
  background: transparent; color: var(--text-secondary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md); padding: 16px;
  font-size: 1.05rem; font-weight: 800; cursor: pointer;
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-outline:active { opacity: 0.7; }

.btn-sm {
  padding: 7px 14px; border-radius: var(--radius-full);
  font-size: 0.8rem; font-weight: 700; cursor: pointer;
  border: 1.5px solid var(--border-color);
  background: var(--bg-card); color: var(--text-secondary);
  transition: all var(--transition);
}
.btn-sm:active { transform: scale(0.95); }

.btn-danger {
  background: rgba(245, 108, 108, 0.1); color: var(--color-danger);
  border-color: rgba(245, 108, 108, 0.3);
}
.btn-danger:active { background: var(--color-danger); color: #fff; }

.btn-icon {
  background: none; border: none; font-size: 1rem;
  cursor: pointer; padding: 4px 8px; color: var(--text-muted);
  border-radius: 6px; transition: all var(--transition);
}
.btn-icon:active { color: var(--color-primary); }

.btn-icon-sm {
  background: none; border: none; font-size: 0.8rem;
  cursor: pointer; color: var(--text-muted); padding: 2px 6px;
  border-radius: 4px; transition: all var(--transition);
}
.btn-icon-sm:active { color: var(--color-danger); }

/* ==================== 统计视图 ==================== */
.stats-summary-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; margin-bottom: 20px;
}
.stat-card {
  border-radius: var(--radius-md); padding: 18px 12px;
  text-align: center; box-shadow: var(--shadow-soft);
}
.chart-card {
  border-radius: var(--radius-md); padding: 20px;
  box-shadow: var(--shadow-soft); margin-bottom: 20px;
}
.streak-card {
  border-radius: var(--radius-md); padding: 28px 20px;
  text-align: center; margin-bottom: 20px;
  box-shadow: var(--shadow-soft);
}

/* ==================== 目标卡片 ==================== */
.goal-card {
  background: var(--bg-card); border-radius: var(--radius-md);
  padding: 20px; margin-bottom: 16px;
  box-shadow: var(--shadow-soft); border: 1.5px solid var(--border-color);
}
.goal-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.goal-cat-badge {
  font-size: 0.75rem; font-weight: 800; padding: 4px 12px;
  border-radius: var(--radius-full);
}
.goal-deadline {
  font-size: 0.75rem; font-weight: 700; padding: 4px 10px;
  border-radius: var(--radius-full);
}
.goal-deadline.overdue { background: rgba(245,108,108,0.15); color: var(--color-danger); }
.goal-deadline.today { background: rgba(232,168,48,0.15); color: var(--color-accent); }
.goal-deadline.urgent { background: rgba(245,108,108,0.1); color: #f56c6c; }
.goal-deadline.soon { background: rgba(232,168,48,0.1); color: var(--color-accent); }
.goal-deadline.normal { background: rgba(103,194,58,0.1); color: var(--color-success); }

.goal-title {
  font-size: 1.1rem; font-weight: 800; color: var(--text-primary);
  margin-bottom: 6px;
}
.goal-desc {
  font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 14px;
  line-height: 1.5;
}
.goal-progress-wrap {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.goal-progress-bar {
  flex: 1; height: 8px; background: var(--border-color);
  border-radius: 4px; overflow: hidden;
}
.goal-progress-fill {
  height: 100%; border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.goal-progress-text {
  font-size: 0.8rem; font-weight: 800; color: var(--text-secondary);
  min-width: 36px; text-align: right;
}

.goal-subgoals {
  background: var(--bg-main); border-radius: var(--radius-sm);
  padding: 12px; margin-bottom: 14px;
}
.goal-subgoal-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.8rem; font-weight: 700; color: var(--text-secondary);
  margin-bottom: 4px;
}
.goal-subgoal-list { margin-top: 8px; }
.subgoal-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border-color);
}
.subgoal-item:last-child { border-bottom: none; }
.subgoal-item.completed .subgoal-check span {
  text-decoration: line-through; color: var(--text-muted);
}
.subgoal-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.88rem; cursor: pointer; flex: 1;
}
.subgoal-check input { accent-color: var(--color-secondary); }

.goal-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}

/* ==================== 日程视图 ==================== */
.week-day-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  padding: 10px 6px; border-radius: var(--radius-md);
  background: var(--bg-card); border: 1.5px solid var(--border-color);
  color: var(--text-secondary); font-weight: 700; cursor: pointer;
  transition: all var(--transition); min-width: 0;
}
.week-day-btn.selected {
  background: var(--color-primary); color: #fff;
  border-color: var(--color-primary);
  box-shadow: 0 6px 16px rgba(var(--color-primary-rgb), 0.3);
  transform: translateY(-3px);
}

/* ==================== 时间轴 ==================== */
#timeline-wrap { padding: 16px 0; }
.timeline-empty {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted); font-size: 0.95rem; font-weight: 600;
}
.timeline-item {
  display: flex; gap: 12px; margin-bottom: 12px; align-items: flex-start;
}
.timeline-time {
  font-size: 0.75rem; font-weight: 700; color: var(--text-muted);
  min-width: 44px; padding-top: 14px;
}
.timeline-card {
  flex: 1; background: var(--bg-card); border-radius: var(--radius-md);
  padding: 14px 16px; box-shadow: var(--shadow-soft);
  border-left: 4px solid var(--color-primary);
}

/* ==================== Toast 通知 ==================== */
.toast {
  padding: 12px 24px; border-radius: var(--radius-full);
  font-size: 0.9rem; font-weight: 700; color: var(--text-primary);
  box-shadow: var(--shadow-md); white-space: nowrap;
  animation: fadeIn 0.3s ease;
}

