/* MPE Product Filters - CSS Complet v1.7.4 */
/* Les couleurs peuvent être surchargées dans le thème enfant */

/* ============================================
   VARIABLES PAR DÉFAUT
   ============================================ */

:root {
    --mpe-primary: #FF6B35;
    --mpe-primary-light: #FF8A50;
    --mpe-secondary: #FF4081;
    --mpe-dark: #2C2C2C;
    --mpe-grey: #757575;
    --mpe-light-grey: #F5F5F5;
    --mpe-white: #ffffff;
    --mpe-border: #eeeeee;
    --mpe-shadow: rgba(0, 0, 0, 0.1);
    --mpe-shadow-hover: rgba(0, 0, 0, 0.15);
}

/* ============================================
   STRUCTURE DE BASE
   ============================================ */

.mpe-filters {
    margin-bottom: 20px;
}

/* ============================================
   MODE SIDEBAR - Structure
   ============================================ */

.mpe-filter .mpe-filters {
    margin-bottom: 0;
}

.mpe-filter .mpe-filters-toggle {
    display: none;
}

.mpe-filter .mpe-filters-overlay {
    display: none;
}

.mpe-filter .mpe-filters-panel {
    position: static;
    width: 100%;
    max-width: none;
    height: auto;
    display: flex;
    flex-direction: column;
    background: transparent;
    box-shadow: none;
}

.mpe-filter .mpe-filters-close {
    display: none;
}

.mpe-filter .mpe-filters-header {
    background: transparent;
    border: none;
    padding: 0 0 15px 0;
}

.mpe-filter .mpe-filters-content {
    padding: 0;
}

.mpe-filter .mpe-filters-actions {
    background: transparent;
    border: none;
    padding: 15px 0 0 0;
}

/* ============================================
   PANEL SLIDE-IN (Mobile)
   ============================================ */

.mpe-filters-panel {
    position: fixed;
    top: 0;
    left: -100%;
    width: 320px;
    max-width: 90vw;
    height: 100vh;
    z-index: 9999;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
    background: var(--mpe-white);
    box-shadow: 5px 0 25px var(--mpe-shadow-hover);
}

.mpe-filters-panel.active {
    left: 0;
}

/* Overlay */
.mpe-filters-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    background: rgba(0, 0, 0, 0.5);
}

.mpe-filters-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Header */
.mpe-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--mpe-light-grey);
    border-bottom: 1px solid var(--mpe-border);
}

.mpe-filters-title,
.mpe-filters-header h3 {
    font-size: 18px !important;
    font-weight: 700 !important;
    color: var(--mpe-dark) !important;
    margin: 0 !important;
}

.mpe-filters-close {
    width: 32px !important;
    height: 32px !important;
    background: var(--mpe-white) !important;
    border: none !important;
    border-radius: 50% !important;
    font-size: 20px !important;
    color: var(--mpe-grey) !important;
    cursor: pointer !important;
    box-shadow: 0 2px 8px var(--mpe-shadow) !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    padding: 0 !important;
}

.mpe-filters-close:hover {
    background: var(--mpe-primary) !important;
    color: var(--mpe-white) !important;
}

/* Contenu */
.mpe-filters-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Groupes de filtres */
.mpe-filter-group {
    background: var(--mpe-light-grey) !important;
    border-radius: 12px !important;
    padding: 15px !important;
    margin-bottom: 15px !important;
}

.mpe-filter-group-title,
.mpe-filter-group h4 {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: var(--mpe-dark) !important;
    margin: 0 0 12px 0 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

/* Liste des filtres */
.mpe-filter-list {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 5px;
}

.mpe-filter-list::-webkit-scrollbar {
    width: 4px;
}

.mpe-filter-list::-webkit-scrollbar-track {
    background: var(--mpe-border);
    border-radius: 2px;
}

.mpe-filter-list::-webkit-scrollbar-thumb {
    background: var(--mpe-primary);
    border-radius: 2px;
}

/* Checkbox - Structure */
.mpe-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px 0;
    gap: 10px;
}

.mpe-checkbox:hover .mpe-checkbox-mark {
    border-color: var(--mpe-primary);
}

.mpe-checkbox input[type="checkbox"] {
    display: none;
}

.mpe-checkbox-mark {
    width: 20px !important;
    height: 20px !important;
    border: 2px solid #ddd !important;
    border-radius: 4px !important;
    background: var(--mpe-white) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    transition: all 0.2s ease !important;
}

.mpe-checkbox-mark::after {
    content: '✓' !important;
    color: var(--mpe-white) !important;
    font-size: 12px !important;
    font-weight: bold !important;
    opacity: 0;
    transform: scale(0);
    transition: all 0.2s ease !important;
}

.mpe-checkbox input[type="checkbox"]:checked + .mpe-checkbox-mark {
    background: var(--mpe-primary) !important;
    border-color: var(--mpe-primary) !important;
}

.mpe-checkbox input[type="checkbox"]:checked + .mpe-checkbox-mark::after {
    opacity: 1 !important;
    transform: scale(1) !important;
}

.mpe-checkbox-label {
    flex: 1;
    font-size: 14px;
    color: var(--mpe-dark);
}

.mpe-checkbox-count {
    font-size: 12px;
    color: var(--mpe-grey);
    margin-left: 5px;
}

/* Slider de prix noUiSlider */
#mpe-price-slider,
.mpe-price-slider {
    margin: 20px 10px 30px;
}

#mpe-price-slider.noUi-target,
.mpe-price-slider .noUi-target {
    background: var(--mpe-border) !important;
    border: none !important;
    border-radius: 5px !important;
    box-shadow: none !important;
    height: 8px !important;
}

#mpe-price-slider .noUi-connect,
.mpe-price-slider .noUi-connect {
    background: linear-gradient(90deg, var(--mpe-primary), var(--mpe-secondary)) !important;
    border-radius: 5px !important;
}

#mpe-price-slider .noUi-handle,
.mpe-price-slider .noUi-handle {
    width: 22px !important;
    height: 22px !important;
    border-radius: 50% !important;
    background: var(--mpe-white) !important;
    border: 3px solid var(--mpe-primary) !important;
    box-shadow: 0 2px 8px var(--mpe-shadow-hover) !important;
    cursor: pointer !important;
    top: -7px !important;
    right: -11px !important;
}

#mpe-price-slider .noUi-handle::before,
#mpe-price-slider .noUi-handle::after,
.mpe-price-slider .noUi-handle::before,
.mpe-price-slider .noUi-handle::after {
    display: none !important;
}

#mpe-price-slider .noUi-handle:focus,
.mpe-price-slider .noUi-handle:focus {
    outline: none !important;
}

.mpe-price-values {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    font-size: 14px;
    font-weight: 600;
    color: var(--mpe-dark);
}

/* Boutons */
.mpe-filters-actions {
    display: flex !important;
    padding: 15px 20px !important;
    gap: 10px !important;
    background: var(--mpe-light-grey) !important;
    border-top: 1px solid var(--mpe-border) !important;
}

.mpe-btn,
button.mpe-btn {
    cursor: pointer !important;
    border: none !important;
    padding: 12px 20px !important;
    border-radius: 50px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    transition: all 0.3s ease !important;
}

.mpe-btn-reset,
.mpe-btn-secondary,
button.mpe-btn-reset,
button.mpe-btn-secondary,
#mpe-filter-reset {
    background: var(--mpe-white) !important;
    color: var(--mpe-grey) !important;
    border: 2px solid #ddd !important;
    flex: 1 !important;
}

.mpe-btn-reset:hover,
.mpe-btn-secondary:hover,
button.mpe-btn-reset:hover,
button.mpe-btn-secondary:hover,
#mpe-filter-reset:hover {
    border-color: var(--mpe-primary) !important;
    color: var(--mpe-primary) !important;
}

.mpe-btn-apply,
.mpe-btn-primary,
button.mpe-btn-apply,
button.mpe-btn-primary,
#mpe-filter-apply {
    background: linear-gradient(135deg, var(--mpe-primary) 0%, var(--mpe-primary-light) 100%) !important;
    color: var(--mpe-white) !important;
    flex: 2 !important;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3) !important;
}

.mpe-btn-apply:hover,
.mpe-btn-primary:hover,
button.mpe-btn-apply:hover,
button.mpe-btn-primary:hover,
#mpe-filter-apply:hover {
    background: linear-gradient(135deg, var(--mpe-primary-light) 0%, var(--mpe-primary) 100%) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4) !important;
}

/* Bouton toggle mobile */
.mpe-filters-toggle {
    display: block;
    background: linear-gradient(135deg, var(--mpe-primary) 0%, var(--mpe-primary-light) 100%);
    color: var(--mpe-white);
    border: none;
    border-radius: 50px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.mpe-filters-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4);
}

/* ============================================
   ÉTATS DE CHARGEMENT
   ============================================ */

#mpe-products-container.loading,
.mpe-products-container.loading,
.products-grid.is-loading {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

#mpe-products-container.loading::after,
.mpe-products-container.loading::after,
.products-grid.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid var(--mpe-light-grey);
    border-top-color: var(--mpe-primary);
    border-radius: 50%;
    animation: mpe-spin 0.8s linear infinite;
}

@keyframes mpe-spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   GRILLES PRODUITS - Structure
   ============================================ */

#mpe-products-container ul.products,
.mpe-products-container ul.products,
.products-grid ul.products {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    list-style: none;
    clear: both;
    margin: 0;
    padding: 0;
}

#mpe-products-container ul.products::before,
#mpe-products-container ul.products::after,
.mpe-products-container ul.products::before,
.mpe-products-container ul.products::after,
.products-grid ul.products::before,
.products-grid ul.products::after {
    display: none;
    content: none;
}

#mpe-products-container ul.products li.product,
.mpe-products-container ul.products li.product,
.products-grid ul.products li.product {
    float: none;
    clear: none;
    margin: 0;
    width: 100%;
    max-width: 100%;
}

/* ============================================
   CARROUSEL - Compatible Divi et nouveau thème
   ============================================ */

.products-carousel,
.mpe-bestsellers-carousel {
    padding: 30px 0;
}

.products-carousel__title {
    font-size: 24px;
    font-weight: 700;
    color: var(--mpe-dark);
    text-align: center;
    margin-bottom: 25px;
}

.products-carousel__swiper,
.mpe-products-swiper {
    padding-bottom: 50px;
}

.products-carousel__swiper .swiper-wrapper,
.mpe-products-swiper .swiper-wrapper {
    align-items: stretch;
}

.products-carousel__swiper .swiper-slide,
.mpe-products-swiper .swiper-slide {
    height: auto;
}

.product-card,
.mpe-product-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--mpe-white);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 15px var(--mpe-shadow);
    transition: all 0.3s ease;
}

.product-card:hover,
.mpe-product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px var(--mpe-shadow-hover);
}

.product-card__link,
.mpe-product-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-card__image,
.mpe-product-image {
    position: relative;
    overflow: hidden;
}

.product-card__image img,
.mpe-product-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.product-card:hover .product-card__image img,
.mpe-product-card:hover .mpe-product-image img {
    transform: scale(1.03);
}

.badge--sale,
.mpe-badge-sale {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    background: var(--mpe-secondary);
    color: var(--mpe-white);
    padding: 5px 12px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 700;
}

.product-card__info,
.mpe-product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 15px;
}

.product-card__title,
.mpe-product-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    color: var(--mpe-dark);
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.product-card__price,
.mpe-product-price {
    margin-top: auto;
    font-size: 18px;
    font-weight: 700;
    color: var(--mpe-primary);
}

.product-card__price del,
.mpe-product-price del {
    color: var(--mpe-grey);
    font-size: 14px;
    margin-right: 8px;
}

.product-card__price ins,
.mpe-product-price ins {
    text-decoration: none;
    color: var(--mpe-secondary);
}

.product-card__actions,
.mpe-product-actions {
    padding: 0 15px 15px;
}

.product-card__actions .button,
.product-card__actions .add_to_cart_button,
.mpe-product-actions .button,
.mpe-product-actions .add_to_cart_button {
    display: block;
    background: linear-gradient(135deg, var(--mpe-primary) 0%, var(--mpe-primary-light) 100%);
    color: var(--mpe-white);
    border: none;
    border-radius: 50px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    width: 100%;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
    transition: all 0.3s ease;
    line-height: 1.4;
}

.product-card__actions .button:hover,
.product-card__actions .add_to_cart_button:hover,
.mpe-product-actions .button:hover,
.mpe-product-actions .add_to_cart_button:hover {
    background: linear-gradient(135deg, var(--mpe-primary-light) 0%, var(--mpe-primary) 100%);
}

/* Swiper pagination */
.products-carousel__swiper .swiper-pagination,
.mpe-products-swiper .swiper-pagination {
    position: relative;
    margin-top: 20px;
    bottom: 0;
}

.products-carousel__swiper .swiper-pagination-bullet,
.mpe-products-swiper .swiper-pagination-bullet {
    width: 10px;
    height: 10px;
    background: #ddd;
    opacity: 1;
    transition: all 0.3s ease;
}

.products-carousel__swiper .swiper-pagination-bullet-active,
.mpe-products-swiper .swiper-pagination-bullet-active {
    background: var(--mpe-primary);
    transform: scale(1.2);
}

/* Swiper navigation */
.products-carousel__swiper .swiper-button-prev,
.products-carousel__swiper .swiper-button-next,
.mpe-products-swiper .swiper-button-prev,
.mpe-products-swiper .swiper-button-next {
    color: var(--mpe-primary);
    background: var(--mpe-white);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    box-shadow: 0 2px 10px var(--mpe-shadow);
}

.products-carousel__swiper .swiper-button-prev::after,
.products-carousel__swiper .swiper-button-next::after,
.mpe-products-swiper .swiper-button-prev::after,
.mpe-products-swiper .swiper-button-next::after {
    font-size: 16px;
    font-weight: bold;
}

@media (max-width: 768px) {
    .products-carousel__swiper .swiper-button-prev,
    .products-carousel__swiper .swiper-button-next,
    .mpe-products-swiper .swiper-button-prev,
    .mpe-products-swiper .swiper-button-next {
        display: none;
    }
}

/* Carrousel vide */
.mpe-carousel-empty {
    text-align: center;
    padding: 30px;
    color: var(--mpe-grey);
    font-size: 14px;
    background: var(--mpe-light-grey);
    border-radius: 12px;
    margin: 20px 0;
}

/* ============================================
   TRI - Structure
   ============================================ */

.woocommerce-ordering {
    position: relative;
}

.woocommerce-ordering.mpe-styled select.mpe-hidden {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.mpe-sorting-wrapper {
    display: inline-block;
}

.mpe-sorting-custom {
    position: relative;
}

.mpe-sorting-selected {
    display: flex !important;
    align-items: center !important;
    cursor: pointer !important;
    background: var(--mpe-white) !important;
    border: 2px solid var(--mpe-border) !important;
    border-radius: 50px !important;
    padding: 10px 20px !important;
    min-width: 220px !important;
    white-space: nowrap !important;
    transition: all 0.3s ease !important;
}

.mpe-sorting-selected:hover {
    border-color: var(--mpe-primary) !important;
}

.mpe-sorting-value {
    flex: 1 !important;
    font-size: 14px !important;
    color: var(--mpe-dark) !important;
}

.mpe-sorting-arrow {
    color: var(--mpe-primary) !important;
    font-size: 10px !important;
    margin-left: 8px !important;
    transition: transform 0.3s ease !important;
}

.mpe-sorting-arrow svg {
    width: 10px !important;
    height: 10px !important;
}

.mpe-sorting-custom.open .mpe-sorting-arrow {
    transform: rotate(180deg);
}

.mpe-sorting-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 100;
    background: var(--mpe-white);
    border: 1px solid var(--mpe-border);
    border-radius: 12px;
    box-shadow: 0 5px 20px var(--mpe-shadow);
    margin-top: 5px;
    overflow: hidden;
}

.mpe-sorting-custom.open .mpe-sorting-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.mpe-sorting-option {
    cursor: pointer;
    padding: 12px 20px;
    font-size: 14px;
    color: var(--mpe-dark);
    transition: all 0.2s ease;
}

.mpe-sorting-option:hover {
    background: var(--mpe-light-grey);
    color: var(--mpe-primary);
}

.mpe-sorting-option.active {
    background: var(--mpe-primary);
    color: var(--mpe-white);
}

/* ============================================
   SCROLL INFINI - Structure
   ============================================ */

.woocommerce-pagination {
    display: none !important;
}

.mpe-loading-more {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    gap: 10px;
    color: var(--mpe-grey);
    font-size: 14px;
}

.mpe-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--mpe-light-grey);
    border-top-color: var(--mpe-primary);
    border-radius: 50%;
    animation: mpe-spin 0.8s linear infinite;
}

/* ============================================
   RESPONSIVE - Comportements
   ============================================ */

@media (min-width: 992px) {
    .mpe-filters-panel {
        position: static;
        width: 100%;
        max-width: none;
        height: auto;
        display: block !important;
        box-shadow: none;
        background: transparent;
    }

    .mpe-filters-panel.active {
        left: auto;
    }

    .mpe-filters-header {
        display: none;
    }

    .mpe-filters-content {
        display: flex;
        flex-wrap: wrap;
        padding: 0;
        gap: 15px;
    }

    .mpe-filter-group {
        flex: 1;
        min-width: 200px;
        margin-bottom: 0;
    }

    .mpe-filters-overlay {
        display: none;
    }

    .mpe-filters-toggle {
        display: none;
    }

    .mpe-filters-actions {
        width: 100%;
        background: transparent;
        border: none;
        padding: 15px 0 0 0;
        justify-content: flex-start;
    }

    .mpe-btn-reset,
    .mpe-btn-apply {
        flex: 0 0 auto;
        min-width: 120px;
    }

    /* Override sidebar */
    .mpe-filter .mpe-filters-header {
        display: flex;
    }

    .mpe-filter .mpe-filters-content {
        display: block;
        padding: 0;
    }

    .mpe-filter .mpe-filter-group {
        margin-bottom: 15px;
    }
}

@media (max-width: 1200px) {
    #mpe-products-container ul.products,
    .mpe-products-container ul.products,
    .products-grid ul.products {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 991px) {
    .mpe-filters-panel {
        display: none;
    }

    .mpe-filters-panel.active {
        display: flex;
    }

    .mpe-filter .mpe-filters-panel {
        display: flex;
    }

    .mpe-filter .mpe-filters-toggle {
        display: none;
    }
}

@media (max-width: 768px) {
    #mpe-products-container ul.products,
    .mpe-products-container ul.products,
    .products-grid ul.products {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
}

@media (max-width: 480px) {
    #mpe-products-container ul.products,
    .mpe-products-container ul.products,
    .products-grid ul.products {
        grid-template-columns: 1fr;
    }

    .mpe-sorting-selected {
        min-width: 100%;
    }
}
