/* WooCommerce Visual Variations - Optimized Styles */
/* Version: 1.1.0 */

/* ========================================
   VARIABLES (CSS Custom Properties)
   ======================================== */
:root {
    --wcvv-primary-color: #000;
    --wcvv-border-color: #ddd;
    --wcvv-border-radius: 4px;
    --wcvv-transition: all 0.3s ease;
    --wcvv-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --wcvv-shadow-md: 0 4px 8px rgba(0, 0, 0, 0.1);
    --wcvv-shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.2);
    --wcvv-gap: 10px;
    --wcvv-color-swatch-size: 32px;
}

/* ========================================
   CONTAINER
   ======================================== */
.wcvv-variations-wrapper {
    margin-bottom: 20px;
}

/* Hide default select */
.wcvv-hidden-select {
    display: none !important;
    visibility: hidden !important;
}

/* ========================================
   OPTIONS CONTAINER
   ======================================== */
.wcvv-options-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--wcvv-gap);
    margin-top: 10px;
    align-items: flex-start;
}

/* ========================================
   INDIVIDUAL OPTION
   ======================================== */
.wcvv-option {
    position: relative;
    cursor: pointer;
    transition: var(--wcvv-transition);
    /* Prevent text selection */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Hover effect - only for non-touch devices */
@media (hover: hover) and (pointer: fine) {
    .wcvv-option:hover:not(.wcvv-disabled) {
        transform: translateY(-2px);
    }
}

/* Focus state for keyboard navigation */
.wcvv-option:focus {
    outline: 2px solid var(--wcvv-primary-color);
    outline-offset: 2px;
}

.wcvv-option:focus:not(:focus-visible) {
    outline: none;
}

/* ========================================
   COLOR SWATCHES
   ======================================== */
.wcvv-color-container {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 2px solid transparent;
    border-radius: 6px;
    transition: var(--wcvv-transition);
    cursor: pointer;
    background-color: #fff;
    /* Better rendering */
    will-change: border-color, background-color;
}

@media (hover: hover) {
    .wcvv-option:hover .wcvv-color-container {
        background-color: #f8f9fa;
        border-color: var(--wcvv-border-color);
    }
}

.wcvv-option.wcvv-selected .wcvv-color-container {
    border-color: var(--wcvv-primary-color);
    background-color: #f8f9fa;
}

.wcvv-color-swatch {
    display: inline-block;
    width: var(--wcvv-color-swatch-size);
    height: var(--wcvv-color-swatch-size);
    border-radius: 50%;
    border: 2px solid transparent;
    position: relative;
    transition: var(--wcvv-transition);
    flex-shrink: 0;
    box-shadow: var(--wcvv-shadow-sm);
    /* GPU acceleration */
    transform: translateZ(0);
    backface-visibility: hidden;
}

@media (hover: hover) {
    .wcvv-option:hover .wcvv-color-swatch {
        box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
    }
}

.wcvv-option.wcvv-selected .wcvv-color-swatch {
    border-width: 3px;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--wcvv-primary-color);
}

.wcvv-color-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    line-height: 1.2;
}

/* ========================================
   BUTTON/TEXT SWATCHES
   ======================================== */
.wcvv-button-swatch {
    display: inline-block;
    padding: 10px 20px;
    border: 2px solid var(--wcvv-border-color);
    border-radius: var(--wcvv-border-radius);
    background-color: #fff;
    font-size: 14px;
    font-weight: 500;
    transition: var(--wcvv-transition);
    cursor: pointer;
    min-width: 60px;
    text-align: center;
    box-shadow: var(--wcvv-shadow-sm);
    line-height: 1.2;
    /* GPU acceleration */
    transform: translateZ(0);
    backface-visibility: hidden;
}

@media (hover: hover) {
    .wcvv-option:hover .wcvv-button-swatch {
        border-color: #999;
        box-shadow: var(--wcvv-shadow-md);
    }
}

.wcvv-option.wcvv-selected .wcvv-button-swatch {
    background-color: var(--wcvv-primary-color);
    color: #fff;
    border-color: var(--wcvv-primary-color);
    box-shadow: var(--wcvv-shadow-lg);
}

/* ========================================
   DISABLED STATE
   ======================================== */
.wcvv-option.wcvv-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.wcvv-option.wcvv-disabled .wcvv-color-container,
.wcvv-option.wcvv-disabled .wcvv-button-swatch {
    position: relative;
}

/* Diagonal line through disabled options */
.wcvv-option.wcvv-disabled .wcvv-color-container::after,
.wcvv-option.wcvv-disabled .wcvv-button-swatch::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 5%;
    right: 5%;
    height: 2px;
    background-color: #dc3545;
    transform: translateY(-50%) rotate(-15deg);
    pointer-events: none;
    /* Ensure line is visible */
    z-index: 1;
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.wcvv-option.wcvv-just-selected {
    animation: pulse 0.3s ease;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .wcvv-option,
    .wcvv-color-container,
    .wcvv-color-swatch,
    .wcvv-button-swatch {
        transition: none !important;
        animation: none !important;
    }
    
    .wcvv-option:hover:not(.wcvv-disabled) {
        transform: none !important;
    }
}

/* ========================================
   LOADING STATE
   ======================================== */
.wcvv-variations-wrapper.wcvv-loading .wcvv-options-container {
    opacity: 0.6;
    pointer-events: none;
}

/* ========================================
   VARIATIONS FORM ADJUSTMENTS
   ======================================== */
.variations .label {
    font-weight: 600;
    margin-bottom: 5px;
    display: block;
}

.variations .value {
    margin-bottom: 15px;
}

/* ========================================
   RESPONSIVE - TABLET
   ======================================== */
@media (max-width: 768px) {
    :root {
        --wcvv-gap: 8px;
        --wcvv-color-swatch-size: 28px;
    }
    
    .wcvv-color-container {
        gap: 6px;
        padding: 5px 10px;
    }
    
    .wcvv-color-name {
        font-size: 13px;
    }
    
    .wcvv-button-swatch {
        padding: 8px 16px;
        font-size: 13px;
        min-width: 50px;
    }
}

/* ========================================
   RESPONSIVE - MOBILE
   ======================================== */
@media (max-width: 480px) {
    :root {
        --wcvv-gap: 6px;
        --wcvv-color-swatch-size: 24px;
    }
    
    .wcvv-color-container {
        gap: 6px;
        padding: 4px 8px;
    }
    
    .wcvv-color-name {
        font-size: 12px;
    }
    
    .wcvv-button-swatch {
        padding: 6px 12px;
        font-size: 12px;
        min-width: 45px;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
/* Screen reader only text */
.wcvv-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .wcvv-button-swatch {
        border-width: 3px;
    }
    
    .wcvv-color-swatch {
        border-width: 3px;
    }
    
    .wcvv-option.wcvv-selected .wcvv-color-swatch {
        box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--wcvv-primary-color);
    }
}

/* ========================================
   RTL SUPPORT
   ======================================== */
[dir="rtl"] .wcvv-options-container {
    direction: rtl;
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    .wcvv-option:hover {
        transform: none !important;
    }
    
    .wcvv-color-swatch,
    .wcvv-button-swatch {
        box-shadow: none !important;
    }
}

/* ========================================
   DARK MODE SUPPORT (Optional)
   ======================================== */
@media (prefers-color-scheme: dark) {
    .wcvv-color-container {
        background-color: #1a1a1a;
    }
    
    .wcvv-option.wcvv-selected .wcvv-color-container,
    .wcvv-option:hover .wcvv-color-container {
        background-color: #2a2a2a;
    }
    
    .wcvv-button-swatch {
        background-color: #1a1a1a;
        border-color: #444;
        color: #fff;
    }
    
    .wcvv-color-name {
        color: #e0e0e0;
    }
}
