/* Container */
.custom-swatches {
    display: flex !important;
    gap: 12px !important;
    margin: 15px 0 !important;
    flex-wrap: wrap !important;
}

/* Bottone */
.swatch-btn {
    width: 50px !important;
    height: 50px !important;
    border-radius: 50% !important;
    border: 2px solid #ddd !important;
    cursor: pointer !important;
    background-size: cover !important;
    background-position: center !important;
    position: relative !important;
    transition: all 0.2s ease !important;
}

/* Selezione */
.swatch-btn.active {
    border-color: #000 !important;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #000 !important;
    transform: scale(1.05);
}

/* La Spunta (Check) */
.gmg-check-mark {
    display: none;
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #000;
    border-radius: 50%;
    border: 2px solid #fff;
    z-index: 10;
}

.swatch-btn.active .gmg-check-mark {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.swatch-btn.active .gmg-check-mark::after {
    content: '✓';
    color: #fff;
    font-size: 11px;
    font-weight: bold;
}

/* Container Galleria */
#gmg-gallery-container {
    transition: opacity 0.3s;
    min-height: 300px;
    width: 100%;
}

/* Forza visibilità miniature nello shortcode */
#gmg-gallery-container .flex-control-nav.flex-control-thumbs {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
    margin-top: 15px !important;
    padding: 0 !important;
    list-style: none !important;
}

#gmg-gallery-container .flex-control-thumbs li {
    width: 80px !important;
    cursor: pointer;
}

#gmg-gallery-container .flex-control-thumbs li img {
    border-radius: 4px;
    border: 1px solid #ddd;
    display: block !important;
}

#gmg-gallery-container .flex-control-thumbs li img.flex-active {
    border-color: #000;
}

.gmg-shadow-gallery { width: 100%; position: relative; }
.gmg-main-viewport { margin-bottom: 15px; border-radius: 12px; overflow: hidden; background: #fff; }
.gmg-main-img { width: 100%; display: block; height: auto; cursor: zoom-in; }
.gmg-thumbs-strip { display: flex; gap: 10px; flex-wrap: wrap; }
.gmg-thumb-unit { width: 70px; height: 70px; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer; transition: 0.2s; }
.gmg-thumb-unit.active { border-color: #c00; } /* Colore viola come il tuo pulsante */
.gmg-thumb-unit img { width: 100%; height: 100%; object-fit: cover; }

/* Griglia degli swatch: riga singola con scroll orizzontale (desktop e mobile) */
.gmg-swatches-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 15px;
    margin-bottom: 20px;
    /* Forza il contenitore a restare dentro la sua colonna: senza questi 3,
       se il tema/Elementor lo mette in un layout flex, il blocco tende ad
       espandersi con tutte le card e va a capo sotto l'altra colonna
       invece di scrollare al suo interno. */
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding-bottom: 10px;
}

/* Scrollbar nascosta: lo scroll resta funzionante (swipe/trascinamento) ma senza barra visibile */
.gmg-swatches-grid::-webkit-scrollbar {
    display: none;
    height: 0;
}

.gmg-swatches-grid {
    scrollbar-width: none;    /* Firefox */
    -ms-overflow-style: none; /* Edge/IE legacy */
}

/* Card dello swatch: larghezza fissa, scorrimento orizzontale (swipe/trascinamento) */
.gmg-swatch-card {
    background: #ffffff;
    border-radius: 15px;
    padding: 10px;
    width: 120px;
    flex: 0 0 auto;
    scroll-snap-align: start;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
}

.gmg-swatch-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.1);
}

/* Stato attivo/selezionato */
.gmg-swatch-card.active {
    border-color: #c00; /* Viola come il tuo tema */
}

/* Immagine del cerchione */
.gmg-swatch-image {
    width: 80px;
    height: 80px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    margin: 0 auto 10px;
}

/* Etichetta nome colore */
.gmg-swatch-label {
    font-size: 14px;
    font-weight: 500;
    line-height: 16px;
    color: #333;
    text-transform: capitalize;
}

/* Checkmark sopra l'immagine */
.gmg-swatch-check {
    position: absolute;
    bottom: 45px;
    right: 20px;
    background: #e0e0e0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.gmg-swatch-card.active .gmg-swatch-check {
    display: flex;
    background: #c00;
    color: white;
}

/* Nasconde la select nativa di WooCommerce in sicurezza */
.woocommerce div.product form.cart .variations select {
    display: none !important;
}

/* Griglia degli swatches nel loop */
.gmg-loop-swatches-grid {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 15px;
    flex-wrap: wrap;
}

/* Isola rigorosamente lo stile solo sull'elemento specifico per evitare icone giganti altrove */
div.gmg-loop-swatches-grid .gmg-loop-swatch-item {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-color: transparent !important;
    border: 0px solid #eee !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1) !important;
    cursor: pointer;
    transition: transform 0.2s ease;
}

div.gmg-loop-swatches-grid .gmg-loop-swatch-item:hover {
    transform: scale(1.1);
    border-color: #c00 !important;
}

/* --- ZOOM IMMAGINE PRODOTTO (lightbox a schermo intero al click) --- */

body.gmg-lightbox-open {
    overflow: hidden !important;
}

.gmg-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 0;
    transition: opacity 0.25s ease;
    cursor: zoom-out;
}

.gmg-lightbox-img{
    background-color: white;
}

.gmg-lightbox-overlay.is-visible {
    opacity: 1;
}

.gmg-lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    cursor: default;
}

.gmg-lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 42px;
    line-height: 1;
    cursor: pointer;
    font-weight: 300;
    user-select: none;
}

/* Wrapper varianti WooCommerce: scroll orizzontale senza barra visibile.
   "overflow: scroll" forzava sempre la barra classica (visibile su Windows/desktop
   con mouse); con "auto" + scrollbar nascosta lo scroll funziona ma resta invisibile. */
.woocommerce div.product form.cart .variations {
    display: block;
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: none;    /* Firefox */
    -ms-overflow-style: none; /* Edge/IE legacy */
}

.woocommerce div.product form.cart .variations::-webkit-scrollbar {
    display: none;
    height: 0;
}
