/**
 * WC Product Swatches & Badges - Swatches CSS
 */

/* Wrapper */
.wc-psb-swatches-wrapper {
    margin: 20px 0;
}

/* Label */
.wc-psb-swatches-label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 14px;
    color: #333;
}

.wc-psb-swatches-label .required {
    color: #e74c3c;
    margin-left: 3px;
}

/* Swatches container - uses inline styles for gap */
.wc-psb-swatches {
    display: flex;
    flex-wrap: wrap;
    /* gap is set via inline CSS from settings */
}

/* Individual swatch - uses inline styles for size, border-radius */
.wc-psb-swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* width, height, border, border-radius set via inline CSS */
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

.wc-psb-swatch:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Letter fallback */
.wc-psb-swatch-letter {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
}

/* Selected indicator */
.wc-psb-swatch.selected::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    text-shadow: 0 0 3px rgba(0,0,0,0.8);
}

/* Dark background check mark adjustment */
.wc-psb-swatch.selected.dark-bg::after {
    color: #fff;
}

.wc-psb-swatch.selected.light-bg::after {
    color: #333;
    text-shadow: 0 0 3px rgba(255,255,255,0.8);
}

/* Tooltip enhancement */
.wc-psb-swatch[title] {
    position: relative;
}

/* Custom tooltip (optional enhancement) */
.wc-psb-swatch::before {
    content: attr(data-name);
    position: absolute;
    bottom: calc(100% + 8px);
    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: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    z-index: 100;
}

.wc-psb-swatch::after {
    /* Only if we want custom tooltip arrow */
}

/* Show tooltip on hover */
.wc-psb-swatches-wrapper[data-tooltip="custom"] .wc-psb-swatch:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Selected color display */
.wc-psb-selected-color {
    margin-top: 12px;
    font-size: 14px;
    padding: 8px 12px;
    background: #f7f7f7;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.wc-psb-selected-label {
    color: #666;
}

.wc-psb-selected-value {
    font-weight: 600;
    color: #333;
}

/* Validation error state */
.wc-psb-swatches-wrapper.has-error .wc-psb-swatches {
    border: 2px solid #e74c3c;
    padding: 5px;
    border-radius: 4px;
}

.wc-psb-swatches-wrapper.has-error .wc-psb-swatches-label {
    color: #e74c3c;
}

/* Out of stock swatch */
.wc-psb-swatch.out-of-stock {
    opacity: 0.4;
    cursor: not-allowed;
    position: relative;
}

.wc-psb-swatch.out-of-stock::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom right,
        transparent calc(50% - 1px),
        #e74c3c calc(50% - 1px),
        #e74c3c calc(50% + 1px),
        transparent calc(50% + 1px)
    );
}

/* Disabled state */
.wc-psb-swatch.disabled {
    pointer-events: none;
    opacity: 0.5;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .wc-psb-swatches {
        gap: 6px !important;
    }
    
    .wc-psb-swatch {
        width: 35px !important;
        height: 35px !important;
    }
}

/* Animation */
@keyframes wc-psb-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0,0,0,0.2);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(0,0,0,0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0,0,0,0);
    }
}

.wc-psb-swatch.selected {
    animation: wc-psb-pulse 0.3s ease-out;
}
