/* ============================================================
 * 家庭电子菜单 · 全局样式（参考抖音「给女朋友做的电子菜单」风格）
 * 粉色主色 / 左右分栏 / 圆形加号 / 底部结算条 · 手机端优先
 * ============================================================ */
:root {
  --primary: #E86070;        /* 主色：柔粉（来自参考作品） */
  --primary-light: #FDE9EC;
  --primary-dark: #d14e5e;
  --bg: #F7F8FA;             /* 页面底：浅灰白 */
  --card: #ffffff;
  --text: #333333;
  --text-light: #999999;
  --line: #f0f0f0;
  --green: #3fa758;
  --shadow: 0 2px 10px rgba(120, 90, 60, 0.06);
}

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

html { font-size: 16px; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* 手机端主容器：居中限制宽度 */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ===== 头部（仿参考作品：头像 + 店名 + 粉底） ===== */
.header {
  background: var(--primary);
  color: #fff;
  padding: 16px 16px 14px;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(232, 96, 112, 0.25);
  flex-shrink: 0;
}
.header .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header .avatar {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  flex-shrink: 0;
}
.header .brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 1px;
}
.header .brand p {
  font-size: 0.75rem;
  opacity: 0.92;
  margin-top: 3px;
}
.header .nav {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}
.header .nav a {
  color: #fff;
  text-decoration: none;
  font-size: 0.8rem;
  padding: 5px 14px;
  border-radius: 20px;
  background: rgba(255,255,255,0.22);
}
.header .nav a.active { background: #fff; color: var(--primary); font-weight: 600; }

/* ===== 左右分栏主体 ===== */
.layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* 左侧分类侧边栏 */
.sidebar {
  width: 92px;
  background: var(--bg);
  overflow-y: auto;
  flex-shrink: 0;
  padding-bottom: 84px;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }
.sidebar .cat {
  padding: 16px 6px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-light);
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}
.sidebar .cat .cat-emoji { display: block; font-size: 1.15rem; margin-bottom: 3px; }
.sidebar .cat.active {
  background: #fff;
  color: var(--primary);
  font-weight: 700;
}
.sidebar .cat.active::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 22px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}

/* 右侧菜品列表 */
.content {
  flex: 1;
  background: #fff;
  overflow-y: auto;
  padding: 10px 12px 100px;
  min-width: 0;
}
.content .cat-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  padding: 6px 2px 10px;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 5;
}
.content .cat-title small { color: var(--text-light); font-weight: 400; margin-left: 6px; }

/* ===== 菜品卡片（左图右文 + 圆形加号） ===== */
.dish-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.dish-card .dish-img {
  width: 74px; height: 74px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--line);
}
.dish-info { flex: 1; min-width: 0; }
.dish-info .dish-name { font-size: 0.98rem; font-weight: 600; }
.dish-info .dish-tag {
  display: block;
  font-size: 0.68rem;
  color: var(--text-light);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dish-info .dish-sold {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--text-light);
  margin-top: 4px;
  background: #f5f5f5;
  border-radius: 4px;
  padding: 1px 6px;
}

/* 数量控件：圆形加号 / - 数量 + */
.stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding-left: 6px;
}
.stepper .add-btn {
  width: 44px; height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(232, 96, 112, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stepper .add-btn:active { transform: scale(0.92); }
.stepper.has-qty .add-btn { display: none; }

.stepper .qty-ctrl {
  display: none;
  align-items: center;
  gap: 8px;
}
.stepper.has-qty .qty-ctrl { display: flex; }
.stepper .qty-ctrl button {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--primary);
  background: #fff;
  color: var(--primary);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stepper .qty-ctrl button:active { background: var(--primary-light); }
.stepper .qty-ctrl .num {
  min-width: 20px;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

/* ===== 底部下单栏（扫码点餐风格：购物车查看 + 下单按钮） ===== */
.cart-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 30;
  box-shadow: 0 -2px 12px rgba(120, 90, 60, 0.08);
}
.cart-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  padding: 4px 2px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}
.cart-btn .cart-icon {
  position: relative;
  font-size: 1.7rem;
  line-height: 1;
  flex-shrink: 0;
}
.cart-btn .cart-icon .badge-num {
  position: absolute;
  top: -6px; right: -10px;
  min-width: 18px; height: 18px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #fff;
}
.cart-btn .cart-text {
  font-size: 0.72rem;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn {
  border: none;
  border-radius: 22px;
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(232, 96, 112, 0.35);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { background: #d8cfc7; box-shadow: none; }

/* ===== 弹窗 ===== */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(40, 30, 20, 0.45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.mask.show { display: flex; }
.sheet {
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 82vh;
  overflow-y: auto;
}
.sheet h3 { font-size: 1.1rem; margin-bottom: 6px; }
.sheet .sub { font-size: 0.78rem; color: var(--text-light); margin-bottom: 14px; }

.order-summary {
  background: var(--primary-light);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
  max-height: 140px;
  overflow-y: auto;
}
.order-summary .row { display: flex; justify-content: space-between; font-size: 0.9rem; padding: 3px 0; }
.order-summary .row b { color: var(--primary); }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--primary); }
.field textarea { resize: vertical; min-height: 56px; }

.sheet .btn-full { width: 100%; margin-top: 6px; }

/* ===== 购物车查看面板 ===== */
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}
.sheet-head h3 { margin-bottom: 0; }
.btn-sm.ghost {
  flex: 0 0 auto;
  padding: 6px 14px;
  font-size: 0.8rem;
  color: var(--text-light);
  border-color: var(--line);
}
.cart-empty {
  text-align: center;
  color: var(--text-light);
  font-size: 0.88rem;
  padding: 30px 0;
}
.cart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.cart-item .ci-img {
  width: 44px; height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--line);
}
.cart-item .ci-name {
  flex: 1;
  min-width: 0;
  font-size: 0.92rem;
  font-weight: 600;
}
.cart-item .ci-ctrl {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}
.cart-item .ci-ctrl button {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--primary);
  background: #fff;
  color: var(--primary);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cart-item .ci-ctrl button:active { background: var(--primary-light); }
.cart-item .ci-ctrl .num {
  min-width: 18px;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
}
.cart-item .ci-del {
  border: none;
  background: none;
  font-size: 1.1rem;
  color: #c8c0b8;
  cursor: pointer;
  padding: 6px 4px;
  flex-shrink: 0;
}
.cart-item .ci-del:active { color: #d9534f; }
.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 2px 4px;
  font-size: 0.95rem;
}
.cart-total b { color: var(--primary); font-size: 1.1rem; }

/* 提交成功提示 */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(40, 30, 20, 0.88);
  color: #fff;
  padding: 18px 26px;
  border-radius: 12px;
  font-size: 0.95rem;
  text-align: center;
  z-index: 99;
  display: none;
}
.toast.show { display: block; animation: fadein 0.25s; }
@keyframes fadein { from { opacity: 0; transform: translate(-50%,-50%) scale(0.9); } }

/* ===== 后台页 ===== */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 600;
}
.badge.new { background: var(--primary-light); color: var(--primary); }
.badge.done { background: #e8f6ec; color: var(--green); }

.order-card {
  background: var(--card);
  border-radius: 14px;
  margin: 0 12px 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.order-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.order-head .who { flex: 1; min-width: 0; }
.order-head .who .name { font-size: 0.98rem; font-weight: 700; }
.order-head .who .time { font-size: 0.72rem; color: var(--text-light); margin-top: 2px; }
.order-head .total { font-size: 0.95rem; font-weight: 700; color: var(--primary); }
.order-head .arrow { color: var(--text-light); font-size: 0.8rem; transition: transform 0.2s; }
.order-card.open .order-head .arrow { transform: rotate(90deg); }

.order-body { display: none; padding: 12px 14px; }
.order-card.open .order-body { display: block; }

.order-remark {
  background: var(--primary-light);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.85rem;
  margin-bottom: 12px;
}
.order-remark .label { color: var(--text-light); margin-right: 6px; }

.dish-step {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #fff;
}
.dish-step .ds-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.dish-step .ds-head img {
  width: 44px; height: 44px;
  border-radius: 8px;
  object-fit: cover;
}
.dish-step .ds-title { font-size: 0.92rem; font-weight: 700; }
.dish-step .ds-qty {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: 20px;
  padding: 2px 10px;
  font-weight: 700;
}
.dish-step .ds-ingredients {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: #fbf7f2;
  border-radius: 8px;
}
.dish-step .ds-ig-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  margin-right: 2px;
}
.dish-step .ds-ig {
  font-size: 0.74rem;
  color: #6b5c50;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 8px;
}
.dish-step ol {
  padding-left: 0;
  list-style: none;
}
.dish-step ol li {
  position: relative;
  padding: 6px 0 6px 34px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: #54463d;
}
.dish-step ol li::before {
  content: attr(data-n);
  position: absolute;
  left: 0; top: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dish-step .ds-source {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 0.72rem;
  color: var(--text-light);
}
.dish-step .ds-source details.ds-video-link { margin-top: 8px; }
.dish-step .ds-source summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 600;
  user-select: none;
  display: inline-block;
}
.dish-step .ds-source details[open] summary { margin-bottom: 6px; }
.dish-step .ds-source a {
  display: block;
  font-size: 0.72rem;
  color: #1a6fd4;
  word-break: break-all;
  background: #f5f8fd;
  border-radius: 6px;
  padding: 6px 10px;
}

.order-actions { display: flex; gap: 10px; margin-top: 4px; }
.btn-sm {
  flex: 1;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 22px;
  padding: 9px 0;
  font-size: 0.88rem;
  cursor: pointer;
}
.btn-sm.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-sm.danger { color: #d9534f; border-color: #f3c6c4; }

.empty {
  text-align: center;
  color: var(--text-light);
  font-size: 0.9rem;
  padding: 60px 20px;
}
.empty .emoji { font-size: 2.4rem; display: block; margin-bottom: 10px; }

.toolbar {
  display: flex;
  gap: 8px;
  padding: 12px;
  flex-shrink: 0;
}
.toolbar .btn-sm { flex: 0 0 auto; padding: 8px 16px; }

/* ===== 食材仓库页 ===== */
/* 统计 + 筛选条（sticky，header 下方） */
.pantry-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  flex-shrink: 0;
}
.pantry-stats { display: flex; align-items: center; gap: 10px; font-size: 0.8rem; color: var(--text-light); }
.pantry-stats b { font-size: 1.02rem; }
.pantry-stats .stat-total b { color: var(--text); }
.pantry-stats .stat-missing {
  background: #fdecec;
  color: #d9534f;
  border-radius: 20px;
  padding: 3px 10px;
  font-weight: 600;
}
.pantry-stats .stat-missing b { color: #d9534f; }
.pantry-filters { display: flex; gap: 6px; }
.chip-filter {
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--text-light);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}
.chip-filter.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* 搜索框 */
.pantry-search {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 12px 10px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 9px 12px;
  flex-shrink: 0;
}
.pantry-search:focus-within { border-color: var(--primary); }
.pantry-search .ps-icon { font-size: 0.95rem; opacity: 0.7; }
.pantry-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--text);
  background: transparent;
}
.pantry-search input::placeholder { color: #c2b9b0; }
.pantry-search .ps-clear {
  border: none;
  background: #f0ece7;
  color: var(--text-light);
  width: 20px; height: 20px;
  border-radius: 50%;
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* 一键批量设置 */
.pantry-actions {
  display: flex;
  gap: 8px;
  margin: 0 12px 10px;
  flex-shrink: 0;
}
.chip-action {
  flex: 1;
  border-radius: 20px;
  padding: 8px 0;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  background: #fff;
}
.chip-action:active { transform: scale(0.97); }
.chip-action.all-have { color: var(--green); border: 1.5px solid #bfe3c8; background: #eefaf1; }
.chip-action.all-none { color: #d9534f; border: 1.5px solid #f3c6c4; background: #fdf3f3; }

/* 分组列表 */
.pantry-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 30px;
}
.pantry-group { margin-bottom: 16px; }
.pg-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  padding: 4px 2px 8px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.pg-title small {
  color: var(--text-light);
  font-weight: 400;
  font-size: 0.72rem;
  background: #f0ece7;
  border-radius: 10px;
  padding: 1px 8px;
}

/* 食材行 */
.pantry-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: 12px;
  padding: 11px 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}
.pantry-item:active { transform: scale(0.985); }
.pantry-item.missing { background: #fdf3f3; box-shadow: 0 2px 8px rgba(217, 83, 79, 0.08); }
.pi-info { flex: 1; min-width: 0; }
.pi-name { font-size: 0.95rem; font-weight: 600; }
.pantry-item.missing .pi-name { color: #d9534f; }
.pi-used {
  font-size: 0.7rem;
  color: var(--text-light);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pantry-item.missing .pi-used { color: #d99a95; }

/* 状态切换胶囊 */
.pi-toggle {
  flex-shrink: 0;
  border: none;
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  min-width: 76px;
  transition: all 0.15s;
}
.pi-toggle.on { background: #e6f4ea; color: var(--green); }
.pi-toggle.off { background: #d9534f; color: #fff; }

/* ===== 后台订单：缺料预警 ===== */
.ds-missing-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  background: #d9534f;
  border-radius: 20px;
  padding: 2px 10px;
  flex-shrink: 0;
  animation: popin 0.25s;
}
@keyframes popin { from { transform: scale(0.8); opacity: 0; } }
.dish-step .ds-ig.missing {
  background: #fdecec;
  color: #d9534f;
  border-color: #f3c6c4;
  font-weight: 600;
}
