/* ====== 家庭菜单计划系统 - 暖色调主题 ====== */
:root {
  --bg: #FFF7E8;
  --card-bg: #FFFFFF;
  --primary: #E67E22;
  --primary-dark: #D35400;
  --primary-light: #F39C12;
  --text: #4A3B2C;
  --text-light: #8B6F4C;
  --text-muted: #A8947B;
  --border: #F0E4CC;
  --border-light: #F5EDDC;
  --danger: #E74C3C;
  --success: #27AE60;
  --info: #2980B9;
  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 28px;
  --radius-btn: 24px;
  --shadow: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 28px rgba(0,0,0,0.1);
  --transition: 0.2s ease;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ====== Skeleton Loading ====== */
.skeleton { padding: 1rem; }
.skeleton-header { height: 48px; background: #e8dcc8; border-radius: var(--radius); margin-bottom: 1rem; animation: pulse 1.5s infinite; }
.skeleton-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.skeleton-card { height: 180px; background: #f0e4cc; border-radius: var(--radius); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { opacity: 0.6; } 50% { opacity: 1; } }

/* ====== Toast ====== */
.toast {
  position: fixed; top: 1rem; left: 50%; transform: translateX(-50%);
  padding: 10px 24px; border-radius: var(--radius-btn); color: white;
  font-weight: 500; z-index: 9999; animation: slideDown 0.3s ease;
  box-shadow: var(--shadow-lg);
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }
@keyframes slideDown { from { transform: translateX(-50%) translateY(-100%); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }

/* ====== Auth Pages ====== */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 1rem; background: linear-gradient(135deg, #FFF7E8 0%, #FDEBD0 50%, #FAD7A1 100%);
}
.auth-card {
  background: white; border-radius: var(--radius-lg); padding: 2.5rem 2rem;
  width: 100%; max-width: 420px; box-shadow: var(--shadow-lg);
}
.auth-card h1 { text-align: center; color: var(--primary-dark); margin-bottom: 0.5rem; font-size: 1.8rem; }
.auth-card .subtitle { text-align: center; color: var(--text-light); margin-bottom: 2rem; font-size: 0.9rem; }

.form-group { margin-bottom: 1.2rem; }
.form-group label { display: block; margin-bottom: 0.4rem; font-weight: 500; color: var(--text); font-size: 0.9rem; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 14px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); font-size: 0.95rem;
  background: #FFFBF5; color: var(--text); transition: var(--transition);
}
.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(230,126,34,0.15);
}
.form-group textarea { min-height: 80px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius-btn); font-weight: 600;
  font-size: 0.95rem; cursor: pointer; border: none; transition: var(--transition);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: white; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.auth-card .switch-link {
  text-align: center; margin-top: 1.5rem; color: var(--text-light);
}
.auth-card .switch-link a { color: var(--primary); cursor: pointer; font-weight: 600; }

/* ====== Main Layout ====== */
.app-layout { min-height: 100vh; display: flex; flex-direction: column; }
.nav-header {
  background: white; padding: 0.8rem 1.5rem; display: flex;
  align-items: center; justify-content: space-between; box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 100;
}
.nav-header .logo { font-size: 1.3rem; font-weight: 700; color: var(--primary-dark); }
.nav-header .nav-links { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.nav-header .nav-links a, .nav-header .nav-links button {
  padding: 6px 14px; border-radius: var(--radius-btn); font-size: 0.9rem;
  font-weight: 500; cursor: pointer; border: none; background: transparent;
  color: var(--text); transition: var(--transition); text-decoration: none;
}
.nav-header .nav-links a:hover, .nav-header .nav-links button:hover { background: var(--border-light); color: var(--primary); }
.nav-header .nav-links a.active { background: var(--primary); color: white; }
.nav-header .user-info { font-size: 0.85rem; color: var(--text-light); }

.main-content { flex: 1; padding: 1.5rem; max-width: 1200px; margin: 0 auto; width: 100%; }

/* ====== Mobile Bottom Nav ====== */
.mobile-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: white; border-top: 2px solid var(--border); z-index: 100;
  padding: 6px 0; box-shadow: 0 -2px 12px rgba(0,0,0,0.05);
}
.mobile-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 0.7rem; color: var(--text-muted); text-decoration: none;
  padding: 4px 8px; transition: var(--transition);
}
.mobile-nav a .icon { font-size: 1.3rem; }
.mobile-nav a.active { color: var(--primary); }

/* ====== Page Header ====== */
.page-header { margin-bottom: 1.5rem; }
.page-header h2 { font-size: 1.5rem; color: var(--text); }
.page-header .actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* ====== Filter Bar ====== */
.filter-bar {
  display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap;
  margin-bottom: 1.5rem; padding: 1rem; background: white;
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.filter-bar select, .filter-bar input {
  padding: 8px 14px; border: 2px solid var(--border); border-radius: var(--radius-btn);
  font-size: 0.9rem; background: #FFFBF5;
}
.filter-bar input { flex: 1; min-width: 150px; }
.filter-bar select:focus, .filter-bar input:focus { outline: none; border-color: var(--primary); }

/* ====== Dish Card Grid ====== */
.dish-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem;
}
.dish-card {
  background: white; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transition: var(--transition); cursor: pointer;
}
.dish-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.dish-card .card-img {
  width: 100%; height: 140px; object-fit: cover;
  background: var(--border-light); display: flex; align-items: center;
  justify-content: center; font-size: 3rem; color: var(--primary);
}
.dish-card .card-body { padding: 0.8rem; }
.dish-card .card-body h3 { font-size: 0.95rem; margin-bottom: 0.3rem; }
.dish-card .card-body .meta {
  font-size: 0.8rem; color: var(--text-light);
  display: flex; justify-content: space-between; align-items: center;
}
.dish-card .card-badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 0.7rem; background: #FDEBD0; color: var(--primary-dark);
}

/* ====== Weekly Planner ====== */
.week-nav {
  display: flex; align-items: center; justify-content: center; gap: 1rem;
  margin-bottom: 1rem; padding: 0.8rem; background: white;
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.week-nav .week-label { font-weight: 700; font-size: 1.1rem; color: var(--primary-dark); min-width: 180px; text-align: center; }

.weekly-table {
  width: 100%; border-collapse: separate; border-spacing: 4px;
  background: white; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.weekly-table th {
  background: var(--primary); color: white; padding: 10px 8px;
  font-size: 0.85rem; text-align: center;
}
.weekly-table td {
  background: var(--border-light); padding: 8px; text-align: center;
  border-radius: 8px; font-size: 0.85rem; cursor: pointer;
  min-width: 110px; transition: var(--transition); position: relative;
  vertical-align: top;
}
.weekly-table td:hover { background: #FDEBD0; }
.weekly-table td.filled { background: #FAD7A1; }
.weekly-table.multi td { padding: 6px 4px; }
.weekly-table td .meal-dish { font-size: 0.8rem; }
.weekly-table td .clear-btn {
  position: absolute; top: 2px; right: 4px; font-size: 0.7rem;
  cursor: pointer; opacity: 0; transition: var(--transition);
  background: var(--danger); color: white; border-radius: 50%;
  width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
}
.weekly-table td:hover .clear-btn { opacity: 1; }
.weekly-table .meal-label { font-weight: 600; color: var(--primary-dark); cursor: default; }

/* Multi-dish tags in weekly table */
.meal-dishes { display: flex; flex-direction: column; gap: 3px; }
.meal-dish-tag {
  background: white; border-radius: 6px; padding: 3px 6px; font-size: 0.78rem;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.meal-dish-tag .dish-remove, .meal-tag-mobile .dish-remove {
  cursor: pointer; color: var(--danger); font-weight: bold; font-size: 0.9rem;
  line-height: 1; padding: 0 2px; border-radius: 50%;
}
.meal-dish-tag .dish-remove:hover, .meal-tag-mobile .dish-remove:hover {
  background: var(--danger); color: white;
}
.meal-tag-mobile {
  background: white; border-radius: 6px; padding: 2px 6px; font-size: 0.75rem;
  display: flex; align-items: center; justify-content: space-between;
  margin: 2px 0;
}

/* Mobile weekly cards */
.weekly-cards { display: none; }
.weekly-cards .day-card {
  background: white; border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 0.8rem; overflow: hidden;
}
.weekly-cards .day-card .day-header {
  background: var(--primary); color: white; padding: 8px 14px; font-weight: 700;
}
.weekly-cards .day-card .meals { padding: 8px; display: flex; gap: 4px; flex-wrap: wrap; }
.weekly-cards .day-card .meal-slot {
  flex: 1; min-width: 80px; padding: 8px; text-align: center;
  background: var(--border-light); border-radius: 8px; cursor: pointer;
  font-size: 0.8rem; transition: var(--transition);
}
.weekly-cards .day-card .meal-slot:hover { background: #FDEBD0; }
.weekly-cards .day-card .meal-slot.filled { background: #FAD7A1; font-weight: 600; }
.weekly-cards .day-card .meal-type { font-weight: 600; color: var(--text-muted); margin-bottom: 2px; }

/* ====== Modal / Overlay ====== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem; animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
  background: white; border-radius: var(--radius-lg); width: 100%;
  max-width: 700px; max-height: 85vh; overflow-y: auto;
  padding: 1.5rem; box-shadow: var(--shadow-lg); animation: scaleIn 0.2s ease;
}
@keyframes scaleIn { from { transform: scale(0.95); } to { transform: scale(1); } }
.modal-content h3 { margin-bottom: 1rem; color: var(--primary-dark); }
.modal-close { float: right; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); }

/* Dish picker grid in modal */
.dish-picker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.6rem;
  max-height: 60vh; overflow-y: auto; margin-bottom: 1rem;
}
.dish-picker-item {
  padding: 10px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--border-light); text-align: center; transition: var(--transition);
  font-size: 0.85rem;
}
.dish-picker-item:hover { background: var(--primary); color: white; }
.dish-picker-item.selected { background: var(--success); color: white; }

/* Selected tags in multi-picker */
.selected-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.selected-tag {
  background: var(--success); color: white; padding: 4px 10px;
  border-radius: var(--radius-btn); font-size: 0.85rem;
  display: flex; align-items: center; gap: 4px;
}

/* Recommendation panel */
.rec-table td { vertical-align: top; padding: 4px 6px; min-width: 100px; }
.rec-dish-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 2px 0; font-size: 0.78rem; border-bottom: 1px dotted var(--border-light); }
.rec-dish-row:last-child { border-bottom: none; }
.rec-dish-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ====== Profile / History ====== */
.profile-card {
  background: white; border-radius: var(--radius); padding: 1.5rem;
  box-shadow: var(--shadow); margin-bottom: 1rem;
}
.profile-card .info-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-light); }
.profile-card .info-row:last-child { border-bottom: none; }
.profile-card .info-label { color: var(--text-light); }
.profile-card .info-value { font-weight: 600; }

.history-list { list-style: none; }
.history-item {
  background: white; border-radius: var(--radius); padding: 1rem;
  box-shadow: var(--shadow); margin-bottom: 0.6rem; cursor: pointer;
  transition: var(--transition);
}
.history-item:hover { background: #FDEBD0; }
.history-item .week-range { font-weight: 700; color: var(--primary-dark); }
.history-item .dish-count { font-size: 0.85rem; color: var(--text-muted); }

/* ====== Admin ====== */
.admin-section { background: white; border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: var(--shadow); }
.admin-section h3 { color: var(--primary-dark); margin-bottom: 1rem; border-bottom: 2px solid var(--border); padding-bottom: 0.5rem; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.admin-table th { background: var(--border-light); padding: 10px; text-align: left; color: var(--text); }
.admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-light); }
.admin-table tr:hover td { background: #FFFBF0; }
.admin-table .actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.edit-form { margin-top: 1rem; padding: 1rem; background: var(--border-light); border-radius: var(--radius-sm); }
.edit-form .form-group { margin-bottom: 0.8rem; }
.edit-form .form-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

/* ====== Responsive ====== */
@media (max-width: 640px) {
  .nav-header .nav-links { display: none; }
  .mobile-nav { display: flex; justify-content: space-around; }
  .main-content { padding: 0.8rem; padding-bottom: 70px; }
  .weekly-table { display: none; }
  .weekly-cards { display: block; }
  .dish-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .filter-bar { flex-direction: column; gap: 0.5rem; }
  .filter-bar input { width: 100%; }
  .admin-table { font-size: 0.8rem; }
}

/* ====== Steps Display ====== */
.steps-content { white-space: pre-line; line-height: 1.8; font-size: 0.95rem; padding: 1rem; background: #FFFBF0; border-radius: var(--radius-sm); }
