/*
 * Variant Offers — Frontend Swatch CSS v2.0
 * Replaces WooCommerce default variation dropdowns with premium swatches.
 * Works with any WordPress theme.
 */

/* ══════════════════════════════════════════════════════
   HIDE DEFAULT WOOCOMMERCE DROPDOWN
   The PHP filter already adds style="display:none" but
   this is a belt-and-suspenders fallback.
══════════════════════════════════════════════════════ */
.vo-variation-swatches-wrap select[style*="display:none"],
.variations select.vo-hidden-select {
    display: none !important;
}

/* ══════════════════════════════════════════════════════
   SWATCH WRAPPER
══════════════════════════════════════════════════════ */
.vo-swatch-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 8px 0 14px;
    padding: 0;
    list-style: none;
}

/* ══════════════════════════════════════════════════════
   SWATCH ITEM — BASE
══════════════════════════════════════════════════════ */
.vo-swatch-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    cursor: pointer;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
    overflow: hidden;
    vertical-align: middle;
    box-sizing: border-box;
}

.vo-swatch-item:hover {
    border-color: #7c3aed;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(124,58,237,.2);
}

.vo-swatch-item:focus-visible {
    outline: 3px solid #7c3aed;
    outline-offset: 2px;
}

/* SELECTED STATE */
.vo-swatch-item.vo-selected {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124,58,237,.18);
    transform: scale(1.05);
}

/* Selected checkmark for color swatches */
.vo-swatch-color .vo-swatch-item.vo-selected::after,
.vo-swatch-item.vo-swatch-color.vo-selected::after {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='white'%3E%3Cpath fill-rule='evenodd' d='M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z' clip-rule='evenodd'/%3E%3C/svg%3E") center/60% no-repeat;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.4));
}

/* DISABLED / OUT OF STOCK */
.vo-swatch-item.vo-disabled,
.vo-swatch-item.vo-out-of-stock {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* Strikethrough for out-of-stock */
.vo-swatch-item.vo-out-of-stock::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom right,
        transparent calc(50% - 1px),
        rgba(220,38,38,.7) calc(50% - 1px),
        rgba(220,38,38,.7) calc(50% + 1px),
        transparent calc(50% + 1px)
    );
    z-index: 2;
    border-radius: inherit;
}

/* ══════════════════════════════════════════════════════
   SHAPES
══════════════════════════════════════════════════════ */
.vo-swatch-wrapper[data-shape="circle"]  .vo-swatch-item,
.vo-shape-circle  { border-radius: 50% !important; }

.vo-swatch-wrapper[data-shape="square"]  .vo-swatch-item,
.vo-shape-square  { border-radius: 0 !important; }

.vo-swatch-wrapper[data-shape="rounded"] .vo-swatch-item,
.vo-shape-rounded { border-radius: 8px !important; }

.vo-swatch-wrapper[data-shape="pill"]    .vo-swatch-item,
.vo-shape-pill    { border-radius: 9999px !important; width: auto !important; padding: 0 14px !important; }

/* ══════════════════════════════════════════════════════
   SIZES
══════════════════════════════════════════════════════ */
.vo-swatch-wrapper[data-size="small"]  .vo-swatch-item { width: 26px !important; height: 26px !important; }
.vo-swatch-wrapper[data-size="medium"] .vo-swatch-item { width: 36px !important; height: 36px !important; }
.vo-swatch-wrapper[data-size="large"]  .vo-swatch-item { width: 48px !important; height: 48px !important; }

/* ══════════════════════════════════════════════════════
   TYPE: COLOR
══════════════════════════════════════════════════════ */
.vo-swatch-item.vo-swatch-color .vo-swatch-color,
.vo-swatch-color-inner {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
}

/* ══════════════════════════════════════════════════════
   TYPE: IMAGE
══════════════════════════════════════════════════════ */
.vo-swatch-item.vo-swatch-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    display: block;
    pointer-events: none;
}

/* ══════════════════════════════════════════════════════
   TYPE: TEXT / BUTTON / LABEL
══════════════════════════════════════════════════════ */
.vo-swatch-item.vo-swatch-text,
.vo-swatch-item.vo-swatch-button {
    width: auto !important;
    min-width: 36px;
    padding: 0 12px;
    height: 36px;
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
}

.vo-swatch-item.vo-swatch-text:hover,
.vo-swatch-item.vo-swatch-button:hover {
    background: #f5f3ff;
    border-color: #7c3aed;
    color: #7c3aed;
}

.vo-swatch-item.vo-swatch-text.vo-selected,
.vo-swatch-item.vo-swatch-button.vo-selected {
    background: #7c3aed;
    border-color: #7c3aed;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(124,58,237,.3);
}

.vo-swatch-label {
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    color: inherit;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
}

/* SIZE override for text/button — height should match */
.vo-swatch-wrapper[data-size="small"] .vo-swatch-item.vo-swatch-text,
.vo-swatch-wrapper[data-size="small"] .vo-swatch-item.vo-swatch-button {
    height: 26px !important;
    font-size: 11px !important;
    padding: 0 8px !important;
}
.vo-swatch-wrapper[data-size="large"] .vo-swatch-item.vo-swatch-text,
.vo-swatch-wrapper[data-size="large"] .vo-swatch-item.vo-swatch-button {
    height: 48px !important;
    font-size: 15px !important;
    padding: 0 18px !important;
}

/* ══════════════════════════════════════════════════════
   TYPE: PATTERN / GRADIENT / ICON
══════════════════════════════════════════════════════ */
.vo-swatch-pattern,
.vo-swatch-gradient {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
}

.vo-swatch-icon {
    font-size: 18px;
    line-height: 1;
}

/* ══════════════════════════════════════════════════════
   TOOLTIP
══════════════════════════════════════════════════════ */
.vo-swatch-item[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #111827;
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    padding: 4px 9px;
    border-radius: 5px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.vo-swatch-item[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #111827;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 9999;
}

.vo-swatch-item[data-tooltip]:hover::after,
.vo-swatch-item[data-tooltip]:hover::before { opacity: 1; }

/* ══════════════════════════════════════════════════════
   ATTRIBUTE LABEL ROW
══════════════════════════════════════════════════════ */
.vo-attribute-label-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.vo-attribute-label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

.vo-selected-value {
    font-size: 13px;
    color: #7c3aed;
    font-weight: 500;
}

/* ══════════════════════════════════════════════════════
   SWATCH GROUP CONTAINER
══════════════════════════════════════════════════════ */
.vo-swatch-group {
    margin-bottom: 16px;
}

.vo-oos-notice {
    font-size: 12px;
    color: #dc2626;
    margin-top: 4px;
}

/* ══════════════════════════════════════════════════════
   LOADING STATE (while variation loads)
══════════════════════════════════════════════════════ */
.vo-swatch-item.vo-loading {
    animation: voSwatchPulse 0.8s ease-in-out infinite alternate;
}

@keyframes voSwatchPulse {
    from { opacity: 0.6; }
    to   { opacity: 1; }
}

/* ══════════════════════════════════════════════════════
   OFFER CARDS (product page)
══════════════════════════════════════════════════════ */
.vo-offer-builder {
    margin: 24px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
}

.vo-offer {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.vo-offer-card {
    position: relative;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px 14px;
    cursor: pointer;
    background: #fff;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.15s ease;
    text-align: center;
}

.vo-offer-card:hover {
    border-color: #7c3aed;
    box-shadow: 0 4px 16px rgba(124,58,237,.12);
    transform: translateY(-2px);
}

.vo-offer-card.vo-selected {
    border-color: #7c3aed;
    box-shadow: 0 0 0 4px rgba(124,58,237,.14);
}

.vo-card-title  { font-size: 15px; font-weight: 700; color: #111827; margin-bottom: 4px; }
.vo-card-subtitle { font-size: 12px; color: #6b7280; margin-bottom: 8px; }
.vo-sale-price  { font-size: 18px; font-weight: 800; color: #7c3aed; }
.vo-compare-price { font-size: 13px; color: #9ca3af; text-decoration: line-through; margin-bottom: 2px; display: block; }
.vo-per-unit    { font-size: 11px; color: #9ca3af; margin-top: 2px; }
.vo-savings     { display: inline-block; background: #dcfce7; color: #166534; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; margin-bottom: 6px; }

.vo-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: #7c3aed;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(124,58,237,.25);
}

.vo-stock-status {
    font-size: 12px;
    font-weight: 600;
    margin-top: 8px;
}
.vo-out-of-stock-msg { color: #dc2626; }
.vo-low-stock    { color: #d97706; }

.vo-card-selected-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    background: #7c3aed;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
}
.vo-offer-card.vo-selected .vo-card-selected-indicator { opacity: 1; }
.vo-card-selected-indicator svg { width: 12px; height: 12px; color: #fff; }

/* Animate in */
.vo-animate-fade-up {
    animation: voFadeUp 0.35s ease both;
}
@keyframes voFadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Pricing loading */
.vo-pricing-loading { opacity: 0.65; }
.vo-pricing-loading .vo-sale-price::after {
    content: '...';
    display: inline-block;
    animation: voSwatchPulse 0.6s ease infinite alternate;
}

/* ══════════════════════════════════════════════════════
   COUNTDOWN TIMER
══════════════════════════════════════════════════════ */
.vo-countdown-wrap { margin: 16px 0; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.vo-countdown-label { font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 10px; }
.vo-countdown-timer { display: flex; align-items: center; gap: 6px; }
.vo-countdown-block { text-align: center; }
.vo-countdown-digit { display: block; background: #1e1b4b; color: #fff; font-size: 22px; font-weight: 800; padding: 8px 12px; border-radius: 8px; min-width: 52px; font-variant-numeric: tabular-nums; }
.vo-countdown-unit  { display: block; font-size: 10px; color: #9ca3af; text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; }
.vo-countdown-sep   { font-size: 22px; color: #d1d5db; font-weight: 700; padding-bottom: 16px; }

/* ══════════════════════════════════════════════════════
   SAVINGS DISPLAY
══════════════════════════════════════════════════════ */
.vo-savings-display { display: inline-flex; align-items: center; gap: 5px; padding: 5px 12px; border-radius: 20px; font-size: 13px; font-weight: 600; }
.vo-savings-style--badge  { background: #dcfce7; color: #166534; }
.vo-savings-style--banner { background: #dcfce7; color: #166534; width: 100%; justify-content: center; border-radius: 8px; padding: 10px 16px; }
.vo-savings-style--inline { background: none; padding: 0; color: #059669; }

/* ══════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .vo-offer { grid-template-columns: 1fr 1fr; }
    .vo-countdown-digit { font-size: 18px; padding: 6px 9px; min-width: 42px; }
}

@media (prefers-reduced-motion: reduce) {
    .vo-swatch-item, .vo-offer-card {
        transition: none !important;
        animation: none !important;
    }
}


/* ══════════════════════════════════════════════════════
   HIDE WOOCOMMERCE DEFAULT ELEMENTS WE REPLACE
══════════════════════════════════════════════════════ */

/* Hide WooCommerce "Clear" variations link — we handle deselection
   by clicking the same swatch again (toggle behaviour) */
.variations_form .reset_variations,
.woocommerce-variation-add-to-cart .reset_variations,
a.reset_variations {
    display: none !important;
}

/* Hide WC's own "Choose an option" label row label when swatches are active */
.variations_form .variations td.label label {
    /* Keep label visible — but remove extra bottom margin WC adds */
    margin-bottom: 0 !important;
}

/* ══════════════════════════════════════════════════════
   COLOR SWATCH INNER — fill the full button
══════════════════════════════════════════════════════ */
.vo-swatch-item.vo-swatch-color {
    padding: 0 !important;
    overflow: hidden !important;
}

.vo-swatch-color-inner {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: inherit !important;
    pointer-events: none;
}

/* Color swatch selected — white checkmark overlay */
.vo-swatch-item.vo-swatch-color.vo-selected::after {
    content: '' !important;
    position: absolute !important;
    inset: 0 !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='white'%3E%3Cpath fill-rule='evenodd' d='M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z' clip-rule='evenodd'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 60% !important;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)) !important;
    z-index: 2 !important;
    pointer-events: none !important;
}

/* For very light colors (white, ivory, cream) — use dark checkmark */
.vo-swatch-item.vo-swatch-color.vo-selected.vo-light-color::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23111827'%3E%3Cpath fill-rule='evenodd' d='M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z' clip-rule='evenodd'/%3E%3C/svg%3E") !important;
}

/* Gradient swatches (multi/rainbow) */
.vo-swatch-item.vo-swatch-color .vo-swatch-color-inner[style*="linear-gradient"] {
    border-radius: inherit !important;
}

/* ══════════════════════════════════════════════════════
   SELECTED VALUE DISPLAY NEXT TO LABEL
══════════════════════════════════════════════════════ */
.vo-attribute-label-wrap {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    margin-bottom: 8px !important;
    flex-wrap: wrap !important;
}

.vo-attribute-label {
    font-size: 13.5px !important;
    font-weight: 600 !important;
    color: #374151 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif !important;
}

.vo-selected-value {
    font-size: 13.5px !important;
    color: #7c3aed !important;
    font-weight: 600 !important;
}

/* ══════════════════════════════════════════════════════
   WC VARIATION TABLE — normalize spacing
══════════════════════════════════════════════════════ */
.variations_form .variations {
    border-collapse: separate !important;
    border-spacing: 0 !important;
}
.variations_form .variations tr td,
.variations_form .variations tr th {
    padding: 0 0 16px !important;
    vertical-align: top !important;
    border: none !important;
}
.variations_form .variations td.label {
    padding-right: 12px !important;
    padding-top: 10px !important;
    white-space: nowrap !important;
    width: auto !important;
    min-width: 60px !important;
}
.variations_form .variations td.value {
    width: 100% !important;
}
