/* Product Bundle Frontend Styles - Complete Fixed Version with Mobile Improvements */
/* File: assets/css/product-bundle-frontend.css */

/* ========================================
   Screen Reader Only - Accessible hiding
   ======================================== */

.ecosupp-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ========================================
   Base Bundle Container Styles
   ======================================== */

.ecosupp-product-bundle-options {
    margin: 30px 0;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    background: #f8f9fa;
    font-family: inherit;
    direction: rtl;
}

.ecosupp-product-bundle-combined {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 24px;
    direction: rtl;
}

/* ========================================
   Bundle Title
   ======================================== */

.bundle-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 20px 0;
    color: #333;
    text-align: right;
    direction: rtl;
}

/* ========================================
   Bundle Options Layout
   ======================================== */

.bundle-options-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.bundle-option-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    transition: all 0.3s ease;
    position: relative;
    direction: rtl;
    text-align: right;
}

.bundle-option-item:hover {
    border-color: #007cba;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.15);
}

.bundle-option-item.selected {
    border-color: #007cba;
    background: #f0f8ff;
}

/* ========================================
   Bundle Content Layout
   ======================================== */

.bundle-content {
    display: flex;
    align-items: center;
    gap: 20px;
    justify-content: space-between;
}

/* Style 1: Title | Price | Button */
.bundle-layout-style1 .bundle-product-name {
    text-align: right;
    order: 1;
    flex: 0 0 40%;
}

.bundle-layout-style1 .bundle-pricing {
    text-align: center;
    order: 2;
    flex: 0 0 35%;
}

.bundle-layout-style1 .bundle-actions {
    order: 3;
    flex: 0 0 25%;
    text-align: left;
}

/* Style 2: Button | Price | Title */
.bundle-layout-style2 .bundle-actions {
    order: 1;
    flex: 0 0 25%;
}

.bundle-layout-style2 .bundle-pricing {
    text-align: center;
    order: 2;
    flex: 0 0 35%;
}

.bundle-layout-style2 .bundle-product-name {
    text-align: right;
    order: 3;
    flex: 0 0 40%;
}

/* ========================================
   Bundle Info and Pricing
   ======================================== */

.bundle-pricing {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.price-row-horizontal {
    display: flex;
    align-items: baseline;
    gap: 10px;
    justify-content: center;
    margin-bottom: 4px;
    flex-direction: row-reverse;
}

.bundle-crossed-price {
    text-decoration: line-through;
    color: #999;
    font-size: 16px;
}

.bundle-main-price {
    font-size: 24px;
    font-weight: 700;
    color: #000;
}

.bundle-price-breakdown {
    margin-top: 6px;
    line-height: 1.4;
    font-size: 12px;
    color: #666;
}

/* ========================================
   Bundle Badge
   ======================================== */

.bundle-badge-text {
    display: inline-block;
    background: #ffc107;
    color: #333;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    margin-top: 8px;
}

/* ========================================
   Bundle Add to Cart Button
   ======================================== */

.bundle-add-to-cart-btn {
    background: #2c5f4f;
    color: white;
    border: none;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
    white-space: nowrap;
}

.bundle-add-to-cart-btn:hover {
    background: #1e4a3a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(44, 95, 79, 0.3);
}

.bundle-add-to-cart-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.bundle-add-to-cart-btn.loading {
    opacity: 0.8;
}

.bundle-add-to-cart-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.bundle-add-to-cart-btn.success {
    background: #28a745 !important;
}

/* ========================================
   Combined Bundle Styles
   ======================================== */

.combined-bundle-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.combined-bundle-items {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
}

.combined-bundle-items h4 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.bundle-items-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.bundle-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
}

.bundle-item:last-child {
    border-bottom: none;
}

.bundle-item-name {
    font-weight: 500;
    color: #333;
    flex: 1;
}

.bundle-item-quantity {
    background: #2c5f4f;
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.combined-bundle-cart {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: nowrap;
}

.bundle-total-price {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    flex: 0 0 auto;
}

.bundle-crossed-price {
    text-decoration: line-through;
    color: #999;
    font-size: 18px;
}

.bundle-main-price {
    font-size: 28px;
    font-weight: 700;
    color: #000;
}

/* ========================================
   Quantity Selector - COMPLETE FIX
   ======================================== */

.bundle-quantity-button-wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Universal quantity container for all bundle types */
.ecosupp-product-bundle-combined .quantity,
.ecosupp-product-bundle-options .quantity,
.bundle-quantity-button-wrapper .quantity,
.combined-bundle-cart .quantity {
    display: inline-flex !important;
    align-items: center;
    border: 2px solid #ddd !important;
    border-radius: 30px !important;
    overflow: hidden;
    background: #fff !important;
    height: 40px !important;
    position: relative;
    margin: 0;
    width: auto !important;
}

/* Quantity buttons for all contexts */
.ecosupp-product-bundle-combined .qty-btn,
.ecosupp-product-bundle-combined .minus,
.ecosupp-product-bundle-combined .plus,
.ecosupp-product-bundle-options .qty-btn,
.bundle-quantity-button-wrapper .qty-btn,
.bundle-quantity-button-wrapper .minus,
.bundle-quantity-button-wrapper .plus,
.combined-bundle-cart .qty-btn,
.combined-bundle-cart .minus,
.combined-bundle-cart .plus {
    background: #fff !important;
    border: none !important;
    width: 36px !important;
    height: 36px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    font-size: 20px !important;
    font-weight: 400 !important;
    color: #666 !important;
    transition: all 0.2s ease !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
}

.ecosupp-product-bundle-combined .qty-btn:hover,
.bundle-quantity-button-wrapper .qty-btn:hover,
.combined-bundle-cart .qty-btn:hover {
    background: #f0f0f0 !important;
    color: #333 !important;
}

.ecosupp-product-bundle-combined .minus,
.bundle-quantity-button-wrapper .minus,
.combined-bundle-cart .minus {
    border-right: 1px solid #ddd !important;
}

.ecosupp-product-bundle-combined .plus,
.bundle-quantity-button-wrapper .plus,
.combined-bundle-cart .plus {
    border-left: 1px solid #ddd !important;
}

/* Quantity input for all contexts */
.ecosupp-product-bundle-combined input[type="number"],
.ecosupp-product-bundle-combined input.qty,
.ecosupp-product-bundle-options input[type="number"],
.bundle-quantity-button-wrapper input[type="number"],
.bundle-quantity-button-wrapper input.qty,
.combined-bundle-cart input[type="number"],
.combined-bundle-cart input.qty {
    border: none !important;
    background: transparent !important;
    width: 50px !important;
    text-align: center !important;
    padding: 0 !important;
    margin: 0 !important;
    height: 36px !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    color: #333 !important;
    -moz-appearance: textfield !important;
    outline: none !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}

.ecosupp-product-bundle-combined input[type="number"]::-webkit-outer-spin-button,
.ecosupp-product-bundle-combined input[type="number"]::-webkit-inner-spin-button,
.bundle-quantity-button-wrapper input[type="number"]::-webkit-outer-spin-button,
.bundle-quantity-button-wrapper input[type="number"]::-webkit-inner-spin-button,
.combined-bundle-cart input[type="number"]::-webkit-outer-spin-button,
.combined-bundle-cart input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

/* ========================================
   Combined Bundle Add Button
   ======================================== */

.combined-bundle-add-btn {
    background: #2c5f4f !important;
    color: #fff !important;
    border: none !important;
    padding: 12px 28px !important;
    border-radius: 30px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-width: 140px;
    position: relative;
}

.combined-bundle-add-btn:hover {
    background: #1e4a3a !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(44, 95, 79, 0.3);
}

.combined-bundle-add-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.combined-bundle-add-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.combined-bundle-add-btn.success {
    background: #28a745 !important;
}

/* ========================================
   Out of Stock Styles
   ======================================== */

.ecosupp-product-bundle-options.out-of-stock,
.ecosupp-product-bundle-combined.out-of-stock {
    opacity: 0.7;
}

.out-of-stock-message {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 12px 20px;
    border-radius: 4px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 500;
}

.bundle-option-item.out-of-stock {
    opacity: 0.5;
    pointer-events: none;
}

.bundle-option-item.out-of-stock .bundle-add-to-cart-btn {
    background: #6c757d !important;
    cursor: not-allowed;
}

/* ========================================
   Loading Animation
   ======================================== */

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   Mini Cart Protection Styles
   ======================================== */

/* Reset mini cart styles to prevent conflicts */
.widget_shopping_cart .quantity,
.woocommerce-mini-cart .quantity,
.cart_list .quantity,
.dropdown-cart .quantity,
.wd-dropdown-cart .quantity {
    display: block !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
}

.widget_shopping_cart .quantity input,
.woocommerce-mini-cart .quantity input,
.cart_list .quantity input,
.dropdown-cart .quantity input,
.wd-dropdown-cart .quantity input {
    width: auto !important;
    border: 1px solid #ddd !important;
    background: #fff !important;
    padding: 5px !important;
    height: auto !important;
    font-size: 14px !important;
    -webkit-appearance: auto !important;
}

.widget_shopping_cart button:not(.qty-btn),
.woocommerce-mini-cart button:not(.qty-btn),
.dropdown-cart button:not(.qty-btn) {
    all: revert;
}

.woocommerce-mini-cart-item {
    display: flex !important;
    align-items: flex-start !important;
    padding: 10px 0 !important;
    border-bottom: 1px solid #eee !important;
}

.woocommerce-mini-cart-item:last-child {
    border-bottom: none !important;
}

.woocommerce-mini-cart-item dl.variation dt:empty,
.woocommerce-mini-cart-item dl.variation dd:empty {
    display: none !important;
}

.woocommerce-mini-cart-item .variation dd p {
    margin: 0 !important;
    font-size: 13px !important;
    color: #666 !important;
}

/* ========================================
   MOBILE RESPONSIVE STYLES - YOUR FIX
   ======================================== */

@media (max-width: 768px) {
    /* Container adjustments */
    .ecosupp-product-bundle-options,
    .ecosupp-product-bundle-combined {
        padding: 16px;
        margin: 20px 0;
    }
    
    /* Make bundle content horizontal */
    .bundle-content {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 10px !important;
        width: 100% !important;
    }
    
    /* Product name - left side */
    .bundle-product-name {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
        order: 1 !important;
        font-size: 14px !important;
        max-width: none !important;
    }
    
    /* Pricing - center */
    .bundle-pricing {
        flex: 1 1 auto !important;
        text-align: center !important;
        order: 2 !important;
        max-width: none !important;
    }
    
    /* Keep price breakdown below main price */
    .bundle-pricing .price-row-horizontal {
        display: block !important;
    }
    
    /* Make price breakdown more compact */
    .bundle-price-breakdown {
        font-size: 11px !important;
        line-height: 1.2 !important;
        margin-top: 4px !important;
    }
    
    .bundle-main-price {
        font-size: 18px !important;
    }
    
    .bundle-crossed-price {
        font-size: 14px !important;
    }
    
    /* Button - right side */
    .bundle-actions {
        flex: 0 0 auto !important;
        order: 3 !important;
        max-width: none !important;
    }
    
    .bundle-add-to-cart-btn,
    .combined-bundle-add-btn {
        padding: 10px 16px !important;
        border-radius: 25px !important;
        white-space: nowrap !important;
        font-size: 14px !important;
        min-width: 80px !important;
        max-width: calc(100vw - 100px) !important;
    }
    
    /* Badge text below the horizontal content */
    .bundle-badge-text {
        margin-top: 10px !important;
        width: 100% !important;
        text-align: center !important;
        font-size: 12px !important;
        display: block !important;
    }
    
    /* Ensure option items have proper spacing */
    .bundle-option-item {
        margin-bottom: 15px !important;
        padding: 15px !important;
    }
    
    /* Combined bundle specific mobile styles */
    .combined-bundle-cart {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .bundle-total-price {
        align-items: center;
        width: 100%;
        text-align: center;
    }
    
    .bundle-quantity-button-wrapper {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        gap: 12px;
    }
    
    .bundle-quantity-button-wrapper .quantity {
        flex: 0 0 auto;
    }
    
    .combined-bundle-add-btn {
        flex: 1;
        padding: 12px 20px !important;
        font-size: 14px !important;
        min-width: unset;
    }
    
    .bundle-title {
        font-size: 18px;
        margin-bottom: 15px;
    }
}

/* Small mobile (below 480px) */
@media (max-width: 479px) {
    .ecosupp-product-bundle-options,
    .ecosupp-product-bundle-combined {
        padding: 12px;
        margin: 15px -10px;
    }
    
    /* Even more compact for small screens */
    .bundle-content {
        gap: 8px !important;
    }
    
    .bundle-product-name {
        font-size: 13px !important;
    }
    
    .bundle-main-price {
        font-size: 16px !important;
    }
    
    .bundle-add-to-cart-btn {
        padding: 8px 16px !important;
        font-size: 13px !important;
        min-width: 80px !important;
    }
    
    .bundle-title {
        font-size: 16px;
        margin-bottom: 12px;
    }
    
    .bundle-badge-text {
        font-size: 11px;
        padding: 3px 10px;
    }
    
    .bundle-quantity-button-wrapper {
        flex-direction: column;
        gap: 12px;
    }
    
    .bundle-quantity-button-wrapper .quantity {
        width: 100%;
        justify-content: center;
    }
    
    .combined-bundle-add-btn {
        width: 100%;
        padding: 14px 24px !important;
    }
}

/* ========================================
   WooCommerce Integration Styles
   ======================================== */

.woocommerce .ecosupp-product-bundle-options {
    clear: both;
}

.woocommerce .ecosupp-bundle-add-to-cart {
    font-family: inherit;
}

.single-product .ecosupp-product-bundle-options {
    margin-top: 25px;
}

/* ========================================
   Accessibility Improvements
   ======================================== */

.bundle-option-item:focus,
.bundle-add-to-cart-btn:focus,
.combined-bundle-add-btn:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* ========================================
   RTL Support
   ======================================== */

body.rtl .ecosupp-product-bundle-options,
body.rtl .ecosupp-product-bundle-combined {
    direction: rtl;
    text-align: right;
}

body.rtl .bundle-quantity-button-wrapper {
    flex-direction: row-reverse;
}

body.rtl .bundle-quantity-button-wrapper .minus {
    border-right: none !important;
    border-left: 1px solid #ddd !important;
}

body.rtl .bundle-quantity-button-wrapper .plus {
    border-left: none !important;
    border-right: 1px solid #ddd !important;
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .ecosupp-product-bundle-options {
        border: 1px solid #000;
        background: white;
        color: black;
        box-shadow: none;
    }

    .bundle-option-item {
        border: 1px solid #000;
        background: white;
        box-shadow: none;
    }

    .bundle-add-to-cart-btn,
    .combined-bundle-add-btn {
        display: none;
    }
}

/* ========================================
   Combined Bundle Price Display Styles
   For archive, shop, cart, and checkout
   ======================================== */

.ecosupp-bundle-regular-price {
    color: #999;
    font-size: 0.9em;
    margin-left: 8px;
    text-decoration: line-through;
}

.ecosupp-bundle-sale-price {
    color: #e74c3c;
    font-weight: 600;
    text-decoration: none;
    background: none;
}

/* Cart and mini-cart price display */
.woocommerce-cart-form .ecosupp-bundle-regular-price,
.woocommerce-mini-cart .ecosupp-bundle-regular-price,
.woocommerce-checkout .ecosupp-bundle-regular-price {
    display: inline-block;
    margin-left: 5px;
}

.woocommerce-cart-form .ecosupp-bundle-sale-price,
.woocommerce-mini-cart .ecosupp-bundle-sale-price,
.woocommerce-checkout .ecosupp-bundle-sale-price {
    display: inline-block;
}

/* Archive page price display for bundles */
.woocommerce ul.products li.product .price .ecosupp-bundle-regular-price,
.woocommerce-page ul.products li.product .price .ecosupp-bundle-regular-price {
    font-size: 0.85em;
    opacity: 0.7;
}

.woocommerce ul.products li.product .price .ecosupp-bundle-sale-price,
.woocommerce-page ul.products li.product .price .ecosupp-bundle-sale-price {
    font-size: 1em;
    color: var(--wd-primary-color, #e74c3c);
}

/* Fix overflow and button issues on mobile */
@media (max-width: 768px) {
    .ecosupp-product-bundle-options,
    .ecosupp-product-bundle-combined {
        overflow-x: hidden;
        max-width: 100%;
    }

    .bundle-add-to-cart-btn,
    .combined-bundle-add-btn {
        overflow: hidden;
        text-overflow: ellipsis;
        box-sizing: border-box;
    }

    .combined-bundle-cart {
        overflow: hidden;
    }

    .bundle-quantity-button-wrapper {
        overflow: hidden;
        max-width: 100%;
    }
}
