.pymaddtocart-container {
    display: block;
    width: 100% !important;
    direction: rtl;
}

/* استایل برای فرم‌های دینامیک */
.pymaddtocart-dynamic {
    position: relative;
}

.pymaddtocart-dynamic .pymaddtocart-form {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.pymaddtocart-dynamic.loading .pymaddtocart-form {
    opacity: 0.7;
}

/* استایل برای لودر */
.quantity-loader {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: loading 1s linear infinite;
}

.pymaddtocart-form {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100% !important;
}

.pymaddtocart-quantity-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.pymaddtocart-quantity-label {
    display: inline-block;
    color: #333;
}

.quantity.pymaddtocart-quantity {
    display: flex;
    justify-content: end;
}

.pymaddtocart-layout-horizontal .pymaddtocart-form {
    flex-direction: row;
    align-items: center;
}

.pymaddtocart-quantity {
    position: relative;
    display: inline-flex;
    align-items: center;
    border: 1px solid #ccc;
    border-radius: 12px;
    padding: 5px;
    background-color: #fff;
    box-shadow: -5px 5px 20px -10px rgba(204,204,204,1);
}

.pymaddtocart-quantity .input-text {
    width: 50px !important;
    height: 32px !important;
    text-align: center;
    border: none;
    background-color: #fbfbfb;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: none;
}

.pymaddtocart-quantity .input-text::-webkit-inner-spin-button,
.pymaddtocart-quantity .input-text::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* اولویت بالا برای دکمه‌ی Add to Cart */
button.single_add_to_cart_button.button.alt.pymaddtocart-button.icon-before {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box;
}

/* در صورتی که فرم شما با Flex Layout چیده شده */
.pymaddtocart-layout-horizontal .pymaddtocart-form button.single_add_to_cart_button {
    flex: 1 1 auto !important;
}

.pymaddtocart-btn {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.pymaddtocart-btn svg,
.pymaddtocart-btn i {
    width: 18px;
    height: 18px;
}

.pymaddtocart-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 16px !important;
    background-color: #066737 !important;
    color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
    box-sizing: border-box;
    line-height: 1 !important;
    min-height: 48px !important;
}

.pymaddtocart-button:hover,
.woocommerce .pymaddtocart-button:hover {
    background-color: #BD9E6B !important;
    color: #fff !important;
}

.pymaddtocart-button:focus,
.woocommerce .single_add_to_cart_button.button.alt.pymaddtocart-button:focus {
    background-color: #BD9E6B !important;
}

/* استایل برای تراز کردن متن و آیکون در دکمه */
.pymaddtocart-button-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 8px;
}

.pymaddtocart-button-content svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.pymaddtocart-button-content span {
    line-height: 1;
    vertical-align: middle;
}

/* استایل‌های ساختار شماره 2 */
.pymaddtocart-structure-structure_2 :is(.elementor-product-simple .cart, .elementor-product-variable .woocommerce-variation-add-to-cart) {
    height: 50px;
    margin-top: 10px;
    width: 100% !important;
    display: flex;
    flex-direction: column;
}

/* مخفی کردن فضای اضافی برای محصولات تک متغیره */
.pymaddtocart-structure-structure_2 .pym-variation-container-title-wrapper:empty {
    display: none !important;
}

.pymaddtocart-structure-structure_2 .pym-variation-swatches:empty {
    display: none !important;
}

/* حذف margin و padding اضافی برای کانتینرهای خالی */
.pymaddtocart-structure-structure_2 .pym-variation-container-title-wrapper:not(:has(*)) {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.pymaddtocart-structure-structure_2 .pym-variation-swatches:not(:has(.pym-variation-swatch)) {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* مخفی کردن کانتینرهای سواچ که توسط JavaScript مخفی شده‌اند */
.pymaddtocart-structure-structure_2 .pym-variation-swatches[style*="display: none"] {
    margin: 0 !important;
    padding: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* اطمینان از عدم نمایش کانتینرهای خالی در تمام ساختارها */
.pym-variation-container-title-wrapper:empty,
.pym-variation-swatches:empty {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.pymaddtocart-structure-structure_2 .pymaddtocart-structure-structure_2 {
    width: 100% !important;
    display: flex;
    flex-direction: column;
}

.pymaddtocart-structure-structure_2 .quantity {
    width: 100%;
    gap: 15px;
    display: none;
}

.pymaddtocart-quantity-container {
    display: flex;
    width: 100%;
    height: 100%;
    background: #fff;
    justify-content: center;
    border-radius: 10px;
    box-shadow: 0 0 10px -5px #999;
    padding: 5px;
}

.pymaddtocart-structure-structure_2 .pymaddtocart-quantity-container > div {
    flex-basis: 32%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pymaddtocart-structure-structure_2 .pymaddtocart-quantity-box {
    flex-direction: column;
    flex-grow: 1;
    justify-content: space-between !important;
}

.pymaddtocart-structure-structure_2 .pymaddtocart-quantity-span {
    width: 100%;
    font-size: 1.1rem;
    line-height: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
}

.pymaddtocart-structure-structure_2 .pymaddtocart-text-span {
    font-size: .6rem;
    opacity: .9;
    white-space: nowrap;
    display: inline-block;
}

.pymaddtocart-structure-structure_2 .pymaddtocart-plus-btn,
.pymaddtocart-structure-structure_2 .pymaddtocart-minus-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.pymaddtocart-structure-structure_2 .pymaddtocart-minus-btn .pymaddtocart-minus-svg {
    display: none;
}

.pymaddtocart-structure-structure_2 .pymaddtocart-go-to-shop {
    /* background color and text color will be set by Elementor controls */
    border-radius: 10px;
    box-shadow: 0 0 10px -5px #999;
    flex-basis: 100%;
    padding: 1px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 500;
    font-size: .9rem;
    text-decoration: none;
}

.pymaddtocart-structure-structure_2 .single_add_to_cart_button {
    margin: 0 !important;
    /* background color will be set by Elementor controls */
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100% !important;
    min-width: 100% !important;
    flex: 1 1 100% !important;
    box-sizing: border-box !important;
}

.pymaddtocart-structure-structure_2 .quantity-loader {
    --loader-width: 8px;
    --loader-color1: #fff;
    --loader-color2: #cccccc9f;
    width: var(--loader-width);
    aspect-ratio: 1;
    border-radius: 50%;
    animation: loading 1s infinite linear alternate;
}

.pymaddtocart-structure-structure_2 .pymaddtocart-quantity-span .quantity-loader {
    --loader-width: 7px;
    width: var(--loader-width);
    --loader-color1: #000000b6;
    --loader-color2: rgba(105, 105, 105, 0.624);
}

@keyframes loading {
    0%  {box-shadow: calc(3px + var(--loader-width)) 0 var(--loader-color1), calc(-1 * var(--loader-width) - 3px) 0 var(--loader-color2);background: var(--loader-color1)}
    33% {box-shadow: calc(3px + var(--loader-width)) 0 var(--loader-color1), calc(-1 * var(--loader-width) - 3px) 0 var(--loader-color2);background: var(--loader-color2)}
    66% {box-shadow: calc(3px + var(--loader-width)) 0 var(--loader-color2), calc(-1 * var(--loader-width) - 3px) 0 var(--loader-color1); background: var(--loader-color2)}
    100%{box-shadow: calc(3px + var(--loader-width)) 0 var(--loader-color2), calc(-1 * var(--loader-width) - 3px) 0 var(--loader-color1); background: var(--loader-color1)}
}

/* استایل‌های موجودی برای محصولات متغیر */
.pym-stock-in {
    color: #28a745;
    font-weight: 500;
}

.pym-stock-out {
    color: #dc3545;
    font-weight: 500;
}

/* استایل‌های برچسب قیمت پرداختی */
.pym-payment-price-label {
    display: inline-block;
    margin: 0 8px 8px 0;
    font-weight: 500;
    text-align: center;
}

/* استایل‌های برچسب قیمت پرداختی داخل قیمت متغیر */
.pym-variation-price .pym-payment-price-label {
    display: inline-block;
    margin: 0 8px 0 0;
    font-weight: 500;
    text-align: center;
}

/* استایل‌های قیمت متغیر برای نمایش عناصر خطی */
.pym-variation-price {
    /* اجازه می‌دهد توسط تنظیمات ویجت (align/block/inline) کنترل شود */
    display: inline-block;
    width: 100%;
}

/* نمایش جدید: سمت راست لیبل+درصد زیر هم، سمت چپ قیمت */
.pym-variation-price {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.pym-variation-price .pym-variation-price-matched,
.pym-variation-price .pym-variation-price-amount {
    display: inline-block;
    vertical-align: middle;
}

/* کانتینر عمودی برای لیبل و درصد (سمت راست) */
.pym-variation-price .pym-payment-extra {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.pym-variation-price .pym-payment-price-label {
    display: block;
    width: fit-content;
    margin: 0;
    font-weight: 500;
    text-align: right;
}

.pym-variation-price .pym-discount-percentage {
    display: inline-block;
    margin: 0;
    font-weight: bold;
    text-align: center;
    background-color: #dc3545;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
    width: fit-content;
    align-self: flex-start;
}

/* استایل‌های درصد تخفیف */
.pym-discount-percentage {
    display: inline-block;
    margin: 0 4px;
    font-weight: bold;
    text-align: center;
    background-color: #dc3545;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
    width: fit-content;
    align-self: center;
}

/* استایل‌های responsive برای عناصر جدید */
@media (max-width: 768px) {
    .pym-payment-price-label {
        font-size: 14px;
        margin-bottom: 6px;
    }

    .pym-discount-percentage {
        font-size: 12px;
        padding: 3px 6px;
        margin-bottom: 6px;
    }
}

/* استایل‌های Badge تخفیف سواچ‌ها */
.pym-swatch-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    z-index: 10;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* برای زبان‌های RTL، موقعیت Badge را تنظیم کنیم */
[dir="rtl"] .pym-swatch-badge {
    right: auto;
    left: -8px;
}

/* استایل‌های مربوط به سواچ‌های انتخاب شده */
.pym-variation-swatch.selected,
.pym-variation-swatch.active {
    border-color: var(--pym-primary-color, #007cba) !important;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.3);
    transform: scale(1.05);
}

/* استایل‌های مربوط به سواچ‌های غیرفعال */
.pym-variation-swatch.pym-disabled {
    opacity: 0.4;
    cursor: not-allowed !important;
    pointer-events: none;
    filter: grayscale(50%);
}

.pym-variation-swatch.pym-disabled:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* استایل‌های دکمه Reset */
.pym-variation-reset-container {
    display: flex !important;
    justify-content: flex-start !important;
    margin-bottom: 15px !important;
    padding: 0 5px !important;
}

.pym-variation-reset-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 8px 12px !important;
    background: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 6px !important;
    color: #6c757d !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
    outline: none !important;
}

.pym-variation-reset-btn:hover {
    background: #e9ecef !important;
    border-color: #adb5bd !important;
    color: #495057 !important;
    transform: translateY(-1px) !important;
}

.pym-variation-reset-btn:active {
    transform: translateY(0) !important;
    background: #dee2e6 !important;
}

.pym-variation-reset-btn svg {
    width: 14px !important;
    height: 14px !important;
    transition: transform 0.2s ease !important;
}

.pym-variation-reset-btn:hover svg {
    transform: rotate(180deg) !important;
}

.pym-reset-text {
    font-family: inherit !important;
}

/* حالت disabled برای دکمه Reset */
.pym-variation-reset-btn:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

/* استایل responsive برای دکمه Reset */
@media (max-width: 768px) {
    .pym-variation-reset-btn {
        padding: 6px 10px !important;
        font-size: 12px !important;
    }
    
    .pym-variation-reset-btn svg {
        width: 12px !important;
        height: 12px !important;
    }
}

.pym-variation-swatch.selected .pym-swatch-badge {
    opacity: 1;
    transform: scale(1);
}

/* نمایش Badge در حالت‌های مختلف */
.pym-variation-swatch:hover .pym-swatch-badge,
.pym-variation-swatch:focus .pym-swatch-badge {
    opacity: 1;
    transform: scale(1);
}


/* مخفی کردن Badge زمانی که مقدار ندارد */
.pym-variation-swatch .pym-swatch-badge:empty,
.pym-variation-swatch .pym-swatch-badge[data-value="0"] {
    display: none !important;
}

/* استایل‌های responsive برای Badge */
@media (max-width: 768px) {
    .pym-swatch-badge {
        font-size: 10px;
        top: -6px;
        right: -6px;
        padding: 1px 3px;
    }

    [dir="rtl"] .pym-swatch-badge {
        left: -6px;
    }
}

/* استایل‌های اضافی برای سازگاری بهتر */
.pymaddtocart-container .pym-variation-swatch {
    position: relative;
    overflow: visible;
}

/* استایل‌های قیمت‌گذاری نشده */
.pym-variation-price .pym-no-price {
    color: #dc3545;
    font-weight: 500;
    font-style: italic;
    opacity: 0.8;
}

.pym-variation-price-no-price {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
}

.pym-variation-price-no-price .pym-no-price {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 8px 12px;
    border-radius: 6px;
    color: #6c757d;
    font-size: 14px;
}