﻿@charset "utf-8";
/* ═════════════════════════
   modern-product.css
   全域設定、產品列表版面、分頁（含行動版 RWD）
   ═════════════════════════ */

/* ── 全域變數 ── */
:root {
    --primary-color: #0056b3;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --light-bg: #f8f9fa;
    --border-color: #dee2e6;
    --text-dark: #212529;
    --text-light: #6c757d;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    color: var(--text-dark);
    line-height: 1.6;
    background-color: #fff;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* ── 頁面標題區 ── */
.page-header {
    margin: 30px 0 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.page-header h2 {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--primary-color);
}

.page-header h1 small {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-light);
    margin-left: 10px;
}

/* ── 麵包屑 ── */
.breadcrumb {
    list-style: none;
    display: flex;
    padding: 0;
    margin: 0;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "/";
    padding: 0 8px;
    color: var(--text-light);
}

.breadcrumb-item a {
    color: var(--primary-color);
    text-decoration: none;
}

.breadcrumb-item.active {
    color: var(--text-light);
}

/* ── 主要版面佈局 ── */
.product-layout {
    display: flex;
    gap: 30px;
    margin-top: 20px;
}

/* ── 側邊欄 ── */
.product-sidebar {
    flex: 0 0 250px;
}

.sidebar-widget {
    background: var(--light-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.sidebar-widget h3 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
    color: var(--primary-color);
}

/* ── 搜尋表單 ── */
.search-form .form-group {
    margin-bottom: 15px;
}

.form-select,
.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-select:focus,
.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-input-group {
    display: flex;
    gap: 10px;
}

.search-input-group .form-input {
    flex: 1;
}

.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background-color 0.2s, opacity 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #004494;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background-color: var(--primary-color);
    color: white;
}

.btn-search {
    white-space: nowrap;
}

/* ── 分類選單 ── */
.category-list,
.subcategory-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.category-item {
    margin-bottom: 8px;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 8px;
}

.category-item > a {
    font-weight: 600;
    display: block;
    padding: 6px 0;
}

.category-list a {
    text-decoration: none;
    color: var(--text-dark);
    transition: color 0.2s, padding-left 0.2s;
}

.category-list a:hover,
.category-list a.active {
    color: var(--primary-color);
    padding-left: 8px;
}

.subcategory-list {
    margin-top: 8px;
    margin-left: 15px;
    font-size: 0.95rem;
}

.subcategory-list li {
    margin-bottom: 5px;
}

.subcategory-list li.active a {
    color: var(--primary-color);
    font-weight: 500;
}

/* ── 主要內容區 ── */
.product-main {
    flex: 1;
}

/* ── 產品網格 ── */
/*
 * 欄位斷點對照（視窗寬度，含側邊欄 250px + gap 30px）：
 *   > 1080px  → 3欄
 *   864–1080px → 2欄
 *   < 864px   → 1欄（側邊欄已折疊，主區全寬）
 */
.product-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);   /* 預設：>1080px 顯示3欄 */
    gap: 20px;
    margin-bottom: 30px;
}

/* ── 產品卡片 ── */
.product-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--box-shadow);
}

.product-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.product-image {
    position: relative;
    aspect-ratio: 1 / 1;
    background: var(--light-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.product-card:hover .product-image img {
    transform: scale(1.05);
}

.product-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--primary-color);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 1;
}

.product-badge.sale {
    background: #dc3545;
}

.product-badge.new {
    background: var(--success-color);
}

.product-info {
    padding: 15px;
    text-align: center;
}

.product-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text-dark);
    line-height: 1.4;
    height: 2.8em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-id {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 8px;
}

.product-price .price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
}

.product-price .price.contact {
    font-size: 0.9rem;
    color: #856404;
    background-color: #fff3cd;
    padding: 3px 8px;
    border-radius: 4px;
}

/* ── 無商品提示 ── */
.no-products {
    text-align: center;
    padding: 60px 20px;
    background: var(--light-bg);
    border-radius: var(--border-radius);
}

.no-products p {
    margin-bottom: 20px;
    font-size: 1.2rem;
    color: var(--text-light);
}

/* ══════════════
   分頁導航
   ══════════════ */

.pagination-nav {
    display: flex;
    justify-content: center;
    margin-top: 30px;
    overflow-x: auto;          /* 極小螢幕防止溢出 */
}

.pagination {
    display: flex;
    list-style: none;
    padding: 0;
    gap: 5px;
    flex-wrap: nowrap;
}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    min-width: 38px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    text-decoration: none;
    color: var(--primary-color);
    background: white;
    font-size: 0.95rem;
    line-height: 1;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.page-link:hover {
    background-color: var(--light-bg);
    border-color: var(--primary-color);
}

.page-item.active .page-link {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.page-item.disabled .page-link {
    color: var(--text-light);
    pointer-events: none;
    cursor: default;
    opacity: 0.6;
}

/*
 * 上/下一頁：同時包含文字 <span class="pg-text"> 與圖示 <span class="pg-icon">
 * 桌機顯示文字，行動版（≤600px）切換為圖示
 */
.pg-icon {
    display: none;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
}

.pg-text {
    display: inline;
}

/* ════════════════
   響應式設計
   ════════════════ */

/*
 * ┌──────────────────────────────┐
 * │  產品欄位斷點總覽                                    │
 * │  > 1080px  → 3欄（桌機）                            │
 * │  864–1080px → 2欄（小桌機 / 大平板）                │
 * │  ≤ 864px   → 1欄（平板 / 手機，側邊欄折疊至下方）   │
 * └──────────────────────────────┘
 */

/* 小桌機 / 大平板：2欄（1080px 以下） */
@media (max-width: 1080px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 平板 / 手機：1欄（864px 以下） */
@media (max-width: 864px) {
    .product-layout {
        flex-direction: column;
    }

    .product-sidebar {
        flex: auto;
        width: 100%;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .product-grid {
        grid-template-columns: repeat(1, 1fr);
    }

    /*
     * 行動版排序：有篩選條件時商品列表顯示在上，側邊欄移到下方
     * ASP 使用方式：
     *   <main class="product-page container<%=IIf(enBigClassName<>"" Or enSmallClassName<>"" Or searchKeyword<>"", " has-filter", "")%>">
     */
    .has-filter .product-main {
        order: 1;
    }

    .has-filter .product-sidebar {
        order: 2;
    }
}

/* 手機搜尋按鈕全寬（480px 以下） */
@media (max-width: 480px) {
    .search-input-group {
        flex-wrap: wrap;
    }

    .search-input-group .btn-search {
        width: 100%;
    }
}

/* ── 分頁行動版（≤600px）：最多顯示5個頁碼 + 圖示按鈕 ── */
@media (max-width: 600px) {

    /* 切換為圖示，隱藏文字 */
    .pg-text { display: none; }
    .pg-icon { display: inline; }

    /* 所有頁碼與上下頁按鈕統一大小 */
    .pagination .page-link {
        padding: 0;
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
        min-width: unset;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* 上下頁圖示字體稍大，視覺上與數字等重 */
    .prev-item .pg-icon,
    .next-item .pg-icon {
        font-size: 1.2rem;
        font-weight: 700;
        line-height: 1;
    }

    /*
     * 只顯示距離目前頁 ≤ 2 的頁碼（共最多5個）
     * ASP 輸出時在 <li> 上加 data-dist="N"（N = |頁碼 - 目前頁|）
     */
    .pagination .page-item[data-dist="3"],
    .pagination .page-item[data-dist="4"],
    .pagination .page-item[data-dist="5"],
    .pagination .page-item[data-dist="6"],
    .pagination .page-item[data-dist="7"] {
        display: none;
    }
}
