/**
 * Custom Variation Buttons
 * Button-style variant selectors for better UX
 *
 * @version 1.1.0
 *
 * FIX v1.1.0: Only hide TABLE-based variations, not our custom div.pc-variations
 * The .variations class is required for WooCommerce JS compatibility (.variations select),
 * so we must NOT hide .pc-variations.variations - only table.variations.
 */

/* FORCE HIDE OLD VARIATIONS TABLE (only table elements, not our custom div) */
.variations_form table.variations,
table.variations {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Variation Groups */
.pc-variations {
    margin: 2px 0 4px !important;
    display: block !important;
    position: relative;
    z-index: 10;
}

.pc-variation-group {
    margin-bottom: 4px;
}

.pc-variation-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #1a3a1a;
    margin-bottom: 6px;
    text-transform: none;
}

/* Variation Buttons - FIXED CLICKABILITY */
.pc-variation-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    position: relative;
    z-index: 20;
}

.pc-variation-btn {
    padding: 8px 14px;
    background: white;
    border: 2px solid #e5e8e5;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #2c2c2c;
    cursor: pointer !important;
    pointer-events: auto !important;
    transition: all 0.2s ease;
    position: relative;
    z-index: 25;
    min-width: 60px;
    text-align: center;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    user-select: none;
}

.pc-variation-btn:hover {
    border-color: #89A550;
    background: rgba(137, 165, 80, 0.05);
    transform: translateY(-1px);
}

.pc-variation-btn:focus {
    outline: 2px solid #89A550;
    outline-offset: 2px;
}

.pc-variation-btn:active:not(.disabled) {
    transform: translateY(0);
    background: rgba(137, 165, 80, 0.1);
}

.pc-variation-btn.selected {
    background: #89A550;
    border-color: #89A550;
    color: white;
    box-shadow: 0 4px 12px rgba(137, 165, 80, 0.3);
}

.pc-variation-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed !important;
    pointer-events: none !important;
    position: relative;
    background: #f5f5f5 !important;
    border-color: #e0e0e0 !important;
    color: #999 !important;
}

.pc-variation-btn.disabled::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: #ccc;
    transform: translateY(-50%);
}

/* Make available options more prominent */
.pc-variation-btn:not(.disabled):not(.selected) {
    opacity: 1;
    background: white;
    border-color: #e5e8e5;
    color: #2c2c2c;
    font-weight: 600;
}

/* Highlight available options when one is selected */
.pc-variations:has(.pc-variation-btn.selected) .pc-variation-btn:not(.disabled):not(.selected) {
    border-color: #89A550;
    background: rgba(137, 165, 80, 0.05);
}

/* Hidden selects (for WooCommerce compatibility) */
.pc-variation-select {
    display: none !important;
}

/* Reset button */
.reset_variations {
    display: inline-block;
    margin-top: 6px;
    padding: 4px 12px;
    font-size: 12px;
    color: #666;
    text-decoration: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.reset_variations:hover {
    color: #89A550;
    border-color: #89A550;
    background: rgba(137, 165, 80, 0.05);
}

/* ===== Enriched Size Swatches (CRO: price in button) ===== */
.pc-swatch--size .pc-swatch__price,
.pc-variation-btn .pc-swatch__price {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #6B6B68;
    margin-top: 2px;
    line-height: 1.2;
}

.pc-swatch--size.selected .pc-swatch__price,
.pc-variation-btn.selected .pc-swatch__price {
    color: rgba(255, 255, 255, 0.85);
}

/* Size swatches with price need more vertical padding */
.pc-swatch--size:has(.pc-swatch__price),
.pc-variation-btn:has(.pc-swatch__price) {
    padding: 6px 12px 4px;
    min-width: 60px;
}

/* Contextual plant range info below size buttons */
.pc-variation-context {
    font-size: 12px;
    color: #2D5A3D;
    margin-top: 4px;
    padding: 4px 8px;
    background: #E8F5E9;
    border-radius: 4px;
    line-height: 1.3;
    transition: opacity 0.2s ease;
}

/* Mobile optimizations */
@media (max-width: 600px) {
    .pc-variation-btn {
        padding: 7px 12px;
        font-size: 13px;
        min-width: 56px;
    }

    .pc-swatch--size:has(.pc-swatch__price),
    .pc-variation-btn:has(.pc-swatch__price) {
        padding: 6px 10px 4px;
        min-width: 52px;
    }

    .pc-variation-context {
        font-size: 11px;
    }
}

/* Additional overrides to ensure old TABLE variations are hidden */
.woocommerce div.product form.cart table.variations {
    display: none !important;
}

/* Our custom variations are always visible (uses .pc-variations.variations) */
.woocommerce div.product form.cart .pc-variations {
    display: block !important;
}