/* CPMLS Cart UX — v1.1.5
 * 顏色沿用懸浮選單的變數（--cfm-primary / --cfm-secondary），沒有就用預設值。 */

:root {
    --cux-primary: var(--cfm-primary, #1a5276);
    --cux-accent: var(--cfm-secondary, #4ecdc4);
    --cux-border: #e6e9ee;
    --cux-muted: #8a94a3;
    --cux-warn-bg: #fff8e1;
    --cux-warn-bd: #f2c94c;
    --cux-warn-tx: #7a5a00;
    --cux-badge: #e53935;
    --cux-radius: 12px;
}

html.cpmls-cux-busy, html.cpmls-cux-busy * { cursor: progress !important; }
.cpmls-cux-i18n-box { display: none !important; }

/* ── 重複車型提示 ── */
.cpmls-cux-dup {
    background: var(--cux-warn-bg);
    border: 1px solid var(--cux-warn-bd);
    border-left-width: 4px;
    border-radius: 8px;
    color: var(--cux-warn-tx);
    padding: 12px 16px;
    margin: 0 0 16px;
    font-size: 0.92rem;
    line-height: 1.5;
}
.cpmls-cux-dup__msg { margin: 0 0 6px; font-weight: 600; }
.cpmls-cux-dup__list { margin: 0; padding: 0; list-style: none; }
.cpmls-cux-dup__list li { margin: 2px 0; }
.cpmls-cux-dup__model { font-weight: 700; margin-right: 6px; }
.cpmls-cux-dup__model::after { content: ":"; }
.cpmls-cux-dup__item + .cpmls-cux-dup__item::before { content: " · "; opacity: .6; }

.cpmls-cux-dup-tag {
    display: inline-block;
    margin: 4px 0 0;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--cux-warn-bg);
    border: 1px solid var(--cux-warn-bd);
    color: var(--cux-warn-tx);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.6;
}
.cpmls-cux-dup-tag__model { margin-left: 4px; font-weight: 700; }
td.product-name .cpmls-cux-dup-tag { display: table; }
.cpmls-cux-dinfo .cpmls-cux-dup-tag { align-self: flex-start; }

/* 購物車頁：黃框（或沒有黃框時的工具列）與上方保留間距 */
.woocommerce-cart-form .cpmls-cux-dup,
.woocommerce-cart-form > .cpmls-cux-toolbar:first-child { margin-top: 20px; }

/* ── 購物車工具列 ── */
.cpmls-cux-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 18px;
    padding: 10px 14px;
    margin: 0 0 12px;
    border: 1px solid var(--cux-border);
    border-radius: 10px;
    background: #fff;
    font-size: 0.92rem;
}
.cpmls-cux-all { display: inline-flex; align-items: center; gap: 6px; margin: 0; cursor: pointer; font-weight: 600; }
.cpmls-cux-sel b, .cpmls-cux-sum b { margin-left: 4px; color: var(--cux-primary); }
.cpmls-cux-hint { flex-basis: 100%; margin: 0; color: var(--cux-muted); font-size: 0.82rem; }

.cpmls-cux-cb, .cpmls-cux-all-cb {
    width: 18px; height: 18px; margin: 0 8px 0 0;
    accent-color: var(--cux-primary);
    vertical-align: middle;
    cursor: pointer;
}
td.product-remove { white-space: nowrap; }

tr.cpmls-cux-off td:not(.product-remove) > *:not(.cpmls-cux-cb):not(a.remove),
li.cpmls-cux-off > *:not(.cpmls-cux-cb):not(.cpmls-cux-x),
.cpmls-cux-ritem.is-stashed > *:not(.cpmls-cux-cb):not(.cpmls-cux-x),
.cpmls-cux-ditem.is-stashed > *:not(.cpmls-cux-cb):not(.cpmls-cux-x) { opacity: .5; }
.cpmls-cux-stash-tag {
    display: inline-block; margin-left: 6px; padding: 0 8px;
    border-radius: 999px; background: #eef1f5; color: var(--cux-muted);
    font-size: 0.72rem; line-height: 1.7; vertical-align: middle;
}

.cpmls-cux-x {
    border: 0; background: transparent; cursor: pointer;
    width: 28px; height: 28px; border-radius: 50%;
    font-size: 1.25rem; line-height: 1; color: var(--cux-muted);
    padding: 0; vertical-align: middle;
}
.cpmls-cux-x:hover { background: #fdecea; color: #c62828; }

/* ── 最近刪除／暫存清單 ── */
.cpmls-cux-removed, .cpmls-cux-stash {
    margin: 16px 0;
    border: 1px solid var(--cux-border);
    border-radius: var(--cux-radius);
    background: #fff;
}
.cpmls-cux-removed > summary {
    cursor: pointer; list-style: none;
    padding: 12px 16px; font-weight: 600; color: var(--cux-primary);
    display: flex; align-items: center; gap: 6px;
}
.cpmls-cux-removed > summary::-webkit-details-marker { display: none; }
.cpmls-cux-removed > summary::before {
    content: ""; width: 0; height: 0;
    border-left: 6px solid currentColor; border-top: 5px solid transparent; border-bottom: 5px solid transparent;
    transition: transform .15s;
}
.cpmls-cux-removed[open] > summary::before { transform: rotate(90deg); }
.cpmls-cux-n { color: var(--cux-muted); font-weight: 500; }
.cpmls-cux-stash__title { margin: 0; padding: 12px 16px 2px; font-weight: 600; color: var(--cux-primary); }
.cpmls-cux-stash__hint { margin: 0; padding: 0 16px 8px; color: var(--cux-muted); font-size: 0.82rem; }
.cpmls-cux-ritem .cpmls-cux-cb, .cpmls-cux-ditem .cpmls-cux-cb { margin: 0; flex-shrink: 0; }

.cpmls-cux-rlist { list-style: none; margin: 0; padding: 0 16px; }
.cpmls-cux-ritem {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 0; border-top: 1px solid var(--cux-border);
}
.cpmls-cux-rinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cpmls-cux-name { font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
.cpmls-cux-price { font-size: 0.85rem; color: var(--cux-muted); }
.cpmls-cux-rbtn { white-space: nowrap; font-size: 0.85rem !important; }
.cpmls-cux-ractions {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px 14px; border-top: 1px solid var(--cux-border);
}
.cpmls-cux-linkbtn {
    border: 0; background: transparent; padding: 0; cursor: pointer;
    color: var(--cux-muted); font-size: 0.82rem; text-decoration: underline;
}
.cpmls-cux-thumb { flex-shrink: 0; width: 52px; }
.cpmls-cux-thumb img { width: 52px !important; height: 52px !important; object-fit: cover; border-radius: 8px; display: block; }

/* ── 懸浮球：購物車圖示與角標 ── */
.cpmls-cux-cfm-btn { position: relative; }
.cpmls-cux-badge {
    display: none;
    position: absolute; top: 2px; right: 0;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: var(--cux-badge); color: #fff;
    font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
    box-shadow: 0 0 0 2px #fff;
    pointer-events: none;
    z-index: 2;
}
.cpmls-cux-badge.is-on { display: block; }
.cpmls-cux-badge.is-dot { min-width: 10px; width: 10px; height: 10px; padding: 0; top: 6px; right: 6px; }
.cpmls-cux-badge--trigger { top: -2px; right: -2px; }
/* 選單展開時懸浮球本體的角標收起來，避免和圖示列上的重複 */
.cfm-container.cfm-open .cpmls-cux-badge--trigger { display: none; }

/* ── 側邊小窗 ── */
.cpmls-cux-drawer-backdrop {
    position: fixed; inset: 0; z-index: 1000004;
    background: rgba(15, 23, 42, .35);
    opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.cpmls-cux-drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }
html.cpmls-cux-lock, html.cpmls-cux-lock body { overflow: hidden; }

.cpmls-cux-drawer {
    position: fixed; top: 0; bottom: 0; z-index: 1000005;
    width: 400px; max-width: 90vw;
    background: #fff;
    display: flex; flex-direction: column;
    box-shadow: 0 0 24px rgba(0, 0, 0, .12);
    transition: transform .32s cubic-bezier(.2, .8, .2, 1);
    color: var(--cux-primary);
}
.cpmls-cux-drawer--right { right: 0; transform: translateX(105%); border-radius: 18px 0 0 18px; }
.cpmls-cux-drawer--left  { left: 0;  transform: translateX(-105%); border-radius: 0 18px 18px 0; }
.cpmls-cux-drawer.is-open { transform: translateX(0); }

.cpmls-cux-drawer__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px; border-bottom: 1px solid var(--cux-border);
}
.cpmls-cux-drawer__title { font-weight: 700; font-size: 1.05rem; }
.cpmls-cux-drawer__close {
    border: 0; background: transparent; cursor: pointer;
    width: 34px; height: 34px; border-radius: 50%;
    font-size: 1.5rem; line-height: 1; color: var(--cux-muted); padding: 0;
}
.cpmls-cux-drawer__close:hover { background: #f2f4f7; }

.cpmls-cux-drawer__loading {
    display: none; padding: 24px 18px; color: var(--cux-muted); text-align: center;
}
.cpmls-cux-drawer.is-loading .cpmls-cux-drawer__loading { display: block; }
/* 已經有內容（上次的快取）就不顯示「載入中」文字，只靠頂端進度線 */
.cpmls-cux-drawer.is-loading:has(.cpmls-cux-drawer__body:not(:empty)) .cpmls-cux-drawer__loading { display: none; }

.cpmls-cux-drawer__body {
    flex: 1; overflow-y: auto; overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.cpmls-cux-dbody { display: flex; flex-direction: column; min-height: 100%; }
.cpmls-cux-dbody > .cpmls-cux-dup { margin: 14px 16px 0; }
.cpmls-cux-dempty { padding: 32px 18px; text-align: center; color: var(--cux-muted); margin: 0; }
.cpmls-cux-drawer__error { padding: 28px 18px; text-align: center; color: var(--cux-muted); }
.cpmls-cux-drawer__error p { margin: 0 0 12px; }
.cpmls-cux-drawer.is-loading .cpmls-cux-drawer__error { display: none; }

/* 先顯示上次內容、背景更新時：只在頂端放一條進度線，不遮住內容 */
.cpmls-cux-drawer::after {
    content: ""; position: absolute; left: 0; top: 0; height: 2px; width: 0;
    background: var(--cux-accent); opacity: 0; transition: none;
}
.cpmls-cux-drawer.is-loading::after { opacity: 1; width: 85%; transition: width 4s cubic-bezier(.1, .7, .2, 1); }

.cpmls-cux-dtool {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 16px 4px; font-size: 0.88rem;
}
.cpmls-cux-dtool .cpmls-cux-sel b { margin-left: 2px; }

.cpmls-cux-ditems { list-style: none; margin: 0; padding: 4px 16px; }
.cpmls-cux-ditem {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0; border-bottom: 1px solid var(--cux-border);
}
.cpmls-cux-dinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cpmls-cux-dinfo .cpmls-cux-stash-tag { align-self: flex-start; margin-left: 0; }
.cpmls-cux-dmeta { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

/* 數量加減 */
.cpmls-cux-step {
    display: inline-flex; align-items: center;
    border: 1px solid var(--cux-border); border-radius: 8px; overflow: hidden;
    height: 28px;
}
.cpmls-cux-step__btn {
    width: 28px; height: 28px; border: 0; background: #f5f7fa; padding: 0;
    font-size: 1rem; line-height: 1; color: var(--cux-primary); cursor: pointer;
}
.cpmls-cux-step__btn:disabled { color: #c3c9d2; cursor: not-allowed; }
.cpmls-cux-step__n { min-width: 30px; text-align: center; font-size: 0.88rem; font-weight: 600; }
.cpmls-cux-qty { color: var(--cux-muted); }

.cpmls-cux-dbody .cpmls-cux-removed, .cpmls-cux-dbody .cpmls-cux-stash { margin: 12px 16px; }

.cpmls-cux-dfoot {
    margin-top: auto;
    position: sticky; bottom: 0;
    background: #fff;
    border-top: 1px solid var(--cux-border);
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
}
.cpmls-cux-dsub { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; font-size: 0.95rem; }
.cpmls-cux-dsub strong { font-size: 1.1rem; }
.cpmls-cux-dbtns { display: flex; gap: 10px; }
.cpmls-cux-dbtns .cpmls-cux-dbtn {
    flex: 1; display: inline-flex; align-items: center; justify-content: center;
    min-height: 44px; padding: 0 12px; margin: 0;
    border-radius: 10px; border: 1.5px solid var(--cux-primary);
    font-size: 0.95rem; font-weight: 700; text-decoration: none; line-height: 1.2;
    transition: opacity .15s ease;
}
.cpmls-cux-dbtns .cpmls-cux-dbtn--cart     { background: #fff; color: var(--cux-primary); }
.cpmls-cux-dbtns .cpmls-cux-dbtn--checkout { background: var(--cux-primary); color: #fff; }
.cpmls-cux-dbtns .cpmls-cux-dbtn:hover     { opacity: .88; }

/* ── Toast ── */
.cpmls-cux-toast {
    position: fixed; left: 50%; bottom: 96px; z-index: 1000020;
    transform: translateX(-50%) translateY(16px);
    background: var(--cux-primary); color: #fff;
    padding: 10px 18px; border-radius: 10px;
    font-size: 0.88rem; font-weight: 600;
    max-width: calc(100vw - 32px); text-align: center;
    opacity: 0; pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .15);
}
.cpmls-cux-toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── 手機 ── */
@media (max-width: 640px) {
    .cpmls-cux-toolbar { gap: 8px 12px; padding: 10px 12px; }
    .cpmls-cux-drawer { width: 88vw; }
    .cpmls-cux-ritem { flex-wrap: wrap; }
    .cpmls-cux-ritem .cpmls-cux-rbtn { margin-left: 64px; }
}

@media (prefers-reduced-motion: reduce) {
    .cpmls-cux-drawer, .cpmls-cux-drawer-backdrop, .cpmls-cux-toast { transition: none; }
}

.cpmls-cux-dup-wrap:empty { display: none; }

/* ── 結帳頁唯讀小窗（v1.1.3） ── */
.cpmls-cux-lock-note {
    margin: 14px 16px 0; padding: 10px 14px;
    border-radius: 8px; background: #eef4f9; color: var(--cux-primary);
    font-size: 0.88rem; font-weight: 600; line-height: 1.5;
}
.cpmls-cux-dbody.is-readonly .cpmls-cux-line { font-size: 0.9rem; }
.cpmls-cux-dnote { margin: 8px 16px 0; color: var(--cux-muted); font-size: 0.82rem; }
.cpmls-cux-dbody.is-readonly .cpmls-cux-dbtns .cpmls-cux-dbtn { flex: 1 1 100%; }

/* 贈品等特殊價格商品：勾選框固定 */
.cpmls-cux-cb[data-locked] { opacity: .55; cursor: not-allowed; }
