/* ============================================================
   食光外卖 H5 —— 全局公共样式
   移动端优先，页面最大宽度 480px 居中，方便桌面浏览器预览
   ============================================================ */

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #e9eaee;
  color: #222;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img { display: block; width: 100%; }
ul, li { list-style: none; }
a { color: inherit; text-decoration: none; }
input, button, textarea, select { font: inherit; outline: none; border: none; background: none; }
button { cursor: pointer; }

:root {
  --primary: #ff5331;
  --primary-dark: #e84120;
  --primary-grad: linear-gradient(135deg, #ff7b46 0%, #ff3d2a 100%);
  --price: #ff3d2e;
  --gold: #f5a623;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #222222;
  --text-2: #666666;
  --text-3: #999999;
  --line: #f0f0f0;
  --radius: 12px;
  --nav-h: 46px;
  --tab-h: 56px;
}

/* ---------- 页面容器 ---------- */
.page {
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow: clip; /* clip 不产生滚动容器，页内 sticky（吸顶分类栏/头部）才能正常吸附 */
}
.has-tabbar { padding-bottom: calc(var(--tab-h) + 38px + env(safe-area-inset-bottom)); }
.section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 700;
  margin: 14px 14px 8px;
}
.section-title::before {
  content: "";
  width: 4px;
  height: 14px;
  border-radius: 2px;
  background: var(--primary-grad);
}
.section-title .more { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--text-3); }

/* ---------- 顶部导航栏 ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.navbar .nav-title { font-size: 17px; font-weight: 600; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navbar .nav-back {
  position: absolute;
  left: 4px;
  top: 0;
  height: var(--nav-h);
  width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.navbar .nav-back svg { width: 21px; height: 21px; stroke: #333; stroke-width: 2.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.navbar .nav-right { position: absolute; right: 14px; top: 0; height: var(--nav-h); display: flex; align-items: center; color: var(--text-2); font-size: 13px; }
.navbar.pink { background: var(--primary-grad); border-bottom: none; }
.navbar.pink .nav-title, .navbar.pink .nav-right { color: #fff; }
.navbar.pink .nav-back svg { stroke: #fff; }

/* ---------- 底部标签栏（含中间凸起购物车） ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff;
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
}
.tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #9aa0a6;
  font-size: 11px;
}
.tabbar-item .ico { font-size: 21px; line-height: 1; }
.tabbar-item.active { color: var(--primary); font-weight: 600; }

/* ---------- 徽章 ---------- */
.badge {
  position: absolute;
  top: -5px;
  right: -9px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--price);
  color: #fff;
  font-size: 10px;
  font-style: normal;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #fff;
}

/* ---------- 卡片 / 按钮 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  margin: 10px 12px;
  padding: 12px 14px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border-radius: 22px;
  padding: 0 20px;
  font-size: 15px;
  transition: opacity .15s, transform .05s;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--primary-grad); color: #fff; font-weight: 600; box-shadow: 0 6px 14px rgba(255, 80, 40, .28); }
.btn-block { width: 100%; }
.btn-outline { border: 1px solid var(--primary); color: var(--primary); background: #fff; }
.btn-gray { background: #f2f2f4; color: #555; }
.btn-sm { height: 30px; border-radius: 15px; padding: 0 14px; font-size: 13px; }

/* ---------- 价格 / 标签 ---------- */
.price { color: var(--price); font-weight: 800; font-family: "DIN Alternate", "Arial", sans-serif; }
.price::before { content: "¥"; font-size: .72em; margin-right: 1px; font-weight: 600; }
.price-old { color: #b5b5b5; text-decoration: line-through; font-weight: 400; font-size: 11px; margin-left: 5px; }
.tag {
  display: inline-block;
  font-size: 10px;
  line-height: 1.5;
  padding: 0 5px;
  border-radius: 3px;
  margin-right: 4px;
  transform: scale(0.95);
  transform-origin: left center;
}
.tag-hot { background: #fff0ec; color: #ff5331; }
.tag-new { background: #eaf7ee; color: #18a058; }
.tag-rec { background: #fff6e6; color: #f08f00; }
.tag-veg { background: #eef5ff; color: #3b7df0; }

/* ---------- 数量步进器 ---------- */
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper .minus, .stepper .plus {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}
.stepper .plus { background: var(--primary); color: #fff; box-shadow: 0 3px 7px rgba(255, 80, 40, .35); }
.stepper .minus { border: 1.5px solid #d8d8d8; color: #888; background: #fff; }
.stepper .num { min-width: 26px; text-align: center; font-weight: 600; }

/* ---------- 表单 ---------- */
.field {
  display: flex;
  align-items: center;
  background: #fff;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.field:last-child { border-bottom: none; }
.field > label { width: 80px; color: #333; flex-shrink: 0; }
.field input, .field textarea, .field .val { flex: 1; min-width: 0; color: #222; }
.field input::placeholder, .field textarea::placeholder { color: #b5b5b5; }
.field .arrow { color: #c8c8c8; }
.field textarea { resize: none; height: 60px; }
.form-group { background: #fff; border-radius: var(--radius); margin: 10px 12px; overflow: hidden; }

/* ---------- 单元行（我的页面） ---------- */
.cell {
  display: flex;
  align-items: center;
  background: #fff;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  width: 100%;
  text-align: left;
}
.cell:last-child { border-bottom: none; }
.cell .c-ico {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-right: 11px;
  background: #fff3ef;
}
.cell .c-label { flex: 1; font-size: 14.5px; }
.cell .c-val { color: var(--text-3); font-size: 13px; margin-right: 4px; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell .arrow { color: #c8c8c8; font-size: 16px; }
.cell-group { border-radius: var(--radius); overflow: hidden; margin: 10px 12px; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 80px 0 60px; color: var(--text-3); }
.empty .e-ico { font-size: 60px; margin-bottom: 12px; opacity: .8; }
.empty .e-txt { font-size: 14px; margin-bottom: 18px; }

/* ---------- 复选/单选圆点 ---------- */
.check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid #cfcfcf;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}
.check.on { background: var(--primary); border-color: var(--primary); }
.check.on::after { content: ""; width: 9px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translateY(-1px); }

/* 开关 */
.switch { position: relative; width: 42px; height: 24px; border-radius: 12px; background: #ddd; transition: background .2s; flex-shrink: 0; }
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: left .2s;
}
.switch.on { background: var(--primary); }
.switch.on::after { left: 20px; }

/* ---------- 底部操作条 ---------- */
.action-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  background: #fff;
  display: flex;
  align-items: center;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  gap: 10px;
  z-index: 90;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, .06);
}
.action-bar.has-tabbar { bottom: var(--tab-h); }
.action-bar .ab-total { flex: 1; font-size: 13px; color: #333; }
.action-bar .ab-total b { font-size: 20px; color: var(--price); font-family: "DIN Alternate", Arial; }
.action-bar .btn { height: 40px; border-radius: 20px; padding: 0 26px; }
.page-pad-bottom { padding-bottom: 80px; }

/* ---------- 弹层：Toast / Dialog / ActionSheet / Loading ---------- */
.toast {
  position: fixed;
  z-index: 9999;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, .82);
  color: #fff;
  padding: 18px 24px;
  border-radius: 12px;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  max-width: 72%;
  text-align: center;
  z-index: 9999;
}
.toast .t-ico { font-size: 34px; line-height: 1; }

.mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 46px;
  animation: fade .2s;
}
.dialog {
  width: 100%;
  max-width: 300px;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  text-align: center;
  animation: pop .22s;
}
.dialog .d-title { padding: 20px 16px 6px; font-size: 17px; font-weight: 700; }
.dialog .d-content { padding: 4px 18px 20px; color: #666; font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-all; }
.dialog .d-btns { display: flex; border-top: 1px solid #f0f0f0; }
.dialog .d-btn { flex: 1; height: 48px; display: flex; align-items: center; justify-content: center; color: #333; font-size: 16px; }
.dialog .d-btn + .d-btn { border-left: 1px solid #f0f0f0; }
.dialog .d-btn.primary { color: var(--primary); font-weight: 700; }

.sheet-mask { align-items: flex-end; padding: 0; }
.sheet {
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  animation: slideUp .25s ease;
  max-height: 75vh;
  display: flex;
  flex-direction: column;
}
.sheet .s-header { display: flex; align-items: center; justify-content: center; padding: 15px; position: relative; font-weight: 700; font-size: 15px; border-bottom: 1px solid var(--line); }
.sheet .s-close { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 18px; color: #999; }
.sheet .s-body { overflow-y: auto; padding: 8px 0; }

#loading {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
}
#loading .l-box { background: rgba(0,0,0,.72); color: #fff; border-radius: 12px; padding: 20px 26px; display: flex; flex-direction: column; align-items: center; gap: 12px; font-size: 13px; }
.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* ---------- 评分星星 ---------- */
.stars { color: #ffb400; letter-spacing: 2px; font-size: 15px; }
.stars .off { color: #e2e2e2; }
.stars.sm { font-size: 12px; letter-spacing: 1px; }

/* ---------- 骨架屏 ---------- */
.skeleton { background: linear-gradient(90deg, #eee 25%, #f6f6f6 37%, #eee 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
@keyframes slideUp { from { transform: translateY(100%); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes flyUp { 0% { opacity:0; transform:translateY(10px);} 100% {opacity:1; transform:translateY(0);} }
.bump { animation: bump .35s ease; }
.fly-in { animation: flyUp .3s ease both; }

/* ---------- 订单状态时间轴 ---------- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: #eee; }
.timeline li { position: relative; padding-bottom: 16px; font-size: 13px; color: var(--text-3); }
.timeline li::before {
  content: "";
  position: absolute;
  left: -21px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ddd;
  border: 2px solid #fff;
}
.timeline li.active { color: #333; font-weight: 600; }
.timeline li.active::before { background: var(--primary); box-shadow: 0 0 0 3px #ffe3da; }
.timeline li .t-time { display: block; font-weight: 400; font-size: 11px; color: #aaa; margin-top: 2px; }

/* ---------- 通用小工具 ---------- */
.flex { display: flex; }
.flex1 { flex: 1; min-width: 0; }
.between { display: flex; align-items: center; justify-content: space-between; }
.center { display: flex; align-items: center; justify-content: center; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ellipsis-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.mb8 { margin-bottom: 8px; }
hr.soft { border: none; border-top: 8px solid var(--bg); }
