/**
 * USA List 前端樣式
 * 
 * @package Uni_Shopee_Affiliate_TW
 * @since 1.1.82
 */

/* ===== 容器樣式 ===== */
.usa-list-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

/* ===== 標題區域 ===== */
.usa-list-header {
    margin-bottom: 30px;
    text-align: center;
}

.usa-list-title {
    font-size: 28px;
    font-weight: 600;
    color: #333;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== 桌面版 4x4 網格 ===== */
.usa-list-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    width: 100%;
}

/* ===== 商品卡片基礎樣式 ===== */
.usa-product-card {
    background: #fff;
    border: 1px solid #e1e1e1;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.usa-product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: #667eea;
}

/* ===== 商品圖片區域 ===== */
.usa-product-image {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: #f8f9fa;
}

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

.usa-product-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: #e9ecef;
    color: #6c757d;
    font-size: 14px;
}

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

/* ===== 商品標籤 ===== */
.usa-product-badges {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
}

.usa-product-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    margin-right: 6px;
    margin-bottom: 6px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.usa-product-badge.commission {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    box-shadow: 0 2px 8px rgba(238, 90, 36, 0.3);
}

/* ===== 黑名單按鈕 ===== */
.usa-blacklist-button {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
}

.blacklist-toggle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    color: #ff4757;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.blacklist-toggle:hover {
    background: #ff4757;
    color: #fff;
    transform: scale(1.1);
}

.blacklist-toggle.active {
    background: #2ed573;
    color: #fff;
}

.blacklist-toggle.active:before {
    content: '✓';
}

/* ===== 商品內容區域 ===== */
.usa-product-content {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.usa-product-title {
    font-size: 15px !important;
    font-weight: 600 !important;
    color: #1e1e1e;
    margin: 0 0 10px 0;
    line-height: 1.3;
    height: 40px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ===== 店家資訊 ===== */
.usa-product-shop {
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.usa-product-shop i {
    margin-right: 4px;
    color: #ec923e;
    font-size:13px;
    margin-top:5px;

}

/* ===== 價格區域 ===== */
.usa-product-price {
    margin-bottom: 12px;
}

.usa-price-main {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.usa-price-current {
    font-size: 16px !important;
    font-weight: 700;
    color: #cf4d1e;
}

.usa-price-original {
    font-size: 12px;
    color: #999;
    text-decoration: line-through;
}

.usa-discount-badge {
    display: inline-block;
    background: #cf4d1e;
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 4px;
}

.usa-product-commission {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 16px;
    display: inline-block;
}

/* ===== 統計資訊 ===== */
.usa-product-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.usa-product-rating {
    display: flex;
    align-items: center;
    gap: 4px;
}

.usa-rating-stars {
    color: #ffc107;
    font-size: 14px;
}

.usa-rating-number {
    font-size: 12px;
    color: #666;
}

.usa-product-sales {
    font-size: 12px;
    color: #999;
    font-weight: 500;
}


/* ===== 操作按鈕 ===== */
.usa-product-actions {
    margin-top: auto;
}

.usa-product-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    text-decoration: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.usa-product-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    text-decoration: none;
    color: #fff;
}

.usa-product-link .dashicons {
    width: 16px;
    height: 16px;
    font-size: 16px;
    margin-right: 6px;
}

/* ===== 空狀態 ===== */
.usa-list-empty {
    text-align: center;
    padding: 60px 20px;
    color: #7f8c8d;
}

.usa-empty-icon {
    font-size: 48px;
    margin-bottom: 20px;
    opacity: 0.6;
}

.usa-list-empty h4 {
    font-size: 18px;
    color: #2c3e50;
    margin: 0 0 10px 0;
}

.usa-list-empty p {
    font-size: 14px;
    margin: 0;
}

/* ===== 大平板版 (1025px - 1200px) ===== */
@media (max-width: 1200px) and (min-width: 1025px) {
    .usa-list-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 18px;
    }
    
    .usa-list-container {
        padding: 18px;
    }
    
    .usa-product-image {
        height: 190px;
    }
}

/* ===== 平板版橫向 (769px - 1024px) ===== */
@media (max-width: 1024px) and (min-width: 769px) {
    .usa-list-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
    
    .usa-list-container {
        padding: 16px;
    }
    
    .usa-product-image {
        height: 180px;
    }
    
    .usa-product-title {
        font-size: 14px;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
}

/* ===== 小平板版直向 (481px - 768px) ===== */
@media (max-width: 768px) and (min-width: 481px) {
    .usa-list-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
    
    .usa-list-container {
        padding: 14px;
    }
    
    .usa-product-image {
        height: 160px;
    }
    
    .usa-product-title {
        font-size: 13px;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
}

/* ===== 手機版 2x2 滑動效果 (480px 以下) ===== */
@media (max-width: 480px) {
    .usa-list-container {
        padding: 12px 0;
        overflow: hidden;
        max-width: 100vw;
    }
    
    .usa-list-header {
        margin-bottom: 16px;
        padding: 0 12px;
    }
    
    .usa-list-title {
        font-size: 20px;
    }
    
    /* 滑動容器 */
    .usa-list-grid {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        gap: 0;
        padding: 0 12px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        scroll-behavior: smooth;
    }
    
    .usa-list-grid::-webkit-scrollbar {
        display: none;
    }
    
    /* 滑動頁面 */
    .usa-slide-page {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(2, 1fr);
        gap: 8px;
        min-width: calc(100vw - 24px);
        max-width: calc(100vw - 24px);
        scroll-snap-align: start;
        padding-right: 12px;
        flex-shrink: 0;
        box-sizing: border-box;
    }
    
    .usa-slide-page:last-child {
        padding-right: 0;
    }
    
    /* 手機版商品卡片 */
    .usa-product-card {
        border-radius: 10px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
        width: 100%;
        max-width: none;
        overflow: hidden;
    }
    
    .usa-product-image {
        height: 100px;
    }
    
    .usa-product-image-placeholder {
        font-size: 12px;
    }
    
    .usa-product-content {
        padding: 8px;
    }
    
    .usa-product-title {
        font-size: 12px;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        min-height: 30px;
        margin-bottom: 6px;
        line-height: 1.3;
    }
    
    .usa-product-shop {
        margin-bottom: 6px;
        font-size: 10px;
    }
    
    .usa-product-price {
        margin-bottom: 6px;
        font-size: 12px;
    }
    
    .usa-price-current {
        font-size: 13px;
    }
    
    .usa-product-stats {
        margin-bottom: 8px;
        font-size: 10px;
    }
    
    .usa-product-link {
        padding: 6px 8px;
        font-size: 11px;
    }
    
    .usa-product-badges {
        top: 6px;
        left: 6px;
    }
    
    .usa-product-badge {
        padding: 2px 4px;
        font-size: 9px;
    }
    
    .usa-blacklist-button {
        top: 6px;
        right: 6px;
    }
    
    .blacklist-toggle {
        width: 20px;
        height: 20px;
        font-size: 12px;
    }
}

/* ===== 滑動指示器 ===== */
@media (max-width: 480px) {
    .usa-list-container::after {
        content: '';
        display: block;
        width: 100%;
        height: 4px;
        background: linear-gradient(90deg, 
            rgba(102, 126, 234, 0.3) 0%, 
            rgba(102, 126, 234, 0.8) 50%, 
            rgba(102, 126, 234, 0.3) 100%);
        margin-top: 20px;
        border-radius: 2px;
    }
}

/* ===== 載入動畫 ===== */
.usa-list-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.usa-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: usa-spin 1s linear infinite;
}

@keyframes usa-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== 錯誤狀態 ===== */
.usa-list-error {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    color: #c53030;
    padding: 16px;
    border-radius: 8px;
    text-align: center;
    margin: 20px 0;
}

/* ===== 動畫效果 ===== */
.usa-product-card {
    animation: usa-fadeInUp 0.6s ease-out;
}

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

/* 延遲動畫 */
.usa-product-card:nth-child(1) { animation-delay: 0.1s; }
.usa-product-card:nth-child(2) { animation-delay: 0.2s; }
.usa-product-card:nth-child(3) { animation-delay: 0.3s; }
.usa-product-card:nth-child(4) { animation-delay: 0.4s; }
.usa-product-card:nth-child(5) { animation-delay: 0.5s; }
.usa-product-card:nth-child(6) { animation-delay: 0.6s; }
.usa-product-card:nth-child(7) { animation-delay: 0.7s; }
.usa-product-card:nth-child(8) { animation-delay: 0.8s; }

/* ===== 高對比度支援 ===== */
@media (prefers-contrast: high) {
    .usa-product-card {
        border: 2px solid #333;
    }
    
    .usa-product-link {
        background: #333;
    }
    
    .usa-product-title {
        color: #000;
    }
}

/* ===== 減少動畫支援 ===== */
@media (prefers-reduced-motion: reduce) {
    .usa-product-card,
    .usa-product-image img,
    .usa-product-link,
    .blacklist-toggle {
        transition: none;
        animation: none;
    }
    
    .usa-product-card:hover {
        transform: none;
    }
}
