/* ============================================================================
   商品卡 · 价格区 v3（2026-11-13 三版）
   ----------------------------------------------------------------------------
   【用户反馈的三个问题】
   1. 价格不够红       → 原 #b42318 是砖红（S=79%），看着发闷
   2. 折扣标签不够鲜艳 → 淡粉底 + 细边 + 11px 字，几乎没有存在感
   3. 布局不居中       → 左对齐后价格在左、日均在右、原价缩进，整块松散

   ----------------------------------------------------------------------------
   【设计决策：中轴对齐 + 折扣标签做主视觉】

   为什么改居中：
   商品卡是"单件商品"的展示单元，视觉重心应该落在卡片中轴上。
   左对齐适合"表格里的一列"（方便上下比对），但这里是**多张卡横向平铺**，
   左对齐会让每张卡的留白都堆在右侧，整排看起来重心偏左。

   新的三段中轴：
             ┌───────── 7折 ─────────┐   ← 折扣标签：顶部居中，最强视觉
             │   ¥3.50  元/月付       │   ← 主价格：居中，28px 高饱和红
             │  原价 ¥5.00  省¥1.50   │   ← 对比行：居中，灰 + 红
             └──────── 0.12/天 ───────┘   ← 日均：居中，最小、最灰

   层级逻辑：折扣 → 实付价 → 省多少 → 日均参考
   从"决策依据"到"辅助参考"逐层递减，符合用户扫视顺序。

   ----------------------------------------------------------------------------
   【配色：把红提到真正的"红"】
   主红 #e8322a（S=82%, L=54%）—— 比 #b42318 亮一档、饱和一档，
   在白底上足够跳但不像 #ff0000 那么刺眼（纯红在浅色 UI 里会"烧屏"）。
   价格数字与折扣标签共用主红，形成"这是一套定价信息"的暗示。

   折扣标签用**实心红底 + 白字**：
   上一版是浅粉底 + 红字，属于"辅助信息"的视觉强度，
   但折扣恰恰是最能促成决策的元素，必须给它最强的对比。

   购买按钮：取自用户指定截图 #1d4ed8（Tailwind blue-700），带轻微横向渐变。
   ============================================================================ */

:root {
  /* 价格红：主色 / 深一档（hover / 描边） / 浅底（省金额药丸） */
  --cfx-red: #e8322a;
  --cfx-red-dark: #c9261f;
  --cfx-red-soft: #fff1f0;
  --cfx-red-border: #ffd7d3;
  /* 购买按钮：取自用户指定截图（#1d4ed8，Tailwind blue-700） */
  --cfx-buy: #1d4ed8;
  --cfx-buy-hover: #1a45c0;
  --cfx-buy-active: #163aa3;
}

/* ---------- 外层：纵向居中排列 ---------- */
.shopping-item .bx-price-frame {
  position: relative !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;      /* ★ 中轴对齐 */
  gap: 3px !important;
  padding: 0 !important;
  min-height: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  text-align: center !important;
}

/* 覆盖 discount.css 里权重更高的 padding 规则（见 v2 踩坑记录） */
.shopping-item .bx-price-frame:not(:has(.bx-disc-row)),
.shopping-item .bx-price-frame:not(:has(.bx-disc-badge)) {
  padding: 0 !important;
  min-height: 0 !important;
  justify-content: flex-start !important;
}

/* ============================================================
   ① 折扣标签：价格右侧的箭头（v4）
   ------------------------------------------------------------
   为什么从"顶部独立块"改成"价格右侧箭头"：

   顶部独立块虽然醒目，但它在价格**上方**，与价格没有"指向关系" ——
   视觉上像三个各自独立的信息（7折 / 价格 / 原价），读者要自己脑补关联。

   改成右侧箭头后：
     ¥3.50 元/月付 ▶7折
                     ╲ 尖角指向右方 = "这个价是折后的，再往外还有原价"
   箭头前进的方向与"原价 → 折后价 → 省多少"的信息流一致，
   三者被一个视觉动线串起来，不再各说各话。

   几何实现用 clip-path（不是 border 三角）：
   · border 三角做不出"带文字的箭头体"
   · clip-path 裁剪的是元素本体，文字可以正常居中，
     且不增加 DOM 节点、不依赖伪元素定位。
   右侧留 7px 给尖角，文字右内边距比左侧多 3px，保证视觉重心居中。
   ============================================================ */
.shopping-item .bx-disc-badge {
  /* 定位复位：旧样式是 absolute，会让 order / flex 布局全部失效 */
  position: static !important;
  top: auto !important;
  right: auto !important;
  left: auto !important;
  bottom: auto !important;

  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0 !important;

  height: 21px !important;
  min-width: 0 !important;
  /* ★ 尖角在左 → 内边距必须"左边大于右边"：
     左侧 15px（含 9px 尖角），右侧 7px。
     如果沿用"左小右大"，文字会明显偏右。 */
  padding: 0 7px 0 15px !important;
  margin-left: 8px !important;
  border-radius: 0 !important;

  background: var(--cfx-red) !important;
  border: 0 !important;
  color: #ffffff !important;
  font-size: 11.5px !important;
  font-weight: 800 !important;
  line-height: 21px !important;
  letter-spacing: .3px !important;
  white-space: nowrap !important;
  box-shadow: none !important;

  /* ★ 箭头形状：尖角朝左，指向左边的价格
     ------------------------------------------------------------
     用户要求"箭头应该指向价格方向"。
     之前的尖角在右侧，视觉上是"从价格往外飞出去"，方向反了。
     改成左侧尖角后，箭头像一支指回价格的箭头，
     表达"这个折扣力度属于左边这个价格"。

     顶点坐标：
       (9px,0) → (100%,0) → (100%,100%) → (9px,100%) → (0,50%)
       左边在垂直中点处收成尖，右边保持平直。
     尖角进深 9px ≈ 高度的 43%，接近 45° 标准箭头角。 */
  -webkit-clip-path: polygon(9px 0, 100% 0, 100% 100%, 9px 100%, 0 50%);
  clip-path: polygon(9px 0, 100% 0, 100% 100%, 9px 100%, 0 50%);

  /* 箭头指向右方，跟"价格 → 折扣"的阅读方向一致 */
  align-self: center !important;
  vertical-align: middle !important;
  transform: translateY(-1px);   /* 与金额视觉基线对齐（金额有下沉） */
}

/* 闪电图标隐藏（clip-path 会把图标也裁掉，且视觉噪音） */
.shopping-item .bx-disc-badge svg {
  display: none !important;
}

/* ============================================================
   ② 主价格行：居中
   ============================================================ */
.shopping-item .bx-price-line {
  display: flex !important;
  align-items: baseline !important;
  justify-content: center !important;   /* ★ 居中 */
  flex-wrap: nowrap !important;
  gap: 0 !important;
  line-height: 1 !important;
  min-height: 30px !important;
  white-space: nowrap !important;
  font-size: 0 !important;              /* 消除模板空白节点 */
  padding: 0 !important;
  margin: 0 !important;
  width: 100% !important;
  overflow: hidden !important;
}

.shopping-item .bx-price-line > * {
  font-size: 12px !important;
  flex-shrink: 0 !important;
  white-space: nowrap !important;
}

/* 货币符号：与金额同色，稍小 */
.shopping-item .bx-price-cur {
  font-size: 15px !important;
  font-weight: 700 !important;
  color: var(--cfx-red) !important;
  margin-right: 1px !important;
}

/* 金额整数：28px、高饱和红、等宽数字 */
.shopping-item .bx-price-int {
  font-size: 28px !important;
  font-weight: 800 !important;
  line-height: 1 !important;
  letter-spacing: -.8px !important;
  color: var(--cfx-red) !important;
  font-variant-numeric: tabular-nums !important;
  font-feature-settings: "tnum" 1 !important;
}

/* 小数：16px，比整数低一档但仍是红色（不降饱和） */
.shopping-item .bx-price-dec {
  font-size: 16px !important;
  font-weight: 800 !important;
  color: var(--cfx-red) !important;
  font-variant-numeric: tabular-nums !important;
  letter-spacing: -.2px !important;
}

/* 计价单位：灰、常规字重 */
.shopping-item .bx-price-unit {
  font-size: 12px !important;
  font-weight: 400 !important;
  color: #6b7280 !important;
  margin-left: 5px !important;
  letter-spacing: 0 !important;
}

/* 废弃元素 */
.shopping-item .bx-price-divider {
  display: none !important;
}

/* ============================================================
   ③ 对比行：原价划线 + 省多少，居中
   ============================================================ */
.shopping-item .bx-disc-row {
  display: flex !important;
  align-items: baseline !important;
  justify-content: center !important;    /* ★ 居中 */
  flex-wrap: wrap !important;
  gap: 0 7px !important;
  min-height: 17px !important;
  line-height: 17px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  font-size: 11.5px !important;
  text-align: center !important;
  width: 100% !important;
}

.shopping-item .bx-disc-origin-label {
  font-size: 11.5px !important;
  font-weight: 400 !important;
  color: #9aa3b0 !important;
}

.shopping-item .bx-disc-origin {
  font-size: 11.5px !important;
  font-weight: 400 !important;
  color: #9aa3b0 !important;
  text-decoration: line-through !important;
  text-decoration-color: #c3cad4 !important;
  text-decoration-thickness: 1px !important;
  font-variant-numeric: tabular-nums !important;
}

/* 「省 ¥1.50」：浅红药丸，把省的钱做成一个"小奖励" */
.shopping-item .bx-disc-save {
  display: inline-flex !important;
  align-items: baseline !important;
  gap: 2px !important;
  padding: 0 5px !important;
  border-radius: 3px !important;
  background: var(--cfx-red-soft) !important;
  border: 1px solid var(--cfx-red-border) !important;
  font-size: 11px !important;
  line-height: 15px !important;
}

.shopping-item .bx-disc-save-label {
  font-size: 11px !important;
  font-weight: 400 !important;
  color: var(--cfx-red-dark) !important;
}

.shopping-item .bx-disc-save-amount {
  font-size: 11px !important;
  font-weight: 800 !important;
  color: var(--cfx-red) !important;
  font-variant-numeric: tabular-nums !important;
}

/* ============================================================
   ④ 日均价：最底部的辅助信息
   ------------------------------------------------------------
   两种摆法（延续 v2 的判断）：
   · 有折扣标签 → 独立一行、居中、最灰
   · 无折扣标签 → 并进价格行末尾（否则整块只剩价格，太空）
   ============================================================ */
.shopping-item .bx-price-line .bx-price-perday-inline {
  display: none !important;
}

/* 有折扣时：日均价独立一行，居中、最灰。
   ------------------------------------------------------------
   ⚠️ 试过用负 margin 把它并入「原价/省」那一行，
   结果文字重叠（负 margin 会把它压到上一行内容上）。
   负 margin 在 flex 容器里不可靠 —— 它只移动视觉位置，
   不参与布局计算，一定会在某些字号/宽度下压字。

   回退为独立一行，靠"压行高 + 0 间距"把总高度控制在 18px。
   这是"排名信息"的常规摆法，不花哨但绝对不出错。 */
.shopping-item .bx-price-perday {
  display: block !important;
  order: 3;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  font-size: 11.5px !important;
  font-weight: 400 !important;
  color: #9aa3b0 !important;
  line-height: 14px !important;
  min-height: 14px !important;
  white-space: nowrap !important;
  font-variant-numeric: tabular-nums !important;
  text-align: center !important;
  align-self: center !important;
  /* 有折扣时它是第二行的补充信息，与上方 disc-row 只隔 1px */
  margin-top: -1px !important;
}

/* ---------- 日均价的显示逻辑（v4 调整） ----------
   有折扣：价格行里已经有「¥3.50 元/月付 ▶7折」，
          再塞日均价会挤爆（实测 3 个元素总宽超出卡片宽度），
          所以日均价改到第二行，与原价/省并排。
   无折扣：价格行只有金额 + 单位，空间充足，日均价直接跟在后面。 */
.shopping-item .bx-price-frame:has(.bx-disc-badge) .bx-price-line .bx-price-perday-inline {
  display: none !important;
}

/* 有折扣时，日均价从独立行改为并入"原价/省"那一行（行尾） */
.shopping-item .bx-price-frame:has(.bx-disc-badge) .bx-disc-row {
  flex-wrap: nowrap !important;
}

/* 无折扣：独立行版隐藏 */
.shopping-item .bx-price-frame:not(:has(.bx-disc-badge)) .bx-price-perday {
  display: none !important;
}

.shopping-item .bx-price-frame:not(:has(.bx-disc-badge)) .bx-price-line .bx-price-perday-inline {
  display: inline-flex !important;
  align-items: baseline !important;
  margin-left: 9px !important;
  padding-left: 9px !important;
  border-left: 1px solid #e6eaf0 !important;
  font-size: 11.5px !important;
  font-weight: 400 !important;
  color: #9aa3b0 !important;
  line-height: 1 !important;
  white-space: nowrap !important;
  font-variant-numeric: tabular-nums !important;
}

/* ============================================================
   ⑤ 立即购买：亮蓝（取自用户指定截图 #1d4ed8）
   ============================================================ */
.shopping-item .buy-btn,
.shopping-item .price-box .buy-btn {
  height: 40px !important;
  border-radius: 7px !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  letter-spacing: .5px !important;
  color: #ffffff !important;
  /* 轻微横向渐变：左亮右深，模拟图片里的侧光感 */
  background: linear-gradient(90deg, #2460e8 0%, #1d4ed8 55%, #1e50da 100%) !important;
  border: 1px solid #1b48c9 !important;
  box-shadow: 0 1px 2px rgba(29, 78, 216, .28) !important;
  transition: background .16s ease, box-shadow .16s ease !important;
}

.shopping-item .buy-btn span,
.shopping-item .price-box .buy-btn span {
  color: #ffffff !important;
}

.shopping-item .buy-btn i,
.shopping-item .price-box .buy-btn i {
  color: #ffffff !important;
  margin-right: 7px !important;
  font-size: 15px !important;
}

.shopping-item .buy-btn:hover,
.shopping-item .price-box .buy-btn:hover {
  /* hover 加深一档（不是提亮 —— 蓝色提亮会发灰） */
  background: linear-gradient(90deg, #1f55d6 0%, #1a45c0 55%, #1b48c5 100%) !important;
  border-color: #163aa3 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px -4px rgba(29, 78, 216, .5) !important;
}

.shopping-item .buy-btn:active,
.shopping-item .price-box .buy-btn:active {
  background: #163aa3 !important;
  border-color: #163aa3 !important;
  box-shadow: inset 0 2px 4px rgba(9, 30, 80, .3) !important;
}

.shopping-item .buy-btn:focus-visible {
  outline: 2px solid #6b96f5 !important;
  outline-offset: 2px !important;
}

/* ============================================================
   ⑥ 售罄态：全部转灰，且**不得**受价格红 / 折扣红 / 购买蓝影响
   ============================================================ */
.shopping-item.is-sold-out .bx-price-int,
.shopping-item.is-sold-out .bx-price-dec,
.shopping-item.is-sold-out .bx-price-cur,
.shopping-item.is-sold-out .bx-disc-save-amount,
.shopping-item.is-sold-out .bx-disc-save-label {
  color: #9aa3b0 !important;
}

.shopping-item.is-sold-out .bx-disc-badge {
  background: #f1f3f6 !important;
  border-color: #e2e6ec !important;
  color: #9aa3b0 !important;
  box-shadow: none !important;
}

.shopping-item.is-sold-out .bx-disc-save {
  background: #f6f7f9 !important;
  border-color: #e6e9ee !important;
}

.shopping-item.is-sold-out .buy-btn,
.shopping-item.is-sold-out .buy-btn span,
.shopping-item.is-sold-out .buy-btn i,
.shopping-item .buy-btn.is-sold-out-btn,
.shopping-item .buy-btn.is-sold-out-btn span,
.shopping-item .buy-btn.is-sold-out-btn i {
  background: #f1f3f6 !important;
  border-color: #e2e6ec !important;
  color: #9aa3b0 !important;
  box-shadow: none !important;
  transform: none !important;
}

.shopping-item.is-sold-out .buy-btn:hover,
.shopping-item.is-sold-out .buy-btn:active,
.shopping-item .buy-btn.is-sold-out-btn:hover,
.shopping-item .buy-btn.is-sold-out-btn:active {
  background: #f1f3f6 !important;
  border-color: #e2e6ec !important;
  color: #9aa3b0 !important;
  box-shadow: none !important;
  cursor: not-allowed !important;
}

/* ============================================================
   移动端（≤750px）
   ------------------------------------------------------------
   居中布局不需要改方向，只需缩小字号。
   ============================================================ */
@media screen and (max-width: 750px) {
  .shopping-item .bx-price-frame {
    gap: 2px !important;
  }

  .shopping-item .bx-disc-badge {
    height: 20px !important;
    min-width: 0 !important;
    padding: 0 6px 0 13px !important;
    margin-left: 7px !important;
    font-size: 11px !important;
    line-height: 20px !important;
    /* 手机上尖角同样朝左，进深 8px */
    -webkit-clip-path: polygon(8px 0, 100% 0, 100% 100%, 8px 100%, 0 50%);
    clip-path: polygon(8px 0, 100% 0, 100% 100%, 8px 100%, 0 50%);
  }

  .shopping-item .bx-price-line {
    min-height: 27px !important;
  }

  .shopping-item .bx-price-int {
    font-size: 25px !important;
    letter-spacing: -.6px !important;
  }

  .shopping-item .bx-price-dec {
    font-size: 14px !important;
  }

  .shopping-item .bx-price-cur {
    font-size: 14px !important;
  }

  .shopping-item .bx-price-unit {
    font-size: 11.5px !important;
    margin-left: 4px !important;
  }

  .shopping-item .bx-disc-row,
  .shopping-item .bx-disc-origin-label,
  .shopping-item .bx-disc-origin,
  .shopping-item .bx-disc-save-label,
  .shopping-item .bx-disc-save-amount {
    font-size: 11px !important;
  }

  .shopping-item .bx-price-perday,
  .shopping-item .bx-price-line .bx-price-perday-inline {
    font-size: 11px !important;
  }

  .shopping-item .bx-price-perday {
    font-size: 11px !important;
    line-height: 13px !important;
    min-height: 13px !important;
  }

  .shopping-item .buy-btn,
  .shopping-item .price-box .buy-btn {
    height: 42px !important;
    font-size: 14px !important;
  }
}

/* 超窄屏（≤360） */
@media screen and (max-width: 360px) {
  .shopping-item .bx-price-int {
    font-size: 23px !important;
  }

  .shopping-item .bx-price-dec {
    font-size: 13px !important;
  }

  .shopping-item .bx-price-cur {
    font-size: 13px !important;
  }

  .shopping-item .bx-price-unit {
    font-size: 11px !important;
    margin-left: 3px !important;
  }

  .shopping-item .bx-disc-origin-label,
  .shopping-item .bx-disc-origin {
    font-size: 10.5px !important;
  }
}

/* 尊重减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  .shopping-item .buy-btn {
    transition: none !important;
  }
}

/* ============================================================
   商品介绍里的「说明」红字 —— 一律跟随后台
   ------------------------------------------------------------
   2026-11-24 改：这里原本把后台写死的 color:#ff0000 压成
   --cfx-red-dark(#c9261f)，card_unify.css 里还压过一次 #b23a2e，
   结果「后台富文本编辑器里是亮红、前台商品卡里是暗红」。
   现在删掉全部颜色覆盖：内联 style 直接生效，后台写什么色前台就什么色。
   只保留售罄态的降灰（售罄卡整体去色，避免红字在灰卡里抢眼）。
   ============================================================ */

/* 售罄卡：说明文字也转灰（唯一允许改色的场景） */
.shopping-item.is-sold-out .bx-spec-raw span[style*="color: #ff0000"],
.shopping-item.is-sold-out .bx-spec-raw span[style*="color:#ff0000"],
.shopping-item.is-sold-out .bx-spec-raw span[style*="color: rgb(255, 0, 0)"],
.shopping-item.is-sold-out .bx-spec-raw font[color="red"],
.shopping-item.is-sold-out .bx-spec-raw font[color="#ff0000"] {
  color: #9aa3b0 !important;
  font-weight: 400 !important;
}
