:root{
    --gap: 20px;
    --radius: 16px;
    --border: #eceef3;
    --text: #111;
    --muted: #6b7280;
    --bg: #fff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 8px 18px rgba(0,0,0,.10);
    --primary: var(--primary-yellow, #ffe799);
    --focus: rgba(255,214,77,.45);
}

body {
    background: var(--main-background);
}

/* ===================== Layout ===================== */
.page-search .main-container { max-width: none; }

.page-search .search-layout { margin: 0 auto; }

/* centre proprement 4 cartes par ligne dans l'espace dispo */
.page-search .product-grid {
    max-width: 1600px;      /* ~ 4 cartes + 3 espaces */
    margin-inline: auto;    /* centre */
    justify-content: center;
}

.search-layout{
    /*width: min(1600px, 100%);*/
    margin-left: 0;          /* colle la grille au bord gauche */
    margin-right: auto;
    padding: 16px;
    display: grid;
    grid-template-columns: 320px 1fr;  /* sidebar + contenu */
    gap: 24px;
}

@media (max-width: 900px){
    .search-layout{
        grid-template-columns: 1fr;      /* sidebar au-dessus sur mobile */
    }
}

/* ===================== Sidebar / Filtres ===================== */
.search-filters{
    margin: 50px 0 0 50px;
    position: sticky;
    top: 84px;
    align-self: start;
}

@media (max-width: 900px){
    .search-filters{ position: static; }
}

.filters-form{
    display: grid;
    gap: 12px;
}

.filter-box{
    padding: 20px 54px 20px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    box-shadow: var(--shadow-sm);
}

.filter-title{
    font-weight: 800;
    margin-bottom: 8px;
}

.facet-list{ display: grid; gap: 4px; }

.facet-item{
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.facet-input{
    width: 16px;
    height: 16px;
}

.facet-label{ color: var(--text); }
.facet-count{ color: var(--muted); }

/* ======= UI Controls ======= */
.ui-select,
.filters-form input[type="search"],
.filters-form input[type="text"]{
    width: 100%;
    height: 42px;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid #cfd8dc;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
    font: inherit;
}

.ui-select:focus,
.filters-form input:focus{
    outline: none;
    border-color: #9aa9b5;
    box-shadow: 0 0 0 3px rgba(154,169,181,.2);
}

/* ===================== Résultats ===================== */
.results-area{
    /*width: 100%;*/
    display: flex;
    flex-direction: column;
    align-items: center;
}

.results-header{ align-items: baseline; }

.results-count{
    display: inline-flex;
    align-items: baseline;
    background: var(--primary);
    gap: 8px;
    color: #111;
    border-radius: 12px;
    font-size: 15px;
    margin-bottom: 10px;
    padding: 4px 20px;

}

.results-count strong{
    font-size: clamp(22px, 2.2vw, 32px);
    line-height: 1;
    box-shadow: var(--shadow-sm);
}

/* ===================== Grille Produits ===================== */
.product-grid{
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap);
    justify-content: center;
    margin-inline: auto;
    max-width: 1320px;
}


/* Les styles de .product-card sont définis plus bas dans la section "Harmonisation cartes" */

.product-link{
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    text-decoration: none;
    color: var(--text);
}

/* Image : ratio fixe + fallback propre */
.product-image{
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    background: #f5f6f9;
    border-radius: 12px;
}

/* Classe ajoutée si on force le placeholder via onerror */
.product-image.is-placeholder{ opacity: .9; }

.product-name{
    font-weight: 800;
    font-size: 16px;
    line-height: 1.25;
}

.product-price{
    font-weight: 700;
}

/* ===================== Accessibilité Focus ===================== */
*:focus-visible{
    outline: none;
    box-shadow:
            0 0 0 3px rgba(0,0,0,.08),
            0 0 0 6px var(--focus);
    border-radius: 12px;
}

/* ===== Facet tree (catégories hiérarchiques) ===== */
.facet-tree-list{
    list-style: none;
    margin: 0;
    padding-left: 0;
}

.facet-tree-item{
    position: relative;
    padding: 2px 0;
}

.facet-toggle{
    appearance: none;
    border: none;
    background: none;
    cursor: pointer;
    width: 18px;
    height: 18px;
    margin-right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.facet-toggle::before{
    content: '▸'; /* caret fermé */
    font-size: 14px;
    line-height: 1;
    transform-origin: center;
    transition: transform .15s ease;
    color: #777;
}
.facet-tree-item.is-open > .facet-toggle::before{
    transform: rotate(90deg); /* caret ouvert */
}

.facet-toggle--spacer{
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-right: 6px;
}

.facet-checkline{
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.facet-children{
    display: none;
    padding-left: 18px; /* indentation enfants */
    margin-top: 4px;
}
.facet-children.is-open{
    display: block;
}

/* ===== Harmonisation cartes “highlight” dans la grille produits ===== */

/* 4 cartes par ligne, centrées, largeur max "propre" */
.product-grid{
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap);
    justify-content: center;
    max-width: 1600px;
    margin-inline: auto;
}

/* chaque cell conserve une largeur fixe */
.product-card{
    flex: 0 0 360px;      /* largeur fixe de 360px (4 cartes par ligne) */
    width: 360px;
    box-sizing: border-box;
    list-style: none;
}

/* même rendu que le carousel */
.product-card .highlight-card{
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;

    height: 460px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 10px;

    box-shadow: var(--shadow-sm);
    transition: transform .2s ease, box-shadow .2s ease;
}
.product-card .highlight-card:hover{
    transform: translateY(-3px);
    box-shadow: 0 8px 18px rgba(0,0,0,.10);
}

.product-card .highlight-clickable{
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

/* image identique au carousel */
.product-card .highlight-imgwrap{
    width: 100%;
    aspect-ratio: 16/10;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
}
.product-card .highlight-imgwrap img{
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: auto;
    display: block;
}

/* texte/prix */
.product-card .highlight-label{
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    text-align: center;
}
.product-card .highlight-name{
    font-weight: 800;
    font-size: 16px;
    line-height: 1.25;
    min-height: 2.6em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.product-card .highlight-price{
    color: #de3d41;
    font-weight: 600;
}

/* bandeau actions identique au carousel (+ responsive) */
.product-card .highlight-actions{
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 10px;
    padding: 8px;
    background: #fff;
    border-top: 1px solid #eee;
    border-radius: 8px;
}
.product-card .highlight-actions > .qty,
.product-card .highlight-actions > .add-to-cart{
    flex: 1 1 0;
    min-width: 0;
}

/* Responsive: 3 cartes sur tablette large */
@media (max-width: 1500px){
    .product-card{
        flex: 0 0 340px;
        width: 340px;
    }
}

/* Responsive: 2 cartes sur tablette */
@media (max-width: 1100px){
    .product-card{
        flex: 0 0 360px;
        width: 360px;
    }
}

/* Responsive: 2 cartes sur mobile large */
@media (max-width: 900px){
    .product-card{
        flex: 0 0 340px;
        width: 340px;
    }
}

/* Responsive: 1 carte sur mobile */
@media (max-width: 750px){
    .product-card{
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
    }
}