/* product_sections.css 產品展示區塊樣式 - 簡化版 (搜尋連結) */
/* 版本: 2.0 - 移除 AJAX 展開功能，改為搜尋連結 */
/* 最後更新: 2025-09-29 */

/* ========================================
   1. 基礎產品區塊樣式
   ======================================== */

.product-sections-common {
    margin: 40px 0;
    padding: 20px 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    position: relative;
}

.product-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ========================================
   2. 區塊標題樣式
   ======================================== */

.section-header {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
}

.section-title {
    font-size: 28px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 10px 0;
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(45deg, #8b7355, #d4a574);
    border-radius: 2px;
}

.section-subtitle {
    color: #7f8c8d;
    font-size: 16px;
    margin: 0 0 15px 0;
}

.view-more-link {
    color: #8b7355;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.view-more-link:hover {
    color: #d4a574;
}

/* ========================================
   3. 產品網格樣式 - 響應式佈局
   ======================================== */

.products-grid-wrapper {
    position: relative;
}

.products-grid {
    display: grid;
    gap: 25px;
    margin-bottom: 30px;
    grid-template-columns: repeat(4, 1fr);
}

/* ========================================
   4. 響應式斷點
   ======================================== */

/* 平板版：3列 (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
}

/* 手機版：2列 (小於768px) */
@media (max-width: 767px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .product-container {
        padding: 0 15px;
    }
}

/* 小手機版優化 (小於480px) */
@media (max-width: 480px) {
    .products-grid {
        gap: 12px;
    }
    
    .product-container {
        padding: 0 10px;
    }
}

/* 極小螢幕 (小於360px) */
@media (max-width: 360px) {
    .products-grid {
        gap: 10px;
    }
}

/* ========================================
   5. 產品卡片樣式
   ======================================== */

.product-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid #f0f0f0;
    position: relative;
    animation: slideInUp 0.6s ease forwards;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   6. 產品圖片區域
   ======================================== */

.product-image-wrapper {
    position: relative;
    overflow: hidden;
    background: #f8f9fa;
    aspect-ratio: 1 / 1;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-card:hover .product-image {
    transform: scale(1.05);
}

/* 錯誤圖片樣式 */
.error-image {
    opacity: 0.6;
    filter: grayscale(50%);
}

/* ========================================
   7. 產品標籤
   ======================================== */

.product-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    z-index: 2;
}

.product-badge.new {
    background: linear-gradient(45deg, #27ae60, #2ecc71);
}

.product-badge.sales {
    background: linear-gradient(45deg, #e74c3c, #f39c12);
}

.product-badge.promotion {
    background: linear-gradient(45deg, #9b59b6, #e91e63);
}

/* ========================================
   8. 快速檢視覆蓋層
   ======================================== */

.quick-view-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.product-card:hover .quick-view-overlay {
    opacity: 1;
}

.quick-view-btn {
    background: white;
    color: #2c3e50;
    padding: 10px 20px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    transform: translateY(10px);
}

.product-card:hover .quick-view-btn {
    transform: translateY(0);
}

.quick-view-btn:hover {
    background: #8b7355;
    color: white;
    text-decoration: none;
}

/* ========================================
   9. 產品資訊區域
   ======================================== */

.product-info {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-name {
    margin-bottom: 10px;
    flex: 1;
}

.product-name a {
    color: #2c3e50;
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.3s ease;
}

.product-name a:hover {
    color: #8b7355;
    text-decoration: none;
}

/* ========================================
   10. 銷售資訊
   ======================================== */

.product-sales {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #7f8c8d;
    font-size: 14px;
    margin-bottom: 15px;
}

.sales-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.sales-icon.new {
    color: #27ae60;
}

.sales-icon.sales {
    color: #e74c3c;
}

.sales-icon.promotion {
    color: #9b59b6;
}

/* ========================================
   11. 產品底部區域
   ======================================== */

.product-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-top: auto;
}

.product-price {
    font-size: 18px;
    font-weight: 700;
    color: #8b7355;
}

.buy-button {
    background: linear-gradient(45deg, #8b7355, #d4a574);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.buy-button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(139, 115, 85, 0.3);
    text-decoration: none;
}

.cart-icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.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;
}

/* ========================================
   12. 搜尋按鈕包裝器 (新)
   ======================================== */

.expand-button-wrapper {
    text-align: center;
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #e2e8f0;
}

/* 搜尋連結按鈕樣式 */
.expand-button.search-link,
.expand-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px 35px;
    background: linear-gradient(135deg, #8b7355 0%, #d4a574 100%);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(139, 115, 85, 0.3);
}

.expand-button.search-link:hover,
.expand-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(139, 115, 85, 0.4);
    background: linear-gradient(135deg, #d4a574 0%, #8b7355 100%);
    color: white;
    text-decoration: none;
}

.expand-button.search-link:active,
.expand-button:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 115, 85, 0.3);
}

.expand-icon {
    width: 22px;
    height: 22px;
    fill: currentColor;
    transition: transform 0.3s ease;
}

/* 搜尋圖示動畫 */
.expand-button.search-link:hover .expand-icon {
    transform: scale(1.1);
}

.expand-text {
    font-weight: 600;
}

/* ========================================
   13. 區塊裝飾樣式
   ======================================== */

.latest-products-section {
    position: relative;
}

.latest-products-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, #27ae60, #2ecc71);
    border-radius: 0 2px 2px 0;
}

.sales-ranking-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, #e74c3c, #f39c12);
    border-radius: 0 2px 2px 0;
}

.promotion-ranking-section.left-decoration::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, #9b59b6, #e91e63);
    border-radius: 0 2px 2px 0;
}

/* ========================================
   14. 響應式字體和間距調整
   ======================================== */

@media (max-width: 768px) {
    .section-title {
        font-size: 24px;
    }
    
    .section-subtitle {
        font-size: 14px;
    }
    
    .product-card {
        border-radius: 10px;
    }
    
    .product-info {
        padding: 15px;
    }
    
    .product-name a {
        font-size: 14px;
    }
    
    .product-price {
        font-size: 16px;
    }
    
    .buy-button {
        width: 36px;
        height: 36px;
    }
    
    .cart-icon {
        width: 16px;
        height: 16px;
    }
    
    .expand-button.search-link,
    .expand-button {
        padding: 12px 28px;
        font-size: 14px;
    }
    
    .expand-icon {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 480px) {
    .section-title {
        font-size: 20px;
    }
    
    .product-name a {
        font-size: 13px;
        -webkit-line-clamp: 2;
    }
    
    .product-price {
        font-size: 14px;
    }
    
    .product-sales {
        font-size: 12px;
        gap: 4px;
    }
    
    .sales-icon {
        width: 14px;
        height: 14px;
    }
    
    .buy-button {
        width: 32px;
        height: 32px;
    }
    
    .cart-icon {
        width: 14px;
        height: 14px;
    }
    
    .expand-button.search-link,
    .expand-button {
        width: 100%;
        max-width: 300px;
        padding: 12px 24px;
        font-size: 14px;
    }
    
    .expand-icon {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 360px) {
    .product-info {
        padding: 12px;
    }
    
    .product-name a {
        font-size: 12px;
    }
    
    .product-price {
        font-size: 13px;
    }
    
    .buy-button {
        width: 30px;
        height: 30px;
    }
    
    .cart-icon {
        width: 12px;
        height: 12px;
    }
    
    .expand-button.search-link,
    .expand-button {
        padding: 10px 20px;
        font-size: 13px;
    }
}

/* ========================================
   15. 平滑滾動行為
   ======================================== */

html {
    scroll-behavior: smooth;
}

/* ========================================
   16. 無障礙支援
   ======================================== */

/* 減少動畫模式 */
@media (prefers-reduced-motion: reduce) {
    .product-card,
    .expand-icon,
    .quick-view-btn,
    .buy-button,
    .product-image,
    .expand-button,
    .expand-button.search-link {
        transition: none;
    }
    
    .product-card {
        animation: none;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* 高對比度模式支援 */
@media (prefers-contrast: high) {
    .product-card {
        border: 2px solid #000;
    }
    
    .product-badge {
        border: 1px solid #000;
    }
    
    .expand-button,
    .expand-button.search-link {
        border: 2px solid #000;
    }
}

/* ========================================
   17. 打印樣式
   ======================================== */

@media print {
    .quick-view-overlay,
    .expand-button-wrapper,
    .buy-button {
        display: none !important;
    }
    
    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
    }
    
    .product-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .product-sections-common {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ========================================
   18. 深色模式支援 (可選)
   ======================================== */

@media (prefers-color-scheme: dark) {
    .product-sections-common {
        background: #1a202c;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }
    
    .section-title {
        color: #f7fafc;
    }
    
    .section-subtitle,
    .view-more-link {
        color: #a0aec0;
    }
    
    .view-more-link:hover {
        color: #d4a574;
    }
    
    .product-card {
        background: #2d3748;
        border-color: #4a5568;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }
    
    .product-card:hover {
        box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    }
    
    .product-name a {
        color: #f7fafc;
    }
    
    .product-name a:hover {
        color: #d4a574;
    }
    
    .product-sales {
        color: #a0aec0;
    }
    
    .product-image-wrapper {
        background: #2d3748;
    }
    
    .quick-view-btn {
        background: #4a5568;
        color: #f7fafc;
    }
    
    .quick-view-btn:hover {
        background: #8b7355;
        color: white;
    }
}

/* ========================================
   19. 焦點樣式 (鍵盤導航)
   ======================================== */

.expand-button:focus,
.expand-button.search-link:focus,
.buy-button:focus,
.quick-view-btn:focus,
.product-name a:focus,
.view-more-link:focus {
    outline: 3px solid #8b7355;
    outline-offset: 2px;
}

/* ========================================
   20. 載入狀態和過渡效果
   ======================================== */

/* 淡入動畫增強 */
.product-card[style*="opacity: 0"] {
    opacity: 0 !important;
    transform: translateY(20px);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 圖片載入過渡 */
.product-image[loading="lazy"] {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 20%,
        #f0f0f0 40%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* ========================================
   21. 互動反饋增強
   ======================================== */

/* 按鈕點擊效果 */
.expand-button.search-link:active::before,
.expand-button:active::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 30px;
    transform: translate(-50%, -50%) scale(0);
    animation: ripple 0.6s ease-out;
}

@keyframes ripple {
    to {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* ========================================
   22. 效能優化
   ======================================== */

/* GPU 加速 */
.product-card,
.product-image,
.quick-view-overlay,
.expand-button,
.expand-button.search-link {
    will-change: transform;
}

/* 防止文字選取（按鈕） */
.expand-button,
.expand-button.search-link,
.buy-button {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* ========================================
   23. 瀏覽器相容性修正
   ======================================== */

/* IE11 Grid 備援 */
@supports not (display: grid) {
    .products-grid {
        display: flex;
        flex-wrap: wrap;
        margin: -12.5px;
    }
    
    .product-card {
        width: calc(25% - 25px);
        margin: 12.5px;
    }
    
    @media (max-width: 1024px) and (min-width: 768px) {
        .product-card {
            width: calc(33.333% - 20px);
        }
    }
    
    @media (max-width: 767px) {
        .product-card {
            width: calc(50% - 15px);
        }
    }
}

/* Safari aspect-ratio 備援 */
@supports not (aspect-ratio: 1 / 1) {
    .product-image-wrapper {
        padding-top: 100%;
        height: 0;
        position: relative;
    }
    
    .product-image-wrapper .product-image {
        position: absolute;
        top: 0;
        left: 0;
    }
}