/**
 * GS Variation Swatches - Minimal & Luxury Frontend Stylesheet
 * Author: Giulio Soligo
 */

:root {
    --gs-swatch-accent: #ca3c08;
}

/* ==========================================================================
   Layout Form Variazioni WooCommerce
   ========================================================================== */
.variations_form table.variations {
    width: 100%;
    margin-bottom: 1.2em;
    border: none;
}

.variations_form table.variations tbody,
.variations_form table.variations tr {
    display: block;
    border: none;
    width: 100%;
}

.variations_form table.variations th.label {
    display: block;
    width: 100%;
    padding: 0 0 10px 0;
    text-align: left;
    font-size: 15px;
    font-weight: 700;
    color: #2c2523;
}

.variations_form table.variations td.value {
    display: block;
    width: 100%;
    padding: 0;
}

.gs-swatches-wrapper {
    margin: 4px 0 18px;
    display: block;
    clear: both;
}

.gs-swatches-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: center;
}

/* ==========================================================================
   Swatch Item Base (Pulsante Minimal)
   ========================================================================== */
.gs-swatch-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    height: 38px;
    padding: 6px 16px;
    background-color: #ffffff;
    color: #2c2523;
    border: 1.5px solid #dcd7cc;
    box-sizing: border-box;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    user-select: none;
    outline: none;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.gs-swatch-item:hover:not(.gs-out-of-stock) {
    border-color: var(--gs-swatch-accent, #ca3c08);
    color: var(--gs-swatch-accent, #ca3c08);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}

.gs-swatch-item:focus-visible {
    outline: 2px solid var(--gs-swatch-accent, #ca3c08);
    outline-offset: 2px;
}

/* ==========================================================================
   Stato Selezionato (Active)
   ========================================================================== */
.gs-swatch-item.selected {
    background-color: var(--gs-swatch-accent, #ca3c08) !important;
    border-color: var(--gs-swatch-accent, #ca3c08) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(202, 60, 8, 0.28) !important;
    transform: translateY(-1px);
}

.gs-swatch-item.selected .gs-text-label {
    color: #ffffff !important;
}

/* ==========================================================================
   Forme (Shapes)
   ========================================================================== */
.gs-shape-pill .gs-swatch-item {
    border-radius: 24px;
}

.gs-shape-rounded-10 .gs-swatch-item {
    border-radius: 10px;
}

.gs-shape-rounded .gs-swatch-item {
    border-radius: 6px;
}

.gs-shape-square .gs-swatch-item {
    border-radius: 0px;
}

/* ==========================================================================
   Color & Image Swatches
   ========================================================================== */
.gs-swatch-item.gs-swatch-color,
.gs-swatch-item.gs-swatch-image {
    padding: 3px;
    width: 38px;
    min-width: 38px;
    height: 38px;
}

.gs-color-preview {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    box-shadow: inset 0 0 1px rgba(0,0,0,0.2);
}

.gs-image-preview {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

/* ==========================================================================
   Gestione Varianti Esaurite (Out Of Stock)
   ========================================================================== */
.gs-swatch-item.gs-out-of-stock {
    cursor: not-allowed;
    opacity: 0.42;
    background-color: #f8fafc;
    border-color: #e2e8f0;
    color: #94a3b8;
}

/* Sbarrato diagonale */
.gs-swatch-item.gs-out-of-stock::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1.5px;
    background-color: #ef4444;
    transform: rotate(-35deg);
    transform-origin: center;
    pointer-events: none;
}

/* Nascondi completamente se configurato */
.gs-behavior-hide .gs-swatch-item.gs-out-of-stock {
    display: none !important;
}

/* Scuotimento errore al clic su elemento esaurito */
@keyframes gs-shake-anim {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

.gs-swatch-item.gs-shake {
    animation: gs-shake-anim 0.35s ease-in-out;
}

/* ==========================================================================
   Tooltips (Disattivati per pulsanti di solo testo per massima pulizia)
   ========================================================================== */
.gs-swatch-button .gs-tooltip {
    display: none !important;
}

.gs-tooltip {
    position: absolute;
    bottom: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background-color: #1e293b;
    color: #ffffff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11.5px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.15s ease-in-out;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    z-index: 99;
}

.gs-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 4px;
    border-style: solid;
    border-color: #1e293b transparent transparent transparent;
}

.gs-swatch-color:hover .gs-tooltip,
.gs-swatch-image:hover .gs-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Reset / Svuota selezioni nativo WooCommerce */
.reset_variations {
    font-size: 13px !important;
    color: #888888 !important;
    text-decoration: underline !important;
    margin-top: 6px !important;
    display: inline-block !important;
    transition: color 0.15s ease;
}

.reset_variations:hover {
    color: var(--gs-swatch-accent, #ca3c08) !important;
}
