/* ==========================================================
 * ABTAL - Metrage Calculator & Product Page Styles
 * Extracted from inline styles for caching performance
 * ========================================================== */

/* Cacher le prix WooCommerce sous les variations */
.woocommerce-variation-price,
.woocommerce-variation-availability,
.single_variation_wrap .woocommerce-variation-price {
    display: none !important;
}

/* ===== METRAGE CALCULATOR - Hook Version ===== */
.metrage-calculator.metrage-hook {
    width: 100%;
    background: #f8f8f8;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    font-family: 'Montserrat', sans-serif;
}

.metrage-hook .calc-row {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
}

.metrage-hook .calc-label {
    font-weight: 600;
    font-size: 13px;
    color: #333;
    width: 130px;
    flex-shrink: 0;
}

.metrage-hook .calc-sublabel {
    display: block;
    font-weight: 400;
    font-size: 10px;
    color: #888;
}

.metrage-hook .calc-input {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    height: 36px;
}

.metrage-hook .calc-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: #e53e3e;
    color: #fff;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    margin: 0;
}

.metrage-hook .calc-btn:hover {
    background: #c53030;
}

.metrage-hook .calc-input input {
    width: 60px !important;
    height: 36px !important;
    border: none !important;
    border-left: 1px solid #ddd !important;
    border-right: 1px solid #ddd !important;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    -moz-appearance: textfield;
}

.metrage-hook .calc-input input::-webkit-outer-spin-button,
.metrage-hook .calc-input input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.metrage-hook .calc-price {
    font-weight: 700;
    font-size: 15px;
    color: #e53e3e;
    margin-left: auto;
    padding-left: 15px;
    white-space: nowrap;
}

.metrage-hook .calc-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 5px 0;
    margin-top: 5px;
}

.metrage-hook .calc-total-label {
    font-weight: 700;
    font-size: 15px;
    color: #333;
    text-transform: uppercase;
}

.metrage-hook .calc-total-price {
    display: flex;
    align-items: center;
    gap: 10px;
}

.metrage-hook .total-regular-price {
    text-decoration: line-through;
    color: #999;
    font-size: 14px;
}

.metrage-hook .total-sale-price {
    font-weight: 700;
    font-size: 18px;
    color: #e53e3e;
}

@media (max-width: 480px) {
    .metrage-hook .calc-label {
        width: 100px;
        font-size: 12px;
    }
    .metrage-hook .calc-btn {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
    .metrage-hook .calc-input {
        height: 32px;
    }
    .metrage-hook .calc-input input {
        width: 45px !important;
        height: 32px !important;
        font-size: 13px;
    }
    .metrage-hook .calc-price {
        font-size: 13px;
        padding-left: 10px;
    }
    .metrage-hook .total-sale-price {
        font-size: 16px;
    }
}

/* ===== METRAGE CALCULATOR - Shortcode Version ===== */
/* Cacher le champ quantité WooCommerce original quand le calculateur est présent */
.woocommerce-variation-add-to-cart .quantity,
.woocommerce-variation-add-to-cart .e-atc-qty-button-holder .quantity,
.e-atc-qty-button-holder .quantity {
    display: none !important;
}

/* Annuler le margin ajouté par Elementor Pro sur le bouton Add to Cart */
.elementor-widget-woocommerce-product-add-to-cart form.cart .button,
.elementor-widget-woocommerce-product-add-to-cart form.cart button,
.elementor-widget-wc-add-to-cart form.cart .button,
.elementor-widget-wc-add-to-cart form.cart button {
    margin-inline-start: 0 !important;
}

.metrage-calculator.metrage-shortcode {
    width: 100%;
    background: #f8f8f8;
    padding: 15px;
    border-radius: 8px;
    margin: 10px 0;
    font-family: 'Montserrat', sans-serif;
}

.metrage-shortcode .calc-row {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
    gap: 15px;
}

.metrage-shortcode .calc-label {
    font-weight: 600;
    font-size: 13px;
    color: #333;
    width: 130px;
    flex-shrink: 0;
}

.metrage-shortcode .calc-sublabel {
    display: block;
    font-weight: 400;
    font-size: 10px;
    color: #888;
}

.metrage-shortcode .calc-input {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    height: 36px;
}

.metrage-shortcode .calc-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #d1d5db;
    background: #f8f8f8;
    color: #374151;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    margin: 0;
}

.metrage-shortcode .calc-btn:hover {
    background: #e5e7eb;
}

.metrage-shortcode .calc-input input {
    width: 60px !important;
    height: 36px !important;
    border: none !important;
    border-left: 1px solid #ddd !important;
    border-right: 1px solid #ddd !important;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    -moz-appearance: textfield;
}

.metrage-shortcode .calc-input input::-webkit-outer-spin-button,
.metrage-shortcode .calc-input input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.metrage-shortcode .calc-price {
    font-weight: 700;
    font-size: 15px;
    color: #374151;
    margin-inline-start: auto;
    padding-inline-start: 15px;
    white-space: nowrap;
}

.metrage-shortcode .calc-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 5px 0;
    margin-top: 5px;
}

.metrage-shortcode .calc-total-label {
    font-weight: 700;
    font-size: 15px;
    color: #333;
    text-transform: uppercase;
}

.metrage-shortcode .calc-total-price {
    display: flex;
    align-items: center;
    gap: 10px;
}

.metrage-shortcode .total-regular-price {
    text-decoration: line-through;
    color: #999;
    font-size: 14px;
}

.metrage-shortcode .total-sale-price {
    font-weight: 700;
    font-size: 18px;
    color: #1f2937;
}

/* Ligne Récapitulatif */
.metrage-shortcode .calc-row-recap {
    background: #f0f0f0;
    margin: 0 -15px;
    padding: 10px 15px;
    border-bottom: none;
}

.metrage-shortcode .calc-recap-detail {
    font-size: 13px;
    color: #555;
    font-weight: 500;
    flex: 1;
}

/* Style quantité WooCommerce */
.woocommerce-variation-add-to-cart .quantity {
    display: inline-flex !important;
    align-items: stretch !important;
    border: 1px solid #d1d5db !important;
    border-radius: 4px !important;
    overflow: hidden !important;
    background: #fff !important;
    height: 36px !important;
}

.woocommerce-variation-add-to-cart .quantity input.qty {
    width: 60px !important;
    height: 36px !important;
    border: none !important;
    border-left: 1px solid #d1d5db !important;
    border-right: 1px solid #d1d5db !important;
    text-align: center !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #333 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    -moz-appearance: textfield !important;
}

.woocommerce-variation-add-to-cart .quantity input.qty::-webkit-outer-spin-button,
.woocommerce-variation-add-to-cart .quantity input.qty::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

.woocommerce-variation-add-to-cart .quantity .qty-btn {
    width: 36px !important;
    height: 36px !important;
    border: none !important;
    background: #f8f8f8 !important;
    color: #374151 !important;
    font-size: 20px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    transition: background 0.2s !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    padding: 0 !important;
    margin: 0 !important;
}

.woocommerce-variation-add-to-cart .quantity .qty-btn:hover {
    background: #e5e7eb !important;
}

@media (max-width: 480px) {
    .metrage-shortcode .calc-label {
        width: 100px;
        font-size: 12px;
    }
    .metrage-shortcode .calc-btn {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
    .metrage-shortcode .calc-input {
        height: 32px;
    }
    .metrage-shortcode .calc-input input {
        width: 45px !important;
        height: 32px !important;
        font-size: 13px;
    }
    .metrage-shortcode .calc-price {
        font-size: 13px;
        padding-left: 10px;
    }
    .metrage-shortcode .total-sale-price {
        font-size: 16px;
    }
    /* Récapitulatif en vertical sur mobile */
    .metrage-shortcode .calc-row-recap {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    .metrage-shortcode .calc-row-recap .calc-label {
        width: 100%;
        margin-bottom: 3px;
    }
    .metrage-shortcode .calc-recap-detail {
        font-size: 11px;
        line-height: 1.4;
    }
}

/* ===== MINI CALCULATEUR QUANTITÉ - TOUS PRODUITS ===== */
.qty-calculator {
    width: 100%;
    background: #f8f8f8;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    font-family: 'Montserrat', sans-serif;
}

.qty-calculator .calc-row {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
}

.qty-calculator .calc-row:last-of-type {
    border-bottom: none;
}

.qty-calculator .calc-label {
    font-weight: 600;
    font-size: 13px;
    color: #333;
    width: 130px;
    flex-shrink: 0;
}

.qty-calculator .calc-input {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    height: 36px;
}

.qty-calculator .calc-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #d1d5db;
    background: #f8f8f8;
    color: #374151;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    margin: 0;
}

.qty-calculator .calc-btn:hover {
    background: #e5e7eb;
}

.qty-calculator .calc-input input {
    width: 60px !important;
    height: 36px !important;
    border: none !important;
    border-left: 1px solid #d1d5db !important;
    border-right: 1px solid #d1d5db !important;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    -moz-appearance: textfield;
}

.qty-calculator .calc-input input::-webkit-outer-spin-button,
.qty-calculator .calc-input input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.qty-calculator .calc-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 5px 0;
    margin-top: 5px;
}

.qty-calculator .calc-total-label {
    font-weight: 700;
    font-size: 15px;
    color: #333;
    text-transform: uppercase;
}

.qty-calculator .calc-total-price {
    display: flex;
    align-items: center;
    gap: 10px;
}

.qty-calculator .total-regular-price {
    text-decoration: line-through;
    color: #999;
    font-size: 14px;
}

.qty-calculator .total-sale-price {
    font-weight: 700;
    font-size: 18px;
    color: #1f2937;
}

/* Cacher le prix WooCommerce et l'ancienne quantité */
.qty-calculator-active .woocommerce-variation-price,
.qty-calculator-active .woocommerce-Price-amount,
.qty-calculator-active .single_variation .price {
    display: none !important;
}

.qty-calculator-active .woocommerce-variation-add-to-cart .quantity {
    display: none !important;
}

@media (max-width: 480px) {
    .qty-calculator .calc-label {
        width: 100px;
        font-size: 12px;
    }
    .qty-calculator .calc-btn {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
    .qty-calculator .calc-input {
        height: 32px;
    }
    .qty-calculator .calc-input input {
        width: 45px !important;
        height: 32px !important;
        font-size: 13px;
    }
    .qty-calculator .total-sale-price {
        font-size: 16px;
    }
}

/* ===== BOUTON ADD TO CART ===== */
.single_add_to_cart_button,
.single_add_to_cart_button.button,
.single_add_to_cart_button.button.alt,
form.cart .single_add_to_cart_button,
.woocommerce .single_add_to_cart_button,
.woocommerce-variation-add-to-cart .single_add_to_cart_button,
.elementor-widget-woocommerce-product-add-to-cart .single_add_to_cart_button,
.elementor-widget-wc-add-to-cart .single_add_to_cart_button {
    background-color: #e53e3e !important;
    color: #ffffff !important;
    border: none !important;
    transition: background-color 0.3s ease !important;
}

.single_add_to_cart_button:hover,
.single_add_to_cart_button.button:hover,
.single_add_to_cart_button.button.alt:hover,
form.cart .single_add_to_cart_button:hover,
.woocommerce .single_add_to_cart_button:hover,
.woocommerce-variation-add-to-cart .single_add_to_cart_button:hover,
.elementor-widget-woocommerce-product-add-to-cart .single_add_to_cart_button:hover,
.elementor-widget-wc-add-to-cart .single_add_to_cart_button:hover {
    background-color: #c53030 !important;
    color: #ffffff !important;
}

.single_add_to_cart_button:disabled,
.single_add_to_cart_button.disabled,
.single_add_to_cart_button:disabled:hover {
    background-color: #ccc !important;
    color: #666 !important;
    cursor: not-allowed !important;
}

/* ===== FIX MOBILE - VARIATIONS SELECTS ===== */
.variations_form select,
.variations select,
#pa_hauteur,
#pa_largeur,
#pa_longueur {
    position: relative !important;
    z-index: 10 !important;
    pointer-events: auto !important;
    touch-action: manipulation !important;
    cursor: pointer !important;
    min-height: 44px !important;
    font-size: 16px !important;
}

.variations_form select::before,
.variations_form select::after,
.variations td.value::before,
.variations td.value::after {
    pointer-events: none !important;
}

.variations_form,
.variations_form .variations,
.variations_form table.variations,
.variations_form table.variations tr,
.variations_form table.variations td,
.variations_form table.variations td.value,
.variations_form .value {
    position: relative !important;
    overflow: visible !important;
    z-index: auto !important;
}

.elementor-widget-woocommerce-product-add-to-cart,
.elementor-widget-woocommerce-product-add-to-cart .elementor-widget-container,
.elementor-add-to-cart,
.elementor-product-variable,
.single_variation_wrap {
    overflow: visible !important;
}

@media (max-width: 768px) {
    .variations_form select,
    #pa_hauteur,
    #pa_largeur,
    #pa_longueur {
        min-height: 50px !important;
        font-size: 16px !important;
        padding: 12px 15px !important;
        -webkit-tap-highlight-color: rgba(0,0,0,0.2);
    }
}

/* ===== RTL Support pour Arabe ===== */
html[lang="ar"] .variations_form table.variations tr,
html[dir="rtl"] .variations_form table.variations tr,
body.rtl .variations_form table.variations tr {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-bottom: 15px;
}

html[lang="ar"] .variations_form table.variations th.label,
html[dir="rtl"] .variations_form table.variations th.label,
body.rtl .variations_form table.variations th.label {
    order: 1;
    text-align: right;
    width: 100%;
    padding-bottom: 5px;
}

html[lang="ar"] .variations_form table.variations td.value,
html[dir="rtl"] .variations_form table.variations td.value,
body.rtl .variations_form table.variations td.value {
    order: 2;
    width: 100%;
}

html[lang="ar"] .variations_form table.variations td.value select,
html[dir="rtl"] .variations_form table.variations td.value select,
body.rtl .variations_form table.variations td.value select {
    width: 100%;
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] .jet-woo-quantity-button-added.position-horizontal,
html[lang="ar"] .jet-woo-quantity-button-added.position-horizontal {
    direction: ltr;
}

/* ===== RTL Cart/Checkout Fixes ===== */
html[dir="rtl"] .table-heading-name,
html[dir="rtl"] .table-heading-quantity,
html[dir="rtl"] .table-heading-price {
    font-size: 0 !important;
    line-height: 0 !important;
}
html[dir="rtl"] .table-heading-name::after {
    content: "المنتج";
    font-size: 14px !important;
    line-height: normal !important;
}
html[dir="rtl"] .table-heading-quantity::after {
    content: "الكمية";
    font-size: 14px !important;
    line-height: normal !important;
}
html[dir="rtl"] .table-heading-price::after {
    content: "السعر";
    font-size: 14px !important;
    line-height: normal !important;
}

html[dir="rtl"] .cart_totals > h2 {
    display: none !important;
}

html[dir="rtl"] .wc-proceed-to-checkout a.checkout-button {
    font-size: 0 !important;
    line-height: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}
html[dir="rtl"] .wc-proceed-to-checkout a.checkout-button::after {
    content: "إتمام الطلب";
    font-size: 18px !important;
    line-height: normal !important;
    color: #fff !important;
}

html[dir="rtl"] .jet-woo-quantity-button-added.position-horizontal {
    direction: ltr;
}

html[dir="rtl"] .woocommerce-Price-amount,
html[dir="rtl"] .woocommerce-Price-amount bdi {
    direction: ltr;
    unicode-bidi: isolate;
    display: inline-block;
}

/* ===== LANGUAGE SWITCHER ===== */
.flag-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.flag {
    font-size: 14px;
    line-height: 1;
    display: block;
}

.custom-lang-switcher-dropdown {
    position: relative;
    display: inline-block;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
}

.current-lang-display {
    background-color: transparent;
    color: #4B5563;
    padding: 8px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 200ms;
    font-weight: 400;
    font-size: 14px;
    border-style: solid;
    border-width: 1px;
    border-color: #E5E7EB;
    border-radius: 100px;
}

.current-lang-display:hover {
    color: #1F2937;
}

.current-lang-display .lang-name {
    font-size: 14px;
    color: #4B5563;
}

.lang-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 150px;
    background-color: #ffffff;
    border: 1px solid #E5E7EB;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    margin-top: 4px;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: #4B5563;
    text-decoration: none;
    transition: all 200ms;
    font-size: 14px;
    border-bottom: 1px solid #F3F4F6;
}

.lang-option:last-child {
    border-bottom: none;
}

.lang-option:hover {
    background-color: #F9FAFB;
    color: #1F2937;
}

.lang-option.active {
    background-color: #F3F4F6;
    font-weight: 500;
    color: #1F2937;
}

.lang-option .flag,
.current-lang-display .flag {
    font-size: 14px;
}

.custom-lang-switcher-buttons {
    display: flex;
    gap: 4px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    align-items: center;
}

.lang-button {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 15px;
    border-style: solid;
    border-width: 1px;
    border-color: #E5E7EB;
    border-radius: 100px;
    background-color: transparent;
    color: #4B5563;
    text-decoration: none;
    transition: all 200ms;
    font-weight: 400;
    font-size: 14px;
}

.lang-button:hover {
    background-color: #F3F4F6;
    color: #1F2937;
}

.lang-button.active {
    background-color: #E5E7EB;
    color: #1F2937;
    font-weight: 500;
}

.lang-button .flag {
    font-size: 14px;
}

.dropdown-arrow {
    font-size: 10px;
    transition: transform 200ms;
    color: #4B5563;
    margin-left: 2px;
}

.custom-lang-switcher-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

@media (max-width: 768px) {
    .current-lang-display {
        padding: 6px 8px;
        gap: 4px;
    }
    .lang-button {
        padding: 6px 8px;
    }
    .flag,
    .lang-button .flag,
    .lang-option .flag,
    .current-lang-display .flag {
        font-size: 14px;
    }
    .custom-lang-switcher-buttons {
        gap: 2px;
    }
    .lang-dropdown-menu {
        min-width: 130px;
    }
}
