/*
 * 手机点餐页样式。
 * 配色沿用小程序（app.wxss）：主色 #c0392b，价格 #e64340，底 #f5f5f5。
 * 单位一律用 px —— 小程序的 rpx 在浏览器里没有对应物，
 * 而点餐页的元素本来就该按物理尺寸给（拇指点得到），不需要按屏宽等比缩放。
 */

:root {
  --primary: #c0392b;
  --price: #e64340;
  --text: #333;
  --muted: #999;
  --line: #eee;
  --bg: #f5f5f5;
  --topbar-h: 44px;
  /* 底部固定条的高度 + 安全区，内容区靠它留白 */
  --footer-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  /* 微信内置浏览器会按系统设置放大字号，把布局撑坏 */
  -webkit-text-size-adjust: 100%;
}

body { overflow: hidden; }

button { font: inherit; color: inherit; border: none; background: none; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; }

/* ---------------------------------- 顶栏 ---------------------------------- */

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--primary);
  color: #fff;
  z-index: 30;
}

.topbar-back {
  font-size: 26px;
  line-height: 1;
  width: 24px;
  margin-left: -6px;
  color: #fff;
}

.topbar-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.topbar-nav { display: flex; gap: 14px; }
.topbar-link { font-size: 13px; opacity: 0.92; }

/* ---------------------------------- 容器 ---------------------------------- */

.app {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* 顶栏显示时，内容整体下移 */
.app.with-topbar { top: var(--topbar-h); }

.scroll { height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---------------------------------- 通用块 ---------------------------------- */

.card {
  background: #fff;
  border-radius: 8px;
  margin: 10px;
  padding: 12px;
}

.row-between { display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--muted); font-size: 12px; }
.price { color: var(--price); font-weight: 700; }
.divider { height: 1px; background: var(--line); margin: 8px 0; }
.strong { font-weight: 600; }

.empty {
  padding: 60px 24px;
  text-align: center;
  color: var(--muted);
  line-height: 1.8;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 44px;
  border-radius: 22px;
  background: #fff;
  border: 1px solid #ddd;
  font-size: 15px;
}

.btn-primary { background: var(--primary); color: #fff; border: none; }
.btn-primary[disabled], .btn[disabled] { background: #ccc; color: #fff; border: none; opacity: 1; }
.btn-block { margin: 10px; width: calc(100% - 20px); }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  background: #eee;
  color: #666;
}

.tag-pending   { background: #fff3e0; color: #e67e22; }
.tag-cooking   { background: #e3f2fd; color: #1976d2; }
.tag-served    { background: #e8f5e9; color: #2e7d32; }
.tag-paid      { background: #eee;    color: #888;    }
.tag-cancelled { background: #fbe9e7; color: #c0392b; }

/* ---------------------------------- 入口页 ---------------------------------- */

/*
 * 绝对定位铺满 .app，而不是 min-height:100%。
 * 视图内容外面包着一层 .view（每次渲染换新容器，见 main.js），它是 auto 高，
 * 百分比高度找不到参照物会被当成 auto —— 于是 justify-content:center 没有可分配的
 * 剩余空间，整页内容全挤在顶部。.menu 用的也是这个办法。
 */
.enter {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.enter-table {
  font-size: 52px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
  margin: 6px 0 2px;
}

.enter-hint { color: var(--muted); margin-bottom: 28px; line-height: 1.8; }
.enter .btn { max-width: 280px; }
.enter-unpaid {
  background: #fff3e0;
  color: #e67e22;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 18px;
  font-size: 13px;
}

/* ---------------------------------- 菜单页 ---------------------------------- */

.menu {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
}

.menu-cats {
  width: 88px;
  flex: none;
  background: #f0f0f0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--footer-h) + var(--safe-b));
}

.cat {
  padding: 14px 6px;
  text-align: center;
  font-size: 13px;
  color: #666;
  line-height: 1.3;
  border-left: 3px solid transparent;
}

.cat.active {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  border-left-color: var(--primary);
}

.menu-dishes {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
  padding-bottom: calc(var(--footer-h) + var(--safe-b) + 12px);
}

.cat-title {
  padding: 10px 12px 4px;
  font-size: 13px;
  color: var(--muted);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 1;
}

.dish { display: flex; padding: 10px 12px; gap: 10px; }
.dish + .dish { border-top: 1px solid #f5f5f5; }
.dish.sold-out .dish-img, .dish.sold-out .dish-name { opacity: 0.45; }

.dish-img {
  width: 72px; height: 72px;
  flex: none;
  border-radius: 6px;
  object-fit: cover;
  background: #f2f2f2;
}

.dish-img-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #bbb;
}

.dish-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dish-name { font-size: 15px; line-height: 1.4; }
.dish-desc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  /* 描述最多两行，长了截断 —— 否则一条菜能把半屏占满 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dish-bottom { margin-top: auto; padding-top: 6px; display: flex; align-items: center; justify-content: space-between; }
.dish-bottom .price { font-size: 15px; }

/* ---- 加减器 ---- */
.stepper { display: flex; align-items: center; gap: 8px; }

.step-btn {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 1;
  border: 1px solid var(--primary);
  color: var(--primary);
  background: #fff;
}

.step-btn.plus { background: var(--primary); color: #fff; }
.step-qty { min-width: 16px; text-align: center; font-size: 14px; }

/* ---------------------------------- 购物车 ---------------------------------- */

.cart-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--footer-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  align-items: center;
  background: #fff;
  border-top: 1px solid var(--line);
  z-index: 25;
}

.cart-summary { flex: 1; display: flex; align-items: center; gap: 10px; padding-left: 14px; }

.cart-icon {
  position: relative;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}

/*
 * 类名别再叫 empty —— 全局的空状态 .empty 带着 padding: 60px 24px，
 * 撞上之后 border-box 下 36px 的图标被内边距撑成 48×120，
 * 底栏里就是一个盖住半个屏幕的灰椭圆。
 */
.cart-icon.is-empty { background: #bbb; }

.badge {
  position: absolute;
  top: -4px; right: -6px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: #ff9500;
  color: #fff;
  font-size: 11px;
  line-height: 17px;
  text-align: center;
}

.cart-total { font-size: 16px; }

.cart-submit {
  width: 110px;
  height: var(--footer-h);
  display: flex; align-items: center; justify-content: center;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
}

.cart-submit.disabled { background: #ccc; }

.cart-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 24;
}

.cart-panel {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--footer-h) + var(--safe-b));
  max-height: 55vh;
  background: #fff;
  border-radius: 12px 12px 0 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
}

.cart-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: #666;
}

.cart-clear { color: var(--muted); }
.cart-list { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.cart-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.cart-item + .cart-item { border-top: 1px solid #f7f7f7; }
.cart-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------- 确认页 / 订单 ---------------------------------- */

.line { display: flex; align-items: center; padding: 7px 0; gap: 10px; }
.line + .line { border-top: 1px solid #f7f7f7; }
.line-name { flex: 1; min-width: 0; }
.line-qty { color: var(--muted); width: 40px; text-align: right; }
.line-amount { width: 72px; text-align: right; }

.remark-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  resize: none;
  outline: none;
  background: #fafafa;
}

.remark-input:focus { border-color: var(--primary); background: #fff; }

.total-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--footer-h) + var(--safe-b));
  padding: 0 0 var(--safe-b) 14px;
  display: flex;
  align-items: center;
  background: #fff;
  border-top: 1px solid var(--line);
  z-index: 25;
}

.total-bar .total-text { flex: 1; font-size: 16px; }

/* ---------------------------------- 取餐号 ---------------------------------- */

.pickup { text-align: center; padding: 28px 20px 10px; }
.pickup-label { color: var(--muted); font-size: 13px; }

.pickup-no {
  font-size: 72px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
  letter-spacing: 2px;
  margin: 4px 0 8px;
}

.pickup-tip {
  display: inline-block;
  background: #fff3e0;
  color: #e67e22;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  line-height: 1.7;
}

/* ---------------------------------- 订单列表 ---------------------------------- */

.order-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.order-pickup { font-size: 20px; font-weight: 700; color: var(--primary); }
.order-meta { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------------------------------- toast / 预览 ---------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  max-width: 78%;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  z-index: 60;
  /* 提示是给人看的，不该挡住下面的按钮 */
  pointer-events: none;
}

.preview {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.preview-img { max-width: 100%; max-height: 100%; object-fit: contain; }

[hidden] { display: none !important; }
