/* Shop Products Grid Widget Styles */
/* Tous les sélecteurs scopés sous .shop-products-grid-widget pour garantir la spécificité dans l'éditeur Elementor */

.shop-products-grid-widget {
    width: 100%;
    max-width: 100%;
}

/* Toolbar Styles */
.shop-products-grid-widget .shop-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.shop-products-grid-widget .shop-toolbar .sorting-label {
    font-size: 16px;
    color: #666;
    font-weight: normal;
}

.shop-products-grid-widget .shop-toolbar #shop-orderby {
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    background: white;
    color: #333;
    max-width: 130px;
    flex-shrink: 0;
    appearance: none;
    -webkit-appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 4 5%22><path fill=%22%23666%22 d=%22M2 0L0 2h4zm0 5L0 3h4z%22/></svg>');
    background-repeat: no-repeat;
    background-position: right 4px center;
    background-size: 8px;
}

.shop-products-grid-widget .shop-toolbar #products-count-display {
    font-size: 16px;
    color: #666;
    flex-shrink: 0;
}

/* Products Grid */
.shop-products-grid-widget .shop-products-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 30px;
    align-items: start;
}

/* Product Card */
.shop-products-grid-widget .product-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.shop-products-grid-widget .product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Product Image */
.shop-products-grid-widget .product-image {
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    border-radius: 8px 8px 0 0;
}

.shop-products-grid-widget .product-image a {
    display: block;
    height: 100%;
}

.shop-products-grid-widget .product-image img {
    width: 100%;
    height: 100%;
    display: block;
    transition: transform 0.3s ease;
}

/* Mode Couvrir (défaut) — l'image remplit le cadre, peut être coupée */
.image-fit-cover .product-image img {
    object-fit: cover;
}

/* Mode Contenir — l'image entière est visible */
.image-fit-contain .product-image img {
    object-fit: contain;
}

/* Mode Hauteur automatique — l'image garde ses proportions naturelles */
.image-fit-auto .product-image {
    height: auto !important;
}

.image-fit-auto .product-image a {
    height: auto;
}

.image-fit-auto .product-image img {
    height: auto;
    object-fit: unset;
}

.shop-products-grid-widget .product-card:hover .product-image img {
    transform: scale(1.05);
}

.shop-products-grid-widget .sale-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #ff4444;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    z-index: 2;
}

/* Product Content (brand + title area) */
.shop-products-grid-widget .product-content {
    padding: 15px;
    margin: 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* Product Brand */
.shop-products-grid-widget .product-brand {
    margin: 0 0 4px 0;
    font-size: 12px;
    font-weight: 600;
    color: #888;
    text-align: center;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.shop-products-grid-widget .product-title {
    margin: 0;
    font-size: 16px;
    line-height: 1.4;
    color: #333;
    word-wrap: break-word;
}

.shop-products-grid-widget .product-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.3s ease;
}

.shop-products-grid-widget .product-title a:hover {
    color: #007cba;
}

/* Spacer — pushes bottom section down */
.shop-products-grid-widget .product-card .spacer {
    flex: 1;
}

/* Bottom Section (price, swatches, button) */
.shop-products-grid-widget .product-bottom-section {
    padding: 0 15px 15px 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.shop-products-grid-widget .product-price {
    font-size: 18px;
    font-weight: bold;
    color: #007cba;
    text-align: center;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .3em;
}

.shop-products-grid-widget .product-price .woocommerce-Price-amount {
    color: inherit;
}

.shop-products-grid-widget .product-price del {
    color: #999;
    font-weight: normal;
    margin-right: 8px;
}

/* Swatches Wrapper */
.shop-products-grid-widget .product-swatches-wrapper {
    min-height: 40px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding-top: 5px;
}

/* Swatches empty placeholder */
.shop-products-grid-widget .product-swatches-placeholder {
    min-height: 40px;
}

/* Color Swatches */
.shop-products-grid-widget .swatches-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    margin-bottom: 5px;
}

.shop-products-grid-widget .swatch.fallback {
    background: #ccc;
}

/* Swatch items (unified) */
.shop-products-grid-widget .swatch,
.shop-products-grid-widget .color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid #ddd;
    display: inline-block;
    margin: 2px;
    cursor: default;
    flex-shrink: 0;
    box-sizing: border-box;
}

.shop-products-grid-widget .more-colors {
    font-size: 12px;
    color: #666;
    text-align: center;
    margin-bottom: 4px;
}

/* Customize Button */
.shop-products-grid-widget .customize-button {
    display: inline-block;
    width: 100%;
    padding: 10px 15px;
    background-color: #007cba;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    margin-top: auto;
}

.shop-products-grid-widget .customize-button:hover {
background-color: #005a87;
color: white;
}

/* Pagination */
.shop-products-grid-widget .shop-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 30px;
    padding: 20px 0;
}

.shop-products-grid-widget .shop-pagination .page-numbers {
    display: inline-block;
    padding: 8px 12px;
    margin: 0 2px;
    background: #fff;
    border: 1px solid #ddd;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.shop-products-grid-widget .shop-pagination .page-numbers:hover,
.shop-products-grid-widget .shop-pagination .page-numbers.current {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

/* AJAX Pagination Buttons */
.shop-products-grid-widget .ajax-page-btn {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    color: #666;
    cursor: pointer;
    transition: background 0.2s ease;
}

.shop-products-grid-widget .ajax-page-btn:hover {
    background: #f0f0f0;
}

.shop-products-grid-widget .shop-pagination .current-page {
    padding: 8px 12px;
    background: #007cba;
    color: white;
    border-radius: 4px;
    font-weight: bold;
}

/* AJAX Pagination container */
.shop-products-grid-widget .shop-pagination.ajax-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 30px;
}

/* AJAX Loading indicator */
.shop-products-grid-widget .ajax-loading {
    display: none;
    text-align: center;
    margin-top: 20px;
}

.shop-products-grid-widget .ajax-loading .ajax-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Infinite Scroll */
.shop-products-grid-widget .infinite-scroll-trigger {
    text-align: center;
    margin: 30px 0;
    padding: 20px;
}

.shop-products-grid-widget #load-more-spinner {
    display: none;
    text-align: center;
    margin: 20px 0;
}

.shop-products-grid-widget #load-more-spinner .ajax-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.shop-products-grid-widget #load-more-spinner p {
    margin-top: 10px;
    color: #666;
}

.shop-products-grid-widget .load-more-btn {
    background: #007cba;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.shop-products-grid-widget .load-more-btn:hover {
    background: #005a87;
}

.shop-products-grid-widget .loading-spinner {
    display: inline-block;
    padding: 15px 30px;
    background: #f8f8f8;
    border-radius: 25px;
    color: #666;
    font-size: 14px;
}

.shop-products-grid-widget .loading-spinner::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* No Products Found */
.shop-products-grid-widget .no-products-found {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 16px;
}

/* === VIEW TOGGLE BUTTONS === */
.shop-products-grid-widget .view-toggle {
    display: flex;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

.shop-products-grid-widget .view-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #999;
    cursor: pointer;
    transition: all 0.2s ease;
}

.shop-products-grid-widget .view-toggle-btn:hover {
    color: #666;
    border-color: #bbb;
}

.shop-products-grid-widget .view-toggle-btn.active {
    background: #007cba;
    color: #fff;
    border-color: #007cba;
}

/* === LIST VIEW LAYOUT === */
.shop-products-grid-widget .shop-products-grid.view-list {
    grid-template-columns: 1fr !important;
}

.shop-products-grid-widget .shop-products-grid.view-list .product-card {
    display: grid;
    grid-template-columns: 200px 1fr;
    grid-template-rows: auto 1fr;
    text-align: left;
    height: auto;
}

.shop-products-grid-widget .shop-products-grid.view-list .product-image {
    grid-column: 1;
    grid-row: 1 / -1;
    width: 100%;
    height: 100%;
}

.shop-products-grid-widget .shop-products-grid.view-list .product-image a {
    height: 100%;
    display: block;
}

.shop-products-grid-widget .shop-products-grid.view-list .product-image img {
    height: 100%;
    width: 100%;
    object-fit: cover;
}

.shop-products-grid-widget .shop-products-grid.view-list .product-content {
    grid-column: 2;
    grid-row: 1;
    height: auto;
    padding: 15px 15px 5px 15px;
    min-width: 0;
    align-items: flex-start;
    justify-content: flex-start;
}

.shop-products-grid-widget .shop-products-grid.view-list .product-brand {
    text-align: left;
    width: 100%;
}

.shop-products-grid-widget .shop-products-grid.view-list .product-title {
    height: auto !important;
    -webkit-line-clamp: unset !important;
    width: 100%;
}

.shop-products-grid-widget .shop-products-grid.view-list .spacer {
    display: none;
}

.shop-products-grid-widget .shop-products-grid.view-list .product-bottom-section {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 5px 15px 15px 15px;
    min-width: 0;
}

.shop-products-grid-widget .shop-products-grid.view-list .product-price {
    justify-content: flex-start;
    height: auto;
    width: 100%;
}

.shop-products-grid-widget .shop-products-grid.view-list .product-swatches-wrapper {
    align-items: flex-start;
    min-height: auto;
    max-width: 100%;
    width: 100%;
}

.shop-products-grid-widget .shop-products-grid.view-list .swatches-list {
    justify-content: flex-start;
    flex-wrap: wrap;
}

.shop-products-grid-widget .shop-products-grid.view-list .customize-button {
    width: auto;
    white-space: nowrap;
    align-self: flex-start;
}

/* List view responsive — retour en vertical sur mobile */
@media (max-width: 600px) {
    .shop-products-grid-widget .shop-products-grid.view-list .product-card {
        display: flex;
        flex-direction: column;
    }

    .shop-products-grid-widget .shop-products-grid.view-list .product-image {
        width: 100%;
        height: 200px;
    }

    .shop-products-grid-widget .shop-products-grid.view-list .product-content {
        padding: 15px;
    }

    .shop-products-grid-widget .shop-products-grid.view-list .product-bottom-section {
        align-items: center;
        padding: 5px 15px 15px 15px;
    }

    .shop-products-grid-widget .shop-products-grid.view-list .product-price {
        justify-content: center;
    }

    .shop-products-grid-widget .shop-products-grid.view-list .swatches-list {
        justify-content: center;
    }

    .shop-products-grid-widget .shop-products-grid.view-list .customize-button {
        width: 100%;
        align-self: center;
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .shop-products-grid-widget .shop-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
}

@media (max-width: 768px) {
    
    .shop-products-grid-widget .product-title {
        font-size: 15px;
    }
    
    .shop-products-grid-widget .color-swatch {
        width: 18px;
        height: 18px;
    }
    
    .shop-products-grid-widget .shop-pagination .page-numbers {
        padding: 6px 10px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .shop-products-grid-widget .shop-toolbar {
        padding: 10px 0;
        margin-bottom: 15px;
    }
    
    .shop-products-grid-widget .customize-button {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* Loading States */
.shop-products-grid-widget .shop-products-grid.loading {
    opacity: 0.6;
    pointer-events: none;
}

.shop-products-grid-widget .shop-products-grid.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translate(-50%, -50%);
    z-index: 10;
}

/* Filter Integration */
.shop-products-grid-widget.filtered .product-card {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.shop-products-grid-widget.filtered .product-card.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

/* Accessibility */
.shop-products-grid-widget .customize-button:focus,
.shop-products-grid-widget select:focus,
.shop-products-grid-widget .page-numbers:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .shop-products-grid-widget .shop-toolbar,
    .shop-products-grid-widget .shop-pagination,
    .shop-products-grid-widget .infinite-scroll-trigger,
    .shop-products-grid-widget .customize-button {
        display: none !important;
    }
    
    .shop-products-grid-widget .shop-products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    .shop-products-grid-widget .product-card {
        break-inside: avoid;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
    }
}
