/* CODwo Variation Swatches */

.codwo-swatches-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 10px 0;
}

.codwo-swatch-item {
    cursor: pointer;
    position: relative;
    transition: transform 0.16s ease;
}

.codwo-swatch-item:hover {
    transform: translateY(-1px);
}

.codwo-swatch-label {
    display: block;
    margin-top: 5px;
    text-align: center;
    font-size: 11px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--codwo-text-muted, #5c6f83);
    transition: color .18s ease, font-weight .18s ease;
}

.codwo-swatch-item.selected .codwo-swatch-label {
    color: var(--codwo-primary, #0f4c81);
    font-weight: 700;
}

/* Checkmark overlay on selected color + image swatches — floats at the top-inline-end corner.
   Button swatches keep the fill/text-swap selected style (no tick needed there). */
.codwo-swatch-color .codwo-swatch-item.selected,
.codwo-swatch-image .codwo-swatch-item.selected {
    position: relative;
}
.codwo-swatch-color .codwo-swatch-item.selected::after,
.codwo-swatch-image .codwo-swatch-item.selected::after {
    content: "";
    position: absolute;
    top: -4px;
    inset-inline-end: -4px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background-color: var(--codwo-primary, #0f4c81);
    background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 11px 11px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2), 0 0 0 2px #fff;
    z-index: 3;
    pointer-events: none;
    animation: codwo-swatch-tick-pop .22s ease-out;
}
@keyframes codwo-swatch-tick-pop {
    0%   { transform: scale(0.3); opacity: 0; }
    60%  { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Button swatches — firm up the selected state: bolder label + subtle glow ring */
.codwo-swatch-button .codwo-swatch-item.selected .codwo-button-swatch,
.codwo-swatch-item.selected .codwo-button-swatch {
    font-weight: 700;
    box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.14);
}

.codwo-swatch-color .codwo-color-swatch {
    display: block;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 8px rgba(15, 34, 54, 0.2);
}

.codwo-swatch-item.selected .codwo-color-swatch {
    border-color: var(--codwo-primary, #0f4c81);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.12);
}

.codwo-swatch-image .codwo-image-swatch {
    width: 62px;
    height: 62px;
    border-radius: 10px;
    object-fit: cover;
    border: 2px solid #d7dee8;
}

.codwo-swatch-item.selected .codwo-image-swatch,
.codwo-swatch-image .codwo-image-swatch:hover {
    border-color: var(--codwo-primary, #0f4c81);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.12);
}

.codwo-swatch-button .codwo-button-swatch {
    display: inline-block;
    min-width: 52px;
    padding: 10px 16px;
    border: 1px solid #c4d0de;
    border-radius: 10px;
    background: #fff;
    color: var(--codwo-text, #102235);
    font-size: 14px;
    line-height: 1.1;
    font-weight: 600;
    text-align: center;
}

.codwo-swatch-item.selected .codwo-button-swatch,
.codwo-button-swatch:hover {
    border-color: var(--codwo-primary, #0f4c81);
    color: var(--codwo-primary, #0f4c81);
    background: #eef4fb;
}

.codwo-swatch-item.out-of-stock {
    opacity: 0.42;
    cursor: not-allowed;
}

.codwo-swatch-item.out-of-stock::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 155%;
    transform: translate(-50%, -50%) rotate(45deg);
    background: #be4040;
}

/* Shape modifiers — applied to .codwo-swatches-wrapper via data-shape, or to individual items.
   !important ensures skin overrides (which redeclare border-radius for polish) cannot win
   over the user-selected shape in admin. */
.codwo-swatches-wrapper[data-shape="circle"] .codwo-color-swatch,
.codwo-swatches-wrapper[data-shape="circle"] .codwo-image-swatch,
.codwo-swatches-wrapper[data-shape="circle"] .codwo-button-swatch,
.codwo-swatch-item.codwo-shape-circle .codwo-color-swatch,
.codwo-swatch-item.codwo-shape-circle .codwo-image-swatch,
.codwo-swatch-item.codwo-shape-circle .codwo-button-swatch {
    border-radius: 999px !important;
    aspect-ratio: 1 / 1;
    width: var(--codwo-swatch-size, 42px);
    height: var(--codwo-swatch-size, 42px);
    min-width: 0;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.codwo-swatches-wrapper[data-shape="square"] .codwo-color-swatch,
.codwo-swatches-wrapper[data-shape="square"] .codwo-image-swatch,
.codwo-swatches-wrapper[data-shape="square"] .codwo-button-swatch,
.codwo-swatch-item.codwo-shape-square .codwo-color-swatch,
.codwo-swatch-item.codwo-shape-square .codwo-image-swatch,
.codwo-swatch-item.codwo-shape-square .codwo-button-swatch {
    border-radius: 2px !important;
}

.codwo-swatches-wrapper[data-shape="rounded-square"] .codwo-color-swatch,
.codwo-swatches-wrapper[data-shape="rounded-square"] .codwo-image-swatch,
.codwo-swatches-wrapper[data-shape="rounded-square"] .codwo-button-swatch,
.codwo-swatch-item.codwo-shape-rounded-square .codwo-color-swatch,
.codwo-swatch-item.codwo-shape-rounded-square .codwo-image-swatch,
.codwo-swatch-item.codwo-shape-rounded-square .codwo-button-swatch {
    border-radius: 8px !important;
}

.codwo-swatches-wrapper[data-shape="round"] .codwo-color-swatch,
.codwo-swatches-wrapper[data-shape="round"] .codwo-image-swatch,
.codwo-swatches-wrapper[data-shape="round"] .codwo-button-swatch,
.codwo-swatch-item.codwo-shape-round .codwo-color-swatch,
.codwo-swatch-item.codwo-shape-round .codwo-image-swatch,
.codwo-swatch-item.codwo-shape-round .codwo-button-swatch {
    border-radius: 999px !important;
}

/* Per-attribute size variable — wrapper sets --codwo-swatch-size from PHP */
.codwo-swatches-wrapper[style*="--codwo-swatch-size"] .codwo-color-swatch,
.codwo-swatch-item[style*="--codwo-swatch-size"] .codwo-color-swatch {
    width: var(--codwo-swatch-size);
    height: var(--codwo-swatch-size);
}

.codwo-swatches-wrapper[style*="--codwo-swatch-size"] .codwo-image-swatch,
.codwo-swatch-item[style*="--codwo-swatch-size"] .codwo-image-swatch {
    width: calc(var(--codwo-swatch-size) * 1.5);
    height: calc(var(--codwo-swatch-size) * 1.5);
}

.codwo-swatches-wrapper[style*="--codwo-swatch-size"] .codwo-button-swatch,
.codwo-swatch-item[style*="--codwo-swatch-size"] .codwo-button-swatch {
    min-height: var(--codwo-swatch-size);
    line-height: 1.1;
}

@media (max-width: 576px) {
    .codwo-swatch-color .codwo-color-swatch {
        width: 36px;
        height: 36px;
    }

    .codwo-swatch-image .codwo-image-swatch {
        width: 54px;
        height: 54px;
    }

    .codwo-swatch-button .codwo-button-swatch {
        padding: 8px 12px;
        font-size: 13px;
    }
}
