/* ============================================================
   健康管理系统 - 一周饮食安排
   现代化、轻量化、健康主题风格
   ============================================================ */

:root {
  --green-50: #f0fdf4;
  --green-100: #dcfce7;
  --green-200: #bbf7d0;
  --green-300: #86efac;
  --green-400: #4ade80;
  --green-500: #22c55e;
  --green-600: #16a34a;
  --green-700: #15803d;

  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-300: #fcd34d;
  --amber-500: #f59e0b;
  --amber-600: #d97706;

  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #f0fdf4 0%, #f0f9ff 100%);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============ 顶部导航 ============ */
.app-header {
  background: linear-gradient(135deg, var(--green-600), var(--green-500));
  color: white;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.logo p {
  font-size: 0.8rem;
  opacity: 0.9;
  margin-top: 2px;
}

.top-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.nav-btn.active {
  background: white;
  color: var(--green-700);
  font-weight: 600;
}

/* ============ 主内容区 ============ */
.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.view {
  display: none;
  animation: fadeIn 0.4s ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-title {
  font-size: 1.5rem;
  color: var(--gray-800);
  font-weight: 700;
}

.section-desc {
  color: var(--gray-500);
  margin: 8px 0 24px;
  font-size: 0.95rem;
}

/* ============ 用户简述横幅 ============ */
.user-banner {
  background: white;
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
}

.user-info {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.user-badge {
  background: var(--green-50);
  color: var(--green-700);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--green-200);
}

.user-note {
  color: var(--gray-600);
  font-size: 0.9rem;
  line-height: 1.7;
}

/* ============ 菜单模式切换器 ============ */
.mode-switcher {
  background: white;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.mode-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-700);
  white-space: nowrap;
}

.mode-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mode-btn {
  background: var(--gray-50);
  color: var(--gray-600);
  border: 1.5px solid var(--gray-200);
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.mode-btn:hover {
  border-color: var(--green-300);
  color: var(--green-700);
}

.mode-btn.active {
  background: linear-gradient(135deg, var(--green-600), var(--green-500));
  color: white;
  border-color: var(--green-500);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.mode-info {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--gray-600);
  flex-wrap: wrap;
}

.mode-info #currentMenuName {
  background: var(--green-50);
  color: var(--green-700);
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 600;
  border: 1px solid var(--green-200);
}

.mode-desc {
  color: var(--gray-500);
  font-size: 0.82rem;
}

.mode-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 4px;
}

.action-btn {
  background: var(--green-50);
  color: var(--green-700);
  border: 1.5px solid var(--green-200);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.action-btn:hover {
  background: var(--green-100);
}

.action-btn.active {
  background: var(--green-600);
  color: white;
  border-color: var(--green-600);
}

/* ============ 周日期选择条 ============ */
.week-selector {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 24px;
}

.day-tab {
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 14px 6px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.day-tab:hover {
  border-color: var(--green-300);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.day-tab.active {
  border-color: var(--green-500);
  background: linear-gradient(135deg, var(--green-500), var(--green-400));
  color: white;
  box-shadow: var(--shadow-md);
}

.day-tab .day-name {
  font-size: 0.95rem;
  font-weight: 700;
  display: block;
}

.day-tab .day-theme {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 4px;
  display: block;
}

.day-tab.active .day-theme {
  color: rgba(255, 255, 255, 0.9);
}

/* ============ 当日主题 ============ */
.day-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.day-header h2 {
  font-size: 1.6rem;
  color: var(--gray-800);
}

.day-header .day-tag {
  background: var(--green-100);
  color: var(--green-700);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.day-header .day-cal {
  color: var(--gray-500);
  font-size: 0.9rem;
}

/* ============ 餐次卡片网格 ============ */
.meal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
}

.meal-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.meal-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.meal-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.meal-type {
  font-size: 0.78rem;
  color: white;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
}

.meal-type.breakfast { background: var(--amber-500); }
.meal-type.snack1 { background: var(--green-400); }
.meal-type.lunch { background: var(--green-600); }
.meal-type.snack2 { background: var(--green-400); }
.meal-type.dinner { background: var(--amber-600); }

.meal-cal {
  font-size: 0.85rem;
  color: var(--gray-500);
  font-weight: 600;
}

.meal-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.meal-emoji {
  font-size: 1.4rem;
}

.meal-meta {
  display: flex;
  gap: 14px;
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-bottom: 12px;
}

.meal-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.meal-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.meal-tag {
  background: var(--green-50);
  color: var(--green-700);
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--green-100);
}

.meal-ingredients {
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
}

.meal-ingredients h4 {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ingredient-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.ingredient-item {
  font-size: 0.85rem;
  color: var(--gray-700);
}

.ingredient-item .ing-name {
  font-weight: 500;
}

.ingredient-item .ing-amount {
  color: var(--gray-400);
  font-size: 0.8rem;
}

.meal-action {
  margin-top: auto;
}

.btn-recipe {
  width: 100%;
  background: var(--green-50);
  color: var(--green-700);
  border: 1.5px solid var(--green-200);
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-recipe:hover {
  background: var(--green-500);
  color: white;
  border-color: var(--green-500);
}

/* ============ 营养概览 ============ */
.nutrition-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.nutrition-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
}

.nutrition-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.nutrition-day {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gray-800);
}

.nutrition-theme {
  font-size: 0.78rem;
  color: var(--green-600);
  background: var(--green-50);
  padding: 2px 10px;
  border-radius: 12px;
}

.nutrition-total {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--green-600);
  margin-bottom: 14px;
}

.nutrition-total small {
  font-size: 0.8rem;
  color: var(--gray-400);
  font-weight: 400;
}

.nutrition-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nutrition-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.nutrition-bar .nb-label {
  width: 44px;
  color: var(--gray-500);
  flex-shrink: 0;
}

.nutrition-bar .nb-track {
  flex: 1;
  height: 8px;
  background: var(--gray-100);
  border-radius: 4px;
  overflow: hidden;
}

.nutrition-bar .nb-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.nutrition-bar .nb-value {
  width: 48px;
  text-align: right;
  color: var(--gray-600);
  font-weight: 600;
}

.nb-fill.breakfast { background: var(--amber-500); }
.nb-fill.snack1 { background: var(--green-400); }
.nb-fill.lunch { background: var(--green-600); }
.nb-fill.snack2 { background: var(--green-400); }
.nb-fill.dinner { background: var(--amber-600); }

/* ============ 健康原则 ============ */
.principles-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.principle-item {
  background: white;
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--green-500);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.principle-num {
  background: var(--green-100);
  color: var(--green-700);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.principle-text {
  color: var(--gray-700);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ============ 餐次时间建议 ============ */
.tips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.tip-card {
  background: white;
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
}

.tip-card h4 {
  font-size: 1rem;
  color: var(--green-700);
  margin-bottom: 6px;
}

.tip-card p {
  color: var(--gray-600);
  font-size: 0.88rem;
  line-height: 1.65;
}

/* ============ 采购清单 ============ */
.shopping-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.shopping-category {
  background: white;
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
}

.shopping-category h3 {
  font-size: 1.05rem;
  color: var(--gray-800);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-100);
}

.shopping-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shopping-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--gray-700);
  cursor: pointer;
  user-select: none;
}

.shopping-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--green-500);
  cursor: pointer;
  flex-shrink: 0;
}

.shopping-item.checked {
  text-decoration: line-through;
  color: var(--gray-400);
}

/* ============ 健康档案 ============ */
.profile-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
}

.profile-section {
  margin-bottom: 24px;
}

.profile-section h3 {
  font-size: 1.1rem;
  color: var(--green-700);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--green-100);
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.profile-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.profile-item .pi-label {
  font-size: 0.8rem;
  color: var(--gray-400);
}

.profile-item .pi-value {
  font-size: 1rem;
  color: var(--gray-800);
  font-weight: 600;
}

.profile-principles {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-principles li {
  background: var(--green-50);
  color: var(--gray-700);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border-left: 3px solid var(--green-400);
}

/* ============ 弹窗 ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 16px;
  z-index: 1000;
  overflow-y: auto;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.25s ease;
}

.modal {
  background: white;
  border-radius: var(--radius-xl);
  max-width: 640px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 28px;
  background: linear-gradient(135deg, var(--green-600), var(--green-500));
  color: white;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.35);
}

.modal-body {
  padding: 24px 28px 32px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-section {
  margin-bottom: 22px;
}

.modal-section h4 {
  font-size: 0.85rem;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.modal-ingredients {
  background: var(--gray-50);
  border-radius: var(--radius-md);
  padding: 14px 18px;
}

.modal-ingredients table {
  width: 100%;
  border-collapse: collapse;
}

.modal-ingredients td {
  padding: 5px 0;
  font-size: 0.9rem;
  color: var(--gray-700);
}

.modal-ingredients td:first-child {
  font-weight: 500;
  width: 60%;
}

.modal-ingredients td:last-child {
  color: var(--gray-500);
  text-align: right;
}

.modal-steps {
  list-style: none;
  counter-reset: step;
}

.modal-steps li {
  counter-increment: step;
  position: relative;
  padding-left: 36px;
  margin-bottom: 12px;
  color: var(--gray-700);
  font-size: 0.92rem;
  line-height: 1.7;
}

.modal-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  background: var(--green-500);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.modal-tip {
  background: var(--amber-50);
  border-left: 4px solid var(--amber-500);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--gray-700);
  font-size: 0.9rem;
  line-height: 1.65;
}

.modal-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.modal-tags .meal-tag {
  font-size: 0.8rem;
}

/* ============ 页脚 ============ */
.app-footer {
  text-align: center;
  padding: 24px;
  color: var(--gray-400);
  font-size: 0.85rem;
  border-top: 1px solid var(--gray-200);
  margin-top: 40px;
}

/* ============ 响应式 ============ */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-nav {
    width: 100%;
    overflow-x: auto;
  }

  .week-selector {
    grid-template-columns: repeat(7, minmax(80px, 1fr));
    overflow-x: auto;
  }

  .day-tab {
    padding: 10px 4px;
  }

  .day-tab .day-name {
    font-size: 0.85rem;
  }

  .day-tab .day-theme {
    font-size: 0.65rem;
  }

  .meal-grid {
    grid-template-columns: 1fr;
  }

  .modal-body {
    padding: 18px 20px 24px;
  }
}

@media (max-width: 480px) {
  .logo h1 {
    font-size: 1.2rem;
  }

  .nav-btn {
    padding: 6px 12px;
    font-size: 0.82rem;
  }

  .week-selector {
    grid-template-columns: repeat(7, minmax(70px, 1fr));
    gap: 4px;
  }
}
