/* ============================================================
   Variation Swatches for WooCommerce - Frontend Styles
   ============================================================ */

/* ── CSS Variables (theme override সহজে করা যাবে) ───────── */
:root {
    --vsw-size: 60px;
    --vsw-radius: 6px;
    --vsw-border-color: #e2e8f0;
    --vsw-border-selected: #1a1a2e;
    --vsw-shadow-selected: 0 0 0 3px rgba(26, 26, 46, 0.15);
    --vsw-gap: 8px;
    --vsw-transition: all 0.18s ease;
    --vsw-label-color: #6b7280;
    --vsw-value-color: #111827;
    --vsw-oos-color: #ef4444;
    --vsw-text-bg: #f8fafc;
    --vsw-text-bg-hover: #f1f5f9;
    --vsw-text-color: #374151;
}

/* ── Selected Label ──────────────────────────────────────── */
.vsw-selected-label {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
    font-size: 0.875rem;
    line-height: 1.4;
}

.vsw-label-name {
    color: var(--vsw-label-color);
    font-weight: 500;
}

.vsw-selected-value {
    color: var(--vsw-value-color);
    font-weight: 600;
    min-height: 1.2em;
    transition: var(--vsw-transition);
}

.vsw-selected-value.vsw-has-value {
    color: var(--vsw-border-selected);
}

/* ── Swatches Container ──────────────────────────────────── */
.vsw-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: var(--vsw-gap);
    align-items: flex-start;
}

/* ── Individual Swatch Item ──────────────────────────────── */
.vsw-swatch-item {
    position: relative;
    width: var(--vsw-size);
    height: var(--vsw-size);
    border-radius: var(--vsw-radius);
    border: 2px solid var(--vsw-border-color);
    overflow: hidden;
    cursor: pointer;
    transition: var(--vsw-transition);
    box-sizing: border-box;
    flex-shrink: 0;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vsw-swatch-item:hover {
    border-color: #94a3b8;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
}

/* ── Selected State ──────────────────────────────────────── */
.vsw-swatch-item.vsw-selected {
    border-color: var(--vsw-border-selected) !important;
    box-shadow: var(--vsw-shadow-selected) !important;
    transform: translateY(-1px);
}

.vsw-swatch-item.vsw-selected::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--vsw-border-selected);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 6l3 3 5-5' stroke='%23fff' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 2;
}

/* ── Image Inside Swatch ─────────────────────────────────── */
.vsw-swatch-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease;
    pointer-events: none;
}

.vsw-swatch-item:hover img {
    transform: scale(1.05);
}

/* ── Text Swatch (no image) ──────────────────────────────── */
.vsw-text-swatch {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--vsw-text-color);
    text-align: center;
    line-height: 1.3;
    padding: 2px 6px;
    word-break: break-word;
    hyphens: auto;
    white-space: normal;
}

.vsw-text-only {
    background: var(--vsw-text-bg);
    min-width: var(--vsw-size);
    width: auto;
    padding: 0 10px;
}

.vsw-text-only:hover {
    background: var(--vsw-text-bg-hover);
}

.vsw-text-only.vsw-selected {
    background: #1a1a2e;
}

.vsw-text-only.vsw-selected .vsw-text-swatch {
    color: #fff;
}

/* ── Out of Stock ─────────────────────────────────────────── */
.vsw-oos-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

/* Cross style */
.vsw-out-of-stock.vsw-oos-cross {
    opacity: 0.55;
    cursor: not-allowed;
}

.vsw-out-of-stock.vsw-oos-cross .vsw-oos-overlay {
    display: block !important;
}

.vsw-out-of-stock.vsw-oos-cross .vsw-oos-overlay::before,
.vsw-out-of-stock.vsw-oos-cross .vsw-oos-overlay::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 2px;
    background: var(--vsw-oos-color);
    transform-origin: center;
}

.vsw-out-of-stock.vsw-oos-cross .vsw-oos-overlay::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.vsw-out-of-stock.vsw-oos-cross .vsw-oos-overlay::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

/* Blur style */
.vsw-out-of-stock.vsw-oos-blur {
    filter: blur(1px) grayscale(50%);
    opacity: 0.6;
    cursor: not-allowed;
}

/* Disabled style */
.vsw-out-of-stock.vsw-disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Tooltip ─────────────────────────────────────────────── */
.vsw-swatch-item[title] {
    position: relative;
}

/* CSS-only tooltip */
.vsw-swatch-item[title]:hover::before {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a2e;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: 4px;
    pointer-events: none;
    z-index: 999;
    line-height: 1.4;
    letter-spacing: 0.01em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.vsw-swatch-item[title]:hover::after {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1a1a2e;
    pointer-events: none;
    z-index: 999;
}

/* ── Image Loading Transition ────────────────────────────── */
.vsw-img-loading {
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

/* ── Hidden original select ──────────────────────────────── */
.vsw-hidden-select {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
}

/* ── Inventory Badge ─────────────────────────────────────── */
.vsw-inventory {
    display: none !important;
    /* flex */
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    font-size: 0.875rem;
    line-height: 1.4;
    animation: vswFadeIn 0.2s ease;
}

.vsw-inventory-label {
    color: var(--vsw-label-color);
    font-weight: 500;
}

.vsw-inventory-count {
    color: var(--vsw-value-color);
    font-weight: 700;
    font-size: 1rem;
}

/* Status variants */
.vsw-inventory[data-status="instock"] .vsw-inventory-count {
    color: #000;
}

.vsw-inventory[data-status="outofstock"] .vsw-inventory-count {
    color: #dc2626;
}

.vsw-inventory[data-status="onbackorder"] .vsw-inventory-count {
    color: #d97706;
}

@keyframes vswFadeIn {
    from {
        opacity: 0;
        transform: translateY(3px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

    .vsw-selected-label {
        font-size: 0.8rem;
    }
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes vswPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(26, 26, 46, 0.3);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(26, 26, 46, 0);
    }
}

.vsw-swatch-item.vsw-just-selected {
    animation: vswPulse 0.4s ease;
}

/* ── Dark Theme Support ──────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    :root {
        --vsw-border-color: #374151;
        --vsw-text-bg: #1f2937;
        --vsw-text-bg-hover: #374151;
        --vsw-text-color: #e5e7eb;
        --vsw-label-color: #9ca3af;
        --vsw-value-color: #f9fafb;
    }

    .vsw-swatch-item {
        background: #111827;
    }
}

/* ── Hide default WooCommerce variation UI ───────────────── */
/* Only hide the stock/availability/description inside the variation area,
   NOT the price — we control price visibility via JS */
.single_variation_wrap .woocommerce-variation-availability,
.single_variation_wrap .woocommerce-variation-description {
    display: none !important;
}

/* Variation price: hidden by default, shown by JS when variation is found */
.single_variation_wrap .woocommerce-variation-price {
    display: none;
}

.reset_variations {
    position: absolute !important;
    bottom: 10px;
    right: 0;
    margin: 0 !important;
    text-decoration: underline !important;
}

.variations .select2-container {
    display: none !important;
    visibility: hidden !important;
}

/* ── Buy Now Disabled State ──────────────────────────────────── */
/* NOTE: pointer-events: none removed intentionally — mobile touch events
   won't fire on elements with pointer-events: none. Disabled state is
   checked purely in JS. */
.vsw-buynow-disabled {
    opacity: 0.45 !important;
    cursor: not-allowed !important;
}

/* ── Sequential Lock: Locked wrapper (previous attribute not selected yet) ── */
/* pointer-events বাদ দেওয়া হয়েছে: CSS-level block mobile touch break করে।
   Blocking শুধু JS-এ হয় (vsw-wrapper-locked class check)। */
.vsw-swatches-wrapper.vsw-wrapper-locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.vsw-swatches-wrapper.vsw-wrapper-locked .vsw-selected-label {
    color: #aaa;
}

.vsw-swatches-wrapper.vsw-wrapper-locked .vsw-swatches {
    filter: grayscale(30%);
}

/* Inactive swatch items inside locked wrappers — visual only, no pointer-events block */
.vsw-swatch-item.vsw-swatch-inactive {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Shake hint — fires when user clicks locked wrapper */
@keyframes vswShakeHint {
    0% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-6px);
    }

    40% {
        transform: translateX(6px);
    }

    60% {
        transform: translateX(-4px);
    }

    80% {
        transform: translateX(4px);
    }

    100% {
        transform: translateX(0);
    }
}

.vsw-swatches-wrapper.vsw-hint-shake {
    animation: vswShakeHint 0.45s ease;
}

/* ── Buy Now Button ──────────────────────────────────────────── */
.vsw-buy-now-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #520205;
    color: #ffffff !important;
    border: 2px solid #520205;
    border-radius: 4px;
    padding: 0 24px;
    height: 44px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.18s ease, border-color 0.18s ease, opacity 0.18s ease, transform 0.15s ease;
    white-space: nowrap;
    vertical-align: middle;
    margin-top: 10px !important;
}

.vsw-buy-now-button:hover:not(:disabled):not(.disabled) {
    background: #3f0103;
    border-color: #3f0103;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(82, 2, 5, 0.3);
}

.vsw-buy-now-button:active:not(:disabled):not(.disabled) {
    transform: translateY(0);
    box-shadow: none;
}

/* Disabled state — no pointer-events: none so touch events still fire on mobile */
.vsw-buy-now-button.disabled,
.vsw-buy-now-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Loading state */
.vsw-buy-now-button.vsw-buynow-loading {
    opacity: 0.7;
    cursor: wait;
    /* pointer-events: none omitted — kept enabled so mobile doesn't lose the tap */
}

.vsw-buy-now-button.vsw-buynow-loading::after {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: vswBtnSpin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes vswBtnSpin {
    to {
        transform: rotate(360deg);
    }
}

/* ══════════════════════════════════════════════════════════════
   Toast Notification — Add to Cart
   ══════════════════════════════════════════════════════════════ */

#vsw-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    display: flex;
    flex-direction: column-reverse;
    gap: 12px;
    pointer-events: none;
    max-width: 360px;
    width: calc(100vw - 48px);
}

/* ── Single Toast ───────────────────────────────────────────── */
.vsw-toast {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #ffffff;
    border-radius: 14px;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, .07),
        0 10px 40px -4px rgba(0, 0, 0, .18),
        0 0 0 1px rgba(0, 0, 0, .05);
    padding: 14px 14px 14px 14px;
    pointer-events: all;
    cursor: default;
    /* Start hidden — slide in from bottom-right */
    opacity: 0;
    transform: translateX(28px) translateY(8px) scale(0.96);
    transition:
        opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform, opacity;
    /* Green left accent */
    border-left: 4px solid #520205;
    position: relative;
    overflow: hidden;
}

.vsw-toast::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(82, 2, 5, .06) 0%, transparent 60%);
    pointer-events: none;
}

/* Visible state */
.vsw-toast--visible {
    opacity: 1;
    transform: translateX(0) translateY(0) scale(1);
}

/* Hiding state */
.vsw-toast--hiding {
    opacity: 0;
    transform: translateX(28px) translateY(4px) scale(0.95);
    transition:
        opacity 0.3s ease,
        transform 0.3s ease;
}

/* ── Product Image ──────────────────────────────────────────── */
.vsw-toast-img {
    width: 56px;
    height: 56px;
    min-width: 56px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}

/* ── Fallback Icon ──────────────────────────────────────────── */
.vsw-toast-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 10px;
    background: linear-gradient(135deg, #520205 0%, #3f0103 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(82, 2, 5, .35);
}

.vsw-toast-icon svg {
    width: 22px;
    height: 22px;
    stroke: #ffffff;
}

/* ── Body / Text ────────────────────────────────────────────── */
.vsw-toast-body {
    flex: 1;
    min-width: 0;
}

.vsw-toast-label {
    margin: 0 0 2px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #000000;
    line-height: 1.3;
}

.vsw-toast-name {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #000000;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Close Button ───────────────────────────────────────────── */
.vsw-toast-close {
    background: none;
    border: none;
    padding: 6px;
    margin: -4px -4px -4px 0;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
    align-self: flex-start;
}

.vsw-toast-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.vsw-toast-close svg {
    width: 15px;
    height: 15px;
}

/* ── Progress bar (auto-dismiss indicator) ──────────────────── */
.vsw-toast::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: linear-gradient(90deg, #520205, #8b0000);
    transform-origin: left;
    animation: vswToastProgress 4s linear forwards;
    border-radius: 0 0 14px 14px;
}

@keyframes vswToastProgress {
    from {
        transform: scaleX(1);
    }

    to {
        transform: scaleX(0);
    }
}

.vsw-toast--hiding::after {
    animation: none;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 480px) {
    #vsw-toast-container {
        bottom: 16px;
        right: 12px;
        left: 12px;
        width: auto;
        max-width: 100%;
    }
}

/* ── Toast always white — brand colors need light background ─ */
.vsw-toast {
    background: #ffffff !important;
    color: #000000 !important;
}

.vsw-toast-label {
    color: #520205 !important;
}

.vsw-toast-name {
    color: #000000 !important;
}