/* ============================================================
   Bento Grid（便当盒布局）设计系统
   - zinc 中性色系 + 少量蓝紫强调渐变
   - rounded-2xl 卡片 / shadow-sm → hover:shadow-md + 上浮
   - CSS Grid 不规则便当盒（今天为大卡，其余大小不一）
   - 新菜闪光特效 + New! 角标
   ============================================================ */

:root {
  /* zinc 色系（亮色） */
  --bg: #fafafa;              /* zinc-50 */
  --card: #ffffff;            /* white */
  --card-2: #f4f4f5;          /* zinc-100 */
  --border: #f4f4f5;          /* zinc-100 */
  --border-strong: #e4e4e7;   /* zinc-200 */
  --text-1: #18181b;          /* zinc-900 */
  --text-2: #52525b;          /* zinc-600 */
  --text-3: #a1a1aa;          /* zinc-400 */

  --blue: #3b82f6;            /* blue-500 */
  --purple: #8b5cf6;          /* violet-500 */
  --amber: #f59e0b;           /* amber-500（评分星） */

  --grad-hero: linear-gradient(135deg, #3b82f6, #8b5cf6);

  --radius-md: 12px;          /* rounded-xl */
  --radius-lg: 16px;          /* rounded-2xl */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 24px -8px rgba(0, 0, 0, 0.14);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #09090b;            /* zinc-950 */
    --card: #18181b;          /* zinc-900 */
    --card-2: #27272a;        /* zinc-800 */
    --border: #27272a;        /* zinc-800 */
    --border-strong: #3f3f46; /* zinc-700 */
    --text-1: #f4f4f5;        /* zinc-100 */
    --text-2: #a1a1aa;        /* zinc-400 */
    --text-3: #71717a;        /* zinc-500 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --shadow-md: 0 12px 30px -8px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; }
svg { display: block; }

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================================
   顶部操作按钮 + 上传页返回
   ============================================================ */
.week-actions { display: flex; align-items: center; gap: 12px; }

.admin-nav { margin-bottom: 16px; }
.admin-nav .btn { display: inline-flex; align-items: center; gap: 6px; }
.admin-nav .btn svg { width: 16px; height: 16px; }

main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 96px; }
.view { display: none; }
.view.active { display: block; }

/* ============================================================
   菜单视图：周标题 + 移动端日期切换
   ============================================================ */
.week-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 16px; margin-bottom: 16px;
}
.week-title { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; color: var(--text-1); }
.week-range { font-family: var(--font-mono); font-size: 13px; color: var(--text-3); margin-top: 2px; }

/* 移动端日期切换（桌面隐藏） */
.day-nav {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 8px; margin-bottom: 16px;
}
.day-nav-center { text-align: center; }
.day-label { font-size: 16px; font-weight: 600; color: var(--text-1); }
.day-date { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.nav-btn {
  width: 40px; height: 40px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); color: var(--text-2);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background-color .2s ease, color .2s ease, transform .2s ease;
}
.nav-btn svg { width: 20px; height: 20px; }
.nav-btn:hover:not(:disabled) { background: var(--card-2); color: var(--text-1); }
.nav-btn:active:not(:disabled) { transform: scale(0.94); }
.nav-btn:disabled { opacity: 0.3; cursor: default; }

@media (min-width: 1024px) {
  .day-nav { display: none; }
}

/* ============================================================
   Bento 周网格
   ============================================================ */
.week-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

/* 移动端：仅显示当前选中那天（提高特异性，压制下方 .day-card 基类的 display:flex） */
@media (max-width: 1023px) {
  .week-grid .day-card { display: none; }
  .week-grid .day-card.active { display: flex; }
}

/* 桌面：卡片堆叠翻页（从中心向两侧发散，斜着堆叠像翻书） */
@media (min-width: 1024px) {
  .week-grid {
    display: block;
    position: relative;
    height: min(660px, calc(100vh - 180px));
    min-height: 460px;
  }
  .week-grid .day-card {
    position: absolute;
    top: 0;
    left: 50%;
    width: 420px;
    height: 100%;
    transform-origin: 50% 45%;
    will-change: transform, opacity;
    transition: transform .5s cubic-bezier(.2, .8, .2, 1), opacity .5s ease, box-shadow .5s ease;
  }
  /* 未激活卡片：内部不可滚动、不可点菜名，只能整卡点击翻页 */
  .week-grid .day-card:not(.is-active) .day-body { pointer-events: none; }
}

/* ============================================================
   便当盒卡片
   ============================================================ */
.day-card {
  display: flex; flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow .2s ease, transform .2s ease;
}
.day-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

/* 今天：蓝紫渐变头部 + 强调描边 */
.day-card.is-active { border-color: transparent; }
.day-card.is-active .day-head {
  background: var(--grad-hero); color: #fff;
}

.day-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px;
  background: var(--card); color: var(--text-1);
  border-bottom: 1px solid var(--border);
}
.day-card.is-active .day-head { border-bottom-color: transparent; }
.day-weekday { font-weight: 600; font-size: 18px; letter-spacing: -0.01em; }
.day-date { font-family: var(--font-mono); font-size: 12px; color: var(--text-3); margin-top: 1px; }
.day-card.is-active .day-date { color: rgba(255, 255, 255, 0.8); }
.day-badges { display: flex; align-items: center; gap: 6px; }
.pill-today {
  font-size: 11px; font-weight: 600; color: #fff;
  background: var(--grad-hero); border-radius: 999px; padding: 3px 10px;
  box-shadow: var(--shadow-sm);
}
.pill-count {
  font-size: 11px; font-weight: 500; color: var(--text-2);
  background: var(--card-2); border-radius: 999px; padding: 3px 10px;
}
.day-card.is-active .pill-count { background: rgba(255, 255, 255, 0.18); color: #fff; }

.day-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 16px; }

/* 自定义滚动条（细、圆角、轨道透明，替代原生） */
.day-body {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.day-body::-webkit-scrollbar { width: 6px; }
.day-body::-webkit-scrollbar-track { background: transparent; }
.day-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
.day-body::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* 桌面：内容超高时滚动（早餐、午餐保持上下顺序单列） */
@media (min-width: 1024px) {
  .day-card .day-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }
}

/* 餐次分组 */
.meal { display: flex; flex-direction: column; gap: 6px; }
.meal-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  border: 0; background: transparent; padding: 6px 4px; width: 100%;
  cursor: pointer; text-align: left; font-family: inherit;
  border-radius: 8px;
  transition: color .2s ease, background-color .2s ease;
}
.meal-head:hover { color: var(--text-1); background: var(--card-2); }
.meal-head svg { width: 16px; height: 16px; color: var(--text-3); flex-shrink: 0; }
.meal-head .chevron { transition: transform .2s ease; }
.meal.collapsed .meal-head .chevron { transform: rotate(-90deg); }
.meal-count { font-family: var(--font-mono); font-size: 12px; color: var(--text-3); font-weight: 400; margin-left: auto; }
.meal.collapsed .dish-list { display: none; }

.dish-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

/* ============================================================
   菜品行
   ============================================================ */
.dish-row {
  position: relative;
  padding: 9px 12px;
  border-radius: 12px;
  cursor: pointer;
  overflow: hidden;
  transition: background-color .2s ease;
}
.dish-row:hover { background: var(--card-2); }
.dish-row:active { transform: scale(0.985); }

.dish-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dish-name { font-size: 15px; font-weight: 500; color: var(--text-1); line-height: 1.3; }

.dish-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-3); margin-top: 3px;
}
.dish-last { margin-left: auto; }

/* 只读星 */
.stars-summary { display: inline-flex; align-items: center; gap: 2px; }
.star-ico { width: 13px; height: 13px; color: var(--border-strong); }
.star-ico.on { color: var(--amber); }
.rating-count { color: var(--text-3); }

/* 上次吃过 / 首次出现 标签 */
.tag {
  background: var(--card-2); color: var(--text-2);
  border-radius: 6px; padding: 2px 8px; font-size: 11px;
  white-space: nowrap;
}

/* ============================================================
   新菜：闪光 + New! 角标
   ============================================================ */
.dish-row.dish-new {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.07), rgba(139, 92, 246, 0.06));
}
.dish-row.dish-new:hover {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.13), rgba(139, 92, 246, 0.11));
}

/* 流光扫过 */
.dish-row.dish-new::after {
  content: "";
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 25%, rgba(255, 255, 255, 0.65) 50%, transparent 75%);
  transform: translateX(-130%);
  animation: shimmer 2.8s ease-in-out infinite;
}
@media (prefers-color-scheme: dark) {
  .dish-row.dish-new::after {
    background: linear-gradient(110deg, transparent 25%, rgba(255, 255, 255, 0.14) 50%, transparent 75%);
  }
}
@keyframes shimmer {
  0% { transform: translateX(-130%); }
  60%, 100% { transform: translateX(130%); }
}

.badge-new {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 700; letter-spacing: 0.03em; color: #fff;
  background: var(--grad-hero);
  padding: 2px 8px; border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2) inset;
}

/* 闪烁的星星（新菜点缀） */
.sparkle {
  width: 13px; height: 13px; color: var(--amber);
  animation: twinkle 1.5s ease-in-out infinite;
}
.sparkle:nth-of-type(2) { animation-delay: 0.55s; color: var(--purple); }
@keyframes twinkle {
  0%, 100% { opacity: 0.25; transform: scale(0.55) rotate(-12deg); }
  50% { opacity: 1; transform: scale(1.12) rotate(14deg); }
}

/* ============================================================
   空状态
   ============================================================ */
.empty {
  text-align: center; padding: 60px 20px; color: var(--text-3);
  background: var(--card); border: 1px dashed var(--border-strong);
  border-radius: 16px;
}
.empty-icon { color: var(--text-3); margin: 0 auto 12px; width: 52px; height: 52px; }
.empty p { margin: 0 0 16px; }

/* 空卡片：假菜高斯模糊 + 居中「此日期未录入菜单」提示 */
.day-card.empty-card .day-body { position: relative; }
.day-body-blur {
  filter: blur(7px);
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
}
.empty-overlay {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 1;
}
.empty-badge {
  background: var(--text-1);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
}

/* ============================================================
   按钮
   ============================================================ */
.btn {
  border: 0; border-radius: 12px;
  padding: 8px 16px;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: color .2s ease, background-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
@media (min-width: 768px) {
  .btn { padding: 12px 24px; }
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--text-1); color: var(--bg); }
.btn-primary:hover:not(:disabled) { box-shadow: var(--shadow-sm); }
.btn-primary:disabled { background: var(--card-2); color: var(--text-3); cursor: not-allowed; }
.btn-ghost { background: var(--card); color: var(--text-1); border: 1px solid var(--border-strong); }
.btn-ghost:hover { background: var(--card-2); }
.btn-block { width: 100%; margin-top: 12px; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ============================================================
   上传
   ============================================================ */
.upload-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 20px; margin-bottom: 16px;
}
.upload-card h2 { font-weight: 600; font-size: 20px; margin: 0 0 4px; color: var(--text-1); }
.hint { color: var(--text-3); font-size: 13px; margin: 0 0 16px; }
.drop-zone {
  border: 1px dashed var(--border-strong); border-radius: 16px;
  padding: 28px 16px; text-align: center; cursor: pointer; background: var(--bg);
  margin-bottom: 16px;
  transition: border-color .2s ease, background-color .2s ease;
}
.drop-zone:hover { border-color: var(--blue); }
.drop-zone.dragover { border-color: var(--blue); background: rgba(59, 130, 246, 0.05); }
.dz-icon { color: var(--text-3); margin: 0 auto 8px; width: 40px; height: 40px; }
.dz-placeholder { color: var(--text-2); font-size: 13px; }
.preview:not([hidden]) { max-width: 100%; max-height: 280px; border-radius: 12px; margin: 0 auto; display: block; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.field input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  color: var(--text-1);
  padding: 10px 12px; font-size: 14px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.field input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16); }
.field textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  color: var(--text-1);
  padding: 10px 12px; font-size: 14px;
  font-family: var(--font-sans);
  line-height: 1.6;
  resize: vertical;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.field textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16); }
.ocr-status { margin-top: 12px; font-size: 12px; color: var(--text-3); text-align: center; }

/* ============================================================
   校对编辑器
   ============================================================ */
.editor {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.editor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.editor-head h2 { font-weight: 600; font-size: 20px; margin: 0; color: var(--text-1); }
.editor-grid { display: grid; grid-template-columns: 52px repeat(5, minmax(108px, 1fr)); gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.eg-cell { min-height: 58px; }
.eg-head { font-size: 12px; font-weight: 500; text-align: center; padding: 6px 4px; color: var(--text-2); white-space: nowrap; }
.eg-head.today { color: var(--blue); }
.eg-meal { font-size: 12px; color: var(--text-3); display: flex; align-items: center; justify-content: center; }
.eg-cell textarea {
  width: 100%; min-height: 70px;
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: 12px;
  color: var(--text-1); padding: 6px 8px; font-size: 13px;
  resize: vertical;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.eg-cell textarea::placeholder { color: var(--text-3); }
.eg-cell textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16); }

/* ============================================================
   管理后台：编辑已有菜单
   ============================================================ */
.editor-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 16px;
}
.editor-card h2 { font-weight: 600; font-size: 20px; margin: 0 0 4px; color: var(--text-1); }

.admin-dates { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.date-chip {
  border: 1px solid var(--border-strong);
  background: var(--card);
  border-radius: 12px;
  padding: 7px 14px;
  font-size: 13px; color: var(--text-2);
  cursor: pointer; white-space: nowrap;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.date-chip:hover { color: var(--text-1); }
.date-chip.active { background: var(--text-1); color: var(--bg); border-color: var(--text-1); }

.admin-editor { margin-top: 4px; }
.admin-editor-head { margin-bottom: 14px; font-size: 16px; color: var(--text-1); }
.admin-editor-actions { display: flex; gap: 12px; margin-top: 4px; flex-wrap: wrap; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }

.auth-error { color: #ef4444; font-size: 13px; margin-bottom: 8px; }

/* ============================================================
   评分弹窗
   ============================================================ */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 100; display: flex; align-items: flex-end; justify-content: center;
}
.modal-mask[hidden] { display: none; }
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  width: 100%; max-width: 720px;
  box-shadow: var(--shadow-md);
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  animation: fade-in .2s ease-out;
}
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.modal-title { font-weight: 600; font-size: 20px; color: var(--text-1); }
.modal-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.close-btn {
  border: 0; background: var(--card-2);
  width: 32px; height: 32px; border-radius: 12px;
  cursor: pointer; color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  transition: background-color .2s ease, color .2s ease, transform .2s ease;
}
.close-btn svg { width: 16px; height: 16px; }
.close-btn:hover { background: var(--border); color: var(--text-1); }
.close-btn:active { transform: scale(0.94); }
.rating-dims { display: flex; flex-direction: column; gap: 16px; margin-bottom: 8px; }
.dim { display: flex; align-items: center; justify-content: space-between; }
.dim-label { font-size: 14px; font-weight: 500; width: 48px; color: var(--text-2); }
.stars { display: flex; gap: 6px; }
.star { color: var(--border-strong); cursor: pointer; transition: color .15s ease, transform .15s ease; line-height: 0; }
.star svg { width: 28px; height: 28px; }
.star:hover { color: var(--text-3); }
.star.on { color: var(--amber); }
.star:active { transform: scale(0.9); }

@media (min-width: 600px) {
  .modal-mask { align-items: center; padding: 40px; }
  .modal { border-radius: 16px; }
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: var(--text-1); color: var(--bg);
  padding: 10px 18px; border-radius: 12px;
  font-size: 13px; z-index: 200; white-space: nowrap;
  box-shadow: var(--shadow-md);
}
.toast[hidden] { display: none; }

/* 翻页动画：循环到另一端的卡片瞬移（不飞屏） */
.no-anim { transition: none !important; }

/* ============================================================
   无障碍：尊重减少动效偏好
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
