/* =====================
   Devvn Variation Swatches
   ===================== */

/* Container */
.devvn-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 8px;
    align-items: center;
}

/* =====================
   Base Swatch
   ===================== */
.devvn-swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    border: 2px solid transparent;
    transition: box-shadow .15s ease, border-color .15s ease, opacity .15s ease;
    outline: none;
    box-sizing: border-box;
    user-select: none;
}

.devvn-swatch:focus-visible {
    outline: 2px dashed #999;
    outline-offset: 2px;
}

.woocommerce div.product form.cart .variations tr {
    display: flex;
    flex-direction: column;
}
.woocommerce div.product form.cart .variations th {
    text-align: left;
    font-size: 1em;
    padding: 0;
}

/* Selected */
.devvn-swatch.selected {
    box-shadow: 0 0 0 2px var(--main-color, #e03232);
}

/* Disabled — gạch chéo */
.devvn-swatch.disabled {
    opacity: .4;
    cursor: not-allowed;
    pointer-events: none;
    position: relative;
}

/* =====================
   Label Swatch
   ===================== */
.devvn-swatch--label {
    flex-direction: column;
    align-items: center;
    min-width: 90px;
    padding: 8px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    background: #fff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.4;
    color: #333;
}
.devvn-swatch--label:hover {
    border-color: #999;
}
.devvn-swatch--label .devvn-swatch__price {
    color: var(--main-color, #e03232);
    font-size: 12px;
    font-weight: 700;
}
.devvn-swatch--label.selected {
    border-color: var(--main-color, #e03232);
    border-width: 2px;
    background: #fff;
    color: #333;
    box-shadow: none;
}
.devvn-swatch--label.selected .devvn-swatch__price {
    color: var(--main-color, #e03232);
}
.devvn-swatch--label.disabled {
    background: #f5f5f5;
    color: #aaa;
}

/* =====================
   Color Swatch
   ===================== */
.devvn-swatch--color {
    width: 34px;
    height: 34px;
    border-radius: 3px;
    padding: 2px;
    border: 2px solid #e0e0e0;
}
.devvn-swatch--color:hover {
    border-color: #999;
}
.devvn-swatch--color.selected {
    border-color: var(--main-color, #e03232);
}
.devvn-swatch__color {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 1px;
}
.devvn-swatch__color--single {
    background: var(--swatch-color, #ccc);
}
.devvn-swatch__color--dual {
    background: linear-gradient(
        135deg,
        var(--swatch-color, #ccc) 50%,
        var(--swatch-color-2, #fff) 50%
    );
}
/* Ẩn text với color */
.devvn-swatch--color .devvn-swatch__text {
    display: none;
}

/* =====================
   Image Swatch
   ===================== */
.devvn-swatch--image {
    width: 40px;
    height: 40px;
    border: 2px solid #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    padding: 1px;
}
.devvn-swatch--image:hover {
    border-color: #999;
}
.devvn-swatch--image.selected {
    border-color: var(--main-color, #e03232);
}
.devvn-swatch__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
/* Ẩn text với image */
.devvn-swatch--image .devvn-swatch__text {
    display: none;
}

/* =====================
   Tooltip
   ===================== */
.devvn-swatch--color[title]::before,
.devvn-swatch--image[title]::before {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,.78);
    color: #fff;
    font-size: 11px;
    white-space: nowrap;
    padding: 3px 8px;
    border-radius: 3px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease;
    z-index: 99;
}
.devvn-swatch--color[title]::after,
.devvn-swatch--image[title]::after {
    content: '';
    position: absolute;
    bottom: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: rgba(0,0,0,.78);
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease;
    z-index: 99;
}
.devvn-swatch--color:hover[title]::before,
.devvn-swatch--color:hover[title]::after,
.devvn-swatch--image:hover[title]::before,
.devvn-swatch--image:hover[title]::after {
    opacity: 1;
}

/* =====================
   Kích thước
   ===================== */
.devvn-swatches--x-small .devvn-swatch--color { width: 22px; height: 22px; }
.devvn-swatches--x-small .devvn-swatch--image { width: 28px; height: 28px; }
.devvn-swatches--x-small .devvn-swatch--label { padding: 4px 8px; font-size: 11px; min-width: 60px; }
.devvn-swatches--x-small .devvn-swatch--label .devvn-swatch__price { font-size: 10px; }

.devvn-swatches--small .devvn-swatch--color   { width: 28px; height: 28px; }
.devvn-swatches--small .devvn-swatch--image   { width: 34px; height: 34px; }
.devvn-swatches--small .devvn-swatch--label   { padding: 5px 10px; font-size: 12px; min-width: 70px; }
.devvn-swatches--small .devvn-swatch--label .devvn-swatch__price { font-size: 11px; }

.devvn-swatches--large .devvn-swatch--color   { width: 42px; height: 42px; }
.devvn-swatches--large .devvn-swatch--image   { width: 50px; height: 50px; }
.devvn-swatches--large .devvn-swatch--label   { padding: 10px 18px; font-size: 14px; min-width: 110px; }
.devvn-swatches--large .devvn-swatch--label .devvn-swatch__price { font-size: 13px; }

.devvn-swatches--x-large .devvn-swatch--color { width: 52px; height: 52px; }
.devvn-swatches--x-large .devvn-swatch--image { width: 60px; height: 60px; }
.devvn-swatches--x-large .devvn-swatch--label { padding: 12px 22px; font-size: 15px; min-width: 130px; }
.devvn-swatches--x-large .devvn-swatch--label .devvn-swatch__price { font-size: 14px; }

/* =====================
   Hình dạng
   ===================== */
.devvn-swatches--circle .devvn-swatch--color,
.devvn-swatches--circle .devvn-swatch--image {
    border-radius: 50%;
}
.devvn-swatches--circle .devvn-swatch__color {
    border-radius: 50%;
}

.devvn-swatches--rounded .devvn-swatch--color,
.devvn-swatches--rounded .devvn-swatch--image,
.devvn-swatches--rounded .devvn-swatch--label {
    border-radius: 20px;
}
.devvn-swatches--rounded .devvn-swatch__color {
    border-radius: 16px;
}
.devvn-swatches--rounded .devvn-swatch--label.selected::after {
    bottom: 5px;
    right: 8px;
}

/* =====================
   Select gốc ẩn
   ===================== */
.devvn-swatch-select-wrapper {
    display: none !important;
}

/* =====================
   Accessibility — prefers-reduced-motion
   ===================== */
@media (prefers-reduced-motion: reduce) {
    .devvn-swatch {
        transition: none;
    }
    .devvn-swatch--color[title]::before,
    .devvn-swatch--color[title]::after,
    .devvn-swatch--image[title]::before,
    .devvn-swatch--image[title]::after {
        transition: none;
    }
}
