/* WooCommerce Color Swatches Styles */
.wc-swatches-attribute {
    display: flex !important;
    flex-direction: column;
    margin: 15px 0;
    clear: both;
}

.wc-swatches-label {
    font-weight: bold;
    margin-bottom: 10px;
    display: block;
}

.wc-swatches-container {
    display: flex !important;
    flex-wrap: wrap;
    gap: 20px;
}

.wc-swatch-wrapper {
    display: inline-block;
    position: relative;
}

.wc-swatch {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    position: relative;
    display: block;
}

.wc-swatch:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.wc-swatch.selected {
    border-color: #333;
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.wc-swatch.selected::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    font-size: 16px;
}

/* Tooltip styles */
.wc-swatch-wrapper {
    position: relative;
}

.wc-swatch-wrapper::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 1000;
    margin-bottom: 8px;
}

.wc-swatch-wrapper::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 1000;
    margin-bottom: -2px;
}

.wc-swatch-wrapper:hover::before,
.wc-swatch-wrapper:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Hide the original dropdown but keep it functional */
.variations select {
    display: none !important;
}

/* Ensure variation forms work correctly */
.variations .wc-swatches-attribute {
    display: flex !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .wc-swatch {
        width: 35px;
        height: 35px;
    }
    
    .wc-swatches-container {
        gap: 15px;
    }
}

/* Fallback for missing colors - checkerboard pattern */
.wc-swatch[style*="background-color: ;"],
.wc-swatch[style*="background-color:;"],
.wc-swatch:not([style*="background-color"]) {
    background: 
        linear-gradient(45deg, #f0f0f0 25%, transparent 25%), 
        linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #f0f0f0 75%), 
        linear-gradient(-45deg, transparent 75%, #f0f0f0 75%) !important;
    background-size: 4px 4px !important;
    background-position: 0 0, 0 2px, 2px -2px, -2px 0px !important;
    border: 1px solid #ddd !important;
}

/* Color preview for specific named colors */
.wc-swatch[data-value="red"] { background-color: #ff0000 !important; }
.wc-swatch[data-value="blue"] { background-color: #0000ff !important; }
.wc-swatch[data-value="green"] { background-color: #008000 !important; }
.wc-swatch[data-value="black"] { background-color: #000000 !important; }
.wc-swatch[data-value="white"] { 
    background-color: #ffffff !important; 
    border: 1px solid #ddd !important;
}
.wc-swatch[data-value="yellow"] { background-color: #ffff00 !important; }
.wc-swatch[data-value="orange"] { background-color: #ffa500 !important; }
.wc-swatch[data-value="purple"] { background-color: #800080 !important; }