/**
 * 前端展示樣式
 * 
 * @package Uni_Shopee_Affiliate_TW
 * @since 1.0.0
 */

/* 基礎樣式重置 */
.shopee-product,
.shopee-products,
.shopee-categories,
.shopee-brands {
    box-sizing: border-box;
}

.shopee-product *,
.shopee-products *,
.shopee-categories *,
.shopee-brands * {
    box-sizing: border-box;
}

/* 商品卡片樣式 */
.shopee-product {
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 20px;
    position: relative;
}

.shopee-product:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
    border-color: #0073aa;
}

/* 商品圖片 */
.shopee-product-image {
    position: relative;
    overflow: hidden;
    background: #f8f9fa;
    aspect-ratio: 1;
}

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

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

/* 商品內容 */
.shopee-product-content {
    padding: 20px;
}

.shopee-product-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    margin: 0 0 12px 0;
    color: #23282d;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 44px;
}

/* 商品資訊 */
.shopee-product-info {
    margin-bottom: 16px;
}

.shopee-product-price {
    font-size: 20px;
    font-weight: 700;
    color: #ee4d2d;
    margin-bottom: 8px;
}

.shopee-product-commission {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.commission-rate {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: #fff;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.commission-amount {
    color: #28a745;
    font-weight: 600;
    font-size: 14px;
}

/* 評分 */
.shopee-product-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.shopee-rating-stars {
    display: flex;
    gap: 2px;
}

.star {
    font-size: 14px;
    line-height: 1;
}

.star-full {
    color: #ffc107;
}

.star-half {
    color: #ffc107;
    opacity: 0.6;
}

.star-empty {
    color: #e9ecef;
}

.rating-text {
    font-size: 13px;
    color: #6c757d;
}

/* 購買按鈕 */
.shopee-product-actions {
    margin-top: 16px;
}

.shopee-buy-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, #ee4d2d, #ff6b35);
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.shopee-buy-button:hover {
    background: linear-gradient(135deg, #d63384, #ee4d2d);
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(238, 77, 45, 0.3);
}

.shopee-buy-button:active {
    transform: translateY(0);
}

/* 商品列表佈局 */
.shopee-products {
    display: grid;
    gap: 20px;
    margin-bottom: 30px;
}

/* 網格佈局 */
.shopee-products.shopee-products-grid.shopee-columns-1 {
    grid-template-columns: 1fr;
}

.shopee-products.shopee-products-grid.shopee-columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.shopee-products.shopee-products-grid.shopee-columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.shopee-products.shopee-products-grid.shopee-columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

.shopee-products.shopee-products-grid.shopee-columns-5 {
    grid-template-columns: repeat(5, 1fr);
}

.shopee-products.shopee-products-grid.shopee-columns-6 {
    grid-template-columns: repeat(6, 1fr);
}

/* 列表佈局 */
.shopee-products.shopee-products-list {
    grid-template-columns: 1fr;
}

.shopee-products.shopee-products-list .shopee-product {
    display: flex;
    align-items: center;
}

.shopee-products.shopee-products-list .shopee-product-image {
    width: 120px;
    height: 120px;
    flex-shrink: 0;
    aspect-ratio: 1;
}

.shopee-products.shopee-products-list .shopee-product-content {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.shopee-products.shopee-products-list .shopee-product-actions {
    margin-top: 0;
    margin-left: 20px;
}

.shopee-products.shopee-products-list .shopee-buy-button {
    width: auto;
    min-width: 120px;
}

/* 分類和品牌列表 */
.shopee-categories,
.shopee-brands {
    margin-bottom: 20px;
}

.shopee-category-list,
.shopee-brand-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.shopee-category-item,
.shopee-brand-item {
    margin: 0;
}

.shopee-category-link,
.shopee-brand-link {
    display: inline-block;
    padding: 8px 16px;
    background: #f8f9fa;
    color: #495057;
    text-decoration: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid #e9ecef;
}

.shopee-category-link:hover,
.shopee-brand-link:hover {
    background: #0073aa;
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.3);
}

/* 分頁 */
.shopee-pagination {
    text-align: center;
    margin-top: 30px;
    padding: 20px 0;
}

.pagination-info {
    color: #6c757d;
    font-size: 14px;
}

/* 錯誤和空狀態 */
.shopee-error,
.shopee-no-products,
.shopee-no-categories,
.shopee-no-brands {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-size: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.shopee-error {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

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

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

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

/* 響應式設計 */
@media (max-width: 1200px) {
    .shopee-products.shopee-products-grid.shopee-columns-6 {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .shopee-products.shopee-products-grid.shopee-columns-5 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 992px) {
    .shopee-products.shopee-products-grid.shopee-columns-4,
    .shopee-products.shopee-products-grid.shopee-columns-5,
    .shopee-products.shopee-products-grid.shopee-columns-6 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .shopee-products.shopee-products-grid.shopee-columns-3,
    .shopee-products.shopee-products-grid.shopee-columns-4,
    .shopee-products.shopee-products-grid.shopee-columns-5,
    .shopee-products.shopee-products-grid.shopee-columns-6 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .shopee-product-content {
        padding: 16px;
    }
    
    .shopee-product-title {
        font-size: 15px;
        min-height: 40px;
    }
    
    .shopee-product-price {
        font-size: 18px;
    }
    
    /* 列表佈局在手機上改為卡片佈局 */
    .shopee-products.shopee-products-list .shopee-product {
        flex-direction: column;
    }
    
    .shopee-products.shopee-products-list .shopee-product-image {
        width: 100%;
        height: 200px;
    }
    
    .shopee-products.shopee-products-list .shopee-product-content {
        flex-direction: column;
        align-items: stretch;
    }
    
    .shopee-products.shopee-products-list .shopee-product-actions {
        margin-left: 0;
        margin-top: 16px;
    }
    
    .shopee-products.shopee-products-list .shopee-buy-button {
        width: 100%;
    }
}

@media (max-width: 576px) {
    .shopee-products.shopee-products-grid {
        grid-template-columns: 1fr;
    }
    
    .shopee-products {
        gap: 16px;
    }
    
    .shopee-product-content {
        padding: 12px;
    }
    
    .shopee-product-title {
        font-size: 14px;
        min-height: 36px;
    }
    
    .shopee-product-price {
        font-size: 16px;
    }
    
    .shopee-buy-button {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .shopee-category-list,
    .shopee-brand-list {
        flex-direction: column;
        gap: 8px;
    }
    
    .shopee-category-link,
    .shopee-brand-link {
        text-align: center;
    }
}

/* 深色模式支援 */
@media (prefers-color-scheme: dark) {
    .shopee-product {
        background: #1e1e1e;
        border-color: #404040;
        color: #e0e0e0;
    }
    
    .shopee-product-title {
        color: #e0e0e0;
    }
    
    .shopee-product-image {
        background: #2a2a2a;
    }
    
    .shopee-category-link,
    .shopee-brand-link {
        background: #2a2a2a;
        color: #e0e0e0;
        border-color: #404040;
    }
    
    .shopee-error,
    .shopee-no-products,
    .shopee-no-categories,
    .shopee-no-brands {
        background: #2a2a2a;
        color: #b0b0b0;
        border-color: #404040;
    }
    
    .shopee-error {
        background: #3a1f1f;
        color: #ff6b6b;
        border-color: #5a2d2d;
    }
}

/* 高對比度模式 */
@media (prefers-contrast: high) {
    .shopee-product {
        border-width: 2px;
    }
    
    .shopee-buy-button {
        border: 2px solid #fff;
    }
    
    .shopee-category-link,
    .shopee-brand-link {
        border-width: 2px;
    }
}

/* 減少動畫模式 */
@media (prefers-reduced-motion: reduce) {
    .shopee-product,
    .shopee-product-image img,
    .shopee-buy-button,
    .shopee-category-link,
    .shopee-brand-link {
        transition: none;
    }
    
    .shopee-product:hover {
        transform: none;
    }
    
    .shopee-product:hover .shopee-product-image img {
        transform: none;
    }
    
    .shopee-spinner {
        animation: none;
    }
}

/* 列印樣式 */
@media print {
    .shopee-buy-button,
    .shopee-product-actions {
        display: none;
    }
    
    .shopee-product {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .shopee-products {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}
