/* =============================================
   CayXinh Variation Swatches — khớp thiết kế mẫu
   ============================================= */

/* Row Container: Align Label and Swatches inline */
.cxs-swatch-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 15px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Wrap swatches: Flex layout with auto-width */
.cxs-swatches-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 0;
    flex: 1;
    min-width: 0;
    max-width: 100%;
}

/* Nút swatch: compact, width auto, small and beautiful */
.cxs-swatch {
    position: relative;
    border: 1.5px solid #bbb;
    background: #fff;
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 13.5px;
    cursor: pointer;
    text-align: center;
    line-height: 1.3;
    transition: border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
    color: #333;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    height: auto;
    width: auto;
    overflow: hidden;
    box-sizing: border-box;
    /* Native button resets */
    font-family: inherit;
    margin: 0;
    outline: none;
    box-shadow: none;
    text-shadow: none;
    text-transform: none;
}

.woocommerce div.product form.cart .variations {
    margin-bottom: 0;
    border: 0;
    width: 100%;
    table-layout: fixed;
}

/* Label text */
.cxs-swatch .cxs-label {
    font-size: 13.5px;
    color: inherit;
    white-space: nowrap;
    line-height: 1.3;
    text-align: center;
}

/* Hover */
.cxs-swatch:hover:not(.disabled) {
    border-color: #105029;
    color: #105029;
}

/* Selected / active */
.cxs-swatch.selected {
    border-color: #105029;
    background: #f0f9eb;
    color: #105029;
    font-weight: 600;
}

/* Checkmark góc phải khi selected */
.cxs-swatch.selected::after {
    content: "";
    position: absolute;
    bottom: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 16px 16px;
    border-color: transparent transparent #105029 transparent;
    z-index: 1;
}

.cxs-swatch.selected::before {
    content: "✓" !important;
    display: block !important;
    position: absolute;
    bottom: -1px;
    right: 1px;
    color: #fff;
    font-size: 9px;
    font-weight: 900;
    line-height: 1;
    z-index: 2;
}

/* Disabled / out of stock */
.cxs-swatch.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: #e0e0e0 !important;
    background: #fafafa !important;
    color: #aaa !important;
}

/* Strikethrough cho hết hàng */
.cxs-swatch.disabled::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom right,
            transparent 45%,
            rgba(200, 0, 0, 0.45) 45%,
            rgba(200, 0, 0, 0.45) 55%,
            transparent 55%);
    pointer-events: none;
}

/* Hidden select gốc của WooCommerce */
.cxs-hidden-select {
    display: none !important;
}

/* Attribute label */
.cxs-attr-label {
    font-size: 15px;
    color: #333;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    margin-top: 5px;
}

.cxs-attr-label strong {
    color: #105029;
    font-weight: 700;
}

.cxs-selected-name {
    color: #c67c00;
    font-weight: 600;
}

/* Admin preview */
.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: 2 cột trên mobile nhỏ */
@media (max-width: 480px) {
    .cxs-swatches-wrap {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Ẩn giá mặc định ở phần hiển thị biến thể của WooCommerce để tránh lặp giá */
.woocommerce-variation-price,
.single_variation .price {
    display: none !important;
}