/**
 * =========================================================
 * XPLOUDSPORT — COLOR SWATCHES
 * Miniaturas de variantes com troca de imagem
 * =========================================================
 */

/* =========================================================
   SWATCH CONTAINER (no product card)
   ========================================================= */
.xs-swatches {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    flex-wrap: wrap;
}

/* =========================================================
   SWATCH ITEM (Cada miniatura de cor)
   ========================================================= */
.xs-swatch {
    position: relative;
    width: 36px;
    height: 44px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.15s;
    background: #fff;
    padding: 0;
    appearance: none;
    -webkit-appearance: none;
}


.xs-swatch:hover {
    border-color: #999;
}

.xs-swatch.active {
    border-color: var(--xs-color-primary);
    border-width: 2px;
    box-shadow: 0 0 0 1px var(--xs-color-primary);
}

.xs-swatch.out-of-stock {
    opacity: 0.45;
    cursor: pointer; /* Permite clicar para ver "Avise-me" */
}

.xs-swatch.out-of-stock::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg,
        transparent 45%,
        #ccc 45%,
        #ccc 55%,
        transparent 55%
    );
    pointer-events: none;
}

/* Imagem do swatch */
.xs-swatch__image {
    width: 100%;
    height: 100%;
    object-fit: fill;
    object-position: center;
    display: block;
}

/* Swatch de cor sólida (quando não tem imagem) */
.xs-swatch__color {
    width: 100%;
    height: 100%;
}

/* Tooltip do swatch */
.xs-swatch__tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    font-size: 0.6875rem;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.15s;
    pointer-events: none;
    z-index: 10;
}

.xs-swatch:hover .xs-swatch__tooltip {
    opacity: 1;
    visibility: visible;
}

.xs-swatch__tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #333;
}

/* =========================================================
   SWATCH NO SINGLE PRODUCT
   ========================================================= */
.xs-single-product .xs-swatches {
    gap: 6px;
}

.xs-single-product .xs-swatch {
    width: 58px;
    height: 76px;
    border-radius: 4px;
}

.xs-single-product .xs-swatch.active {
    border-width: 2px;
}

/* =========================================================
   SWATCH GROUP (Cor + Tamanho)
   ========================================================= */
.xs-variant-group {
    margin-bottom: 16px;
}

.xs-variant-group__label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.xs-variant-group__label span {
    font-weight: 400;
    color: #666;
}

/* =========================================================
   SWATCH EM GRID/VITRINE (modo compacto)
   ========================================================= */
.xs-product-card .xs-swatches {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 2px;
    padding: 4px 8px;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(4px);
    opacity: 0;
    transform: translateY(4px);
    transition: all 0.2s;
    z-index: 2;
}

.xs-product-card:hover .xs-swatches {
    opacity: 1;
    transform: translateY(0);
}

.xs-product-card .xs-swatch {
    width: 28px;
    height: 34px;
    border-radius: 2px;
}

/* =========================================================
   SWATCH SELETOR (troca imagem principal)
   ========================================================= */
.xs-swatch-selector {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.xs-swatch-selector__label {
    font-size: 0.875rem;
    font-weight: 600;
}

.xs-swatch-selector__current {
    font-weight: 400;
    color: #666;
}

/* =========================================================
   ANIMAÇÃO DE TROCA DE IMAGEM
   ========================================================= */
.xs-image-transition {
    transition: opacity 0.2s ease;
}

.xs-image-transition.loading {
    opacity: 0.5;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 768px) {
    .xs-single-product .xs-swatch {
        width: 48px;
        height: 62px;
    }

    .xs-product-card .xs-swatch {
        width: 24px;
        height: 30px;
    }
}

@media (max-width: 480px) {
    .xs-single-product .xs-swatch {
        width: 42px;
        height: 54px;
    }
}
