/* Liste des produits : une ligne par référence (Figma 438:15359), prix et stock par product-list.js */
.product-list__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px 24px;
    margin: 0;
    padding: 16px;
    border: 1px solid var(--color-grey-light);
    border-radius: 4px;
    background: var(--color-white);

    [data-variant-stock] {
        color: var(--color-grey);
    }

    &[data-state="in_stock"] [data-variant-stock] {
        color: var(--color-success);
    }

    &[data-state="unavailable"] [data-variant-stock] {
        color: var(--color-error);
    }

    &[hidden] {
        display: none;
    }

    .cart-inline-error {
        flex-basis: 100%;
    }
}

/* Colonnes de largeur fixe : stock et commande restent alignés d'une ligne à l'autre, quel que soit le texte */
.product-list__offer {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 220px;
}

.product-list__order {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    width: 280px;
}

@media (max-width: 639px) {
    .product-list__offer,
    .product-list__order {
        width: 100%;
    }
}

/* Tri : sélecteur sans cadre natif, le cadre est celui du libellé */
.product-list__sort {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0 12px 0 16px;
    border: 1px solid var(--color-grey-light);
    border-radius: 4px;
    background: var(--color-white);
    color: var(--color-blue);
    font-size: 14px;
    line-height: 20px;
    font-weight: 500;

    &:focus-within {
        border-color: var(--color-blue);
    }

    select {
        height: 40px;
        padding: 0 20px 0 0;
        border: 0;
        outline: none;
        appearance: none;
        background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2302469A' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right center;
        color: inherit;
        font: inherit;
        cursor: pointer;
    }
}

/* Filtres repliables (product-list.js ajoute data-collapsible) sous 1024 px */
.product-list__filters-toggle {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--color-anthracite);
    font-size: 18px;
    line-height: 26px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;

    svg {
        flex-shrink: 0;
        transition: transform 0.2s;
    }

    [aria-expanded="true"] > & svg,
    &[aria-expanded="true"] svg {
        transform: rotate(180deg);
    }
}

@media (max-width: 1023px) {
    #idalu-product-filters[data-collapsible] {
        gap: 0;
        padding-block: 8px;

        .product-list__filters-toggle {
            display: flex;
        }

        [data-filters-title] {
            display: none;
        }

        &:not([data-open]) [data-filters-panel] {
            display: none;
        }

        &[data-open] [data-filters-panel] {
            padding-block: 8px 16px;
        }
    }

    /* Cases à cocher et liens du formulaire : cibles tactiles confortables */
    #idalu-product-filters label:has(input[type="checkbox"]) {
        min-height: 40px;
    }

    #idalu-product-filters input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }
}

/* Tablette et petit desktop : image, nom et stock sur une ligne, quantité et bouton dessous (le tableau tient dans la colonne) */
@media (min-width: 640px) and (max-width: 1279px) {
    .product-list__row {
        display: grid;
        grid-template-columns: 88px minmax(0, 1fr) 200px;
        column-gap: 20px;

        > :first-child {
            grid-row: span 2;
            align-self: start;
        }

        .product-list__offer {
            width: auto;
        }

        .product-list__order {
            grid-column: 2 / -1;
            width: auto;
        }

        .cart-inline-error {
            grid-column: 2 / -1;
        }
    }
}

/* Mobile : vignette réduite à côté du nom, stock puis quantité et bouton côte à côte */
@media (max-width: 639px) {
    .product-list__row {
        gap: 12px 12px;
        padding: 12px;

        > :first-child {
            width: 56px;
            height: 56px;
        }

        > .min-w-0 {
            flex-basis: calc(100% - 68px);
        }

        .product-list__order {
            flex-wrap: nowrap;
            align-items: flex-end;

            > label {
                flex: 1 1 auto;
            }

            .cart-line__qty {
                width: 100%;
                max-width: 140px;
                height: 44px;

                input {
                    height: 100%;
                }
            }

            [data-variant-add] {
                min-height: 44px;
                flex: 1 1 auto;
            }
        }
    }

    .product-list__sort {
        width: 100%;
        justify-content: space-between;
    }
}

/* Filtres d'attributs : bornes min / max côte à côte dans 208 px, sans les flèches du champ numérique qui rogneraient la valeur */
[data-attribute-range] input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;

    &::-webkit-inner-spin-button,
    &::-webkit-outer-spin-button {
        appearance: none;
        margin: 0;
    }
}
