/**
 * Mobile « forcé » : ne s’applique que si body porte .ajaxcf-catalog-mobile
 * (classe posée en JS + micro-script dans catalog.tpl — évite le thème).
 * Spécificité élevée : body.ajaxcf-catalog-mobile …
 */
body.ajaxcf-catalog-mobile .ajax-catalog-fun,
body.ajaxcf-catalog-mobile .ajax-catalog-fun * {
    box-sizing: border-box;
}

body.ajaxcf-catalog-mobile .ajax-catalog-fun .product-card {
    min-width: 0;
}

/* Reset thème (Bootstrap, Elementor, etc.) à l’intérieur du module */
body.ajaxcf-catalog-mobile .ajax-catalog-fun a,
body.ajaxcf-catalog-mobile .ajax-catalog-fun button,
body.ajaxcf-catalog-mobile .ajax-catalog-fun h2,
body.ajaxcf-catalog-mobile .ajax-catalog-fun h3,
body.ajaxcf-catalog-mobile .ajax-catalog-fun p {
    max-width: 100%;
}

body.ajaxcf-catalog-mobile .ajax-catalog-fun [class~="row"] {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    flex: none !important;
}

body.ajaxcf-catalog-mobile .ajax-catalog-fun [class*="col-"] {
    width: 100% !important;
    max-width: 100% !important;
    flex: none !important;
    float: none !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin: 0 !important;
    position: static !important;
}

body.ajaxcf-catalog-mobile .ajax-catalog-fun img {
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
    float: none !important;
    position: static !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    margin: 0 auto !important;
    vertical-align: top !important;
    object-fit: contain !important;
}

body.ajaxcf-catalog-mobile .ajax-catalog-fun {
    width: 100% !important;
    max-width: 100% !important;
    padding: 4px 6px 12px !important;
    margin: 0 !important;
    overflow-x: hidden !important;
}

body.ajaxcf-catalog-mobile .catalog-header,
body.ajaxcf-catalog-mobile .catalog-header-intro {
    display: none !important;
}

body.ajaxcf-catalog-mobile .catalog-layout {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

body.ajaxcf-catalog-mobile .catalog-categories {
    border-radius: 8px;
    border: 1px solid #e4e8ef;
    padding: 6px 4px 4px;
    margin: 0 0 8px;
    background: #f7f9fc;
}

body.ajaxcf-catalog-mobile .catalog-categories h2 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    font-weight: 600;
    margin: 0 0 4px 6px;
}

body.ajaxcf-catalog-mobile .category-list {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding: 0 0 4px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
}

body.ajaxcf-catalog-mobile .category-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex: 0 0 calc(50% - 4px) !important;
    max-width: calc(50% - 2px) !important;
    min-width: 0;
    min-height: 48px;
    padding: 5px 8px;
    text-align: left;
    margin: 0;
    scroll-snap-align: start;
}

body.ajaxcf-catalog-mobile .category-btn .category-thumb-wrap {
    width: 40px;
    height: 40px;
    min-width: 40px;
    flex-shrink: 0;
}

body.ajaxcf-catalog-mobile .category-description {
    display: none !important;
}

body.ajaxcf-catalog-mobile .category-name {
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-width: 0;
}

body.ajaxcf-catalog-mobile .catalog-products {
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    max-width: 100%;
    overflow: hidden;
}

body.ajaxcf-catalog-mobile .products-sticky {
    position: sticky;
    top: 0;
    z-index: 4;
    background: #fff;
    margin: 0 0 6px;
    padding: 4px 0 6px;
    border-bottom: 1px solid #eef0f4;
}

body.ajaxcf-catalog-mobile .catalog-search-wrap {
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 6px;
}

body.ajaxcf-catalog-mobile .catalog-search-input {
    max-width: 100% !important;
    width: 100% !important;
    font-size: 16px; /* evite le zoom iOS */
}

body.ajaxcf-catalog-mobile .catalog-search-results {
    max-width: 100% !important;
    left: 0 !important;
    right: 0 !important;
    max-height: 50vh;
    z-index: 40;
}

body.ajaxcf-catalog-mobile .products-header h2 {
    font-size: 15px;
    margin: 0 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Filtres : désactivés sur mobile (zone masquée, pas de puce) */
body.ajaxcf-catalog-mobile #products-filters.products-filters,
body.ajaxcf-catalog-mobile .products-filters {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Grille 1 col : pleine largeur utile (ignore --products-per-line) */
body.ajaxcf-catalog-mobile .ajax-catalog-fun .products-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
}

body.ajaxcf-catalog-mobile .ajax-catalog-fun .product-card,
body.ajaxcf-catalog-mobile .ajax-catalog-fun .product-card.row {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    float: none !important;
    clear: both !important;
}

body.ajaxcf-catalog-mobile .ajax-catalog-fun .product-image {
    order: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 120px;
    max-height: 200px;
    height: auto !important;
    flex: 0 0 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    float: none !important;
    margin: 0 !important;
    padding: 8px !important;
    position: relative !important;
    left: auto !important;
    right: auto !important;
}

body.ajaxcf-catalog-mobile .ajax-catalog-fun .product-image img,
body.ajaxcf-catalog-mobile .ajax-catalog-fun .product-image .product-thumb-img {
    display: block !important;
    width: auto !important;
    max-width: 100% !important;
    max-height: 180px !important;
    height: auto !important;
    margin: 0 auto !important;
    object-fit: contain !important;
    object-position: center !important;
    float: none !important;
    position: static !important;
}

body.ajaxcf-catalog-mobile .ajax-catalog-fun .product-body {
    width: 100% !important;
    min-width: 0;
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto;
}

body.ajaxcf-catalog-mobile .ajax-catalog-fun .product-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px 4px;
    min-width: 0;
    width: 100%;
}

body.ajaxcf-catalog-mobile .product-description {
    display: none !important;
}

body.ajaxcf-catalog-mobile .product-name {
    font-size: 14px;
    line-height: 1.3;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

body.ajaxcf-catalog-mobile .product-price {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
}

body.ajaxcf-catalog-mobile .price-final {
    font-size: 16px;
}

body.ajaxcf-catalog-mobile .product-link-label--desktop {
    display: none !important;
}

body.ajaxcf-catalog-mobile .product-link-label--mobile {
    display: inline !important;
}

body.ajaxcf-catalog-mobile .product-link {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 44px;
    margin-top: 4px;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box !important;
    white-space: normal !important;
    text-align: center;
    float: none !important;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    font-size: 14px;
}

/* Modal (hors .ajax-catalog-fun) : même mode mobile */
body.ajaxcf-catalog-mobile .product-modal#catalog-product-modal,
body.ajaxcf-catalog-mobile #catalog-product-modal.product-modal {
    z-index: 2147480000;
}

body.ajaxcf-catalog-mobile #catalog-product-modal .modal-content {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    max-width: 100% !important;
    max-height: none;
    min-height: 100dvh;
    height: 100% !important;
    border-radius: 0;
    transform: none !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0 !important;
    padding: 0 !important;
    position: fixed;
}

body.ajaxcf-catalog-mobile #catalog-product-modal .modal-image-wrapper {
    width: 100% !important;
    min-width: 0 !important;
    flex: 0 0 auto;
    padding: 10px 12px 6px;
}

body.ajaxcf-catalog-mobile #catalog-product-modal .modal-product-image {
    min-height: 180px;
    max-height: 36vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.ajaxcf-catalog-mobile #catalog-product-modal .modal-info-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 14px max(16px, env(safe-area-inset-bottom, 0px)) 14px;
}

body.ajaxcf-catalog-mobile #catalog-product-modal .modal-close {
    top: max(6px, env(safe-area-inset-top, 0px)) !important;
    right: max(6px, env(safe-area-inset-right, 0px)) !important;
    z-index: 2;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.ajaxcf-catalog-mobile #catalog-product-modal .modal-add-cart-btn,
body.ajaxcf-catalog-mobile #catalog-product-modal .modal-view-product-btn {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    min-height: 48px;
}

/* Page module : le thème enferme souvent le contenu — on récupère toute la largeur */
#module-ajaxcatalogfun-catalog {
    overflow-x: hidden;
    max-width: 100% !important;
    box-sizing: border-box;
}

body.ajaxcf-catalog-mobile #module-ajaxcatalogfun-catalog,
body.ajaxcf-catalog-mobile #module-ajaxcatalogfun-catalog .page-content,
body.ajaxcf-catalog-mobile #module-ajaxcatalogfun-catalog .container,
body.ajaxcf-catalog-mobile #module-ajaxcatalogfun-catalog .col,
body.ajaxcf-catalog-mobile #module-ajaxcatalogfun-catalog [class*="col-"] {
    max-width: 100% !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    flex: 1 1 auto !important;
}

body.ajaxcf-catalog-mobile #module-ajaxcatalogfun-catalog .ajax-catalog-fun {
    max-width: 100% !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    overflow-x: hidden;
    padding-left: 2px !important;
    padding-right: 2px !important;
}
