/**
 * WooCommerce Quantity Buttons Pro - Frontend Styles
 * Version: 2.6.0
 * 
 * @package WooCommerce Quantity Buttons Pro
 */

/* =========================================
   Quantity Wrapper
   ========================================= */
.quantity {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    position: relative;
    gap: var(--wc-qty-spacing, 4px);
    vertical-align: middle;
}

/* =========================================
   Quantity Input
   ========================================= */
.quantity input.qty {
    text-align: center;
    width: var(--wc-qty-input-width, 60px) !important;
    height: var(--wc-qty-input-height, 36px) !important;
    line-height: var(--wc-qty-input-height, 36px) !important;
    font-size: var(--wc-qty-input-font-size, 14px) !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box;
    border: 1px solid #ddd;
    border-radius: var(--wc-qty-input-radius, 4px) !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -moz-appearance: textfield;
}

.quantity input.qty:focus {
    border-color: var(--wc-qty-bg, #d60000);
    outline: none;
    box-shadow: 0 0 0 2px rgba(214, 0, 0, 0.1);
}

/* Remove spinner arrows from number input */
.quantity input.qty::-webkit-inner-spin-button,
.quantity input.qty::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* =========================================
   Plus/Minus Buttons - Base Style
   ========================================= */
.quantity button.qty-minus,
.quantity button.qty-plus {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--wc-qty-bg, #d60000);
    color: #fff;
    border: none;
    width: var(--wc-qty-size, 36px);
    height: var(--wc-qty-size, 36px);
    min-width: var(--wc-qty-size, 36px);
    font-size: var(--wc-qty-font-size, 18px);
    font-weight: bold;
    cursor: pointer;
    border-radius: var(--wc-qty-radius, 4px);
    line-height: 1;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

/* Hover Effect */
.quantity button.qty-minus:hover,
.quantity button.qty-plus:hover {
    background: var(--wc-qty-hover, #a30000);
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Active/Click Effect */
.quantity button.qty-minus:active,
.quantity button.qty-plus:active {
    transform: scale(0.95);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Disabled State */
.quantity button.qty-minus:disabled,
.quantity button.qty-plus:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.quantity button.qty-minus:disabled:hover,
.quantity button.qty-plus:disabled:hover {
    background: var(--wc-qty-bg, #d60000);
    transform: none;
}

/* =========================================
   Animation Classes
   ========================================= */
.quantity.animate button.clicked {
    animation: wc-qty-pulse 0.3s ease;
}

@keyframes wc-qty-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Input Animation */
.quantity.qty-changed input.qty {
    animation: wc-qty-highlight 0.4s ease;
}

@keyframes wc-qty-highlight {
    0%, 100% { 
        background: transparent; 
        transform: scale(1);
    }
    50% { 
        background: rgba(214, 0, 0, 0.05);
        transform: scale(1.02);
    }
}

/* =========================================
   Tooltip Styles
   ========================================= */
.quantity button[data-tooltip] {
    position: relative;
}

.quantity button[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    background: #333;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: normal;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 1000;
}

.quantity button[data-tooltip]::after {
    content: '';
    position: absolute;
    bottom: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
}

.quantity button[data-tooltip]:hover::before,
.quantity button[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.quantity button[data-tooltip]:hover::after {
    transform: translateX(-50%);
}

/* =========================================
   Theme Compatibility Fixes
   ========================================= */
.woocommerce .quantity,
.woocommerce-page .quantity,
.elementor-widget-woocommerce-cart .quantity,
.woocommerce table.cart .quantity,
body .quantity,
.woocommerce-cart .quantity {
    display: inline-flex !important;
}

/* Ensure buttons show on all themes */
.quantity button.qty-minus,
.quantity button.qty-plus {
    visibility: visible !important;
    opacity: 1 !important;
}

/* =========================================
   Loading State
   ========================================= */
.quantity.loading {
    opacity: 0.6;
    pointer-events: none;
}

.quantity.loading button {
    cursor: wait;
}

/* =========================================
   Mobile Optimization
   ========================================= */
@media (max-width: 768px) {
    .quantity {
        gap: 3px;
    }
    
    .quantity button.qty-minus,
    .quantity button.qty-plus {
        min-width: 36px;
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    .quantity input.qty {
        width: 50px !important;
        height: 36px !important;
        font-size: 14px !important;
    }
}

@media (max-width: 480px) {
    .quantity button.qty-minus,
    .quantity button.qty-plus {
        min-width: 32px;
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .quantity input.qty {
        width: 45px !important;
        height: 32px !important;
        font-size: 13px !important;
    }
}

/* =========================================
   Dark Mode Support
   ========================================= */
@media (prefers-color-scheme: dark) {
    .quantity input.qty {
        background: #2a2a2a;
        color: #fff;
        border-color: #444;
    }
    
    .quantity input.qty:focus {
        border-color: var(--wc-qty-bg, #d60000);
    }
}

/* =========================================
   Accessibility
   ========================================= */
.quantity button:focus {
    outline: 2px solid var(--wc-qty-bg, #d60000);
    outline-offset: 2px;
}

.quantity button:focus:not(:focus-visible) {
    outline: none;
}

.quantity button:focus-visible {
    outline: 2px solid var(--wc-qty-bg, #d60000);
    outline-offset: 2px;
}

/* Screen reader only text */
.screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
}

/* =========================================
   Print Styles
   ========================================= */
@media print {
    .quantity button.qty-minus,
    .quantity button.qty-plus {
        display: none !important;
    }
    
    .quantity input.qty {
        border: 1px solid #000 !important;
    }
}

/* =========================================
   RTL Support
   ========================================= */
[dir="rtl"] .quantity {
    flex-direction: row-reverse;
}

/* =========================================
   High Contrast Mode
   ========================================= */
@media (prefers-contrast: high) {
    .quantity button.qty-minus,
    .quantity button.qty-plus {
        border: 2px solid currentColor;
    }
    
    .quantity input.qty {
        border: 2px solid #000;
    }
}

/* =========================================
   Reduced Motion
   ========================================= */
@media (prefers-reduced-motion: reduce) {
    .quantity button.qty-minus,
    .quantity button.qty-plus,
    .quantity input.qty {
        transition: none !important;
        animation: none !important;
    }
    
    .quantity.animate button.clicked {
        animation: none !important;
    }
    
    .quantity.qty-changed input.qty {
        animation: none !important;
    }
}

/* =========================================
   Shop/Archive Page Quantity Inputs
   ========================================= */
.wc-qty-shop-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.wc-qty-shop-container.wc-qty-layout-before {
    flex-direction: row-reverse;
}

.wc-qty-shop-container .quantity.wc-qty-shop-loop {
    margin: 0;
}

/* Shop page add to cart button with quantity */
.wc-qty-shop-ajax {
    min-width: 120px;
    flex-shrink: 0;
}

/* Ensure shop quantity buttons are visible */
.wc-qty-shop-loop button.qty-minus,
.wc-qty-shop-loop button.qty-plus {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Mobile responsive for shop quantity */
@media (max-width: 768px) {
    .wc-qty-shop-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .wc-qty-shop-container.wc-qty-layout-before {
        flex-direction: column-reverse;
    }
    
    .wc-qty-shop-container .quantity {
        justify-content: center;
    }
    
    .wc-qty-shop-ajax {
        width: 100%;
        text-align: center;
    }
}

/* =========================================
   Success Messages
   ========================================= */
.wc-qty-success-message {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.wc-qty-toast,
.wc-qty-inline,
.wc-qty-modal-content {
    box-sizing: border-box;
}

.wc-qty-toast *,
.wc-qty-inline *,
.wc-qty-modal-content * {
    box-sizing: border-box;
}

/* Modal overlay */
.wc-qty-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999997;
}

/* Mobile modal adjustments */
@media (max-width: 480px) {
    .wc-qty-modal-content {
        padding: 24px !important;
        width: 95% !important;
    }
    
    .wc-qty-modal-content h3 {
        font-size: 20px !important;
    }
    
    .wc-qty-modal-buttons {
        flex-direction: column !important;
    }
    
    .wc-qty-continue,
    .wc-qty-view-cart {
        width: 100% !important;
    }
}

/* =========================================
   Cart Table Specific Styles
   ========================================= */
.woocommerce-cart-form .quantity {
    margin: 0;
}

.woocommerce table.cart .quantity {
    display: inline-flex !important;
}

/* =========================================
   Mini Cart Widget
   ========================================= */
.widget_shopping_cart .quantity {
    display: inline-flex !important;
    transform: scale(0.9);
}

/* =========================================
   Variable Product Support
   ========================================= */
.variations_form .quantity {
    display: inline-flex !important;
}

/* =========================================
   Grouped Product Support
   ========================================= */
.woocommerce-grouped-product-list .quantity {
    display: inline-flex !important;
}

/* =========================================
   WooCommerce Blocks Support
   ========================================= */
.wc-block-components-quantity-selector .quantity {
    display: inline-flex !important;
}

/* =========================================
   Elementor Widget Support
   ========================================= */
.elementor-widget-woocommerce-product-add-to-cart .quantity {
    display: inline-flex !important;
}

.elementor-widget-woocommerce-cart .quantity {
    display: inline-flex !important;
}

/* =========================================
   Quick View Support
   ========================================= */
.quick-view-content .quantity,
.yith-quick-view-content .quantity,
.woocommerce-quick-view .quantity {
    display: inline-flex !important;
}

/* =========================================
   Order Form / Wholesale Support
   ========================================= */
.wc-mnm-add-to-cart .quantity,
.composite_form .quantity,
.bundle_form .quantity {
    display: inline-flex !important;
}

/* =========================================
   Fix for themes that hide buttons
   ========================================= */
.quantity button.qty-minus[style*="display: none"],
.quantity button.qty-plus[style*="display: none"],
.quantity button.qty-minus[style*="display:none"],
.quantity button.qty-plus[style*="display:none"] {
    display: inline-flex !important;
}

/* =========================================
   Added state for add to cart buttons
   ========================================= */
.wc-qty-shop-ajax.added {
    background-color: #28a745 !important;
}

.wc-qty-shop-ajax.loading {
    opacity: 0.7;
    pointer-events: none;
}
