/**
 * Sparklevida Smart Swatches
 * Auto-sizing variation swatches
 */

/* Hide default WooCommerce dropdowns when swatches active */
.sv-swatches-enabled .variations select {
    display: none !important;
}

/* Swatches Container */
.sv-swatches-wrap {
    margin: 15px 0;
}

.sv-swatches {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 10px;
}

/* Base Swatch */
.sv-swatch {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    background: var(--sv-bg-card, #fff);
    border: 2px solid var(--sv-border, rgba(0,0,0,0.1));
    border-radius: var(--sv-radius-sm, 8px);
    font-size: 14px;
    font-weight: 600;
    color: var(--sv-text, #333);
    cursor: pointer;
    transition: all 0.25s ease;
    min-height: 48px; /* Touch-friendly */
}

.sv-swatch:hover {
    border-color: var(--sv-accent, #B76E79);
    background: var(--sv-accent-glow, rgba(183, 110, 121, 0.08));
}

.sv-swatch.selected {
    border-color: var(--sv-accent, #B76E79);
    background: var(--sv-accent-glow, rgba(183, 110, 121, 0.12));
    box-shadow: 0 0 0 3px var(--sv-accent-glow, rgba(183, 110, 121, 0.15));
}

.sv-swatch.selected::after {
    content: '✓';
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: var(--sv-accent, #B76E79);
    color: white;
    border-radius: 50%;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Size variants for smart auto-sizing */
.sv-swatch-sm {
    /* Short labels: 1oz, 2oz, 4oz, 1lb, 1kg */
    min-width: 70px;
    flex: 0 0 auto;
}

.sv-swatch-md {
    /* Medium labels: 8oz Jar, 4oz Spray */
    min-width: 110px;
    flex: 0 0 auto;
}

.sv-swatch-lg {
    /* Long labels: 4oz Sprayer Bottle */
    min-width: 100%;
    flex: 1 1 100%;
}

/* Responsive grid behavior */
@media (min-width: 400px) {
    .sv-swatch-sm {
        flex: 0 0 calc(33.333% - 8px);
        min-width: 0;
    }
    
    .sv-swatch-md {
        flex: 0 0 calc(50% - 6px);
        min-width: 0;
    }
    
    .sv-swatch-lg {
        flex: 0 0 100%;
    }
}

@media (min-width: 600px) {
    .sv-swatch-sm {
        flex: 0 0 auto;
        min-width: 80px;
    }
    
    .sv-swatch-md {
        flex: 0 0 auto;
        min-width: 120px;
    }
    
    .sv-swatch-lg {
        flex: 0 0 auto;
        min-width: 160px;
    }
}

/* Disabled/Out of stock state */
.sv-swatch.disabled,
.sv-swatch[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    position: relative;
}

.sv-swatch.disabled::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 10%;
    right: 10%;
    height: 2px;
    background: var(--sv-text-muted, #999);
    transform: rotate(-15deg);
}

/* Stock indicator (optional) */
.sv-swatch-stock {
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    padding: 2px 6px;
    background: var(--sv-success, #4ade80);
    color: white;
    border-radius: 10px;
    white-space: nowrap;
}

.sv-swatch-stock.low {
    background: #f59e0b;
}

.sv-swatch-stock.out {
    background: var(--sv-error, #f87171);
}

/* Label inside swatch */
.sv-swatch-label {
    display: block;
    text-align: center;
    line-height: 1.2;
}

/* Variation table adjustments */
.sv-swatches-enabled .variations {
    margin-bottom: 20px;
}

.sv-swatches-enabled .variations tr {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
}

.sv-swatches-enabled .variations .label {
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--sv-text, #333);
}

.sv-swatches-enabled .variations .label label {
    font-size: 14px;
}

/* Reset variation link */
.sv-swatches-enabled .reset_variations {
    margin-top: 10px;
    font-size: 13px;
    color: var(--sv-accent, #B76E79);
}

/* Price update animation */
.sv-swatches-enabled .woocommerce-variation-price {
    transition: opacity 0.3s ease;
}

.sv-swatches-enabled .woocommerce-variation-price.updating {
    opacity: 0.5;
}
