/* C 端真功能页公共样式（c-user-shop / c-user-orders）
   复用 c-user.html 屏①② 的设计语言：奶咖 / 复古绿 / 黄跑灯
   不依赖 c-user.html 的设计稿展示样式（避免引入 .gallery / .phone 容器） */

/* ---------- Tokens ----------
   ⚠️ 本文件不再自建 :root。
   历史上这里定义的 24 个变量中，22 个与 c-center.css 同名且取值冲突
   （靠加载顺序被 c-center 全面覆盖，等于死代码），另 2 个（--c-brand-cream /
   --c-accent-yellow）零引用。全部令牌已统一到 styles/tokens.css 唯一真源。 */

/* ---------- Reset ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--c-font);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 64px;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ---------- 顶部导航 ---------- */
.top-nav {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(180deg, var(--c-green-700) 0%, var(--c-green-900) 100%);
  color: #fff;
  padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 1px 0 rgba(0,0,0,.15);
}
.top-nav .back-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px; font-size: 18px;
  background: rgba(255,255,255,.08);
  flex-shrink: 0;
}
.top-nav .nav-title { font-weight: 700; font-size: 15px; flex: 1; }
.top-nav .who-chip {
  font-size: 12px; padding: 4px 10px;
  background: rgba(255,255,255,.12); border-radius: 999px;
}

/* ---------- 底部 Tab Nav ---------- */
.tab-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  background: #fff;
  border-top: 1px solid var(--c-line);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; /* 自适应列数（4 tab 订单页 / 5 tab 集市页） */
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 8px rgba(0,0,0,.05);
}
.tab-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--c-text-muted);
  padding: 6px 0;
  transition: color .15s;
}
.tab-nav a .tab-ico { font-size: 20px; line-height: 1; }
.tab-nav a.active { color: var(--c-brand); font-weight: 700; }
.tab-nav a.active .tab-ico { transform: scale(1.08); }

/* ---------- 通用区段 ---------- */
.page { max-width: 720px; margin: 0 auto; padding: 14px; }
.section {
  background: var(--c-bg-card);
  border-radius: var(--c-radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--c-shadow-sm);
}
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 0 12px;
  font-size: 14px; font-weight: 700;
}
.section-title .more { font-size: 11px; color: var(--c-text-muted); font-weight: 400; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 16px;
  border-radius: var(--c-radius-sm);
  font-size: 14px; font-weight: 600;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--c-brand-coral); color: #fff; }
.btn-primary:hover { background: var(--c-brand-coral-deep); }
.btn-secondary { background: var(--c-brand); color: #fff; }
.btn-secondary:hover { background: var(--c-brand-soft); }
.btn-ghost { background: var(--c-bg-soft); color: var(--c-text); }
.btn-ghost:hover { background: var(--c-bg-soft); }
.btn-block { width: 100%; }
.btn-sm { min-height: 28px; padding: 0 10px; font-size: 12px; border-radius: 6px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--c-bg-card);
  border-radius: var(--c-radius);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--c-shadow-sm);
}
.card-row {
  display: flex; align-items: center; gap: 10px;
}
.card-thumb {
  width: 56px; height: 56px;
  border-radius: 10px;
  background: var(--c-bg-soft);
  display: grid; place-items: center;
  font-size: 28px;
  flex-shrink: 0;
}
.card-info { flex: 1; min-width: 0; }
.card-title { font-weight: 700; font-size: 14px; }
.card-sub { color: var(--c-text-soft); font-size: 12px; margin-top: 2px; }

/* ---------- 价格 ---------- */
.price { font-weight: 700; color: var(--c-brand-coral-deep); font-variant-numeric: tabular-nums; }
.price-lg { font-size: 22px; font-weight: 800; color: var(--c-brand-coral-deep); font-variant-numeric: tabular-nums; }
.price-sm { font-size: 12px; color: var(--c-text-soft); font-weight: 400; }
.price-range { font-size: 13px; color: var(--c-brand-coral-deep); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 999px;
  font-weight: 600;
  line-height: 1.6;
}
.tag-ok { background: var(--paid-soft); color: var(--c-success); }
.tag-warn { background: var(--warn-soft); color: var(--c-warn); }
.tag-coral { background: rgba(224, 122, 95, 0.12); color: var(--c-brand-coral-deep); }
.tag-brand { background: rgba(29, 59, 38, 0.1); color: var(--c-brand); }
.tag-gray { background: var(--c-bg-soft); color: var(--c-text-soft); }

/* ---------- 列表 ---------- */
.list-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--c-line);
}
.list-row:last-child { border-bottom: none; }

/* ---------- 数量步进 ---------- */
.qty-stepper {
  display: inline-flex; align-items: center;
  border: 1px solid var(--c-line);
  border-radius: 8px;
  overflow: hidden;
}
.qty-stepper button {
  width: 30px; height: 30px;
  font-size: 16px;
  background: var(--c-bg-card);
  color: var(--c-text);
  border: none;
}
.qty-stepper button:hover { background: var(--c-bg-soft); }
.qty-stepper .qty-val {
  min-width: 36px; text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ---------- 空态 ---------- */
.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--c-text-muted);
  font-size: 13px;
}
.empty .empty-ico { font-size: 36px; margin-bottom: 8px; opacity: .5; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; top: 80px;
  transform: translateX(-50%);
  background: rgba(29, 59, 38, 0.94);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  animation: toast-in .2s ease-out;
  max-width: 80%;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- 加载 ---------- */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--c-line);
  border-top-color: var(--c-brand-coral);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 弹层 ---------- */
.sheet-mask {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(29, 59, 38, 0.5);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-end;
}
.sheet-mask[hidden] { display: none; }
.sheet {
  background: #fff;
  width: 100%; max-width: 720px; margin: 0 auto;
  border-radius: 18px 18px 0 0;
  padding: 20px 16px 24px;
  max-height: 80vh; overflow-y: auto;
  animation: sheet-in .25s ease-out;
}
@keyframes sheet-in {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.sheet h3 { margin: 0 0 14px; font-size: 16px; }

/* ---------- Form ---------- */
.field {
  display: flex; flex-direction: column; gap: 4px;
  margin-bottom: 10px;
}
.field label {
  font-size: 12px; color: var(--c-text-soft);
}
.field input, .field select, .field textarea {
  min-height: 40px;
  border: 1px solid var(--c-line);
  border-radius: var(--c-radius-sm);
  padding: 0 12px;
  font-size: 14px;
  background: var(--c-bg-card);
  font-family: inherit;
  color: var(--c-text);
}
.field textarea { padding: 8px 12px; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--c-brand-coral);
}

/* ---------- 状态徽章 ---------- */
.status-pending_pay { background: var(--warn-soft); color: var(--c-warn); }
.status-paid { background: var(--paid-soft); color: var(--c-success); }
.status-sorting, .status-arranged, .status-packaged { background: rgba(29, 59, 38, .1); color: var(--c-brand); }
.status-pending_logistics_pay { background: rgba(224, 122, 95, .15); color: var(--c-brand-coral-deep); }
.status-logistics_paid, .status-delivering { background: var(--paid-soft); color: var(--c-success); }
.status-done { background: rgba(0, 0, 0, .08); color: var(--c-text-muted); }
.status-cancelled { background: var(--danger-soft); color: var(--c-danger); }

/* ---------- 响应式 ---------- */
@media (max-width: 480px) {
  body { font-size: 13px; }
  .page { padding: 10px; }
  .section { padding: 12px; }
  .card-thumb { width: 48px; height: 48px; font-size: 24px; }
}

/* ============================================================
   集市页 · 桌面手机卡片模式（.c-phone 容器）
   桌面（>700px）：内容收进居中 560px 圆角卡片，与直播间页
   （c-user.html）视觉一致；卡片固定视口高度、内部滚动，
   顶栏/底栏/弹层全部约束在卡片内。
   手机端（≤700px）容器无样式 = 原全屏模式。
   ============================================================ */
@media (min-width: 701px) {
  body:has(.c-phone) { padding-bottom: 0; background: var(--c-bg-soft); overflow: hidden; }
  .c-phone {
    position: relative;
    width: 560px; height: calc(100vh - 56px);
    margin: 28px auto;
    display: flex; flex-direction: column;
    background: var(--c-bg);
    border-radius: 24px;
    box-shadow: 0 24px 60px rgba(45, 37, 32, 0.22), 0 2px 8px rgba(45, 37, 32, 0.1);
    overflow: hidden;
  }
  .c-phone .top-nav { flex: none; position: static; }
  .c-phone .page {
    flex: 1; min-height: 0;
    max-width: none;
    overflow-y: auto;
    padding: 14px 16px 20px;
  }
  .c-phone .cart-bar { margin: 12px -16px -20px; bottom: 0; }
  /* 弹层与轻提示约束在卡片可视区内 */
  .c-phone .sheet-mask { position: absolute; }
  .c-phone .toast { position: absolute; }
  .c-phone #addrPickModal { position: absolute !important; }
  /* 底部 tab：从「全屏 fixed」改为卡片内固定条 */
  .c-phone .tab-nav {
    position: static; flex: none;
    left: auto; right: auto;
    grid-template-columns: repeat(5, 1fr);
  }
}

/* ---------- 运营后台开关：C 端底部菜单栏（/api/site-settings c_tabbar='0' → html.no-tabbar） ---------- */
html.no-tabbar .tab-nav { display: none; }
html.no-tabbar .cart-bar { bottom: 0; }   /* 无底栏时结算条贴底 */

/* ---------- 内嵌模式（宿主 c-user.html iframe 加载 ?embed=1）----------
   自身底栏/返回箭头隐藏（导航由宿主底栏接管），并归还 body 底部预留 */
html.embedded .tab-nav,
html.embedded .top-nav .back-btn { display: none; }
html.embedded body { padding-bottom: 0; }
html.embedded .cart-bar { bottom: 0; }

/* ---------- 购物车结算条（负 margin 对齐 .page 内边距） ---------- */
.cart-bar {
  position: sticky; bottom: 62px; z-index: 5;   /* 手机端避开 fixed 底栏 */
  background: #fff; border-top: 1px solid var(--c-line);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  margin: 12px -14px -14px;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}
@media (max-width: 480px) {
  .cart-bar { margin: 12px -10px -12px; }
}

/* ---------- 购物车入口（顶栏按钮 + 徽标） ---------- */
.cart-btn {
  position: relative;
  width: 34px; height: 34px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  transition: background .15s;
}
.cart-btn:hover { background: rgba(255, 255, 255, 0.22); }
.cart-btn .cart-ico { font-size: 17px; line-height: 1; }
.cart-btn .cart-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--c-brand-coral);
  color: #fff; font-size: 10px; font-weight: 700;
  font-family: var(--c-font-mono);
  display: grid; place-items: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.cart-btn .cart-badge[hidden] { display: none; }

/* ---------- 一级分类横向 tab ---------- */
.cat-tabs {
  display: flex; gap: 6px;
  overflow-x: auto; scrollbar-width: none;
  margin-bottom: 12px;
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  flex: none;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--c-line);
  background: #fff;
  font-size: 13px; font-weight: 500;
  color: var(--c-text-soft);
  transition: all .15s;
}
.cat-tab:hover { border-color: var(--c-brand); color: var(--c-brand); }
.cat-tab.on {
  background: var(--c-brand); border-color: var(--c-brand);
  color: #fff; font-weight: 700;
}
/* ---------- 待支付倒计时（订单列表 / 详情） ---------- */
.pay-cd {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; padding: 8px 10px;
  background: var(--primary-soft); border: 1px solid var(--primary-line);
  border-radius: 10px; font-size: 12px; color: var(--primary-deep);
}
.pay-cd .cd-num { font-family: var(--c-font-mono); font-size: 14px; font-weight: 700; }
.pay-cd.expired { background: var(--c-bg-soft); border-color: var(--c-line); color: var(--c-text-muted); }
.pay-cd .cd-pay { margin-left: auto; padding: 5px 12px; font-size: 12px; flex: none; }
