
/* ── Conteneur principal ─────────────────────────────────────── */
.cg-catalogue {
    --cg-gap: 8px;
    --cg-gapm: 4px;
    --cg-card-pad: 8px;
    --cg-img-fit: cover;
    --cg-img-ratio: 1/1;
    --cg-cols-sm: 3;
    --cg-cols-md: 4;
    --cg-cols-lg: 6;
    --cg-cols-xl: 6;
    --cg-header-pl: 16px;
    --cg-header-pr: 16px;
    --cg-header-pt: 10px;
    --cg-header-pb: 10px;
    --cg-margin-top: 16px;
    --cg-margin-bottom: 12px;
    --cg-margin-left: 0px;
    --cg-margin-right: 0px;
    --cg-mobile-cols: 2;

    background: #fff;
    margin: var(--cg-margin-top) var(--cg-margin-right) var(--cg-margin-bottom) var(--cg-margin-left);
    padding: 0;
}

/* ── En-tête section ─────────────────────────────────────────── */
.cg-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--cg-header-pt) var(--cg-header-pr) var(--cg-header-pb) var(--cg-header-pl);
    gap: 12px;
    box-sizing: border-box;
    width: 100%;
    background: #fff;
}

.cg-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2E2F32;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.2;
    flex: 1;
    min-width: 0;
    text-align: left;
    word-break: break-word;
}

.cg-see-all {
    font-size: 0.82rem;
    font-weight: 600;
    color: #0071ce;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
}

/* ── Grille desktop (masquée par défaut) ─────────────────────── */
.cg-grid-desktop {
    display: none;
}

/* ── Grille mobile (affichée par défaut) ─────────────────────── */
.cg-groups-mobile {
    display: block;
}

.cg-grid-mobile {
    display: grid;
    grid-template-columns: repeat(var(--cg-mobile-cols), 1fr);
    gap: var(--cg-gapm);
    padding: 0 var(--cg-gapm);
    background: #fff;
}

.cg-group {
    margin-bottom: var(--cg-gapm);
    background: #fff;
    position: relative; /* nécessaire pour le fondu de scroll en paysage */
}

.cg-group-header {
    padding: 8px var(--cg-header-pl);
    background: #fff;
}

.cg-group-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #2E2F32;
}

/* ── Carte produit ───────────────────────────────────────────── */
.cg-item {
    /* Tous les produits visibles par défaut */
}

.cg-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    text-decoration: none !important;
    color: inherit;
    padding: var(--cg-card-pad);
    border-radius: 4px;
    box-shadow: none !important;
    transition: none !important;
    outline: none !important;
}

.cg-card:hover,
.cg-card:focus,
.cg-card:active,
.cg-card:visited {
    box-shadow: none !important;
    transform: none !important;
    text-decoration: none !important;
    outline: none !important;
}

/* ── Image ───────────────────────────────────────────────────── */
.cg-img-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: var(--cg-img-ratio);
    overflow: hidden;
    border-radius: 2px;
    background: #f5f5f5;
}

.cg-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: var(--cg-img-fit);
    display: block;
}

.cg-img-wrap img.cg-blend {
    mix-blend-mode: multiply;
}

/* ── Infos produit ───────────────────────────────────────────── */
.cg-info {
    padding: 8px 4px 4px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #fff;
}

.cg-name,
.cg-name:hover,
.cg-name:focus,
.cg-name:active,
.cg-name:visited {
    font-size: 0.83rem;
    color: #2E2F32;
    line-height: 1.35;
    margin: 0;
    text-decoration: none !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cg-price,
.cg-price:hover,
.cg-price:focus,
.cg-price:active,
.cg-price:visited {
    font-size: 1rem;
    font-weight: 800;
    color: #2E2F32;
    text-decoration: none !important;
}

/* ── Loader ──────────────────────────────────────────────────── */
.cg-loader {
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: #fff;
}

.cg-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e0e0;
    border-top-color: #0071ce;
    border-radius: 50%;
    animation: cg-spin 0.7s linear infinite;
}

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

/* ── Vide ────────────────────────────────────────────────────── */
.cg-empty {
    text-align: center;
    padding: 40px 16px;
    color: #74767c;
    font-size: 0.9rem;
    background: #fff;
}

/* ═══════════════════════════════════════════════════════════════

/* ── Très petit mobile (≤ 400px) ─────────────────────────────── */
@media (max-width: 400px) {

    .cg-name {
        font-size: 0.75rem;
    }

    .cg-price {
        font-size: 0.8rem;
        font-weight: 800;
        color: #2E2F32;
    }
}

/* ── Mobile portrait (≤ 575px) : grille 2 colonnes ───────────── */
@media (max-width: 575px) {
    .cg-grid-desktop {
        display: none !important;
    }

    .cg-groups-mobile {
        display: block !important;
    }

    .cg-grid-mobile {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--cg-gapm);
        padding: 0 var(--cg-gapm);
    }

    /* Tous les produits visibles */
    .cg-grid-mobile .cg-item {
        display: block !important;
    }

    .cg-section-header {
        padding: 4px 6px;
    }

    .cg-section-title {
        font-size: 1.1rem;
        font-weight: 700;
        color: #2E2F32;
    }

    .cg-see-all {
        font-size: 0.75rem;
    }

    .cg-info {
        padding: 6px 2px 2px;
    }

    .cg-name {
        font-size: 0.75rem;
    }

    .cg-price {
        font-size: 1rem;
        font-weight: 700;
        color: #2E2F32;
    }
}

/* ── Mobile paysage (576px - 767px) : scroll horizontal ──────── *
 * ───────────────────────────────────────────────────────────── */
@media (min-width: 576px) and (max-width: 767px) {
    .cg-grid-desktop {
        display: none !important;
    }

    .cg-groups-mobile {
        display: block !important;
    }

    .cg-grid-mobile {
        display: flex !important;
        grid-template-columns: none !important;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        gap: 8px;
        padding: 0 12px 6px;
        scrollbar-width: none;     /* Firefox */
        -ms-overflow-style: none;  /* IE/Edge */
    }

    .cg-grid-mobile::-webkit-scrollbar {
        display: none;             /* Chrome/Safari */
    }

    .cg-grid-mobile .cg-item {
        display: block !important;
        flex: 0 0 calc(25% - 6px); /* 4 produits visibles avec le gap de 8px */
        min-width: 130px;
        scroll-snap-align: start;
    }

    /* Fondu sur le bord droit pour indiquer qu'on peut glisser */
    .cg-group::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 6px;
        width: 28px;
        background: linear-gradient(to right, rgba(255,255,255,0), rgba(255,255,255,0.95));
        pointer-events: none;
    }

    .cg-card {
        padding: 6px;
        border-radius: 0;
    }

    .cg-info {
        padding: 6px 3px 3px;
    }

    .cg-name {
        font-size: 0.83rem;
        -webkit-line-clamp: 2;
    }

    .cg-price {
        font-size: 0.9rem;
        font-weight: 800;
        color: #2E2F32;
    }

    .cg-section-header {
        padding: 8px 16px;
    }

    .cg-section-title {
        font-size: 1.05rem;
    }

    .cg-see-all {
        font-size: 0.78rem;
    }
}

/* ── Desktop (≥ 768px) : Grille figée, 6 colonnes ────────────── */
@media (min-width: 768px) {
    .cg-grid-desktop {
        display: grid;
        grid-template-columns: repeat(var(--cg-cols-md), 1fr);
        gap: var(--cg-gap);
        padding: 0 var(--cg-header-pl);
        background: #fff;
    }

    .cg-groups-mobile {
        display: none !important;
    }

    /* Tous les produits visibles sur desktop */
    .cg-grid-desktop .cg-item {
        display: block !important;
    }
}

/* ── Tablette / mobile paysage large (768px - 991px) ─────────── *
 * ───────────────────────────────────────────────────────────── */
@media (min-width: 768px) and (max-width: 991px) {
    .cg-grid-desktop {
        display: flex !important;
        grid-template-columns: none !important;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding: 0 var(--cg-header-pl) 6px;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .cg-grid-desktop::-webkit-scrollbar {
        display: none;
    }

    .cg-grid-desktop .cg-item {
        display: block !important;
        flex: 0 0 calc((100% - (var(--cg-gap) * 3)) / 4); /* 4 produits visibles, calcul exact selon le gap */
        min-width: 160px;
        scroll-snap-align: start;
    }

    /* Fondu à droite pour indiquer qu'on peut glisser (reste collé pendant le scroll) */
    .cg-grid-desktop::after {
        content: '';
        flex: 0 0 28px;
        position: sticky;
        right: 0;
        align-self: stretch;
        background: linear-gradient(to right, rgba(255,255,255,0), rgba(255,255,255,0.95));
        pointer-events: none;
    }
}

/* ≥ 992px : on revient à la grille figée 6 colonnes classique */
@media (min-width: 992px) {
    .cg-grid-desktop {
        display: grid !important;
        grid-template-columns: repeat(var(--cg-cols-lg), 1fr);
        overflow-x: visible;
        scroll-snap-type: none;
    }

    .cg-grid-desktop::after {
        content: none;
    }
}

/* ≥ 1200px */
@media (min-width: 1200px) {
    .cg-grid-desktop {
        grid-template-columns: repeat(var(--cg-cols-xl), 1fr);
    }
}

/* ── Très petit mobile (≤ 400px) ─────────────────────────────── */
@media (max-width: 400px) {
    .cg-section-header {
        padding: 8px 8px;
        gap: 4px;
    }

    .cg-section-title {
        font-size: 0.9rem;
    }
}

/* ═══════════════════════════════════════════════════════════════
   ═══════════════════════════════════════════════════════════════ */
@media (orientation: landscape) and (max-height: 500px) {

    .cg-grid-mobile,
    .cg-grid-desktop {
        display: flex !important;
        grid-template-columns: none !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        scroll-snap-type: x mandatory !important;
        -webkit-overflow-scrolling: touch;
        gap: var(--cg-gap) !important;
        padding: 0 12px 6px !important;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .cg-grid-mobile::-webkit-scrollbar,
    .cg-grid-desktop::-webkit-scrollbar {
        display: none;
    }

    .cg-grid-mobile .cg-item,
    .cg-grid-desktop .cg-item {
        display: block !important;
        flex: 0 0 calc((100% - (var(--cg-gap) * 3)) / 4) !important;
        min-width: 140px;
        scroll-snap-align: start;
    }

    .cg-grid-mobile::after,
    .cg-grid-desktop::after {
        content: '';
        flex: 0 0 24px;
        position: sticky;
        right: 0;
        align-self: stretch;
        background: linear-gradient(to right, rgba(255,255,255,0), rgba(255,255,255,0.95));
        pointer-events: none;
    }

    .cg-card {
        padding: 6px;
    }

    .cg-info {
        padding: 6px 3px 3px;
    }

    .cg-name {
        font-size: 0.8rem;
    }

    .cg-price {
        font-size: 0.88rem;
    }
}