@charset "UTF-8";

/* ===== Catalog Shared ===== */
/* Shared legacy catalog cards, grid, and pagination primitives */

/* Legacy WooCommerce loop card base */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}
.product-card {
    background: transparent;
    overflow: hidden;
    position: relative;
    text-align: center;
    padding: 0 45px;
    box-sizing: border-box;
}
.product-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--primary-color);
    color: #fff;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    z-index: 2;
}
.product-image {
    position: relative;
    overflow: hidden;
    background: var(--bg-light);
}
.product-image img {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}
.product-image-placeholder {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    padding: 16px;
    text-align: center;
}
.product-info {
    padding: 10px 5px;
    text-align: center;
}
.product-title {
    font-size: 16px;
    font-weight: 400;
    color: #2C2A8E;
    margin-bottom: 6px;
    line-height: 1.4;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}
.product-title a { color: #2C2A8E; }
.product-title a:hover { color: var(--primary-color); }
.product-card .ulive-card-spec {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.3;
    min-height: 1.3em;
    color: var(--text-medium);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.product-card .ulive-card-spec.is-empty {
    visibility: hidden;
}
.product-card .ulive-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 6px;
    min-height: 16px;
}
.product-card .ulive-card-meta.is-empty {
    visibility: hidden;
}
.product-card .ulive-card-rating {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    min-width: 0;
    flex: 1 1 auto;
}
.product-card .ulive-card-stars {
    display: inline-flex;
    gap: 1px;
    align-items: center;
    line-height: 1;
}
.product-card .ulive-card-stars .icon-star {
    font-size: 12px;
    color: #ddd;
}
.product-card .ulive-card-stars .icon-star:before {
    color: #ddd;
}
.product-card .ulive-card-stars .icon-star.active,
.product-card .ulive-card-stars .icon-star.active:before {
    color: var(--ulive-star-color);
}
.product-card .ulive-card-review-count {
    font-size: 11px;
    color: var(--text-medium);
    white-space: nowrap;
}
.product-card .ulive-card-sales {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-medium);
    white-space: nowrap;
}
.product-price-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.product-price-original {
    font-size: 14px;
    color: var(--text-medium);
    text-decoration: line-through;
}
.product-price {
    font-size: 14px;
    font-weight: 400;
    color: var(--sale-color);
}
.product-price-wrap .woocommerce-Price-amount { font-size: 14px; }
.product-price-wrap del { color: var(--text-medium); }
.product-price-wrap del .woocommerce-Price-amount { font-size: 14px; color: var(--text-medium); }
.product-price-wrap ins { text-decoration: none; color: var(--sale-color); }

/* Shop products grid */
.shop-products-grid {
    margin: 0 0 30px;
    padding: 0 15px;
    display: grid;
    /* 原站分類頁：固定 4 列 180px 方形卡片，中間自適應 gap */
    grid-template-columns: repeat(4, 180px);
    justify-content: space-between;
    gap: 30px 0;
    box-sizing: border-box;
}

/* 無商品 / 搜尋無結果提示，對齊原站文案與版式 */
.ulive-no-products-found {
    text-align: center;
    padding: 80px 20px 100px;
    box-sizing: border-box;
}
.ulive-no-products-found .ulive-nopf-title {
    font-size: 18px;
    font-weight: 700;
    color: #333;
    line-height: 1.5;
    margin: 0 0 16px;
}
.ulive-no-products-found .ulive-nopf-keyword {
    font-weight: 700;
    color: #333;
}
.ulive-no-products-found .ulive-nopf-tip {
    font-size: 14px;
    color: #999;
    line-height: 1.6;
    margin: 0;
}

/* 分類頁商品卡片：180×180方形圖片 + hover 顯示「加入購物車」覆蓋按鈕 */
.shop-products-grid .product-card {
    padding: 0;
    width: 180px;
    text-align: left;
    position: relative;
    overflow: hidden;
}
.shop-products-grid .product-card .product-image {
    position: relative;
    width: 180px;
    height: 180px;
    overflow: hidden;
    background: #f5f5f5;
}
.shop-products-grid .product-card .product-image a {
    display: block;
    width: 180px;
    height: 180px;
}
.shop-products-grid .product-card .product-image img {
    width: 180px !important;
    height: 180px !important;
    max-width: 180px;
    aspect-ratio: unset;
    object-fit: cover;
    display: block;
    margin: 0;
}
.shop-products-grid .product-card .product-info {
    padding: 10px 0;
    text-align: left;
}
.shop-products-grid .product-card .product-price-wrap {
    align-items: flex-start;
}
.shop-products-grid .product-card .product-title {
    text-align: left;
}

/* 「加入購物車」按鈕默認隱藏，hover 卡片時覆蓋在圖片底部 */
.shop-products-grid .product-card .btn-add-cart {
    position: absolute;
    top: 140px;
    left: 0;
    right: 0;
    width: 180px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background: #2C2A8E; /* 主色按鈕 */
    color: #fff;
    font-size: 15px;
    font-weight: 400;
    line-height: 40px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
    z-index: 3;
}
.shop-products-grid .product-card:hover .btn-add-cart {
    opacity: 1;
    visibility: visible;
}
.shop-products-grid .product-card .btn-add-cart:hover {
    background: #1E1B6E;
    color: #fff;
}

/* Pagination */
.woocommerce nav.woocommerce-pagination {
    text-align: center;
    margin-top: 30px;
}

.woocommerce nav.woocommerce-pagination ul {
    display: inline-flex;
    gap: 6px;
    border: none;
    list-style: none;
    padding: 0;
    margin: 0;
}

.woocommerce nav.woocommerce-pagination ul li {
    border: none;
    margin: 0;
}

.woocommerce nav.woocommerce-pagination ul li a,
.woocommerce nav.woocommerce-pagination ul li span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 8px;
    border: 1.5px solid var(--border-light);
    border-radius: 4px;
    color: var(--text-medium);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
}

.woocommerce nav.woocommerce-pagination ul li a:hover,
.woocommerce nav.woocommerce-pagination ul li span.current {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

/* ≤1024px（Nest Hub 1024×600、平板横屏等）：
   该断点隐藏 sidebar，并将布局切回单列，
   shop-layout 必须从 PC 的 260px+840px 固定双栏切回单列 1fr，
   否则 260px 空轨道会占位、840px shop-main 溢出视口，
   造成商品卡只挤在左半屏、toolbar 换行、整体空间浪费。 */
@media (max-width: 1024px) {
    .shop-layout {
        grid-template-columns: 1fr;
        margin: 0;
    }

    .shop-sidebar {
        display: none !important;
        position: static;
        padding-left: 0;
        padding-right: 0;
    }

    .shop-main {
        padding-left: 0;
        padding-right: 0;
    }

    /* Nest Hub（901~1024）保持 4 列 1fr，充分利用横屏空间；
       justify-content 覆盖基础 space-between，避免空余 gap 全部挤到两侧。 */
    .shop-products-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
        justify-content: stretch;
    }

    /* 卡片与图片从 PC 固定 180px 切换为跟随 grid track 自适应，
       否则 4 列 1fr（约 240px）里会出现 180px 卡片靠左、右侧大量空隙。 */
    .shop-products-grid .product-card {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        min-width: 0;
        overflow: visible;
        display: flex;
        flex-direction: column;
        height: 100%;
    }
    .shop-products-grid .product-card .product-image {
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
    }
    .shop-products-grid .product-card .product-image a {
        display: block;
        width: 100% !important;
        height: auto !important;
    }
    .shop-products-grid .product-card .product-image img {
        width: 100% !important;
        height: auto !important;
        max-width: 100% !important;
        aspect-ratio: 1 / 1 !important;
        object-fit: cover !important;
    }
    .shop-products-grid .product-card .product-info {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        padding-left: 2px;
        padding-right: 2px;
    }
    .shop-products-grid .product-card .product-title {
        word-break: break-word;
        overflow-wrap: anywhere;
    }
    .shop-products-grid .product-card .btn-add-cart {
        position: static !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 100% !important;
        height: 40px !important;
        margin: auto 0 20px 0 !important;
        padding: 0 !important;
        border: 1px solid #333 !important;
        border-radius: 3px !important;
        background: #fff !important;
        color: #333 !important;
        font-size: 0 !important;
        line-height: 1 !important;
        opacity: 1 !important;
        visibility: visible !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
    }
    .shop-products-grid .product-card .btn-add-cart .btn-add-cart-label { display: none; }
    .shop-products-grid .product-card .btn-add-cart .icon { font-size: 20px; color: #333; }
    .shop-products-grid .product-card .btn-add-cart:hover,
    .shop-products-grid .product-card .btn-add-cart:focus { background: #f5f5f5 !important; color: #000 !important; }
}

@media (max-width: 900px) {
    .shop-products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 600px) {
    .shop-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

/* Shop Page */
.woocommerce .woocommerce-result-count {
    color: var(--text-light);
    font-size: 0.9rem;
}

.woocommerce .woocommerce-ordering select {
    /* 已由頂部統一規則接管，此處保持僅寫背景避免覆蓋 */
    background-color: #fff;
}

/* Pagination */
.woocommerce nav.woocommerce-pagination ul {
    border: none;
}

.woocommerce nav.woocommerce-pagination ul li {
    border: none;
    margin: 0 4px;
}

.woocommerce nav.woocommerce-pagination ul li a,
.woocommerce nav.woocommerce-pagination ul li span {
    padding: 10px 16px;
    border: 2px solid var(--border-light);
    border-radius: 4px;
    color: var(--text-medium);
    font-weight: 500;
    min-width: 44px;
    text-align: center;
}

.woocommerce nav.woocommerce-pagination ul li a:hover,
.woocommerce nav.woocommerce-pagination ul li span.current {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}


/* ===== Add to Cart button on product cards ===== */
.btn-add-cart {
    display: inline-block;
    padding: 8px 16px;
    background: var(--primary-color);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    margin-top: 6px;
}
.btn-add-cart:hover { background: var(--primary-dark); color: #fff; }
.btn-add-cart.loading {
    opacity: 0.7;
    cursor: not-allowed;
}

@media (max-width: 480px) {
    .product-title {
        font-size: 13px;
}
