@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700&display=swap');

body {
    font-family: "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f4f4f9;
    margin: 0;
    color: #333;
}

main {
    padding-top: 20px;
}

/* 共用容器 */
.container {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
}

/* --- Header 佈局更新 --- */
.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    padding-top: 20px;
    padding-bottom: 20px;
}

.header-main {
    text-align: left;
}

.header-nav {
    display: flex;
    gap: 20px;
}

.header-nav a {
    padding: 8px 15px;
    text-decoration: none;
    color: #495057;
    background-color: #e9ecef;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}

.header-nav a:hover {
    background-color: #00c2dd;
    color: #fff;
}

/* 頁首 Header */
.site-header {
    background-color: #ffffff;
    border-bottom: 1px solid #e9ecef;
}

.site-header .site-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #333;
    text-decoration: none;
    letter-spacing: 1px;
}

.site-header .site-tagline {
    font-size: 1rem;
    color: #6c757d;
    margin: 5px 0 0 0;
}

.controls-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    padding-top: 40px;
}

.main-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    flex-grow: 1;
    align-items: center;
}

/* --- 新增：可切換的搜尋框樣式 --- */
.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.4rem;
    color: #495057;
    padding: 5px 10px;
    transition: color 0.2s;
}

.search-toggle-btn:hover {
    color: #00c2dd;
}

.search-form {
    position: relative;
    display: flex;
    align-items: center;
    /* 新增：預設隱藏和過渡效果 */
    visibility: hidden;
    opacity: 0;
    width: 0;
    transition: opacity 0.3s ease, width 0.3s ease, visibility 0.3s;
}

.search-form input[type="text"] {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 1px solid #ced4da;
    border-radius: 20px;
    transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
    font-size: 0.9rem;
}

/* 當搜尋框啟用時的樣式 */
.search-container.is-active .search-form {
    visibility: visible;
    opacity: 1;
    width: 250px; /* 展開後的寬度 */
}

.search-form button, .search-form .clear-search {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer; 
    color: #aaa;
    font-size: 1rem;
    padding: 0 10px;
    height: 100%;
}

.search-form button {
    right: 0;
    padding-right: 15px;
}

.search-form .clear-search {
    right: 30px;
    font-size: 1.5rem;
    text-decoration: none;
    line-height: 1;
}

.search-form button:hover, .search-form .clear-search:hover {
    color: #333;
}

/* --- 新增：即時搜尋結果樣式 --- */
#live-search-results {
    display: none; /* 預設隱藏 */
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin-top: 8px;
    z-index: 100;
    max-height: 400px;
    overflow-y: auto;
}

#live-search-results ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#live-search-results li a {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    text-decoration: none;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

#live-search-results li:last-child a {
    border-bottom: none;
}

#live-search-results li a:hover {
    background-color: #f8f9fa;
}

.search-result-img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 15px;
}

.search-result-title { display: block; font-weight: 500; }
.search-result-brand { display: block; font-size: 0.8rem; color: #888; }
#live-search-results p { padding: 15px; text-align: center; color: #888; margin: 0; }

.brand-filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.brand-filter-tags a {
    padding: 8px 15px;
    text-decoration: none;
    color: #495057;
    background-color: #f1f3f5;
    border-radius: 20px;
    font-size: 0.9rem;
}

.brand-filter-tags a.active {
    background-color: #00c2dd;
    color: #fff;
    font-weight: 500;
}

/* 新增：通知設定連結樣式 */
.brand-filter-tags a.notification-link {
    background-color: #fff1f1;
    color: #c53030;
    border: 1px solid #fed7d7;
}

.brand-filter-tags a.notification-link:hover {
    background-color: #fed7d7;
}


/* 新增：品牌篩選下拉選單樣式 */
.brand-filter {
    position: relative;
    flex-grow: 1;
    min-width: 180px;
}

.brand-filter select {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 1px solid #ced4da;
    border-radius: 20px;
    background-color: #fff;
    font-size: 0.9rem;
    color: #333;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
}

/* 新增：給螢幕閱讀器使用的 class */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.view-switcher {
    display: flex;
    gap: 5px;
}

.view-switcher .view-btn {
    font-size: 1.5rem;
    padding: 0 10px;
    text-decoration: none;
    color: #ccc;
}

.view-switcher .view-btn.active {
    color: #00c2dd;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.product-card {
    background-color: #fff;
    border-radius: 16px; /* 加大圓角 */
    box-shadow: 0 1px 3px rgba(0,0,0,0.02), 0 4px 8px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: visible; /* 改為 visible，讓品牌徽章可以溢出 */
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05), 0 8px 16px rgba(0,0,0,0.08);
}

/* --- NEW STYLES START HERE --- */

.product-image-container {
    position: relative; /* 設定為相對定位，作為內部絕對定位元素的基準 */
    width: 100%;
    padding-top: 100%; /* 1:1 aspect ratio */
    height: 0;
    border-radius: 16px 16px 0 0; /* 同步加大圓角 */
}

.product-image {
    width: 100%;
    height: 100%; /* 讓圖片填滿容器 */
    object-fit: cover;
    display: block; /* 移除圖片底部的空隙 */
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 16px 16px 0 0; /* 同步加大圓角 */
}

/* 共用的標籤樣式 */
.product-badge {
    position: absolute; /* 絕對定位，相對於 .product-image-container */
    bottom: 0;
    transform: translateY(50%); /* 將標籤向下移動自身高度的 50%，實現跨界效果 */
    color: #fff;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8rem;
    text-align: center;
    line-height: 1.2;
    z-index: 2; /* 確保標籤在內容之上 */
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.product-badge span {
    display: block;
    font-size: 0.7rem;
}

/* 左下角的退稅標籤 */
.tax-refund-badge {
    left: 10px;
    background-color: #e67e22; /* 橘色 */
}

/* 右下角的運費標籤 */
.shipping-badge {
    right: 10px;
    background-color: #00c2dd; /* 主題色 */
    border: none; /* 移除按鈕的預設邊框 */
    cursor: pointer; /* 顯示為可點擊的手指圖示 */
}
.product-info {
    padding: 30px 25px 25px; /* 加大頂部 padding，為徽章留出空間 */
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-title a {
    color: inherit; /* 繼承父元素的顏色 */
    text-decoration: none; /* 移除底線 */
    transition: color 0.2s;
}

.product-model-no {
    font-size: 0.9rem;
    color: #888;
    margin: 0 0 15px 0;
    font-family: "Menlo", "Monaco", "Consolas", "Courier New", monospace;
}

.product-sizes {
    display: inline-flex; /* 使用 inline-flex 來對齊圖示和文字 */
    align-items: center;
    gap: 8px;
    background-color: #f1f3f5; /* 淺灰色背景 */
    color: #495057; /* 深灰色文字 */
    padding: 5px 10px;
    border-radius: 15px; /* 圓角膠囊形狀 */
    font-size: 0.8rem;
    margin: 0 0 15px 0;
    font-weight: 500;
    line-height: 1.2;
}

.product-sizes i {
    color: #868e96; /* 圖示使用稍淺的顏色 */
    font-size: 0.9em;
}

.price-container {
    display: flex;
    flex-direction: column; /* 將價格上下排列 */
    align-items: flex-start; /* 左對齊 */
    gap: 2px; /* 價格之間嘅微小間距 */
    margin-bottom: 10px;
}

.product-price {
    font-size: 1.2rem;
    margin: 0;
    line-height: 1.2;
}

.price-separator {
    font-size: 0.9em;
    font-weight: bold;
    color: #aaa;
    align-self: center;
}

.product-price .price-label {
    font-size: 0.8em;
    color: #666;
    margin-right: 5px;
}

.main-price {
    font-size: 1.4em; /* 主要價格字體放大 */
    font-weight: normal;
    font-weight: bold;
    color: #c0392b; /* 用紅色等搶眼顏色 */
}

.reference-price {
    font-size: 0.9em; /* 參考價字體縮小 */
    color: #888;
    font-weight: normal;
}

/* 單一產品頁的價格樣式 */
.single-page-prices {
    flex-direction: row;
    gap: 20px;
    align-items: center; /* 改為 center 讓 badge 垂直置中 */
    flex-wrap: wrap; /* 允許換行 */
}
.single-page-prices .product-price span {
}
.post-date {
    font-size: 0.85rem;
    color: #888;
    margin: 0 0 15px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.post-date-icon {
    /* 讓圖示顏色與文字一致 */
    fill: currentColor;
    /* 輕微下移，使其在視覺上更置中 */
    transform: translateY(1px);
}

.product-description {
    font-size: 0.9rem;
    color: #666;
    display: none; /* 在卡片視圖中隱藏描述 */
}

.voucher-code {
    position: relative;
    background: #f0fcff;
    border-radius: 8px;
    padding: 12px 15px;
    margin: 20px 0;
    display: flex;
    align-items: stretch;
    gap: 12px;
    border: 1px solid #b3f1fa;
}

/* 新增：簡化版的優惠碼標籤 */
.voucher-tag {
    background-color: #f5f3ff; /* 淡紫色背景 */
    color: #7c3aed;             /* 深紫色文字 */
    border: 1px solid #ddd6fe; /* 淺紫色邊框 */
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    margin-left: 8px;
    display: inline-block;
    vertical-align: middle;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    font-family: inherit;
}

.category-tag {
    display: inline-block;
    background-color: #e9ecef;
    color: #495057;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.75em;
    font-weight: 500;
    margin-left: 8px;
    vertical-align: middle;
    line-height: 1;
}

.voucher-tag:hover {
    background-color: #ede9fe; /* 滑鼠懸停時稍深的淡紫色 */
}
.voucher-tag:disabled {
    background-color: #27ae60; /* 複製成功後變為綠色 */
    color: #fff;
    border-color: #27ae60;
    cursor: default;
}

/* 新增：差價標籤樣式 */
.savings-badge {
    background-color: #27ae60; /* 綠色背景 */
    color: #fff;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 0.8rem;
    font-weight: bold;
    text-align: center;
    align-self: flex-start;
}

/* 新增：價格分隔符 VS */
.price-separator {
    font-size: 1.1rem;
    font-weight: 700;
    color: #adb5bd;
    align-self: center;
    padding: 0 5px; /* 減少 VS 左右的空間 */
}

/* 新增：為 savings-badge 加入圖示 */
.savings-badge i {
    margin-right: 4px;
}

/* 新增：單一產品頁的資訊區塊 */
.product-section {
    padding: 20px 0;
    border-bottom: 1px solid #f0f0f0;
}

.single-product-info > .product-section:last-of-type {
    border-bottom: none;
}

/* 減少價格區塊下方的 padding */
.price-section {
    padding-bottom: 10px;
}

/* 新增：產品操作區塊容器 */
.product-actions {
    margin-top: auto; /* 將此區塊推到卡片底部 */
    padding-top: 10px; /* 與上方內容的間距 */
    display: flex;
    flex-direction: column;
}

/* --- 新增：單一產品頁 UI 優化樣式 --- */
.product-details-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
}

.detail-tag {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #f8f9fa;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: #495057;
}

.detail-tag i {
    color: #00c2dd;
}

.product-specs {
    font-size: 0.9rem;
    color: #6c757d;
    line-height: 1.6;
}
.product-specs p {
    margin: 5px 0;
}

/* 新增：顯眼的尺碼標籤樣式 */
.size-highlight-tag {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background-color: #fffbe6; /* 淡黃色背景 */
    border: 1px solid #ffe58f; /* 黃色邊框 */
    color: #d46b08; /* 深橘色文字 */
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 1rem; /* 稍大字體 */
}

.voucher-icon {
    color: #00a8c0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-right: 10px;
}

.voucher-text {
    flex-grow: 1;
    line-height: 1.2;
}

.voucher-text .code-label {
    font-size: 0.8em;
    color: #008b9e;
    display: block;
}

.voucher-code .code {
    font-weight: bold;
    font-size: 1.1em;
    color: #008b9e;
    word-break: break-all;
}

.single-product-info .copy-btn {
    background-color: #d4f5f9;
    color: #00a8c0;
    border: none;
    padding: 5px;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
    align-self: center;
}

.single-product-info .copy-btn:hover {
    background-color: #00c2dd;
    color: #fff;
}

.copy-btn .copy-feedback {
    position: absolute;
    background-color: #333;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.purchase-button {
    display: block;
    background-color: #00c2dd;
    color: #fff;
    text-align: center; 
    padding: 12px;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.2s, transform 0.2s;
}

.copy-btn:hover {
    background-color: #00a8c0; /* 新主題色的深色版 */
}

.purchase-button:hover {
    background-color: #00a8c0; /* 新主題色的深色版 */
    transform: translateY(-2px);
}

/* --- 單一產品頁面樣式 --- */
.single-product-card {
    display: flex;
    flex-direction: row;
    background-color: #fff;
    border-radius: 16px; /* 加大圓角 */
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    overflow: hidden; /* 確保子元素不會溢出圓角 */
    margin-top: 20px;
}
.single-product-image-container {
    width: 40%;
    flex-shrink: 0;
}
.single-product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.single-product-info {
    padding: 40px;
    flex-grow: 1;
}
.single-product-info .product-header {
    padding-bottom: 20px;
    border-bottom: 1px solid #f0f0f0;
}

.single-product-info .product-title {
    font-size: 2rem;
    line-height: 1.3;
    margin-bottom: 8px;
}

.single-product-info .product-description {
    display: block; /* 覆蓋 grid view 的 -webkit-box 樣式 */
    -webkit-line-clamp: unset;
    line-height: 1.7;
    color: #495057;
}


/* 返回列表按鈕 */
.back-to-list-btn {
    display: inline-block;
    margin-bottom: 20px;
    text-decoration: none;
    color: #495057;
    transition: color 0.2s;
}

.back-to-list-btn:hover {
    color: #000;
}

/* 頁尾 Footer */
.site-footer {
    background-color: #2c3e50;
    color: #aaa;
    padding: 30px 0;
    margin-top: 60px;
    text-align: center;
    font-size: 0.9rem;
}

.site-footer p {
    margin: 5px 0;
}

/* 返回頂部按鈕 */
.back-to-top-btn {
    position: fixed;
    bottom: 20px; /* 預設距離 */
    bottom: calc(20px + env(safe-area-inset-bottom)); /* 針對有 Home Bar 嘅手機做調整 */
    right: 20px; /* 新增：將按鈕靠右對齊 */
    right: calc(20px + env(safe-area-inset-right)); /* 新增：考慮橫向螢幕時嘅右方安全距離 */
    width: 45px;
    height: 45px;
    background-color: #00c2dd;
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
    transform: translateY(20px);
}

.back-to-top-btn.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* --- 分頁樣式 --- */
.pagination {
    text-align: center;
    margin: 40px 0 20px;
}
.pagination a {
    color: #00c2dd;
    padding: 8px 16px;
    text-decoration: none;
    transition: background-color .3s, color .3s;
    border: 1px solid #ddd;
    margin: 0 4px;
    border-radius: 4px;
}
.pagination a.active {
    background-color: #00c2dd;
    color: white;
    border-color: #00c2dd;
}
.pagination a:hover:not(.active) {
    background-color: #f0f0f0;
}

/* --- 404 Error Page --- */
.error-404-container {
    text-align: center;
    padding: 60px 20px;
}

.error-404-icon {
    font-size: 5rem;
    line-height: 1;
    margin-bottom: 20px;
    display: inline-block;
}

.error-404-container h1 {
    font-size: 6rem;
    font-weight: 700;
    margin: 0;
    color: #e9ecef;
    line-height: 1;
}

.error-404-container h2 {
    font-size: 1.75rem;
    margin: 10px 0;
    color: #343a40;
}

.error-404-container p {
    color: #6c757d;
    max-width: 450px;
    margin: 0 auto 30px;
}

.back-to-home-btn {
    display: inline-block;
    background-color: #00c2dd;
    color: #fff;
    padding: 12px 25px;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 500;
    transition: background-color 0.2s, transform 0.2s;
}

.back-to-home-btn:hover {
    background-color: #00a8c0;
    transform: translateY(-2px);
}

/* --- 響應式：單一產品頁面 --- */
@media (max-width: 768px) {
    .single-product-card {
        flex-direction: column; /* 在手機上改為垂直排列 */
    }
    .single-product-image-container {
        width: 100%; /* 圖片寬度佔滿 */
        height: 350px; /* 給圖片一個固定的高度 */
    }
    .single-product-info {
        padding: 25px; /* 縮小手機上的內邊距 */
    }

    /* 手機版價格排版調整 */
    .single-page-prices {
        gap: 8px; /* 統一縮小元素間距 */
        align-items: center; /* 保持垂直置中 */
    }

    .single-page-prices .product-price {
        font-size: 1.1rem; /* 縮小手機上的價格字體 */
    }
}

/* 新增：預設隱藏手機版選單按鈕 */
.mobile-menu-toggle {
    display: none;
}

/* --- 響應式：主頁選單 --- */
@media (max-width: 768px) {
    /* 手機版 Header 置中 */
    .site-header .container {
        flex-direction: column;
        gap: 15px;
    }
    .header-main {
        text-align: center;
    }
    .main-controls {
        justify-content: space-between; /* 讓選單和搜尋框分開在兩邊 */
        width: 100%;
    }

    .mobile-menu-container {
        position: relative;
    }

    .mobile-menu-toggle {
        display: block; /* 只在手機版顯示 */
        background: none;
        border: none;
        font-size: 1.6rem;
        color: #333;
        cursor: pointer;
        padding: 5px;
    }

    .brand-filter-tags {
        display: none; /* 預設隱藏篩選按鈕 */
        position: absolute;
        top: 100%;
        left: 0;
        background-color: #fff;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        padding: 10px;
        margin-top: 10px;
        z-index: 100;
        flex-direction: column;
        align-items: flex-start;
        width: 200px;
    }

    .mobile-menu-container.is-open .brand-filter-tags {
        display: flex; /* 當 is-open class 存在時顯示 */
    }
}