/**
 * WooCommerce General Styles
 *
 * @package Flaman_Storefront
 */

/* =====================================================
   Product Card Styles
   ===================================================== */

.products {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: var(--spacing-lg);
    width: 100%;
    max-width: 100%;
    grid-template-columns: repeat(3, 1fr);
}

.products.grid-view {
    grid-template-columns: repeat(3, 1fr) !important;
}

.products.list-view {
    grid-template-columns: 1fr !important;
}

.product-card {
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--transition-base);
    height: 100%;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.product-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.product-card-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

/* Product Card Image */
.product-card-image {
    position: relative;
    overflow: hidden;
    background: var(--background-gray);
    aspect-ratio: 4 / 3;
}

.product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

/* Placeholder / fallback: show full image, no crop, no hover zoom */
.product-card-image img.woocommerce-placeholder {
    object-fit: contain !important;
    background: #f5f5f5 !important;
}

.product-card:hover .product-card-image img.woocommerce-placeholder,
.product-card:hover .product-card-image img.img-fallback {
    transform: none;
}

.product-card:hover .product-card-image img {
    transform: scale(1.05);
}

.product-card-image .onsale,
.woocommerce ul.products li.product .product-card-image .onsale {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    left: auto;
    background: var(--error);
    color: var(--background);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    line-height: normal;
    min-height: 0;
    min-width: 0;
    margin: 0;
    text-align: left;
    z-index: 2;
}

/* When sale badge and Canadian badge coexist, push Canadian badge below */
.product-card-image .onsale ~ .badge-canadian {
    top: 48px !important;
}

.product-card-image .out-of-stock-badge {
    position: absolute;
    top: var(--spacing-md);
    left: var(--spacing-md);
    background: var(--text-secondary);
    color: var(--background);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    z-index: 2;
}

/* Product Card Info */
.product-card-info {
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    flex-grow: 1;
}

.product-category {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.product-category a {
    color: var(--text-secondary);
}

.product-category a:hover {
    color: var(--primary-color);
}

.woocommerce-loop-product__title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.4;
}

.woocommerce-loop-product__title a {
    color: var(--text-primary);
}

.woocommerce-loop-product__title a:hover {
    color: var(--primary-color);
}

.product-sku {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.product-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-top: auto;
}

.product-price del {
    color: var(--text-disabled);
    font-size: 1rem;
    margin-right: var(--spacing-xs);
}

.product-price ins {
    text-decoration: none;
}

.product-stock-status {
    font-size: 0.875rem;
    font-weight: 500;
}

.product-stock-status .in-stock {
    color: var(--success);
}

.product-stock-status .low-stock {
    color: var(--warning);
}

.product-stock-status .out-of-stock {
    color: var(--error);
}

.product-add-to-cart .button {
    width: 100%;
    text-align: center;
}

/* List View Specific Styles */
.products.list-view .product-card-inner {
    flex-direction: row;
    width: 100%;
}

.products.list-view .product-card-image {
    width: 300px;
    max-width: 300px;
    flex-shrink: 0;
}

.products.list-view .product-card-info {
    flex-grow: 1;
    flex-basis: 0;
    padding: var(--spacing-lg);
    width: 100%;
}

/* =====================================================
   Cart & Checkout
   ===================================================== */

.woocommerce-cart-form {
    background: var(--background);
    padding: var(--spacing-xl);
    border-radius: var(--radius-md);
}

.cart-collaterals {
    margin-top: var(--spacing-xl);
}

.cart_totals {
    background: var(--background-gray);
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
}

/* =====================================================
   Messages & Notices
   ===================================================== */

.woocommerce-message,
.woocommerce-info,
.woocommerce-error {
    padding: var(--spacing-md) var(--spacing-lg) var(--spacing-md) 3rem;
    margin-bottom: var(--spacing-md);
    border-radius: var(--radius-sm);
    border-left: 4px solid;
    position: relative;
}

.woocommerce-message {
    background: rgba(76, 175, 80, 0.1);
    border-color: var(--success);
    color: #2e7d32;
}

.woocommerce-info {
    background: rgba(33, 150, 243, 0.1);
    border-color: var(--info);
    color: #1565c0;
}

.woocommerce-error {
    background: rgba(244, 67, 54, 0.1);
    border-color: var(--error);
    color: #c62828;
}

/* =====================================================
   Infinite Scroll
   ===================================================== */

.infinite-scroll-sentinel {
    padding: var(--spacing-xl) 0;
    text-align: center;
}

.infinite-scroll-spinner {
    display: flex;
    justify-content: center;
    padding: var(--spacing-md) 0;
}

.spinner-dots {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.spinner-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--flaman-red);
    animation: dotPulse 1.2s ease-in-out infinite;
}

.spinner-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.spinner-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

.infinite-scroll-end {
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

/* =====================================================
   Responsive Design
   ===================================================== */

@media (max-width: 1024px) {
    .products.grid-view {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .products.grid-view {
        grid-template-columns: 1fr;
    }

    .products.list-view .product-card-inner {
        flex-direction: column;
    }

    .products.list-view .product-card-image {
        width: 100%;
    }
    }

    .product-card-info {
        padding: var(--spacing-sm);
    }
}
