/* ============ Compare Popup ============ */

/* accent 固定為橘色（切齊 index Buy／compare detail 橘），不再依頁面 BUY 取樣 */
#comparePopup {
    --compare-accent: #ff8a00;
}

.compare-popup-desktop {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9000;
    background: #141416;
    color: #eaeaea;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, .5);
    transform: translateY(100%);
    transition: transform .35s ease;
    font-family: inherit;
}

    /* 有勾選時由底部浮出 */
    .compare-popup-desktop.open {
        transform: translateY(0);
    }

.gbt-restrict-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 24px;
    box-sizing: border-box;
}

/* ---- Header ---- */
.compare-popup-header {
    display: block;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
    cursor: pointer;
}

.compare-popup-header-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 14px;
    padding-bottom: 14px;
}

.compare-switch-icon {
    width: 20px;
    height: 20px;
    fill: #fff;
    transition: transform .3s ease;
    flex-shrink: 0;
}

/* 收合狀態時箭頭朝下 */
.compare-popup-desktop.collapsed .compare-switch-icon {
    transform: rotate(180deg);
}

.compare-header-product-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.info-title {
    font-size: 16px;
    font-weight: 600;
}

/* 數字徽章：fallback 底色（JS 有 BUY 時會以 inline style 覆蓋） */
.info-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: var(--compare-accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.compare-hint {
    margin-left: auto;
    font-size: 13px;
    color: #999;
}

/* ---- Body ---- */
.compare-popup-body {
    overflow: hidden;
    transition: max-height .35s ease;
}

.compare-popup-desktop.collapsed .compare-popup-body {
    max-height: 0 !important;
}

.compare-popup-body-container {
    display: flex;
    align-items: stretch;
    gap: 24px;
    padding-top: 18px;
    padding-bottom: 18px;
}

.compare-product-list {
    display: flex;
    flex: 1;
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow-x: auto;
}

.compare-product-list-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 0 0 180px;
    min-height: 120px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 8px;
    background: #1c1c1f;
}

.product-remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 16px;
    height: 16px;
    fill: #999;
    cursor: pointer;
    transition: fill .2s ease;
}

    .product-remove-btn:hover {
        fill: #fff;
    }

.compare-product-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
}

.compare-product-img-container {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.compare-product-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.compare-product-name-text {
    display: block;
    text-align: center;
    font-size: 13px;
    line-height: 1.3;
}

/* ---- 按鈕群 ---- */
.compare-popup-btn-group {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    flex-shrink: 0;
}

/* 共用尺寸；顏色由 JS 依 BUY 按鈕注入，以下為 fallback */
.compare-btn {
    min-width: 140px;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .2s ease, background .2s ease;
}

.compare-btn-fill {
    border: none;
    background: var(--compare-accent);
    color: #fff;
}

    .compare-btn-fill:hover {
        opacity: .85;
    }

    .compare-btn-fill:disabled {
        opacity: .5;
        cursor: not-allowed;
    }

.compare-btn-outline {
    background: transparent;
    border: 1px solid var(--compare-accent);
    color: var(--compare-accent);
}

    .compare-btn-outline:hover {
        opacity: .85;
    }

/* ---- Add more 搜尋（popup 內）---- */
/* add 項維持與其他 item 同尺寸；搜尋 UI 覆蓋在框內，不浮出框外 */
#comparePopup .add-product-item {
    overflow: hidden;
}

#comparePopup .add-product-item .js-add-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    height: 100%;
    cursor: pointer;
    color: #bbb;
}

#comparePopup .add-product-item .add-product-svg {
    width: 28px;
    height: 28px;
    fill: #bbb;
}

/* 搜尋區塊：覆蓋整個 add 框（inset:0），內部用 flex 直向排列 */
#comparePopup .add-product-item .js-auto-complete-block {
    position: absolute;
    inset: 0;               /* 填滿 add 框，置中覆蓋 */
    display: flex;
    flex-direction: column;
    padding: 10px;
    background: #1c1c1f;
    border-radius: 8px;
    z-index: 5;
}

#comparePopup .add-product-item .search-form-group {
    flex-shrink: 0;         /* 搜尋框固定在上方 */
}

#comparePopup .add-product-item .search-form-control {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    background: #141416;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 6px;
    color: #eaeaea;
    font-size: 13px;
}

/* 建議清單：佔框內剩餘高度，超出捲動（不撐出框外）*/
#comparePopup .compare-search-suggestion {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    flex: 1 1 auto;
    min-height: 0;          /* flex 子項可捲動的關鍵 */
    overflow-y: auto;
}

#comparePopup .compare-search-item {
    padding: 8px 10px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#comparePopup .compare-search-item:hover {
    background: rgba(255, 255, 255, .08);
}

/* ===== Product Compare 區塊（index 卡片 & _Product_Layout 詳情頁共用） ===== */
.product-compare.has-sub {
    position: relative; /* 作為下拉的定位基準 */
}

    .product-compare.has-sub .sub-compare-dropdown {
        position: absolute;
        top: 100%; /* 緊貼 label 正下方 */
        left: 0;
        min-width: 100%;
        width: max-content;
        max-width: 260px;
        margin-top: 6px;
        background: #131315;
        color: #fff;
        border: 1px solid rgba(255, 255, 255, 0.12);
        border-radius: 8px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
        padding: 8px 12px;
        z-index: 40;
        max-height: 240px;
        overflow-y: auto;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-4px);
        transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
    }

    .product-compare.has-sub:hover .sub-compare-dropdown {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

.sub-compare-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sub-compare-item {
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

    .sub-compare-item:last-child {
        border-bottom: none;
    }

@media (max-width: 768px) {
    .compare-popup-body-container {
        flex-direction: column;
    }

    .compare-hint {
        display: none;
    }
}
