/* ====================================
   ONEONELITE - 首頁增強樣式
   與商家頁面統一卡片樣式
   ==================================== */

/* 價格顯示邏輯：PC 版顯示完整，iPad/手機版只顯示特價或原價 */
.price-desktop {
    display: inline;
}

.price-mobile {
    display: none;
}

/* 增強的商品卡片 - 與商家頁面一致 */
.enhanced-card {
    border: 1px solid #e9ecef;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    overflow: hidden;
    background: #fff;
    position: relative; /* 確保子元素絕對定位正常運作 */
}

/* 左上角產品標籤定位 */
.enhanced-card .product-mode {
    width: 70px;
    position: absolute;
    top: 10px;
    left: 0;
    z-index: 2;
}

/* 右上角剩餘數量標籤定位 */
.enhanced-card .product-remain {
    /* width: 50px; */ /* 移除固定寬度，讓內容自動撐開 */
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
}

.enhanced-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
    border-color: #D1080F;
}

/* 增強的商品圖片 */
.enhanced-product-link {
    display: block;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
    height: 0;
    padding-bottom: 100%; /* 預設正方形比例 */
    text-decoration: none !important; /* 移除下底線 */
    position: relative;
    background-color: #f8f9fa; /* 無圖片時的背景色 */
}

.enhanced-product-link:hover,
.enhanced-product-link:focus,
.enhanced-product-link:active {
    text-decoration: none !important; /* 確保所有狀態都無下底線 */
    outline: none; /* 移除 focus 外框 */
}

.enhanced-product-image {
    transition: transform 0.3s ease, filter 0.3s ease;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* 保持比例裁切 */
    object-position: center; /* 居中顯示 */
}

.enhanced-card:hover .enhanced-product-image {
    transform: scale(1.05);
    filter: brightness(1.1);
}

/* 增強的剩餘數量標籤 */
.enhanced-remain {
    font-weight: 600;
    border-radius: 6px;
    border: none; /* 移除白色邊框 */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* 增強的卡片內容 */
.enhanced-card-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 120px; /* 確保最小高度 */
}

.enhanced-product-title {
    font-weight: 600;
    color: #333;
    line-height: 1.4;
    margin-bottom: 0.75rem;
    min-height: 2.8em; /* 使用min-height確保空間 */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* 增強的價格顯示 */
.enhanced-price {
    font-weight: 700;
    font-size: 1.1rem;
}

.enhanced-price .special-price {
    color: #D1080F;
    font-size: 1.2em;
    margin-right: 0.5rem;
}

.enhanced-price .original-price {
    color: #6c757d;
    font-size: 0.9em;
    text-decoration: line-through;
}

/* 增強的組合標籤 */
.enhanced-badges {
    gap: 0.25rem;
}

.enhanced-combo-badge {
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.enhanced-combo-badge:hover {
    transform: scale(1.1);
}

/* 桌面版樣式 */
@media (min-width: 1200px) {
    /* 桌面版也使用正方形圖片 */
    .enhanced-product-link {
        padding-bottom: 100% !important; /* 統一使用正方形 */
    }

    /* 確保桌面版卡片等高 - 最左最右切齊，中間平均分配 */
    .product-list {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: stretch !important;
        justify-content: space-between !important; /* 兩端對齊 */
        row-gap: 1.5rem !important; /* 上下間距 */
        margin: 0 !important;
    }

    .product-list .enhanced-card {
        width: calc((100% - 3rem) / 4) !important; /* 桌面版每行4個，扣除3個間距 */
        margin: 0 !important;
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    /* 使用偽元素填充空位，確保最後一行不足時也靠左 */
    /* 最後一行有3個商品時，添加1個偽元素 */
    .product-list:has(.enhanced-card:nth-child(4n+3):last-child)::after {
        content: "";
        width: calc((100% - 3rem) / 4) !important;
    }

    /* 最後一行有2個商品時，添加2個偽元素 */
    .product-list:has(.enhanced-card:nth-child(4n+2):last-child)::after {
        content: "";
        width: calc((100% - 3rem) / 4 * 2 + 1rem) !important;
    }

    /* 最後一行有1個商品時，添加3個偽元素 */
    .product-list:has(.enhanced-card:nth-child(4n+1):last-child)::after {
        content: "";
        width: calc((100% - 3rem) / 4 * 3 + 2rem) !important;
    }

    /* 當商品總數不足4個時，靠左排列 */
    .product-list:not(:has(.enhanced-card:nth-child(4))) {
        justify-content: flex-start !important;
        gap: 1rem !important;
    }

    .product-list:not(:has(.enhanced-card:nth-child(4)))::after {
        display: none;
    }

    .product-list:not(:has(.enhanced-card:nth-child(4))) .enhanced-card {
        width: calc(25% - 0.75rem) !important;
    }

    .enhanced-card {
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    .enhanced-card-body {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        min-height: 120px;
    }
}

/* iPad 版優化（包含 iPad Mini）*/
@media (max-width: 1199px) and (min-width: 768px) {
    /* iPad 版本：最左最右切齊，中間平均分配 */
    .product-list {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: stretch !important;
        justify-content: space-between !important; /* 兩端對齊 */
        row-gap: 1.5rem !important; /* 上下間距 */
        margin: 0 !important;
    }

    .product-list .enhanced-card {
        width: calc((100% - 3rem) / 4) !important; /* iPad 版每行4個，扣除3個間距 */
        margin: 0 !important;
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    /* 使用偽元素填充空位，確保最後一行不足時也靠左 */
    /* 最後一行有3個商品時，添加1個偽元素 */
    .product-list:has(.enhanced-card:nth-child(4n+3):last-child)::after {
        content: "";
        width: calc((100% - 3rem) / 4) !important;
    }

    /* 最後一行有2個商品時，添加2個偽元素 */
    .product-list:has(.enhanced-card:nth-child(4n+2):last-child)::after {
        content: "";
        width: calc((100% - 3rem) / 4 * 2 + 1rem) !important;
    }

    /* 最後一行有1個商品時，添加3個偽元素 */
    .product-list:has(.enhanced-card:nth-child(4n+1):last-child)::after {
        content: "";
        width: calc((100% - 3rem) / 4 * 3 + 2rem) !important;
    }

    /* 當商品總數不足4個時，靠左排列 */
    .product-list:not(:has(.enhanced-card:nth-child(4))) {
        justify-content: flex-start !important;
        gap: 1rem !important;
    }

    .product-list:not(:has(.enhanced-card:nth-child(4)))::after {
        display: none;
    }

    .product-list:not(:has(.enhanced-card:nth-child(4))) .enhanced-card {
        width: calc(25% - 0.75rem) !important;
    }

    /* 平板統一使用正方形圖片 */
    .enhanced-product-link {
        padding-bottom: 100% !important; /* 強制正方形 */
    }

    /* 確保卡片等高 */
    .enhanced-card {
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    .enhanced-card-body {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        min-height: 110px;
    }
}

@media (max-width: 1199px) {
    /* iPad/手機版：只顯示特價，隱藏原價 */
    .price-desktop {
        display: none !important;
    }

    .price-mobile {
        display: inline !important;
    }

    /* 平板和手機版統一使用正方形圖片 */
    .enhanced-product-link {
        padding-bottom: 100% !important; /* 強制正方形 */
    }

    /* 確保卡片等高 */
    .enhanced-card {
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    .enhanced-card-body {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        min-height: 110px;
    }

    /* 統一的標題樣式 */
    .enhanced-product-title {
        min-height: 2.6em; /* 確保標題區域高度一致 */
    }


    .enhanced-price {
        font-size: 0.95rem;
    }

    /* 手機版特價樣式調整 */
    .enhanced-price .strikethrough {
        font-size: 0.85rem;
        margin-left: 0.25rem;
    }

    /* 調整剩餘數量標籤在手機版的大小 */
    .enhanced-remain {
        font-size: 10px !important;
        padding: 2px 5px !important;
        min-width: 35px !important;
    }

    /* 調整組合標籤在手機版的大小 */
    .enhanced-combo-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }

}

/* 手機版特定樣式 */
@media (max-width: 768px) {
    /* 手機版卡片樣式 */
    .enhanced-card {
        margin-bottom: 1rem;
        border-radius: 16px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .enhanced-card:hover {
        transform: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .enhanced-card-body {
        padding: 0.875rem;
    }

    .enhanced-product-title {
        font-size: 0.95rem;
        line-height: 1.3;
        margin-bottom: 0.5rem;
    }

    .enhanced-price {
        font-size: 0.95rem;
    }

    /* 手機版特價樣式調整 */
    .enhanced-price .strikethrough {
        font-size: 0.85rem;
        margin-left: 0.25rem;
    }

    /* 調整剩餘數量標籤在手機版的大小 */
    .enhanced-remain {
        font-size: 10px !important;
        padding: 2px 5px !important;
        min-width: 35px !important;
    }

    /* 調整組合標籤在手機版的大小 */
    .enhanced-combo-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }

    /* 確保product-list內的卡片排列一致 - 左中右間距一致 */
    .product-list {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: stretch !important;
        justify-content: space-between !important;
        row-gap: 1rem !important;
        margin: 0 !important;
        padding: 0 0.5rem !important; /* 左右各留 0.5rem */
    }

    .product-list .enhanced-card {
        width: calc(50% - 0.5rem) !important; /* 一行兩張，扣除間距 */
        margin: 0 0.5rem 0 0 !important; /* 每張卡片右邊距 0.5rem */
        box-sizing: border-box;
    }

    .product-list .enhanced-card:nth-child(2n) {
        margin-right: 0 !important; /* 每行第二張不需要右邊距 */
    }

    /* 確保卡片內容不受 padding 影響 */
    .product-list .enhanced-card > .card,
    .product-list .enhanced-card.card {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    /* 確保圖片為方形 */
    .product-list .enhanced-product-link {
        padding-bottom: 100% !important; /* 強制正方形 */
    }
}


/* 載入動畫 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.enhanced-card {
    animation: fadeInUp 0.6s ease forwards;
}

/* 為每個商品卡片添加延遲動畫 */
.enhanced-card:nth-child(1) { animation-delay: 0.1s; }
.enhanced-card:nth-child(2) { animation-delay: 0.2s; }
.enhanced-card:nth-child(3) { animation-delay: 0.3s; }
.enhanced-card:nth-child(4) { animation-delay: 0.4s; }
.enhanced-card:nth-child(5) { animation-delay: 0.5s; }
.enhanced-card:nth-child(6) { animation-delay: 0.6s; }
.enhanced-card:nth-child(7) { animation-delay: 0.7s; }
.enhanced-card:nth-child(8) { animation-delay: 0.8s; }

/* 改善文字可讀性 */
.enhanced-product-title {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 改善互動回饋 */
.enhanced-card {
    cursor: pointer;
}

.enhanced-card:active {
    transform: translateY(-2px) scale(0.98);
}
