/**
* 2007-2025 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author    PrestaShop SA <contact@prestashop.com>
*  @copyright 2007-2025 PrestaShop SA
*  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*
* Don't forget to prefix your containers with your own identifier
* to avoid any conflicts with others containers.
*/

/* --------------------------------------------------------------
	 Carrousel de catégories (module ps_categorycarousel)
	 Dépendances : Swiper.js (classes .swiper-*)
	 Objectifs :
	 - Mise en page responsive (1 à 6 colonnes selon largeur)
	 - Images uniformisées (ratio carré par défaut)
	 - Navigation accessible (focus visible, contraste suffisant)
	 - Effets doux (hover/focus) sans surcharger le rendu
	 -------------------------------------------------------------- */

/* Variables CSS (possibilité de surcharger via :root dans le thème) */
:root {
    --cat-carousel-bg: transparent;
    --cat-carousel-slide-bg: #16623f;
    --cat-carousel-slide-bg-hover: #1d784c;
    --cat-carousel-border: #145836;
    --cat-carousel-radius: 10px;
    --cat-carousel-img-ratio: 1;
    --cat-carousel-name-color: #ffffff;
    --cat-carousel-name-color-hover: #e6f8ef;
    --cat-carousel-name-font-size: 1.25rem;
    --cat-carousel-name-font-weight: 600;
    --cat-carousel-transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
    --cat-carousel-shadow: 0 2px 4px -2px rgba(0, 0, 0, 0.08), 0 4px 12px -2px rgba(0, 0, 0, 0.06);
    --cat-carousel-shadow-hover: 0 4px 10px -2px rgba(0, 0, 0, 0.12), 0 6px 18px -4px rgba(0, 0, 0, 0.12);
    --cat-carousel-nav-size: 42px;
    --cat-carousel-nav-bg: #ffffff;
    --cat-carousel-nav-color: #16623f;
    --cat-carousel-nav-border: #16623f;
    --cat-carousel-nav-bg-hover: #16623f;
    --cat-carousel-nav-color-hover: #ffffff;
    --cat-carousel-bullet: #c5cbd2;
    --cat-carousel-bullet-active: #16623f;
    --cat-carousel-grid-size: clamp(220px, 24vw, 320px); /* taille carrée cible desktop (agrandie) */
    --cat-carousel-grid-size-mobile: clamp(120px, 58vw, 160px); /* taille carrée cible mobile */
    --cat-carousel-max-mobile: 94vw; /* largeur maxi logique sur mobile */
}

/* Conteneur principal */
.category-carousel {
    position: relative;
    background: var(--cat-carousel-bg);
    padding: 0.5rem 0 2.5rem; /* espace pour pagination */
    width: 100%;
    --swiper-navigation-size: 20px; /* taille icône Swiper */
    overflow: hidden; /* masque les slides hors vue */
}

/* Bloc global + heading */
.category-carousel-block {
    margin: 1rem 0 2.5rem;
}
.category-carousel-heading-wrapper {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin: 0 0 0.75rem;
}
/* Wrapper Swiper (aucune modif lourde pour laisser Swiper gérer) */
.category-carousel .swiper-wrapper {
    align-items: stretch;
}

/* Slide */
.category-carousel .swiper-slide {
    height: auto; /* Permet au contenu interne d'ajuster la hauteur */
    display: flex;
    align-items: stretch;
    justify-content: stretch;
}

/* Carte interne (lien) */
.category-carousel .swiper-slide > a {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    width: 100%;
    background: var(--cat-carousel-slide-bg);
    /* background: var(--background); */
    border: 1px solid var(--cat-carousel-slide-bg);
    border-radius: var(--cat-carousel-radius);
    /* padding: 1.05rem 1.05rem 1.25rem; */
    text-decoration: none;
    transition: background var(--cat-carousel-transition), box-shadow var(--cat-carousel-transition),
        transform var(--cat-carousel-transition), border-color var(--cat-carousel-transition);
    box-shadow: var(--cat-carousel-shadow);
    overflow: hidden;
    align-items: center; /* centre la grille horizontalement */
}

.category-carousel .swiper-slide > a:hover,
.category-carousel .swiper-slide > a:focus-visible {
    /* background: var(--cat-carousel-slide-bg-hover); */
    background: var(--background);
        box-shadow: 0 3px 12px -4px rgba(0, 0, 0, 0.32), inset 0 0 0 1px #ffffff22;
    transform: translateY(-3px);
    /* border-color: #ffffff44; */
}

.category-carousel .swiper-slide > a:active {
    transform: translateY(0);
}

/* Image */
.category-carousel .swiper-slide img {
    width: 100%;
    aspect-ratio: var(--cat-carousel-img-ratio);
    object-fit: cover;
    border-radius: calc(var(--cat-carousel-radius) - 4px);
    background: #ffffff10; /* léger voile */
    border: 1px solid #ffffff30;
    transition: opacity var(--cat-carousel-transition), filter var(--cat-carousel-transition), transform var(--cat-carousel-transition);
    box-shadow: 0 4px 10px -2px rgba(0, 0, 0, 0.35);
}

.category-carousel .swiper-slide > a:hover img,
.category-carousel .swiper-slide > a:focus-visible img {
    opacity: 0.98;
    filter: saturate(1.08) brightness(1.05);
    transform: scale(1.025);
}

/* Nom de catégorie */
.category-carousel .category-name {
    font-size: var(--cat-carousel-name-font-size);
    font-weight: var(--cat-carousel-name-font-weight);
    line-height: 1.25;
    /* color: var(--cat-carousel-slide-bg); */
    color: #ffffff;
    text-transform: none;
    letter-spacing: 0.2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2; /* propriété standard (support partiel) */
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color var(--cat-carousel-transition);
    min-height: 2.4em; /* réserve pour aligner les cartes même si 1 ligne */
    text-align: center;
    display: flex;
    align-items: center;
    padding-right : 0.5rem;
    padding-left : 0.5rem;
}

.category-carousel .swiper-slide > a:hover .category-name,
.category-carousel .swiper-slide > a:focus-visible .category-name {
    /* color: var(--cat-carousel-name-color-hover); */
    color: var(--cat-carousel-slide-bg);
        text-decoration: underline;
        text-underline-offset: 4px;
}

/* Accessibilité: focus */
.category-carousel .swiper-slide > a:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 2px;
}

/* Pagination (bullets) */
.category-carousel .swiper-pagination {
    bottom: 0.4rem;
}

.category-carousel .swiper-pagination-bullet {
    width: 9px;
    height: 9px;
    background: var(--cat-carousel-bullet);
    opacity: 1;
    margin: 0 5px !important;
    transition: background var(--cat-carousel-transition), transform var(--cat-carousel-transition);
}

.category-carousel .swiper-pagination-bullet:hover,
.category-carousel .swiper-pagination-bullet:focus-visible {
    transform: scale(1.25);
}

.category-carousel .swiper-pagination-bullet-active {
    background: #16623f;
    transform: scale(1.3);
    box-shadow: 0 0 0 4px #16623f22;
}

/* Navigation (précédent / suivant) */
.category-carousel .swiper-button-prev,
.category-carousel .swiper-button-next {
    width: calc(var(--cat-carousel-nav-size) + 6px);
    height: calc(var(--cat-carousel-nav-size) + 6px);
    background: var(--cat-carousel-nav-bg);
    border: 2px solid var(--cat-carousel-nav-border);
    border-radius: 12px; /* rectangle arrondi pour se détacher */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    color: var(--cat-carousel-nav-color);
    top: 45%;
    transition: background var(--cat-carousel-transition), color var(--cat-carousel-transition), border-color var(--cat-carousel-transition),
        transform var(--cat-carousel-transition), box-shadow var(--cat-carousel-transition);
    backdrop-filter: blur(2px);
}

.category-carousel .swiper-button-prev:after,
.category-carousel .swiper-button-next:after {
    font-size: 16px;
    font-weight: 600;
}

.category-carousel .swiper-button-prev:hover,
.category-carousel .swiper-button-next:hover,
.category-carousel .swiper-button-prev:focus-visible,
.category-carousel .swiper-button-next:focus-visible {
    background: var(--cat-carousel-nav-bg-hover);
    color: var(--cat-carousel-nav-color-hover);
    transform: translateY(-3px);
    border-color: var(--cat-carousel-nav-bg-hover);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.category-carousel .swiper-button-disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
}

/* Positionnements adaptés (éviter chevauchement sur petits écrans) */
@media (max-width: 768px) {
    .category-carousel .swiper-button-prev,
    .category-carousel .swiper-button-next {
        top: auto;
        bottom: 2.4rem;
        transform: none;
    }
    .category-carousel .swiper-button-prev {
        left: 8px;
    }
    .category-carousel .swiper-button-next {
        right: 8px;
    }
}

/* Ultra petits écrans & mobiles (élargi à 600px) */
@media (max-width: 600px) {
    .category-carousel {
        padding-bottom: 3rem;
    }
    .category-carousel .swiper-slide > a {
        padding: 0.7rem 0.7rem 0.85rem;
    }
    .category-carousel .category-name {
        font-size: 0.8rem;
    }
}

/* Support dark mode (si le thème définit prefers-color-scheme) */
@media (prefers-color-scheme: dark) {
    :root {
        --cat-carousel-slide-bg: #16623f;
        --cat-carousel-slide-bg-hover: #1d784c;
        --cat-carousel-border: #2e343b;
        --cat-carousel-name-color: #e5e7eb;
        --cat-carousel-name-color-hover: #ffffff;
        --cat-carousel-nav-bg: rgba(34, 37, 41, 0.85);
        --cat-carousel-nav-color: #e5e7eb;
        --cat-carousel-nav-bg-hover: #f1f5f9;
        --cat-carousel-nav-color-hover: #111;
        --cat-carousel-bullet: #555f69;
        --cat-carousel-bullet-active: #f1f5f9;
    }
    .category-carousel .swiper-slide img {
        background: #ffffff12;
        border-color: #ffffff33;
    }
}

/* Réduction motion pour accessibilité */
@media (prefers-reduced-motion: reduce) {
    .category-carousel .swiper-slide > a,
    .category-carousel .swiper-slide img,
    .category-carousel .swiper-pagination-bullet,
    .category-carousel .swiper-button-prev,
    .category-carousel .swiper-button-next {
        transition: none !important;
    }
}

/* Optionnel: animation d'apparition progressive */
/* Slides toujours visibles (on supprime l’animation d’apparition pour éviter tout conflit) */
.category-carousel .swiper-slide {
    opacity: 1 !important;
    transform: none !important;
}

/* Placeholder (si image de catégorie absente) */
.category-carousel .swiper-slide img.is-placeholder {
    object-fit: contain;
    padding: 10%;
    background: linear-gradient(135deg, #f3f4f6, #eceff3);
    border-style: dashed;
}

/* Fallback si aspect-ratio non supporté (IE / anciens navigateurs) */
@supports not (aspect-ratio: 1) {
    .category-carousel .swiper-slide img {
        height: auto;
    }
}

/* Helper classes possibles (si besoin de modifier densité depuis le hook) */
.category-carousel.dense .swiper-slide > a {
    padding: 0.65rem 0.65rem 0.8rem;
}
.category-carousel.dense .category-name {
    font-size: 0.75rem;
}

/* Large variant (plus de respiration) */
.category-carousel.wide .swiper-slide > a {
    padding: 1.1rem 1.1rem 1.25rem;
}
.category-carousel.wide .category-name {
    font-size: 0.95rem;
}

/* Possibilité d'ajouter une bordure accentuée via une classe utilitaire */
.category-carousel.accent-borders .swiper-slide > a {
    border-color: var(--cat-carousel-bullet-active);
}

/* Fin styles carrousel */

/* Quadrillage d'images enfants (2x2) dans le carrousel de catégories */
.category-image-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 6px;
    width: 100%;
    aspect-ratio: 1; /* fallback si pas de height */
        max-height: var(--cat-carousel-grid-size);
        height: var(--cat-carousel-grid-size);
    border-radius: 0; /* uniformisation coins droits */
    overflow: hidden;
    background: var(--cat-carousel-slide-bg);
}
.category-image-grid .grid-item {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 0;
}
.category-image-grid .grid-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 0;
    background: #fff;
    box-shadow: 0 2px 6px -2px rgba(0,0,0,0.08);
}

/* =============================================================
   OVERRIDES UNIFORMISATION STYLE SITE (coins droits, couleurs)
   ============================================================= */
/* Coins droits sur cartes, images, pagination, navigation */
.category-carousel .swiper-slide > a,
.category-carousel .swiper-slide img,
.category-carousel .swiper-button-prev,
.category-carousel .swiper-button-next,
.category-carousel .swiper-pagination-bullet,
.category-carousel .swiper-slide img.is-placeholder {
    border-radius: 0 !important;
}

/* Ajuster border principales pour cohérence avec thème (primary) */
:root {
    --cat-carousel-border: var(--primary); /* Re-map sur couleur thème */
    --cat-carousel-slide-bg: var(--primary);
    --cat-carousel-slide-bg-hover: var(--primary-light);
    --cat-carousel-bullet-active: var(--primary);
    --cat-carousel-grid-height: 200px; /* ajuste avec thème */
}

/* Affiner hover: moins de translation, ombre plus nette, légère lumière interne */
.category-carousel .swiper-slide > a:hover,
.category-carousel .swiper-slide > a:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px -4px rgba(0,0,0,0.35), inset 0 0 0 1px #ffffff22;
}

/* Image hover: subtile au lieu de zoom trop grand */
.category-carousel .swiper-slide > a:hover img,
.category-carousel .swiper-slide > a:focus-visible img {
    transform: scale(1.0125);
    filter: saturate(1.05) brightness(1.04);
}

/* Navigation rectangulaire et hover plus proche du thème */
.category-carousel .swiper-button-prev,
.category-carousel .swiper-button-next {
    border: 1px solid var(--primary);
    background: #fff;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.category-carousel .swiper-button-prev:hover,
.category-carousel .swiper-button-next:hover,
.category-carousel .swiper-button-prev:focus-visible,
.category-carousel .swiper-button-next:focus-visible {
    background: var(--primary);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0,0,0,.25);
}

/* Pagination bullets rectangulaires fins (optionnel) */
.category-carousel .swiper-pagination-bullet {
    width: 18px;
    height: 6px;
    border-radius: 0 !important;
    background: #c5cbd2;
}
.category-carousel .swiper-pagination-bullet-active {
    background: var(--primary);
    box-shadow: 0 0 0 2px #16623f22;
}

/* Taille mobile & petit tablet (<=600px): contraintes strictes pour éviter width astronomique */
@media (max-width: 600px) {
    .category-carousel {
        max-width: var(--cat-carousel-max-mobile);
        margin-left: auto;
        margin-right: auto;
        box-sizing: border-box;
    }
    .category-carousel .swiper-wrapper {
        max-width: var(--cat-carousel-max-mobile);
        box-sizing: border-box;
    }
    .category-carousel .swiper-slide {
        box-sizing: border-box;
        max-width: var(--cat-carousel-max-mobile);
        overflow: hidden;
    }
    .category-carousel .swiper-wrapper {
        justify-content: flex-start; /* évite que le slide 2 apparaisse en premier */
    }
    .category-carousel .swiper-slide {
        display: flex;
        justify-content: center;
    }
    .category-carousel .swiper-slide > a {
        padding: 0.55rem 0.55rem 0.75rem;
        max-width: calc(var(--cat-carousel-grid-size-mobile) + 1.1rem) !important;
        margin: 0 auto !important;
        box-sizing: border-box;
    }
    .category-image-grid {
        aspect-ratio: 1 !important;
        width: var(--cat-carousel-grid-size-mobile) !important;
        height: var(--cat-carousel-grid-size-mobile) !important;
        max-width: var(--cat-carousel-grid-size-mobile) !important;
        max-height: var(--cat-carousel-grid-size-mobile) !important;
        min-height: 120px !important;
        margin: 0 auto !important;
    }
    .category-image-grid .grid-item,
    .category-image-grid .grid-item img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
    .category-carousel .category-name {
        font-size: 0.85rem;
    }
    /* Neutraliser translation hover sur mobile (tactile) */
    .category-carousel .swiper-slide > a:hover,
    .category-carousel .swiper-slide > a:focus-visible {
        transform: none !important;
    }
    /* Sécurité: si calcul Swiper délire -> forcage max */
    .category-carousel .swiper-slide img {
        max-width: 100% !important;
    }
}

/* Ajuster bullet pagination sur très petits écrans */
@media (max-width: 380px) {
    .category-carousel .swiper-pagination-bullet { width: 14px; }
}

