/* products.css */

/* 商品列表頁面樣式 */
.products-container {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* 搜尋區塊 */
.search-section {
    position: sticky;
    /*top: 70px;*/
    z-index: 100;
    background: white;
}

.search-section .card {
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 商品卡片 */
.product-card {
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

.card-img-top-wrapper {
    position: relative;
    padding-top: 100%; /* 1:1 長寬比 */
    overflow: hidden;
    background-color: #f8f9fa; /* 增加背景色，當圖片不夠大時顯示 */
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-img-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain; /* 修改為 contain 讓圖片完整顯示 */
}

.product-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
}

.product-description {
    font-size: 0.9rem;
    color: var(--text-light);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* 商品詳細頁面樣式 */
.product-detail {
    padding: 1rem;
}

/* 圖片輪播樣式 */
.product-gallery {
    border-radius: 0.5rem;
    overflow: hidden;
    margin-bottom: 1rem;
}

.product-gallery .carousel {
    border-radius: 0.5rem;
    overflow: hidden;
}

.product-gallery .carousel-item {
    aspect-ratio: 1;
}

.carousel-img-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fa;
}

.carousel-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    max-height: 100%;
}

.product-gallery .carousel-control-prev,
.product-gallery .carousel-control-next {
    width: 15%;
    background: rgba(0, 0, 0, 0.2);
}

.product-info .table th {
    background-color: rgba(10, 186, 181, 0.1);
    white-space: nowrap;
}

.product-prices {
    overflow-y: auto;
}

.product-prices table {
    margin-bottom: 0;
}

/* 卡片樣式 */
.card {
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: none;
    padding: 1rem;
}

.description-content {
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    line-height: 1.6;
    overflow-x: auto;
}

/* 商品描述內容的表格樣式 */
.description-content table {
    width: 100%;
    margin-bottom: 1rem;
    border-collapse: collapse;
}

.description-content table td,
.description-content table th {
    padding: 0.75rem;
    border: 1px solid #dee2e6;
}

.description-content table th {
    background-color: rgba(10, 186, 181, 0.1);
}

/* 商品描述內容的圖片樣式 */
.description-content img {
    max-width: 100%;
    height: auto;
    margin: 1rem 0;
}

/* 商品描述內容的列表樣式 */
.description-content ul,
.description-content ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

/* 商品描述內的標題樣式 */
.description-content h1,
.description-content h2,
.description-content h3,
.description-content h4,
.description-content h5,
.description-content h6 {
    margin: 1.5rem 0 1rem;
    color: var(--text-color);
}

/* 手機版適配 */
@media (max-width: 768px) {
    .product-gallery {
        margin: -1rem -1rem 1rem -1rem;
        border-radius: 0;
    }
    
    .product-prices {
        margin: 0 -1rem;
    }

    .description-content {
        padding: 0.75rem;
    }
    
    .description-content table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .description-content img {
        margin: 0.75rem 0;
    }

    .card-body {
        padding: 1rem;
    }
}

/* 購物車浮動按鈕 */
.cart-float {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.cart-float .btn {
    width: 3.5rem;
    height: 3.5rem;
    padding: 0;
    position: relative;
}

.cart-float .cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--error-color);
    color: white;
    border-radius: 50%;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    min-width: 1.5rem;
}

.cart-total {
    background: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 新增到購物車動畫 */
@keyframes addToCart {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.add-to-cart-animation {
    animation: addToCart 0.3s ease-in-out;
}

/* 響應式調整 */
@media (max-width: 768px) {
    .products-container {
        padding: 0.5rem;
    }

    .search-section {
        position: static;
        margin-bottom: 1rem;
    }

    .search-section .input-group {
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .search-section .input-group .form-control {
        border-right: none;
    }
    
    .search-section .input-group .btn {
        border-radius: 0;
    }
    
    .search-section .input-group .btn:last-child {
        border-top-right-radius: 0.375rem;
        border-bottom-right-radius: 0.375rem;
    }
    
    #advancedSearch {
        background-color: #f8f9fa;
        padding: 1rem;
        border-radius: 0.375rem;
        margin-top: 0.5rem;
    }

    .product-card .card-title {
        font-size: 1rem;
    }

    .cart-float {
        bottom: 1rem;
        right: 1rem;
    }

    .cart-float .btn {
        width: 3rem;
        height: 3rem;
    }

    .product-detail {
        padding: 0.5rem;
    }

    .product-title {
        font-size: 1.25rem;
    }

    .product-prices {
        font-size: 0.9rem;
    }
}

/* 加載動畫 */
.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2rem;
    height: 2rem;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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