/**
 * Vinella Quantity Bundles - Frontend Styles
 * Version 6.0.0 - With Variation Selectors Inside Tiers
 */

/* Container */
.vqb-bundle-selector {
    margin: 20px 0 25px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Header */
.vqb-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    gap: 15px;
}

.vqb-header-line {
    flex: 1;
    height: 1px;
    background: #ddd;
    max-width: 80px;
}

.vqb-header-text {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: #666;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Tiers Container */
.vqb-tiers {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Individual Tier */
.vqb-tier {
    position: relative;
    background: #ffffff;
    border: 2px solid #e5e5e5;
    border-radius: 12px;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.vqb-tier:hover {
    border-color: var(--vqb-primary, #9B7BB8);
    box-shadow: 0 2px 8px rgba(155, 123, 184, 0.15);
}

/* Selected Tier */
.vqb-tier.vqb-tier-selected {
    background: var(--vqb-selected-bg, #E8DFF0);
    border-color: var(--vqb-primary, #9B7BB8);
    box-shadow: 0 2px 12px rgba(155, 123, 184, 0.2);
}

/* Badge */
.vqb-badge {
    position: absolute;
    top: -10px;
    right: 15px;
    background: var(--vqb-badge-bg, #9B7BB8);
    color: #ffffff;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 4px 12px;
    border-radius: 4px;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Tier Content Layout */
.vqb-tier-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Custom Radio Button */
.vqb-radio {
    position: relative;
    flex-shrink: 0;
}

.vqb-radio input[type="radio"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.vqb-radio-custom {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 2px solid #ccc;
    border-radius: 50%;
    background: #fff;
    transition: all 0.2s ease;
}

.vqb-tier-selected .vqb-radio-custom,
.vqb-radio input[type="radio"]:checked + .vqb-radio-custom {
    border-color: var(--vqb-primary, #9B7BB8);
}

.vqb-radio-custom::after {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--vqb-primary, #9B7BB8);
    transform: scale(0);
    transition: transform 0.2s ease;
}

.vqb-tier-selected .vqb-radio-custom::after,
.vqb-radio input[type="radio"]:checked + .vqb-radio-custom::after {
    transform: scale(1);
}

/* Tier Info */
.vqb-tier-info {
    flex: 1;
    min-width: 0;
}

.vqb-tier-title {
    font-size: 15px;
    font-weight: 700;
    color: #333;
    line-height: 1.3;
    margin-bottom: 2px;
}

.vqb-tier-subtitle {
    font-size: 13px;
    color: var(--vqb-primary, #9B7BB8);
    font-weight: 500;
}

.vqb-tier-savings {
    display: none;
    font-size: 12px;
    color: var(--vqb-primary, #9B7BB8);
    font-weight: 600;
    background: rgba(155, 123, 184, 0.15);
    padding: 3px 10px;
    border-radius: 20px;
    margin-top: 4px;
}

/* Tier Price */
.vqb-tier-price {
    text-align: right;
    flex-shrink: 0;
}

.vqb-price-current {
    font-size: 18px;
    font-weight: 700;
    color: #333;
    line-height: 1.2;
}

.vqb-price-original {
    font-size: 13px;
    color: #999;
    text-decoration: line-through;
    margin-top: 2px;
}

/* Variation Selectors Inside Tier */
.vqb-variation-selectors {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.vqb-variation-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.vqb-variation-row:last-child {
    margin-bottom: 0;
}

.vqb-variation-label {
    font-size: 13px;
    font-weight: 600;
    color: #666;
    min-width: 30px;
}

.vqb-variation-select {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 35px;
}

.vqb-variation-select:focus {
    outline: none;
    border-color: var(--vqb-primary, #9B7BB8);
}

.vqb-variation-select:hover {
    border-color: var(--vqb-primary, #9B7BB8);
}

/* Subscription Option */
.vqb-subscription-option {
    margin-top: 15px;
    border: 2px dashed #333;
    border-radius: 10px;
    padding: 14px 18px;
    background: #fff;
    transition: all 0.2s ease;
}

.vqb-subscription-option:hover {
    border-color: var(--vqb-primary, #9B7BB8);
}

.vqb-subscription-option.vqb-subscription-active {
    border-style: solid;
    border-color: var(--vqb-primary, #9B7BB8);
    background: var(--vqb-selected-bg, #E8DFF0);
}

.vqb-subscription-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    margin: 0;
}

.vqb-subscription-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.vqb-checkbox-custom {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 2px solid #333;
    border-radius: 4px;
    background: #fff;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.vqb-subscription-label input[type="checkbox"]:checked + .vqb-checkbox-custom {
    background: var(--vqb-primary, #9B7BB8);
    border-color: var(--vqb-primary, #9B7BB8);
}

.vqb-checkbox-custom::after {
    content: '✓';
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.vqb-subscription-label input[type="checkbox"]:checked + .vqb-checkbox-custom::after {
    opacity: 1;
}

.vqb-subscription-info {
    flex: 1;
}

.vqb-subscription-title {
    font-size: 14px;
    font-weight: 700;
    color: #333;
    line-height: 1.3;
}

.vqb-subscription-subtitle {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

/* Hide default WooCommerce quantity selector when bundles are active */
.vqb-bundle-selector ~ form.cart .quantity {
    display: none !important;
}

/* Hide default WooCommerce variation selector when bundles are active */
.vqb-bundle-selector ~ form.cart .variations {
    display: none !important;
}

.vqb-bundle-selector ~ form.cart .variations_form .variations {
    display: none !important;
}

.vqb-bundle-selector ~ form.cart table.variations {
    display: none !important;
}

.vqb-bundle-selector ~ form.cart .reset_variations {
    display: none !important;
}

.vqb-bundle-selector ~ form.cart .single_variation_wrap .woocommerce-variation {
    display: none !important;
}

/* Also hide the "Clear" link */
.vqb-bundle-selector ~ form.cart .reset_variations,
.vqb-bundle-selector ~ form.cart a.reset_variations {
    display: none !important;
}

/* Force the add to cart button to be enabled when bundle is selected */
.vqb-bundle-selector ~ form.cart .single_add_to_cart_button {
    opacity: 1 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Hide variation price display (we show our own) */
.vqb-bundle-selector ~ form.cart .woocommerce-variation-price {
    display: none !important;
}

/* Responsive */
@media (max-width: 480px) {
    .vqb-tier {
        padding: 14px 15px;
    }
    
    .vqb-tier-content {
        gap: 12px;
    }
    
    .vqb-tier-title {
        font-size: 13px;
    }
    
    .vqb-tier-subtitle {
        font-size: 11px;
    }
    
    .vqb-tier-savings {
        font-size: 11px;
        padding: 2px 8px;
        margin-top: 3px;
        display: inline-block;
        background: rgba(155, 123, 184, 0.15);
        border-radius: 20px;
        color: var(--vqb-primary, #9B7BB8);
        font-weight: 600;
    }
    
    .vqb-price-current {
        font-size: 16px;
    }
    
    .vqb-price-original {
        font-size: 11px;
    }
    
    .vqb-badge {
        font-size: 9px;
        padding: 3px 8px;
        right: 10px;
    }
    
    .vqb-header-text {
        font-size: 10px;
    }
    
    .vqb-subscription-option {
        padding: 12px 14px;
    }
    
    .vqb-subscription-title {
        font-size: 13px;
    }
    
    .vqb-subscription-subtitle {
        font-size: 11px;
    }
    
    .vqb-variation-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .vqb-variation-select {
        width: 100%;
    }
}

/* Animation for selection */
@keyframes vqb-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(155, 123, 184, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(155, 123, 184, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(155, 123, 184, 0);
    }
}

.vqb-tier.vqb-tier-selected {
    animation: vqb-pulse 0.5s ease-out;
}

/* WooCommerce Integration Fixes */
.woocommerce div.product .vqb-bundle-selector {
    clear: both;
}

.woocommerce div.product form.cart {
    margin-top: 0;
}

/* AJAX Loading State */
form.cart.processing {
    opacity: 0.6;
    pointer-events: none;
}

form.cart.processing button[type="submit"],
form.cart.processing input[type="submit"] {
    position: relative;
}

/* VQB Notice */
.vqb-notice {
    margin-bottom: 15px;
    padding: 12px 15px;
    border-radius: 4px;
}

.vqb-notice.woocommerce-message {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.vqb-notice.woocommerce-error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* Added to cart message */
.vqb-added-message {
    margin-bottom: 20px;
}

.vqb-added-message .button {
    margin-left: 10px;
}

/* Mini Cart Subtotal Styling */
.woocommerce-mini-cart__total .vqb-subtotal-discounted {
    font-weight: 700 !important;
}

.woocommerce-mini-cart__total .vqb-subtotal-original {
    margin-left: 8px !important;
    color: #999 !important;
    font-weight: 400 !important;
    text-decoration: line-through !important;
}

.woocommerce-mini-cart__total .vqb-subtotal-original * {
    text-decoration: line-through !important;
}

/* Cart drawer discount styling */
.vqb-mini-cart-discount {
    padding: 10px 0;
    margin-bottom: 10px;
    border-top: 1px solid #eee;
    font-size: 14px;
    color: #4CAF50;
    font-weight: 600;
}
