/* ==========================================================================
   今天吃什么 (What to Eat) - 纯文字随机闪烁 · 三餐规划 · 宵夜饮品 · 用户专属JSON菜单
   ========================================================================== */

:root {
  --primary: #FF5722;
  --primary-hover: #E64A19;
  --primary-light: #FFEDE6;
  --primary-gradient: linear-gradient(135deg, #FF6F00 0%, #FF3D00 100%);
  --accent-purple: linear-gradient(135deg, #7C3AED 0%, #4F46E5 100%);

  --bg-main: #FAF8F5;
  --bg-card: #FFFFFF;
  --bg-card-subtle: #F4F1EA;
  --text-main: #1F2937;
  --text-muted: #6B7280;
  --text-light: #9CA3AF;
  --border-color: #EAE6DF;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 20px -4px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 32px -6px rgba(255, 87, 34, 0.16);
  --shadow-card: 0 6px 18px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -2px rgba(0, 0, 0, 0.02);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.dark-theme {
  --bg-main: #12141A;
  --bg-card: #1C1F28;
  --bg-card-subtle: #252A36;
  --text-main: #F3F4F6;
  --text-muted: #9CA3AF;
  --text-light: #6B7280;
  --border-color: #2D3342;
  --primary-light: rgba(255, 87, 34, 0.15);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 20px -4px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 32px -6px rgba(0, 0, 0, 0.6);
  --shadow-card: 0 6px 18px -3px rgba(0, 0, 0, 0.5);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

.app-container {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 16px 18px 48px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* --- 顶部导航栏 --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 18px;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-area {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.45rem;
  font-weight: 900;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-status-pill {
  font-size: 0.82rem;
  font-weight: 700;
  background: var(--primary-light);
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 5px 14px;
  border-radius: var(--radius-full);
}

.header-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition-fast);
}

.header-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.header-btn-primary {
  background: var(--primary);
  color: #FFFFFF !important;
  border-color: var(--primary);
}

.header-btn-primary:hover {
  background: var(--primary-hover);
}

.icon-btn-circle {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn-circle:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

/* --- 口味偏好过滤栏（全部随机 vs 清淡口味）--- */
.taste-filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  gap: 10px;
}

.taste-filter-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
}

.taste-pills-group {
  display: flex;
  gap: 8px;
}

.taste-pill {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.taste-pill:hover {
  color: var(--text-main);
}

.taste-pill.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(255, 87, 34, 0.28);
}

/* --- 模块卡片容器 --- */
.section-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 22px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}

.section-top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-headline {
  font-size: 1.18rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-big-action {
  background: var(--primary-gradient);
  color: #FFFFFF;
  border: none;
  padding: 12px 28px;
  border-radius: var(--radius-full);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-bounce);
}

.btn-big-action:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 18px 30px -4px rgba(255, 87, 34, 0.4);
}

.btn-big-action:active:not(:disabled) {
  transform: scale(0.96);
}

.btn-big-action:disabled {
  opacity: 0.75;
  cursor: not-allowed;
}

/* 三餐卡片网格 */
.meals-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 680px) {
  .meals-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.meal-slot-card {
  background: var(--bg-card-subtle);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  min-height: 190px;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.meal-slot-card.rolling {
  border-color: var(--primary);
  box-shadow: 0 0 20px rgba(255, 87, 34, 0.25);
  animation: pulseCard 0.5s infinite alternate;
}

@keyframes pulseCard {
  0% { transform: scale(0.99); }
  100% { transform: scale(1.01); }
}

.meal-slot-card.slot-locked {
  animation: bounceWinner 0.4s var(--transition-bounce);
  border-color: var(--primary);
}

@keyframes bounceWinner {
  0% { transform: scale(0.94); }
  50% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

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

.meal-badge-title {
  font-size: 0.95rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

.meal-count-badge {
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.btn-single-roll {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-single-roll:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.meal-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px 4px;
}

.slot-text-preview {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.slot-text-rolling {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1.3;
  word-break: break-all;
}

.slot-text-winner {
  font-size: 1.45rem;
  font-weight: 900;
  color: var(--text-main);
  line-height: 1.3;
  margin-bottom: 4px;
  word-break: break-all;
}

.slot-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.taste-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  vertical-align: middle;
  margin-left: 4px;
}

.taste-badge.light {
  background: #E8F5E9;
  color: #2E7D32;
}

body.dark-theme .taste-badge.light {
  background: rgba(46, 125, 50, 0.2);
  color: #81C784;
}

.empty-slot-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.btn-quick-add {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px dashed var(--primary);
  padding: 3px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

/* 宵夜与饮品网格 */
.latenight-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 580px) {
  .latenight-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* --- 登录/注册 弹窗 --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.auth-modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 380px;
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  position: relative;
}

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-card-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
}

.auth-tab-btn {
  background: transparent;
  border: none;
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.auth-tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
}

.btn-form-action {
  width: 100%;
  background: var(--primary-gradient);
  color: #FFFFFF;
  border: none;
  padding: 12px;
  border-radius: var(--radius-full);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  margin-top: 8px;
}

/* --- 菜单管理抽屉 --- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 9998;
}

.drawer-overlay.active {
  opacity: 1;
  visibility: visible;
}

.drawer-container {
  position: fixed;
  top: 0;
  right: -100%;
  width: 100%;
  max-width: 480px;
  height: 100%;
  background: var(--bg-card);
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.drawer-overlay.active + .drawer-container,
.drawer-container.active {
  right: 0;
}

@media (max-width: 600px) {
  .drawer-container {
    top: auto;
    bottom: -100%;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: 88vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    transition: bottom 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .drawer-container.active {
    bottom: 0;
  }
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.drawer-title {
  font-size: 1.15rem;
  font-weight: 800;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
}

/* 分类切换标签 */
.manage-category-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.manage-cat-tab {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.manage-cat-tab.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
}

/* 菜品管理列表项 */
.dish-manage-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 8px;
}

.dmi-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dmi-name {
  font-size: 0.92rem;
  font-weight: 800;
}

.dish-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

.tag-normal { background: #FFF3E0; color: #E65100; }
.tag-light { background: #E8F5E9; color: #2E7D32; }

body.dark-theme .tag-normal { background: rgba(230, 81, 0, 0.2); color: #FFB74D; }
body.dark-theme .tag-light { background: rgba(46, 125, 50, 0.2); color: #81C784; }

.dmi-note {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dmi-btn-del {
  background: transparent;
  border: none;
  font-size: 1rem;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px;
  transition: color var(--transition-fast);
}

.dmi-btn-del:hover {
  color: #E53935;
}

.empty-list-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 24px;
}

/* Toast 提示 */
.app-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1F2937;
  color: #FFFFFF;
  padding: 10px 24px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 10001;
  text-align: center;
  max-width: 90vw;
}

body.dark-theme .app-toast {
  background: #374151;
}

.app-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.app-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 10px;
}
