/**
 * Webup Woo - Swatches Styles
 */

/* Swatches container */
.webup-woo-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* Base swatch */
.webup-woo-swatch {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.webup-woo-swatch input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.webup-woo-swatch.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.webup-woo-swatch.disabled::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: var(--webup-woo-text, #333333);
    transform: rotate(-45deg);
}

/* Color swatch */
.webup-woo-swatch-color .webup-woo-swatch-inner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--webup-woo-border, #e0e0e0);
    box-shadow: inset 0 0 0 2px var(--webup-woo-bg, #ffffff);
    transition: all 0.2s ease;
}

.webup-woo-swatch-color:hover .webup-woo-swatch-inner {
    transform: scale(1.1);
}

.webup-woo-swatch-color input:checked + .webup-woo-swatch-inner {
    border-color: var(--webup-woo-primary, #333333);
    box-shadow: inset 0 0 0 2px var(--webup-woo-bg, #ffffff), 0 0 0 2px var(--webup-woo-primary, #333333);
}

/* Large color swatch */
.webup-woo-swatches.size-large .webup-woo-swatch-color .webup-woo-swatch-inner {
    width: 44px;
    height: 44px;
}

/* Small color swatch */
.webup-woo-swatches.size-small .webup-woo-swatch-color .webup-woo-swatch-inner {
    width: 28px;
    height: 28px;
}

/* Image swatch */
.webup-woo-swatch-image .webup-woo-swatch-inner {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    border: 2px solid var(--webup-woo-border, #e0e0e0);
    background-size: cover;
    background-position: center;
    transition: all 0.2s ease;
}

.webup-woo-swatch-image:hover .webup-woo-swatch-inner {
    transform: scale(1.05);
}

.webup-woo-swatch-image input:checked + .webup-woo-swatch-inner {
    border-color: var(--webup-woo-primary, #333333);
    box-shadow: 0 0 0 2px var(--webup-woo-primary, #333333);
}

/* Large image swatch */
.webup-woo-swatches.size-large .webup-woo-swatch-image .webup-woo-swatch-inner {
    width: 56px;
    height: 56px;
}

/* Small image swatch */
.webup-woo-swatches.size-small .webup-woo-swatch-image .webup-woo-swatch-inner {
    width: 36px;
    height: 36px;
}

/* Button/Label swatch */
.webup-woo-swatch-button .webup-woo-swatch-inner {
    min-width: 40px;
    height: 40px;
    padding: 0 15px;
    border-radius: 4px;
    border: 1px solid var(--webup-woo-border, #e0e0e0);
    background-color: var(--webup-woo-bg, #ffffff);
    font-size: 14px;
    font-weight: 500;
    color: var(--webup-woo-text, #333333);
    transition: all 0.2s ease;
}

.webup-woo-swatch-button:hover .webup-woo-swatch-inner {
    border-color: var(--webup-woo-primary, #333333);
}

.webup-woo-swatch-button input:checked + .webup-woo-swatch-inner {
    background-color: var(--webup-woo-primary, #333333);
    border-color: var(--webup-woo-primary, #333333);
    color: #ffffff;
}

/* Large button swatch */
.webup-woo-swatches.size-large .webup-woo-swatch-button .webup-woo-swatch-inner {
    height: 48px;
    padding: 0 20px;
    font-size: 15px;
}

/* Small button swatch */
.webup-woo-swatches.size-small .webup-woo-swatch-button .webup-woo-swatch-inner {
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
}

/* Swatch tooltip */
.webup-woo-swatch[data-tooltip] {
    position: relative;
}

.webup-woo-swatch[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    background-color: var(--webup-woo-text, #333333);
    color: #ffffff;
    font-size: 12px;
    white-space: nowrap;
    border-radius: 4px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    margin-bottom: 8px;
    z-index: 10;
}

.webup-woo-swatch[data-tooltip]::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--webup-woo-text, #333333);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    margin-bottom: -2px;
}

.webup-woo-swatch[data-tooltip]:hover::before,
.webup-woo-swatch[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Swatches in product card */
.webup-woo-product-card .webup-woo-swatches {
    gap: 5px;
}

.webup-woo-product-card .webup-woo-swatch-color .webup-woo-swatch-inner {
    width: 24px;
    height: 24px;
}

.webup-woo-product-card .webup-woo-swatch-image .webup-woo-swatch-inner {
    width: 28px;
    height: 28px;
    border-radius: 4px;
}

.webup-woo-product-card .webup-woo-swatch-button .webup-woo-swatch-inner {
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    font-size: 11px;
}

/* Dropdown fallback (when swatches not available) */
.webup-woo-select-wrapper {
    position: relative;
}

.webup-woo-select {
    width: 100%;
    padding: 12px 40px 12px 15px;
    font-size: 14px;
    border: 1px solid var(--webup-woo-border, #e0e0e0);
    border-radius: 4px;
    background-color: var(--webup-woo-bg, #ffffff);
    color: var(--webup-woo-text, #333333);
    cursor: pointer;
    appearance: none;
}

.webup-woo-select:focus {
    outline: none;
    border-color: var(--webup-woo-primary, #333333);
}

.webup-woo-select-wrapper::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--webup-woo-light-text, #666666);
    pointer-events: none;
}

/* Clear selection */
.webup-woo-clear-selection {
    display: inline-block;
    margin-top: 10px;
    font-size: 13px;
    color: var(--webup-woo-light-text, #666666);
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.2s ease;
}

.webup-woo-clear-selection:hover {
    color: var(--webup-woo-primary, #333333);
}

/* Selected variation display */
.webup-woo-selected-variation {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
    padding: 12px 15px;
    background-color: var(--webup-woo-bg-alt, #f9f9f9);
    border-radius: 6px;
    font-size: 14px;
}

.webup-woo-selected-variation-label {
    font-weight: 500;
    color: var(--webup-woo-text, #333333);
}

.webup-woo-selected-variation-value {
    color: var(--webup-woo-light-text, #666666);
}

/* Variation image preview */
.webup-woo-swatch.has-image:hover .webup-woo-swatch-preview {
    display: block;
}

.webup-woo-swatch-preview {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 100px;
    margin-bottom: 10px;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.webup-woo-swatch-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Variation price update */
.webup-woo-variation-price {
    display: none;
}

.webup-woo-variation-price.active {
    display: block;
}

/* Out of stock variation styling */
.webup-woo-swatch.out-of-stock .webup-woo-swatch-inner {
    opacity: 0.5;
}

.webup-woo-swatch.out-of-stock::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: var(--webup-woo-sale, #e74c3c);
    transform: rotate(-45deg);
    z-index: 1;
}

/* Responsive */
@media (max-width: 768px) {
    .webup-woo-swatch-color .webup-woo-swatch-inner {
        width: 32px;
        height: 32px;
    }

    .webup-woo-swatch-image .webup-woo-swatch-inner {
        width: 40px;
        height: 40px;
    }

    .webup-woo-swatch-button .webup-woo-swatch-inner {
        min-width: 36px;
        height: 36px;
        padding: 0 12px;
        font-size: 13px;
    }
}
