/* ================================================================
   WooCommerce Variation Swatches Pro – Frontend Styles
   ================================================================ */

:root {
    --wvs-size:   36px;
    --wvs-radius: 8px;
    --wvs-accent: #111827;
    --wvs-gap:    8px;
}

/* ── Label row ── */
.wvs-label-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    direction: rtl;
}

.wvs-label {
    font-size: 13px;
    font-weight: 700;
    color: #374151;
}

.wvs-selected-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--wvs-accent);
    background: color-mix(in srgb, var(--wvs-accent) 10%, transparent);
    padding: 2px 8px;
    border-radius: 20px;
    min-width: 20px;
    transition: all 0.2s;
}

/* ── Swatch list ── */
.wvs-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--wvs-gap);
    direction: rtl;
}

/* ── Base swatch button ── */
.wvs-item {
    position: relative;
    width: var(--wvs-size);
    height: var(--wvs-size);
    border-radius: var(--wvs-radius);
    border: 2px solid #e5e7eb;
    background: #fff;
    cursor: pointer;
    padding: 0;
    overflow: hidden;
    transition:
        transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
        border-color 0.15s ease,
        box-shadow 0.15s ease;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Hover ── */
.wvs-item:hover:not(.wvs-disabled) {
    border-color: #9ca3af;
    transform: scale(1.1);
    z-index: 2;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}

/* ── Selected ── */
.wvs-item.wvs-selected {
    border-color: var(--wvs-accent);
    border-width: 2.5px;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--wvs-accent) 20%, transparent);
    transform: scale(1.08);
    z-index: 3;
}

/* ── Disabled (out of stock) ── */
.wvs-item.wvs-disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

/* Cross-out style */
.wvs-item.wvs-disabled::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        transparent calc(50% - 1px),
        #ef4444 calc(50% - 1px),
        #ef4444 calc(50% + 1px),
        transparent calc(50% + 1px)
    );
    border-radius: inherit;
    pointer-events: none;
}

/* Blur variant (toggled via JS) */
.wvs-item.wvs-disabled.wvs-blur-style {
    filter: blur(1.5px) grayscale(0.8);
    opacity: 0.55;
}
.wvs-item.wvs-disabled.wvs-blur-style::after { display: none; }

/* Hide variant */
.wvs-item.wvs-hidden { display: none !important; }

/* ── Checkmark ── */
.wvs-checkmark {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 2;
}

.wvs-item.wvs-selected .wvs-checkmark {
    opacity: 1;
}

/* ── COLOR swatch ── */
.wvs-color-inner {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: calc(var(--wvs-radius) - 2px);
}

/* ── IMAGE swatch ── */
.wvs-img-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.wvs-img-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: calc(var(--wvs-radius) - 2px);
}

/* ── BUTTON / TEXT swatch ── */
.wvs-type-button {
    width: auto !important;
    min-width: var(--wvs-size);
    padding: 0 12px;
    height: var(--wvs-size);
    background: #f8fafc;
}

.wvs-type-button:hover:not(.wvs-disabled) {
    background: #f1f5f9;
}

.wvs-type-button.wvs-selected {
    background: var(--wvs-accent);
    color: #fff;
    border-color: var(--wvs-accent);
}

.wvs-btn-inner {
    font-size: 12px;
    font-weight: 700;
    color: inherit;
    letter-spacing: 0.3px;
    white-space: nowrap;
    line-height: 1;
    position: relative;
    z-index: 1;
}

.wvs-type-button.wvs-selected .wvs-btn-inner {
    color: #fff;
}

/* ── Tooltip ── */
.wvs-item::before {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: #1e293b;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 9px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 100;
    direction: rtl;
}

.wvs-item::after {
    content: '';
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    border: 5px solid transparent;
    border-top-color: #1e293b;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 100;
}

/* Override disabled cross ::after for tooltip arrow — can't, so handle in JS */

.wvs-item.wvs-tooltip-hover::before,
.wvs-item.wvs-tooltip-hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Hide tooltip on disabled cross items */
.wvs-item.wvs-disabled::before,
.wvs-item.wvs-disabled::after {
    display: none;
}

/* ── Clear button ── */
.wvs-clear {
    background: none;
    border: none;
    font-size: 11px;
    color: #94a3b8;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    margin-right: 4px;
    transition: color 0.15s;
    display: none;
    align-items: center;
    gap: 3px;
}

.wvs-clear.wvs-clear-show {
    display: inline-flex;
}

.wvs-clear:hover { color: #ef4444; }

/* ── Wrap spacing ── */
.wvs-wrap {
    margin-bottom: 16px;
}

/* ── Focus ring ── */
.wvs-item:focus-visible {
    outline: 2px solid var(--wvs-accent);
    outline-offset: 3px;
}

/* ── Shop / archive pages ── */
.woocommerce-loop-product__link .wvs-wrap,
.wvs-archive .wvs-wrap {
    padding: 0 8px 8px;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    :root { --wvs-size: 32px; --wvs-gap: 6px; }
}
