/* ================================================================
   Filtre Modèle Aspirateur — filter.css
   ================================================================ */

/* ── Variables (personnalisables) ── */
:root {
    --fma-primary:        #2563eb;
    --fma-primary-hover:  #1d4ed8;
    --fma-border:         #e2e8f0;
    --fma-border-focus:   #2563eb;
    --fma-bg:             #ffffff;
    --fma-bg-hover:       #f1f5f9;
    --fma-text:           #1e293b;
    --fma-text-muted:     #64748b;
    --fma-shadow:         0 4px 24px rgba(0,0,0,.10);
    --fma-radius:         10px;
    --fma-radius-sm:      6px;
}

/* ── Wrapper global ── */
.fma-wrapper {
    margin-bottom: 2rem;
    font-family: inherit;
}

/* ── Label ── */
.fma-label {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-size: .875rem;
    font-weight: 600;
    color: var(--fma-text);
    margin-bottom: .5rem;
}

.fma-label svg {
    color: var(--fma-primary);
    flex-shrink: 0;
}

/* ── Champ de recherche ── */
.fma-search-box {
    position: relative;
    max-width: 480px;
}

.fma-input-wrap {
    position: relative;
}

.fma-input {
    width: 100%;
    padding: .75rem 2.5rem .75rem 1rem;
    border: 2px solid var(--fma-border);
    border-radius: var(--fma-radius);
    font-size: 1rem;
    color: var(--fma-text);
    background: var(--fma-bg);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
}

.fma-input:focus {
    border-color: var(--fma-border-focus);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* Bouton effacer */
.fma-clear {
    position: absolute;
    right: .65rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--fma-text-muted);
    display: flex;
    align-items: center;
    padding: .25rem;
    border-radius: 50%;
    transition: color .2s, background .2s;
}

.fma-clear:hover {
    color: var(--fma-text);
    background: var(--fma-bg-hover);
}

/* ── Dropdown suggestions ── */
.fma-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--fma-bg);
    border: 1px solid var(--fma-border);
    border-radius: var(--fma-radius);
    box-shadow: var(--fma-shadow);
    list-style: none;
    margin: 0;
    padding: .35rem 0;
    z-index: 9999;
    max-height: 320px;
    overflow-y: auto;
}

.fma-results li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem 1rem;
    cursor: pointer;
    transition: background .15s;
    gap: 1rem;
}

.fma-results li:hover,
.fma-results li[aria-selected="true"] {
    background: var(--fma-bg-hover);
}

.fma-suggestion-name {
    font-size: .9375rem;
    color: var(--fma-text);
    font-weight: 500;
}

.fma-suggestion-count {
    font-size: .8rem;
    color: var(--fma-text-muted);
    white-space: nowrap;
    background: var(--fma-border);
    padding: .15rem .5rem;
    border-radius: 999px;
}

.fma-no-result {
    padding: .75rem 1rem;
    color: var(--fma-text-muted);
    font-size: .9rem;
    cursor: default;
}

/* ── Barre filtre actif ── */
.fma-active-filter {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    margin-top: .75rem;
    padding: .6rem 1rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--fma-radius-sm);
    font-size: .9rem;
}

.fma-active-label {
    color: var(--fma-text-muted);
}

.fma-active-name {
    font-weight: 700;
    color: var(--fma-primary);
}

.fma-reset-btn {
    margin-left: auto;
    background: none;
    border: 1px solid var(--fma-primary);
    color: var(--fma-primary);
    border-radius: var(--fma-radius-sm);
    padding: .3rem .85rem;
    font-size: .85rem;
    cursor: pointer;
    transition: background .2s, color .2s;
}

.fma-reset-btn:hover {
    background: var(--fma-primary);
    color: #fff;
}

/* ── Grille produits ── */
.fma-products-inner {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.fma-total {
    font-size: .9rem;
    color: var(--fma-text-muted);
    margin-bottom: .25rem;
}

/* ── Carte produit ── */
.fma-product-card {
    background: var(--fma-bg);
    border: 1px solid var(--fma-border);
    border-radius: var(--fma-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow .2s, transform .2s;
}

.fma-product-card:hover {
    box-shadow: var(--fma-shadow);
    transform: translateY(-2px);
}

.fma-product-link {
    text-decoration: none;
    color: inherit;
    flex: 1;
}

.fma-product-img-wrap {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    background: #f8fafc;
}

.fma-product-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: .5rem;
    transition: transform .3s;
}

.fma-product-card:hover .fma-product-img-wrap img {
    transform: scale(1.04);
}

.fma-badge-out {
    position: absolute;
    top: .5rem;
    left: .5rem;
    background: #ef4444;
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    padding: .2rem .5rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.fma-product-info {
    padding: .85rem;
}

.fma-product-name {
    font-size: .9375rem;
    font-weight: 600;
    margin: 0 0 .25rem;
    line-height: 1.35;
    color: var(--fma-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.fma-product-sku {
    font-size: .78rem;
    color: var(--fma-text-muted);
    margin: 0 0 .4rem;
}

.fma-product-price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--fma-primary);
}

.fma-product-price .woocommerce-Price-amount {
    color: var(--fma-primary);
}

/* Bouton voir le produit */
.fma-add-btn {
    display: block;
    text-align: center;
    padding: .6rem;
    background: var(--fma-primary);
    color: #fff;
    font-size: .875rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .2s;
}

.fma-add-btn:hover {
    background: var(--fma-primary-hover);
    color: #fff;
}

.fma-add-btn--disabled {
    background: #94a3b8;
    pointer-events: none;
}

/* ── État vide ── */
.fma-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--fma-text-muted);
}

.fma-empty svg {
    margin-bottom: 1rem;
    opacity: .35;
}

.fma-empty p {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.fma-btn-secondary {
    background: none;
    border: 1px solid var(--fma-border);
    border-radius: var(--fma-radius-sm);
    padding: .5rem 1.25rem;
    cursor: pointer;
    font-size: .9rem;
    transition: border-color .2s;
}

.fma-btn-secondary:hover {
    border-color: var(--fma-primary);
    color: var(--fma-primary);
}

/* ── Erreur ── */
.fma-error {
    padding: 1.5rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--fma-radius-sm);
    color: #dc2626;
    font-size: .9rem;
}

/* ── Spinner chargement ── */
.fma-spinner {
    display: flex;
    justify-content: center;
    padding: 3rem;
}

.fma-spinner span {
    width: 40px;
    height: 40px;
    border: 3px solid var(--fma-border);
    border-top-color: var(--fma-primary);
    border-radius: 50%;
    animation: fma-spin .7s linear infinite;
}

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

/* ── Pagination ── */
.fma-pages {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: .4rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.fma-page-btn {
    min-width: 38px;
    height: 38px;
    padding: 0 .6rem;
    border: 1px solid var(--fma-border);
    border-radius: var(--fma-radius-sm);
    background: var(--fma-bg);
    cursor: pointer;
    font-size: .875rem;
    color: var(--fma-text);
    transition: border-color .2s, background .2s, color .2s;
}

.fma-page-btn:hover {
    border-color: var(--fma-primary);
    color: var(--fma-primary);
}

.fma-page-btn--active {
    background: var(--fma-primary);
    border-color: var(--fma-primary);
    color: #fff;
    font-weight: 700;
    pointer-events: none;
}

.fma-page-ellipsis {
    color: var(--fma-text-muted);
    padding: 0 .25rem;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .fma-search-box {
        max-width: 100%;
    }

    .fma-products-inner {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }

    .fma-active-filter {
        font-size: .82rem;
    }

    .fma-reset-btn {
        margin-left: 0;
        width: 100%;
        text-align: center;
    }
}
