/* ============================================================
 * LXMall v1.17.0 · 商品对比插件（compare）
 *
 * 颜色全部取自 --pg-* 变量（由 theme-*.css / 配色系统注入），
 * 因此 25 套配色与 11 套布局都能直接复用；布局层可在其后覆盖局部。
 * ============================================================ */

/* ------------------------------------------------------------
 * 1. 顶栏入口
 * ------------------------------------------------------------ */
.cmp-top-link { position: relative; display: inline-flex; align-items: center; gap: 5px; }
.cmp-top-link i { font-size: .84rem; }
.cmp-top-count {
    display: none;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--pg-primary);
    color: #fff;
    font-size: .62rem;
    font-weight: 800;
    line-height: 16px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.cmp-top-link.has-count .cmp-top-count { display: inline-block; }

/* ------------------------------------------------------------
 * 2. 商品卡片上的对比按钮（与收藏按钮并排）
 * ------------------------------------------------------------ */
.pcard-compare {
    position: absolute;
    top: 10px;
    right: 52px;
    z-index: 4;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, .6);
    border-radius: 50%;
    background: rgba(255, 255, 255, .88);
    color: #475569;
    font-size: .88rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity .18s ease, transform .18s ease, color .18s ease, background .18s ease, border-color .18s ease;
    backdrop-filter: blur(6px);
}
.product-card:hover .pcard-compare,
.pcard-compare:focus-visible,
.pcard-compare.on { opacity: 1; transform: translateY(0); }
.pcard-compare:hover { color: var(--pg-primary); background: #fff; }
.pcard-compare.on { color: var(--pg-primary); background: var(--pg-primary-soft); border-color: var(--pg-primary); }
.pcard-compare:focus-visible { outline: 2px solid var(--pg-primary); outline-offset: 2px; }
.pcard-compare-tip {
    position: absolute;
    top: 50%;
    right: calc(100% + 7px);
    transform: translateY(-50%);
    padding: 4px 9px;
    border-radius: 6px;
    background: rgba(20, 24, 35, .92);
    color: #fff;
    font-size: .68rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity .16s ease;
}
.pcard-compare:hover .pcard-compare-tip,
.pcard-compare:focus-visible .pcard-compare-tip { opacity: 1; }
@media (hover: none) {
    .pcard-compare { opacity: 1; transform: none; }
    .pcard-compare-tip { display: none; }
}

/* 详情页图标按钮的选中态 */
.btn-icon-sq[data-compare].on {
    border-color: var(--pg-primary);
    background: var(--pg-primary-soft);
    color: var(--pg-primary);
}

/* ------------------------------------------------------------
 * 3. 浮动对比栏
 * ------------------------------------------------------------ */
.cmp-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1060;
    background: color-mix(in srgb, var(--pg-surface) 92%, transparent);
    border-top: 1px solid var(--pg-line);
    box-shadow: 0 -12px 36px -16px rgba(15, 23, 42, .28);
    backdrop-filter: blur(14px);
    transform: translateY(115%);
    opacity: 0;
    pointer-events: none;
    transition: transform .28s var(--pg-ease, ease), opacity .22s ease;
}
.cmp-bar.is-active { transform: translateY(0); opacity: 1; pointer-events: auto; }
.cmp-bar-inner {
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 92px;
    padding-top: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}
.cmp-bar-head { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.cmp-bar-ico {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    background: var(--pg-primary-soft);
    color: var(--pg-primary);
    font-size: 1rem;
}
.cmp-bar-txt { display: flex; flex-direction: column; min-width: 0; }
.cmp-bar-txt b { font-size: .84rem; font-weight: 700; color: var(--pg-ink); white-space: nowrap; }
.cmp-bar-txt small { font-size: .7rem; color: var(--pg-ink-3); white-space: nowrap; }
.cmp-bar-num {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--pg-primary);
    color: #fff;
    font-size: .66rem;
    line-height: 17px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.cmp-bar-num:empty { display: none; }

.cmp-slots {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.cmp-slots::-webkit-scrollbar { display: none; }
.cmp-slot {
    position: relative;
    flex: 0 0 62px;
    width: 62px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--pg-line);
    border-radius: 10px;
    background: var(--pg-surface-2);
    color: var(--pg-ink-3);
    font-size: .9rem;
    overflow: hidden;
}
.cmp-slot.is-filled { border-style: solid; border-color: var(--pg-line); background: var(--pg-surface); }
.cmp-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cmp-slot-name {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 3px 4px;
    background: linear-gradient(180deg, transparent, rgba(15, 23, 42, .82));
    color: #fff;
    font-size: .58rem;
    line-height: 1.25;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cmp-slot-rm {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: rgba(15, 23, 42, .72);
    color: #fff;
    font-size: .78rem;
    line-height: 1;
    cursor: pointer;
}
.cmp-slot-rm:hover { background: #be123c; }

.cmp-bar-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }
.cmp-clear {
    border: 0;
    background: transparent;
    color: var(--pg-ink-3);
    font-size: .76rem;
    cursor: pointer;
    padding: 6px 4px;
}
.cmp-clear:hover { color: var(--pg-primary); }
.cmp-go {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 11px;
    background: var(--pg-primary);
    color: #fff;
    font-size: .82rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    transition: transform .18s ease, opacity .18s ease;
}
.cmp-go:hover { color: #fff; transform: translateY(-1px); }
.cmp-go.is-disabled { background: var(--pg-surface-3, #e9ecf3); color: var(--pg-ink-3); cursor: not-allowed; }
.cmp-go.is-disabled:hover { transform: none; }
.cmp-go i { font-size: .82rem; }

/* 对比栏出现时给页面底部留白，并避让管理员预览按钮 / 详情页吸底购买条 */
body.cmp-bar-on { padding-bottom: 92px; }
body.cmp-bar-on .wm-preview-bar { bottom: 122px; }
body.cmp-buybar-on .cmp-bar { bottom: calc(66px + env(safe-area-inset-bottom, 0px)); }
body.cmp-bar-on.cmp-buybar-on { padding-bottom: 152px; }

/* ------------------------------------------------------------
 * 4. 轻提示
 * ------------------------------------------------------------ */
.cmp-toast {
    position: fixed;
    left: 50%;
    bottom: 122px;
    z-index: 1090;
    transform: translate(-50%, 12px);
    padding: 9px 18px;
    border-radius: 999px;
    background: rgba(20, 24, 35, .94);
    color: #fff;
    font-size: .8rem;
    font-weight: 600;
    box-shadow: 0 12px 30px -12px rgba(15, 23, 42, .6);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}
.cmp-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
body.cmp-bar-on.cmp-buybar-on .cmp-toast { bottom: 188px; }

/* ------------------------------------------------------------
 * 5. 对比页
 * ------------------------------------------------------------ */
.cmp-page { padding-bottom: 8px; }
.cmp-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
    margin-bottom: 14px;
    border: 1px solid var(--pg-line);
    border-radius: 14px;
    background: var(--pg-surface);
}
.cmp-toolbar-meta { flex: 1 1 auto; min-width: 180px; font-size: .8rem; color: var(--pg-ink-2); }
.cmp-toolbar-meta b { color: var(--pg-primary); font-weight: 800; font-variant-numeric: tabular-nums; }
.cmp-diff-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 13px;
    border: 1px solid var(--pg-line);
    border-radius: 9px;
    background: var(--pg-surface-2);
    color: var(--pg-ink-2);
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .16s ease, color .16s ease, background .16s ease;
}
.cmp-diff-toggle .mark {
    width: 26px;
    height: 15px;
    border-radius: 999px;
    background: var(--pg-line);
    position: relative;
    transition: background .16s ease;
}
.cmp-diff-toggle .mark::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #fff;
    transition: transform .16s ease;
}
.cmp-diff-toggle[aria-pressed="true"] { border-color: var(--pg-primary); color: var(--pg-primary); background: var(--pg-primary-soft); }
.cmp-diff-toggle[aria-pressed="true"] .mark { background: var(--pg-primary); }
.cmp-diff-toggle[aria-pressed="true"] .mark::after { transform: translateX(11px); }
.cmp-toolbar-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .78rem;
    font-weight: 600;
    color: var(--pg-ink-2);
    text-decoration: none;
    padding: 7px 11px;
    border: 1px solid var(--pg-line);
    border-radius: 9px;
}
.cmp-toolbar-link:hover { color: var(--pg-primary); border-color: var(--pg-primary); }

.cmp-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--pg-line);
    border-radius: 16px;
    background: var(--pg-surface);
    box-shadow: var(--pg-shadow, none);
}
.cmp-table { width: 100%; min-width: 640px; border-collapse: separate; border-spacing: 0; }
.cmp-table th, .cmp-table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--pg-line);
    text-align: left;
    vertical-align: top;
    font-size: .82rem;
    color: var(--pg-ink-2);
}
.cmp-table tbody tr:last-child th, .cmp-table tbody tr:last-child td { border-bottom: 0; }
.cmp-table thead th { background: var(--pg-surface-2); vertical-align: top; }
.cmp-col-label {
    width: 152px;
    min-width: 152px;
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--pg-surface-2);
    color: var(--pg-ink-2) !important;
    font-weight: 650;
    font-size: .78rem !important;
}
.cmp-table thead .cmp-col-label { z-index: 4; }
.cmp-table tbody tr:hover td:not(.cmp-col-label) { background: var(--pg-primary-soft); }
.cmp-table tbody tr:hover .cmp-col-label { background: var(--pg-surface-2); }
.cmp-table.is-diff-only tbody tr.cmp-row:not(.is-diff) { display: none; }
.cmp-table tbody tr.is-diff td:not(.cmp-col-label) { color: var(--pg-ink); font-weight: 600; }
.cmp-table tbody tr.is-strong td:not(.cmp-col-label) { color: var(--pg-price); font-weight: 800; font-size: .92rem; }
.cmp-row.is-diff .cmp-col-label::after {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-left: 7px;
    border-radius: 50%;
    background: var(--pg-primary);
    vertical-align: middle;
}
.cmp-group th {
    padding: 10px 16px;
    background: var(--pg-primary-soft);
    color: var(--pg-primary) !important;
    font-size: .74rem !important;
    font-weight: 800;
    letter-spacing: .04em;
}
.cmp-badge-low {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 5px;
    background: #fff1f2;
    color: #be123c;
    font-size: .62rem;
    font-weight: 700;
    vertical-align: middle;
}
.cmp-stock-ok { color: #15803d; }
.cmp-stock-out { color: #be123c; }

.cmp-col-product { min-width: 210px; }
.cmp-product { position: relative; display: block; }
.cmp-product-img {
    width: 100%;
    height: 132px;
    object-fit: contain;
    border-radius: 10px;
    background: var(--pg-surface-2);
    display: block;
    margin-bottom: 10px;
}
.cmp-product-img-ph { display: flex; align-items: center; justify-content: center; color: var(--pg-ink-3); font-size: 1.6rem; }
.cmp-product-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: .86rem;
    font-weight: 700;
    line-height: 1.45;
    color: var(--pg-ink);
    text-decoration: none;
}
.cmp-product-name:hover { color: var(--pg-primary); }
.cmp-product-price { display: block; margin-top: 7px; font-size: 1rem; font-weight: 800; color: var(--pg-price); }
.cmp-col-badges { display: flex; gap: 4px; margin-top: 7px; flex-wrap: wrap; }
.cmp-col-actions { display: flex; gap: 7px; margin-top: 11px; flex-wrap: wrap; }
.cmp-col-actions a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border: 1px solid var(--pg-line);
    border-radius: 8px;
    color: var(--pg-ink-2);
    font-size: .72rem;
    font-weight: 650;
    text-decoration: none;
}
.cmp-col-actions a:hover { border-color: var(--pg-primary); color: var(--pg-primary); }
.cmp-col-actions a.is-main { background: var(--pg-primary); border-color: var(--pg-primary); color: #fff; }
.cmp-col-actions a.is-main:hover { color: #fff; }
.cmp-col-rm {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border: 1px solid var(--pg-line);
    border-radius: 50%;
    background: var(--pg-surface);
    color: var(--pg-ink-3);
    font-size: .82rem;
    line-height: 1;
    cursor: pointer;
}
.cmp-col-rm:hover { color: #be123c; border-color: #fecdd3; }

.cmp-empty { padding: 52px 20px 58px; text-align: center; }
.cmp-empty-ico {
    width: 66px;
    height: 66px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    background: var(--pg-primary-soft);
    color: var(--pg-primary);
    font-size: 1.5rem;
}
.cmp-empty h2 { font-size: 1.12rem; font-weight: 750; color: var(--pg-ink); margin: 0 0 8px; }
.cmp-empty p { font-size: .84rem; color: var(--pg-ink-3); max-width: 420px; margin: 0 auto 20px; line-height: 1.7; }
.cmp-empty-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    border-radius: 11px;
    background: var(--pg-primary);
    color: #fff;
    font-size: .82rem;
    font-weight: 700;
    text-decoration: none;
}
.cmp-empty-btn:hover { color: #fff; }
.cmp-min-note {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 12px 16px;
    margin-bottom: 14px;
    border: 1px dashed var(--pg-line);
    border-radius: 12px;
    background: var(--pg-surface-2);
    font-size: .8rem;
    color: var(--pg-ink-2);
}
.cmp-min-note i { color: var(--pg-primary); font-size: .95rem; }

/* 详情描述展开/收起（对比页与详情页共用） */
.cmp-desc-clamp { max-height: 220px; overflow: hidden; position: relative; }
.cmp-desc-clamp::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 64px;
    background: linear-gradient(180deg, transparent, var(--pg-surface));
    pointer-events: none;
}
.cmp-desc-clamp.is-expanded { max-height: none; }
.cmp-desc-clamp.is-expanded::after { display: none; }
.cmp-expand-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 7px 14px;
    border: 1px solid var(--pg-line);
    border-radius: 9px;
    background: var(--pg-surface);
    color: var(--pg-primary);
    font-size: .78rem;
    font-weight: 650;
    cursor: pointer;
}
.cmp-expand-btn:hover { border-color: var(--pg-primary); }

/* ------------------------------------------------------------
 * 6. 暗色配色与响应式
 * ------------------------------------------------------------ */
body.is-dark .cmp-bar { background: rgba(15, 19, 28, .92); }
body.is-dark .cmp-slot { background: rgba(255, 255, 255, .05); }
body.is-dark .cmp-go.is-disabled { background: rgba(255, 255, 255, .1); }
body.is-dark .cmp-table thead th,
body.is-dark .cmp-col-label { background: rgba(255, 255, 255, .05); }

@media (max-width: 991.98px) {
    .cmp-bar-txt small { display: none; }
    .cmp-bar-inner { gap: 12px; }
}
@media (max-width: 767.98px) {
    .cmp-bar-inner { min-height: 76px; gap: 10px; padding-top: 9px; }
    .cmp-bar-head .cmp-bar-txt { display: none; }
    .cmp-bar-ico { width: 32px; height: 32px; border-radius: 9px; }
    .cmp-slot { flex-basis: 52px; width: 52px; height: 52px; }
    .cmp-slot-name { display: none; }
    .cmp-bar-actions { gap: 6px; }
    .cmp-clear { font-size: .72rem; }
    .cmp-go { padding: 9px 12px; font-size: .76rem; }
    .cmp-go i { display: none; }
    body.cmp-bar-on { padding-bottom: 78px; }
    body.cmp-bar-on .wm-preview-bar { bottom: 104px; }
    body.cmp-bar-on.cmp-buybar-on { padding-bottom: 138px; }
    .cmp-toast { bottom: 100px; }
    body.cmp-bar-on.cmp-buybar-on .cmp-toast { bottom: 166px; }

    .cmp-toolbar { padding: 10px 12px; }
    .cmp-toolbar-meta { min-width: 100%; }
    .cmp-table { min-width: 560px; }
    .cmp-col-label { width: 116px; min-width: 116px; padding: 11px 10px; }
    .cmp-table th, .cmp-table td { padding: 11px 10px; }
    .cmp-product-img { height: 96px; }
    .cmp-col-product { min-width: 168px; }
}
@media (max-width: 479.98px) {
    .cmp-bar-head { display: none; }
    .cmp-slots { gap: 7px; }
    .cmp-slot { flex-basis: 46px; width: 46px; height: 46px; }
    .cmp-go { padding: 8px 10px; }
    .cmp-top-link i { margin-right: 0; }
}

/* ------------------------------------------------------------
 * 7. v1.17.0 细节：选中态反馈 / 顶栏窄屏 / 卡片窄屏避让
 * ------------------------------------------------------------ */
.cmp-top-label { display: inline; }
.cmp-top-link:hover { color: var(--pg-primary); }
.product-card:has(.pcard-compare.on) {
    border-color: color-mix(in srgb, var(--pg-primary) 45%, var(--pg-line));
    box-shadow: 0 0 0 1px var(--pg-primary-soft), var(--pg-shadow, none);
}
.cmp-bar.is-active .cmp-slot.is-filled { animation: cmpSlotIn .26s var(--pg-ease, ease) both; }
@keyframes cmpSlotIn {
    from { opacity: 0; transform: translateY(6px) scale(.94); }
    to   { opacity: 1; transform: none; }
}
@media (max-width: 767.98px) {
    .cmp-top-label { display: none; }
}
@media (max-width: 479.98px) {
    .pcard-compare { right: 10px; top: 50px; }
    .pcard-compare-tip { display: none; }
}
.cmp-group[hidden] { display: none; }
