/*!
 * FPD Toolkit Styles - No-Bleed Version
 * Revision: 15
 * File: /fpd-toolkit/assets/css/fpd-tlkt-styles.css
 * Description: HOTFIX - Made input overrides FPD-specific only to prevent bleeding into regular WooCommerce
 *
 * @author Brian Anderson - Philosopher Dragons Web Design
 * @link https://phdragons.com
 * @link https://github.com/Arconz
 *
 * Note: Email is for support inquiries only. Unsolicited solicitations will be blacklisted.
 * @email arconz@phdragons.com
 *
 * Did it work? Did it inspire you? Did it make you laugh so hard you fell out of your chair?
 * @donate https://coff.ee/arconz
 *
 * Changelog:
 * - Revision 15: HOTFIX - Made input overrides FPD-specific only to prevent bleeding into regular WooCommerce
 * - Revision 14: Added high-priority padding overrides to counter theme's input[type="number"] rules
 * - Revision 13: Removed ALL cart button styling - let theme handle colors completely
 */

/* ===============================================
   HIGH-PRIORITY OVERRIDES - FPD SPECIFIC ONLY
   =============================================== */

/* Override theme's generic input[type="number"] padding - ONLY for FPD products */
.fpd-custom-quantity-wrapper input[type="number"],
.fpd-cart-quantity-wrapper input[type="number"],
.woocommerce .fpd-custom-quantity-wrapper input[type="number"],
.woocommerce-cart .fpd-cart-quantity-wrapper input[type="number"],
div.product .fpd-custom-quantity-wrapper input[type="number"],
input[type="number"]#fpd_custom_quantity,
input[type="number"].fpd-cart-qty-input {
    padding: 6px 8px !important; /* Force override theme's .5rem 1rem */
}

/* Specific width overrides - ONLY for FPD products */
.fpd-custom-quantity-wrapper input[type="number"],
.woocommerce .fpd-custom-quantity-wrapper input[type="number"],
div.product .fpd-custom-quantity-wrapper input[type="number"],
input[type="number"]#fpd_custom_quantity {
    width: 60px !important; /* Product page - fixed width */
}

.fpd-cart-quantity-wrapper input[type="number"].fpd-cart-qty-input,
.woocommerce-cart .fpd-cart-quantity-wrapper input[type="number"] {
    width: 50px !important; /* Cart page - smaller width */
}

/* ===============================================
   RESET & BASE STYLES (Unchanged - working parts)
   =============================================== */

/* Hide standard WC quantity when our custom quantity is active */
.fpd-quantity-enabled .quantity:not(.fpd-custom-quantity-wrapper .quantity) {
    display: none;
}

/* Base container reset for consistent behavior across themes */
.fpd-custom-quantity-wrapper,
.fpd-cart-quantity-wrapper {
    box-sizing: border-box;
    position: relative;
}

/* ===============================================
   ELEMENTOR BUTTON SPACING FIX (High Priority)
   =============================================== */

/* Counter Elementor's button spacing rule specifically for our quantity buttons */
.elementor-widget-woocommerce-product-add-to-cart form.cart .fpd-qty-plus,
.elementor-widget-wc-add-to-cart form.cart .fpd-qty-plus,
.woocommerce div.product .elementor-widget-woocommerce-product-add-to-cart form.cart .fpd-qty-plus,
.woocommerce div.product .elementor-widget-wc-add-to-cart form.cart .fpd-qty-plus {
    margin-left: 0 !important; /* Override Elementor's --button-spacing */
    margin-right: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.elementor-widget-woocommerce-product-add-to-cart form.cart .fpd-qty-minus,
.elementor-widget-wc-add-to-cart form.cart .fpd-qty-minus,
.woocommerce div.product .elementor-widget-woocommerce-product-add-to-cart form.cart .fpd-qty-minus,
.woocommerce div.product .elementor-widget-wc-add-to-cart form.cart .fpd-qty-minus {
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* Ensure our quantity controls stay together as a unit */
.elementor-widget-woocommerce-product-add-to-cart .fpd-custom-quantity-wrapper .fpd-quantity-input-wrapper,
.elementor-widget-wc-add-to-cart .fpd-custom-quantity-wrapper .fpd-quantity-input-wrapper,
.woocommerce div.product .elementor-widget-woocommerce-product-add-to-cart .fpd-custom-quantity-wrapper .fpd-quantity-input-wrapper,
.woocommerce div.product .elementor-widget-wc-add-to-cart .fpd-custom-quantity-wrapper .fpd-quantity-input-wrapper {
    display: inline-flex;
    align-items: stretch;
    gap: 0;
    margin: 0;
}

/* ===============================================
   PRODUCT PAGE STYLES (Minimal, targeted changes)
   =============================================== */

/* Product page quantity wrapper */
.fpd-custom-quantity-wrapper {
    margin: 20px 0;
    clear: both;
}

.fpd-custom-quantity-wrapper label {
    font-weight: bold;
    margin-right: 10px;
    display: inline-block;
    vertical-align: middle;
}

/* Product quantity input containers - only target our specific elements */
.fpd-custom-quantity-wrapper .fpd-quantity-input-wrapper {
    display: inline-flex;
    align-items: stretch;
    height: 38px;
    vertical-align: middle;
    margin: 0;
    gap: 0;
}

/* ===============================================
   CART STYLES (PRESERVE EXISTING COLORS)
   =============================================== */

/* Cart quantity containers - minimal styling to avoid color conflicts */
.fpd-cart-quantity-wrapper {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 0;
    height: 32px;
    margin: 0;
    vertical-align: middle;
    /* Deliberately NOT setting background, color, or border colors */
    /* Let the cart keep its existing color scheme */
}

/* ===============================================
   QUANTITY BUTTONS (Preserve cart colors)
   =============================================== */

/* Product page buttons - can have our styling */
.fpd-custom-quantity-wrapper .fpd-qty-minus,
.fpd-custom-quantity-wrapper .fpd-qty-plus {
    width: 32px;
    height: 38px;
    border: 1px solid #ddd;
    background: #f9f9f9;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    color: #333;
    transition: all 0.3s ease;
    user-select: none;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Cart buttons - ONLY structural properties, NO color overrides */
.fpd-cart-quantity-wrapper .fpd-cart-qty-minus,
.fpd-cart-quantity-wrapper .fpd-cart-qty-plus {
    width: 26px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Absolutely NO color, background, border, or font styling */
    /* Let the cart theme handle ALL visual appearance */
}

/* Product button hover states */
.fpd-custom-quantity-wrapper .fpd-qty-minus:hover:not(:disabled),
.fpd-custom-quantity-wrapper .fpd-qty-plus:hover:not(:disabled) {
    background: #007cba;
    color: white;
    border-color: #005a87;
}

/* ===============================================
   QUANTITY INPUTS (Preserve cart styling)
   =============================================== */

/* Product page inputs */
.fpd-custom-quantity-wrapper input[type="number"],
.fpd-custom-quantity-wrapper .wapf-input,
input#fpd_custom_quantity {
    width: 60px !important;
    text-align: center;
    border: 1px solid #ddd;
    border-left: none;
    border-right: none;
    height: 100%;
    box-sizing: border-box;
    font-size: 16px;
    font-weight: bold;
    background: white;
    padding: 6px 8px !important; /* Override theme's .5rem 1rem padding */
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

/* Cart inputs - ONLY structural, zero visual styling */
.fpd-cart-quantity-wrapper .fpd-cart-qty-input,
table.cart .fpd-cart-qty-input {
    width: 50px !important;
    text-align: center;
    height: 100%;
    box-sizing: border-box;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
    padding: 6px 8px !important; /* Override theme's .5rem 1rem padding */
    /* Let cart theme handle colors but override structure */
}

/* Remove spinner arrows */
input#fpd_custom_quantity::-webkit-outer-spin-button,
input#fpd_custom_quantity::-webkit-inner-spin-button,
.fpd-custom-quantity-wrapper input[type="number"]::-webkit-outer-spin-button,
.fpd-custom-quantity-wrapper input[type="number"]::-webkit-inner-spin-button,
.fpd-cart-qty-input::-webkit-outer-spin-button,
.fpd-cart-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
    display: none;
}

/* Input focus states */
.fpd-custom-quantity-wrapper input[type="number"]:focus,
.fpd-custom-quantity-wrapper .wapf-input:focus,
input#fpd_custom_quantity:focus,
.fpd-cart-qty-input:focus {
    border-color: #007cba;
    box-shadow: 0 0 3px rgba(0, 124, 186, 0.3);
    outline: none;
}

/* ===============================================
   VALIDATION STATES
   =============================================== */

.fpd-cart-qty-input.fpd-qty-invalid,
.fpd-custom-quantity-wrapper input[type="number"].fpd-qty-invalid,
.fpd-custom-quantity-wrapper .wapf-input.fpd-qty-invalid,
input#fpd_custom_quantity.fpd-qty-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 1px rgba(220, 53, 69, 0.2);
    animation: fpd-error-pulse 0.5s ease;
}

.fpd-cart-qty-input.fpd-qty-valid,
.fpd-custom-quantity-wrapper input[type="number"].fpd-qty-valid,
.fpd-custom-quantity-wrapper .wapf-input.fpd-qty-valid,
input#fpd_custom_quantity.fpd-qty-valid {
    border-color: #28a745;
    box-shadow: 0 0 0 1px rgba(40, 167, 69, 0.2);
}

@keyframes fpd-error-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

/* ===============================================
   PROCESSING STATES
   =============================================== */

.fpd-cart-quantity-wrapper.fpd-updating,
.fpd-custom-quantity-wrapper.fpd-updating {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.fpd-cart-quantity-wrapper.fpd-updating::after,
.fpd-custom-quantity-wrapper.fpd-updating::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #333;
    border-radius: 50%;
    animation: fpd-spin 1s linear infinite;
    z-index: 10;
}

@keyframes fpd-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===============================================
   OVERLAY MESSAGING SYSTEM
   =============================================== */

.fpd-cart-update-overlay {
    position: fixed;
    top: 20px;
    right: 20px;
    transform: translateX(100%);
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    max-width: 300px;
}

.fpd-cart-update-overlay.active {
    transform: translateX(0);
    opacity: 1;
}

.fpd-overlay-content {
    background: #fff;
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #2ea2cc;
    font-size: 14px;
    font-weight: 500;
    min-width: 200px;
    word-wrap: break-word;
}

/* Overlay message types */
.fpd-cart-update-overlay.success .fpd-overlay-content {
    border-left-color: #46b450;
    background: #f7fff7;
}

.fpd-cart-update-overlay.warning .fpd-overlay-content {
    border-left-color: #ffb900;
    background: #fffbf0;
}

.fpd-cart-update-overlay.error .fpd-overlay-content {
    border-left-color: #dc3232;
    background: #ffeaea;
}

.fpd-cart-update-overlay.info .fpd-overlay-content {
    border-left-color: #00a0d2;
    background: #f0f8ff;
}

/* ===============================================
   WAPF INTEGRATION - SPECIFIC COMPATIBILITY
   =============================================== */

/* WAPF wrapper compatibility - work with WAPF rather than against it */
.wapf-wrapper .fpd-custom-quantity-wrapper {
    background: transparent;
    border: none;
    padding: 0;
    margin: 10px 0;
}

.wapf-wrapper .fpd-cart-quantity-wrapper {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
}

/* Ensure WAPF fields integrate properly with our quantity controls */
.wapf-wrapper .fpd-custom-quantity-wrapper input.wapf-input {
    border-left: none;
    border-right: none;
}

/* WAPF calculation integration */
.wapf-wrapper .fpd-custom-quantity-wrapper.wapf-recalculating {
    opacity: 0.8;
}

/* ===============================================
   ELEMENTOR COMPATIBILITY
   =============================================== */

/* Elementor Mini Cart specific styles */
.elementor-widget-woocommerce-cart .fpd-cart-quantity-wrapper,
.elementor-cart .fpd-cart-quantity-wrapper {
    flex: 0 0 auto;
}

.elementor-widget-woocommerce-cart .fpd-cart-quantity-wrapper > * {
    flex: 0 0 auto;
}

/* Elementor popup compatibility */
.elementor-popup-modal .fpd-cart-quantity-wrapper,
.elementor-popup-modal .fpd-custom-quantity-wrapper {
    position: relative;
    z-index: 1;
}

/* ===============================================
   RESPONSIVE DESIGN
   =============================================== */

@media (max-width: 768px) {
    .fpd-custom-quantity-wrapper label {
        display: block;
        margin-bottom: 10px;
    }

    .fpd-custom-quantity-wrapper .fpd-quantity-input-wrapper,
    .fpd-cart-quantity-wrapper {
        width: 100%;
        max-width: 200px;
        justify-content: center;
    }

    .fpd-cart-update-overlay {
        top: 10px;
        right: 10px;
        left: 10px;
        transform: translateY(-100%);
        max-width: 90%;
        margin: 0 auto;
    }

    .fpd-cart-update-overlay.active {
        transform: translateY(0);
    }

    .fpd-overlay-content {
        text-align: center;
        font-size: 13px;
        padding: 10px 15px;
    }
}

@media (max-width: 480px) {
    .fpd-qty-minus,
    .fpd-qty-plus {
        width: 28px;
        font-size: 14px;
    }

    .fpd-cart-qty-minus,
    .fpd-cart-qty-plus {
        width: 24px;
        font-size: 12px;
    }

    .fpd-custom-quantity-wrapper input[type="number"],
    input#fpd_custom_quantity {
        width: 55px;
        font-size: 14px;
    }

    .fpd-cart-qty-input {
        width: 45px;
        font-size: 13px;
    }
}

/* ===============================================
   ACCESSIBILITY ENHANCEMENTS
   =============================================== */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .fpd-qty-minus,
    .fpd-qty-plus,
    .fpd-cart-qty-minus,
    .fpd-cart-qty-plus {
        border-width: 2px;
        border-color: #000;
    }

    .fpd-overlay-content {
        border: 2px solid;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .fpd-cart-update-overlay {
        transition: opacity 0.1s;
    }

    .fpd-cart-update-overlay.active {
        transform: translateX(0);
    }

    .fpd-cart-quantity-wrapper.fpd-updating::after,
    .fpd-custom-quantity-wrapper.fpd-updating::after {
        animation: none;
        background: rgba(0, 115, 170, 0.1);
    }

    .fpd-qty-minus:hover:not(:disabled),
    .fpd-qty-plus:hover:not(:disabled),
    .fpd-cart-qty-minus:hover:not(:disabled),
    .fpd-cart-qty-plus:hover:not(:disabled) {
        transform: none;
    }
}

/* Focus visible for keyboard navigation */
.fpd-qty-minus:focus-visible,
.fpd-qty-plus:focus-visible,
.fpd-cart-qty-minus:focus-visible,
.fpd-cart-qty-plus:focus-visible {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Screen reader support */
.fpd-quantity-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}