/**
 * EC Shop - 共享產品卡片樣式
 * 路徑：assets/css/product-card.css
 *
 * 適用：首頁、分類頁、品牌頁、全部產品頁、推介頁、搜尋頁、產品詳情（相關商品）
 * 載入方式：在 front-header.php <head> 加入
 *   <link rel="stylesheet" href="/assets/css/product-card.css">
 */

/* ══════════════════════════════════════════════
   產品網格佈局
   ══════════════════════════════════════════════ */

/* 自適應網格（分類、品牌、搜尋、全部產品、推介） */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

/* 固定 4 欄網格（首頁用） */
.products-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

/* 列表模式 */
.products-grid.list-view {
    grid-template-columns: 1fr;
}
.products-grid.list-view .product-card {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 20px;
}

/* ══════════════════════════════════════════════
   產品卡片 - 容器
   ══════════════════════════════════════════════ */
.product-card {
    background: var(--white);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    transition: all var(--transition);
}
.product-card:hover {
    border-color: var(--primary-light);
    box-shadow: 0 8px 32px rgba(0, 0, 0, .06);
    transform: translateY(-4px);
}

/* ══════════════════════════════════════════════
   產品卡片 - 圖片區域
   ══════════════════════════════════════════════ */
.pc-image {
    display: block;
    overflow: hidden;
    background: #f8fafc;
    position: relative;
}
.pc-image.pc-fit-contain {
    background: #f8fafc;
}
.pc-image.pc-fit-contain img {
    background: #f8fafc;
}

/* 圖片比例 */
.pc-image.pc-ratio-1-1 {
    aspect-ratio: 1 / 1;
}
.pc-image.pc-ratio-3-4 {
    aspect-ratio: 3 / 4;
}
.pc-image.pc-ratio-4-3 {
    aspect-ratio: 4 / 3;
}
.pc-image.pc-ratio-auto {
    aspect-ratio: auto;
}

/* 原圖比例時，圖片高度自動 */
.pc-image.pc-ratio-auto img {
    width: 100%;
    height: auto;
    display: block;
}

/* 非原圖比例時，圖片填滿容器 */
.pc-image:not(.pc-ratio-auto) img {
    width: 100%;
    height: 100%;
    transition: transform .4s ease;
}

/* 顯示方式 */
.pc-image.pc-fit-cover img {
    object-fit: cover;
}
.pc-image.pc-fit-contain img {
    object-fit: contain;
}

/* 裁剪焦點 */
.pc-image.pc-pos-center img {
    object-position: center center;
}
.pc-image.pc-pos-top img {
    object-position: center top;
}
.product-card:hover .pc-image img {
    transform: scale(1.06);
}

.product-card:hover .pc-image.pc-fit-contain img,
.product-card:hover .pc-image.pc-ratio-auto img {
    transform: none;
}

/* ══════════════════════════════════════════════
   產品卡片 - Badge 系統
   ══════════════════════════════════════════════ */

/* 折扣 Badge（紅色） */
.pc-badge {
    position: absolute;
    background: var(--danger);
    color: #fff;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(239, 68, 68, .3);
}

/* 自訂 Badge（後台設定顏色） */
.pc-badge-custom {
    position: absolute;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    z-index: 2;
}

/* Badge 四角定位 */
.badge-pos-top-left     { top: 10px; left: 10px; }
.badge-pos-top-right    { top: 10px; right: 10px; }
.badge-pos-bottom-left  { bottom: 10px; left: 10px; }
.badge-pos-bottom-right { bottom: 10px; right: 10px; }

/* 售罄遮罩 */
.pc-sold-out {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .45);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
}

/* ══════════════════════════════════════════════
   產品卡片 - 資訊區
   ══════════════════════════════════════════════ */
.pc-info {
    padding: 14px 16px 18px;
}

/* 品牌名 */
.pc-brand {
    font-size: 11px;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
    margin-bottom: 4px;
}

/* 產品名（最多兩行截斷） */
.pc-name {
    display: -webkit-box;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    margin-bottom: 8px;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-decoration: none;
}
.pc-name:hover {
    color: var(--primary);
}

/* ══════════════════════════════════════════════
   產品卡片 - 價格
   ══════════════════════════════════════════════ */
.pc-price {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}
.pc-price-now {
    font-size: 17px;
    font-weight: 800;
    color: var(--primary);
}
.pc-price-was {
    font-size: 13px;
    color: var(--text-light);
    text-decoration: line-through;
}

/* 會員價 */
.pc-member-price {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    margin-top: 4px;
}

/* ══════════════════════════════════════════════
   產品卡片 - 加入購物車按鈕
   ══════════════════════════════════════════════ */
.pc-add-cart-btn {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 12px;
    border-radius: 10px;
    border: none;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.product-card:hover .pc-add-cart-btn {
    background: var(--primary);
    color: #fff;
}
.pc-add-cart-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

/* ══════════════════════════════════════════════
   動畫
   ══════════════════════════════════════════════ */
@keyframes pcFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
}
@keyframes pcSpin {
    to { transform: rotate(360deg); }
}

.fade-in {
    animation: pcFadeIn .5s ease both;
}
.stagger-1 { animation-delay: .05s; }
.stagger-2 { animation-delay: .10s; }
.stagger-3 { animation-delay: .15s; }
.stagger-4 { animation-delay: .20s; }
.stagger-5 { animation-delay: .25s; }
.stagger-6 { animation-delay: .30s; }
.stagger-7 { animation-delay: .35s; }
.stagger-8 { animation-delay: .40s; }

/* ══════════════════════════════════════════════
   RWD 響應式
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .products-grid-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .pc-info {
        padding: 10px 12px 14px;
    }
    .pc-name {
        font-size: 13px;
    }
    .pc-price-now {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .products-grid,
    .products-grid-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}
/* ── [QTY DISCOUNT] 數量折扣階梯 ── */
.pi-qty-discount {
    margin: 12px 0;
    border: 1px solid #e8f5e9;
    border-radius: 10px;
    overflow: hidden;
    background: #f6fbf6;
}
.pi-qty-discount-title {
    font-size: 13px;
    font-weight: 700;
    padding: 8px 14px;
    background: #e8f5e9;
    color: #2e7d32;
}
.pi-qty-discount-tiers {
    padding: 6px 14px 10px;
}
.pi-qty-tier {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 13px;
    transition: background 0.2s, box-shadow 0.2s;
}
.pi-qty-tier + .pi-qty-tier {
    border-top: 1px dashed #c8e6c9;
}
.pi-qty-tier.active {
    background: #c8e6c9;
    font-weight: 600;
    box-shadow: inset 3px 0 0 #43a047;
}
.pi-qty-tier .tier-qty {
    min-width: 60px;
    font-weight: 600;
    color: #2e7d32;
}
.pi-qty-tier .tier-discount {
    flex: 1;
    color: #d32f2f;
}
.pi-qty-tier .tier-unit-price {
    font-size: 12px;
    color: var(--text-light);
    white-space: nowrap;
}