/* =============================================
   CayXinh Variation Swatches — Custom (no plugin)
   ============================================= */

/* Wrapper */
.cxs-swatches-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

/* Individual swatch */
.cxs-swatch {
    position: relative;
    min-width: 60px;
    height: 36px;
    padding: 0 10px;
    border-radius: 4px;
    cursor: pointer;
    overflow: hidden;
    border: 2px solid #ddd;
    transition: border-color 0.18s ease, transform 0.15s ease, box-shadow 0.18s ease;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cxs-swatch img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease;
    pointer-events: none;
}

/* Label swatch (text button content) */
.cxs-swatch .cxs-label {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
}

/* Tooltip (attribute name) */
.cxs-swatch::after {
    content: attr(data-label);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: rgba(0,0,0,0.78);
    color: #fff;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 10;
}

.cxs-swatch:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Hover state */
.cxs-swatch:hover:not(.disabled) {
    border-color: #8cca46;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(140, 202, 70, 0.35);
}

.cxs-swatch:hover:not(.disabled) img {
    transform: scale(1.06);
}

/* Selected state */
.cxs-swatch.selected {
    border-color: #00b214;
    box-shadow: 0 0 0 3px rgba(0, 178, 20, 0.2);
    transform: translateY(-1px);
}

/* Selected checkmark */
.cxs-swatch.selected::before {
    content: '✓';
    position: absolute;
    top: 3px;
    right: 4px;
    width: 18px;
    height: 18px;
    background: #00b214;
    color: white;
    font-size: 11px;
    font-weight: bold;
    line-height: 18px;
    text-align: center;
    border-radius: 50%;
    z-index: 2;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Disabled / out of stock */
.cxs-swatch.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
    border-color: transparent !important;
}

/* Strikethrough line for disabled */
.cxs-swatch.disabled::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(
        to bottom right,
        transparent 45%,
        rgba(200,0,0,0.55) 45%,
        rgba(200,0,0,0.55) 55%,
        transparent 55%
    );
    z-index: 3;
    pointer-events: none;
}

/* Hidden original WooCommerce select */
.cxs-hidden-select {
    display: none !important;
}

/* Attribute label above swatches */
.cxs-attr-label {
    font-size: 14px;
    color: #555;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cxs-attr-label strong {
    color: #222;
    font-weight: 600;
}

.cxs-selected-name {
    color: #00b214;
    font-weight: 500;
}

/* Variation image preview fade transition */
.woocommerce-product-gallery__image {
    transition: opacity 0.25s ease;
}

/* Admin: swatch image upload */
.cxs-term-image-wrap {
    margin-top: 12px;
}

.cxs-term-image-wrap img.cxs-preview {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #ddd;
    margin-bottom: 8px;
    display: block;
}

.cxs-term-image-wrap .button {
    margin-right: 6px;
}

/* Responsive */
@media (max-width: 480px) {
    .cxs-swatch {
        width: 58px;
        height: 58px;
    }
}
