/* ============================================
   GBM Beauty — Color Swatches & Variantes Produit
   Styles complets Desktop + Mobile (Mobile-First)
   
   @package GBM_Theme
   @since 1.1.0
   ============================================ */

/* ============================================
   1. CONTENEUR DES SWATCHES
   ============================================ */

.gbm-color-swatches {
    margin: 28px 0 32px 0;
    padding: 0;
}

/* Label "Couleur : Rose Petal" */
.gbm-swatch-label {
    font-family: var(--font-body, 'Montserrat', sans-serif);
    font-size: 14px;
    font-weight: 500;
    color: var(--gbm-gray, #666);
    margin-bottom: 14px;
    letter-spacing: 0.3px;
}

.gbm-swatch-label span {
    font-weight: 700;
    color: var(--gbm-black, #1A1A1A);
    text-transform: capitalize;
}

/* ============================================
   2. LISTE DES BOUTONS SWATCHES
   ============================================ */

.gbm-swatch-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding: 4px 0;
}

.gbm-swatch-more {
    font-family: var(--font-body, 'Montserrat', sans-serif);
    font-size: 11px;
    font-weight: 500;
    color: var(--gbm-gray, #777);
    margin-left: 2px;
    white-space: nowrap;
}

/* ============================================
   3. BOUTON SWATCH INDIVIDUEL
   ============================================ */

.gbm-swatch {
    /* Taille de base — Desktop */
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;

    /* Forme circulaire */
    border-radius: 50%;
    border: 2.5px solid transparent;
    
    /* Anneau extérieur via outline (invisible par défaut) */
    outline: 2.5px solid transparent;
    outline-offset: 3px;

    /* Apparence */
    cursor: pointer;
    position: relative;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Reset du bouton */
    padding: 0;
    margin: 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);

    /* Accessibilité : focus visible */
    -webkit-tap-highlight-color: transparent;
}

/* Effet hover — Desktop uniquement */
@media (hover: hover) and (pointer: fine) {
    .gbm-swatch:hover {
        transform: scale(1.18);
        border-color: rgba(212, 175, 55, 0.5);
        box-shadow: 0 3px 12px rgba(0, 0, 0, 0.18);
    }
}

/* Swatch actif — sélectionné */
.gbm-swatch.active {
    border-color: var(--gbm-gold, #D4AF37);
    outline-color: var(--gbm-gold, #D4AF37);
    box-shadow: 0 2px 10px rgba(212, 175, 55, 0.35);
    transform: scale(1.05);
}

/* Coche (checkmark) sur le swatch actif */
.gbm-swatch.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    font-weight: 900;
    color: #FFFFFF;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    line-height: 1;
}

/* Coche foncée pour les couleurs claires */
.gbm-swatch.active.gbm-swatch-light::after {
    color: #333333;
    text-shadow: none;
}

/* Focus pour accessibilité clavier */
.gbm-swatch:focus-visible {
    outline-color: var(--gbm-gold, #D4AF37);
    outline-width: 3px;
    outline-offset: 3px;
}

/* Effet de pression tactile — Mobile */
.gbm-swatch:active {
    transform: scale(0.92);
    transition-duration: 0.1s;
}

/* ============================================
   4. TRANSITION D'IMAGE PRODUIT (CROSSFADE)
   ============================================ */

/* Image principale avec transition fluide */
#gbm-main-image {
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    will-change: opacity;
}

/* État de fondu sortant */
#gbm-main-image.gbm-fade-out {
    opacity: 0;
    transform: scale(0.98);
}

/* État de fondu entrant (après changement de src) */
#gbm-main-image.gbm-fade-in {
    opacity: 1;
    transform: scale(1);
}

/* ============================================
   5. INDICATEUR SKU VARIANTE
   ============================================ */

.gbm-variant-sku-display {
    font-family: var(--font-body, 'Montserrat', sans-serif);
    font-size: 12px;
    font-weight: 400;
    color: var(--gbm-gray, #999);
    margin-top: 8px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.gbm-variant-sku-display span {
    font-weight: 600;
    color: var(--gbm-black, #1A1A1A);
}

/* ============================================
   6. BOUTON "ADD TO CART" — ÉTAT VARIANTE
   ============================================ */

/* Indication visuelle quand aucune variante n'est sélectionnée */
.gbm-ajax-add-to-cart.gbm-no-variant {
    opacity: 0.6;
    pointer-events: none;
}

/* Animation de confirmation après sélection de variante */
.gbm-ajax-add-to-cart.gbm-variant-selected {
    animation: gbm-pulse-border 0.4s ease-out;
}

@keyframes gbm-pulse-border {
    0% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(212, 175, 55, 0); }
    100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0); }
}

/* ============================================
   7. RESPONSIVE — MOBILE (≤ 768px)
   ============================================ */

@media (max-width: 768px) {

    .gbm-color-swatches {
        margin: 20px 0 24px 0;
    }

    .gbm-swatch-label {
        font-size: 13px;
        margin-bottom: 12px;
    }

    /* --- SWATCHES : Zone tactile optimisée --- */
    .gbm-swatch {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
        border-width: 2px;
        outline-width: 2px;
        outline-offset: 2px;
    }

    .gbm-swatch.active::after {
        font-size: 14px;
    }

    /* --- WRAP DES COULEURS (Eviter le débordement) --- */
    .gbm-swatch-list {
        flex-wrap: wrap !important;
        overflow-x: visible;
        overflow-y: visible;
        gap: 8px;
        padding: 6px 0 10px 0;
        margin: 0;
        justify-content: flex-start;
        max-width: 100%;
    }

    .gbm-swatch-list::-webkit-scrollbar {
        display: none; /* Chrome / Safari */
    }

    /* Retirer le scroll-snap */
    .gbm-swatch {
        flex-shrink: 0;
    }

    /* Indicateur visuel de scroll (dégradé sur les bords) */
    .gbm-color-swatches {
        position: relative;
    }

    .gbm-color-swatches.gbm-has-scroll::after {
        content: '';
        position: absolute;
        right: 0;
        bottom: 10px;
        width: 40px;
        height: 48px;
        background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.95));
        pointer-events: none;
        z-index: 2;
    }

    /* SKU display en mobile */
    .gbm-variant-sku-display {
        font-size: 11px;
        margin-top: 6px;
    }
}

/* ============================================
   8. RESPONSIVE — TABLETTE (769px → 1024px)
   ============================================ */

@media (min-width: 769px) and (max-width: 1024px) {
    .gbm-swatch {
        width: 42px;
        height: 42px;
        min-width: 42px;
        min-height: 42px;
    }

    .gbm-swatch-list {
        gap: 10px;
    }
}

/* ============================================
   9. BOUTON STICKY MOBILE — INTÉGRATION VARIANTE
   ============================================ */

@media (max-width: 768px) {
    /* Le sticky bar mobile affiche la couleur sélectionnée */
    .gbm-mobile-sticky-product {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 999;
        background: #FFFFFF;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 20px;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        border-top: 1px solid rgba(0, 0, 0, 0.06);
    }

    .gbm-mobile-sticky-product .gbm-sticky-price {
        font-family: var(--font-body, 'Montserrat', sans-serif);
        font-size: 18px;
        font-weight: 700;
        color: var(--gbm-black, #1A1A1A);
    }

    .gbm-mobile-sticky-product .gbm-sticky-add-btn {
        padding: 14px 32px;
        background: var(--gbm-black, #1A1A1A);
        color: #FFFFFF;
        border: none;
        border-radius: 8px;
        font-family: var(--font-body, 'Montserrat', sans-serif);
        font-size: 14px;
        font-weight: 700;
        letter-spacing: 1px;
        text-transform: uppercase;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .gbm-mobile-sticky-product .gbm-sticky-add-btn:active {
        transform: scale(0.97);
        background: var(--gbm-gold, #D4AF37);
        color: var(--gbm-black, #1A1A1A);
    }

    /* Pastille de couleur inline dans le sticky bar */
    .gbm-sticky-color-dot {
        display: inline-block;
        width: 14px;
        height: 14px;
        border-radius: 50%;
        border: 1.5px solid rgba(0, 0, 0, 0.15);
        margin-left: 8px;
        vertical-align: middle;
        transition: background-color 0.3s ease;
    }
}

/* Cacher le sticky color dot sur Desktop */
@media (min-width: 769px) {
    .gbm-sticky-color-dot {
        display: none;
    }
}

/* ============================================
   10. ANIMATIONS & MICRO-INTERACTIONS
   ============================================ */

/* Animation d'apparition des swatches au chargement */
@keyframes gbm-swatch-appear {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.gbm-swatch {
    animation: gbm-swatch-appear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Délais en cascade pour chaque swatch */
.gbm-swatch:nth-child(1) { animation-delay: 0.05s; }
.gbm-swatch:nth-child(2) { animation-delay: 0.10s; }
.gbm-swatch:nth-child(3) { animation-delay: 0.15s; }
.gbm-swatch:nth-child(4) { animation-delay: 0.20s; }
.gbm-swatch:nth-child(5) { animation-delay: 0.25s; }
.gbm-swatch:nth-child(6) { animation-delay: 0.30s; }
.gbm-swatch:nth-child(7) { animation-delay: 0.35s; }
.gbm-swatch:nth-child(8) { animation-delay: 0.40s; }
.gbm-swatch:nth-child(9) { animation-delay: 0.45s; }
.gbm-swatch:nth-child(10) { animation-delay: 0.50s; }

/* Ripple effect au clic (subtil) */
.gbm-swatch::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease, opacity 0.4s ease;
    opacity: 0;
    z-index: 1;
}

.gbm-swatch.gbm-ripple::before {
    width: 120%;
    height: 120%;
    opacity: 1;
}

/* ============================================
   11. LAYOUT DESKTOP — PRODUIT AVEC SWATCHES
   ============================================ */

/* S'assurer que les swatches s'intègrent bien dans le layout existant */
@media (min-width: 769px) {
    .gbm-product-detail {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 60px;
        padding: 40px 0;
    }

    /* Colonne droite (info) : les swatches sont sous le prix */
    .gbm-product-detail-info .gbm-color-swatches {
        border-top: 1px solid #F0F0F0;
        border-bottom: 1px solid #F0F0F0;
        padding: 24px 0;
        margin: 24px 0;
    }
}

/* ============================================
   12. PRINT STYLES (masquer les swatches à l'impression)
   ============================================ */

@media print {
    .gbm-color-swatches,
    .gbm-mobile-sticky-product {
        display: none !important;
    }
}

/* ============================================
   13. CORRECTIONS GLOBALES & NETTOYAGE VISUEL
   ============================================ */

/* Suppression de tous les fonds gris sur les images produits */
.gbm-product-image,
.gbm-product-image img,
.gbm-gallery-main,
.gbm-gallery-main img,
.wp-post-image,
.woocommerce-loop-product__link img,
.product img {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Layout adaptatif des grilles produits sur tout le site (Mobile-First) */
@media screen and (max-width: 768px) {
    .products, .gbm-products-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 20px !important;
    }
    
    .product, .type-product, .gbm-product-card-figma {
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }

    /* Le bouton add to cart pleine largeur sur mobile */
    .gbm-ajax-add-to-cart, .add_to_cart_button {
        width: 100% !important;
        margin-top: 10px !important;
    }
}

/* ============================================
   14. RESPONSIVE FOR CARD SWATCHES (+X COLORS BELOW CIRCLES ON MOBILE)
   ============================================ */
@media screen and (max-width: 768px) {
    .gbm-card-color-swatches {
        flex-wrap: wrap !important;
        justify-content: center !important;
    }
    .gbm-card-color-swatches .gbm-swatch-more {
        flex-basis: 100% !important;
        width: 100% !important;
        text-align: center !important;
        margin-left: 0 !important;
        margin-top: 6px !important;
        display: block !important;
        align-self: center !important;
    }
}

