/* مخفی‌سازی عنوان برگه فقط داخل محدوده محتوا */
body.woocommerce-cart .entry-content > .entry-header,
body.woocommerce-cart h1.entry-title {
    display: none;
}

/* ساختار دو ستونه اصلی سبد خرید - دقیقاً محدود به کانتینر محتوا */
body.woocommerce-cart .entry-content > .woocommerce,
body.woocommerce-cart main > .woocommerce,
body.woocommerce-cart #primary .woocommerce {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 380px !important;
    grid-template-areas:
        "notices notices"
        "cartform sidebar" !important;
    gap: 32px !important;
    align-items: start !important;
    width: 100% !important;
    max-width: 1280px !important;
    margin: 0 auto !important;
    padding: 24px 16px !important;
    box-sizing: border-box !important;
    direction: rtl !important;
}

/* ایزوله‌سازی باکس مدل */
body.woocommerce-cart .woocommerce-cart-form *,
body.woocommerce-cart .cart-collaterals * {
    box-sizing: border-box;
}

body.woocommerce-cart .woocommerce-notices-wrapper {
    grid-area: notices !important;
    width: 100% !important;
    margin-bottom: 0 !important;
}

/* ۱. فرم و جدول سبد خرید */
body.woocommerce-cart form.woocommerce-cart-form {
    grid-area: cartform !important;
    min-width: 0 !important;
    width: 100% !important;
    float: none !important;
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

body.woocommerce-cart form.woocommerce-cart-form .woocommerce-cart-form__contents {
    display: block !important;
    width: 100% !important;
    background: #fff;
    border: 1px solid var(--ksn-border, #e5e7eb);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

body.woocommerce-cart form.woocommerce-cart-form table.shop_table thead {
    display: none !important;
}

body.woocommerce-cart form.woocommerce-cart-form table.cart tbody {
    display: block !important;
    width: 100% !important;
}

/* سطر کالا: ستون ۱ (عکس + تعداد) | ستون ۲ (نام + قیمت‌ها + حذف) */
body.woocommerce-cart form.woocommerce-cart-form table.cart tbody tr.woocommerce-cart-form__cart-item {
    display: grid !important;
    grid-template-columns: 110px minmax(0, 1fr) !important;
    grid-template-rows: auto auto auto 1fr !important;
    column-gap: 24px !important;
    row-gap: 10px !important;
    align-items: start !important;
    border: 0 !important;
    border-bottom: 1px solid var(--ksn-border, #e5e7eb) !important;
    background: #fff !important;
    padding: 24px !important;
    margin: 0 !important;
    width: 100% !important;
}

body.woocommerce-cart form.woocommerce-cart-form table.cart tbody tr.woocommerce-cart-form__cart-item:last-child {
    border-bottom: 0 !important;
}

/* تصویر کالا */
body.woocommerce-cart form.woocommerce-cart-form table.cart td.product-thumbnail {
    grid-column: 1 !important;
    grid-row: 1 / 4 !important;
    width: 110px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    display: flex !important;
    justify-content: center !important;
    align-self: start !important;
}

body.woocommerce-cart form.woocommerce-cart-form table.cart td.product-thumbnail img {
    width: 100px !important;
    height: 100px !important;
    object-fit: contain !important;
    border-radius: 8px !important;
    display: block !important;
}

/* باکس تعداد */
body.woocommerce-cart form.woocommerce-cart-form table.cart td.product-quantity {
    grid-column: 1 !important;
    grid-row: 4 !important;
    width: 110px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    display: flex !important;
    justify-content: center !important;
    align-self: end !important;
}

body.woocommerce-cart form.woocommerce-cart-form .spv2-qty-wrapper,
body.woocommerce-cart form.woocommerce-cart-form .spv2-qty-control {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    width: 110px !important;
    height: 38px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 1px solid #dcdfe4 !important;
    border-radius: 8px !important;
    background: #fff !important;
    overflow: hidden !important;
    direction: rtl !important;
}

body.woocommerce-cart form.woocommerce-cart-form .spv2-qty-btn {
    flex: 0 0 32px !important;
    width: 32px !important;
    height: 100% !important;
    border: 0 !important;
    background: transparent !important;
    color: #8b0000 !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    user-select: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

body.woocommerce-cart form.woocommerce-cart-form .spv2-qty-btn:hover {
    background: #f4f5f7 !important;
}

body.woocommerce-cart form.woocommerce-cart-form input.spv2-qty-input,
body.woocommerce-cart form.woocommerce-cart-form .spv2-qty-control input.qty {
    flex: 1 1 auto !important;
    width: 40px !important;
    min-width: 0 !important;
    height: 100% !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #f7f8fa !important;
    text-align: center !important;
    font-weight: 700 !important;
    color: var(--ksn-text-main, var(--ksn-text-main)) !important;
    padding: 0 !important;
    margin: 0 !important;
    -moz-appearance: textfield !important;
    appearance: textfield !important;
}

body.woocommerce-cart form.woocommerce-cart-form input.spv2-qty-input::-webkit-outer-spin-button,
body.woocommerce-cart form.woocommerce-cart-form input.spv2-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

body.woocommerce-cart form.woocommerce-cart-form .spv2-qty-unit {
    display: none !important;
}

/* مشخصات، مبالغ و حذف */
body.woocommerce-cart form.woocommerce-cart-form table.cart td.product-name,
body.woocommerce-cart form.woocommerce-cart-form table.cart td.product-price,
body.woocommerce-cart form.woocommerce-cart-form table.cart td.product-subtotal,
body.woocommerce-cart form.woocommerce-cart-form table.cart td.product-remove {
    grid-column: 2 !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    text-align: right !important;
    min-width: 0 !important;
}

body.woocommerce-cart form.woocommerce-cart-form table.cart td.product-name {
    grid-row: 1 !important;
    font-weight: 700 !important;
    font-size: 15px !important;
    line-height: 1.8 !important;
    margin-bottom: 4px !important;
}

body.woocommerce-cart form.woocommerce-cart-form table.cart td.product-name a {
    color: var(--ksn-text-main, var(--ksn-text-main)) !important;
    text-decoration: none !important;
}

body.woocommerce-cart form.woocommerce-cart-form table.cart td.product-price {
    grid-row: 2 !important;
    font-size: 13px !important;
    color: var(--ksn-text-muted, var(--ksn-text-muted)) !important;
    white-space: nowrap !important;
}

body.woocommerce-cart form.woocommerce-cart-form table.cart td.product-price::before {
    content: "قیمت واحد: ";
    font-weight: 400;
}

body.woocommerce-cart form.woocommerce-cart-form table.cart td.product-subtotal {
    grid-row: 3 !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    color: var(--ksn-text-main, var(--ksn-text-main)) !important;
    white-space: nowrap !important;
    margin-bottom: 8px !important;
}

body.woocommerce-cart form.woocommerce-cart-form table.cart td.product-subtotal::before {
    content: "جمع کل: ";
    font-size: 13px;
    font-weight: 400;
    color: var(--ksn-text-muted, var(--ksn-text-muted));
}

body.woocommerce-cart form.woocommerce-cart-form table.cart td.product-remove {
    grid-row: 4 !important;
    align-self: end !important;
    line-height: 38px !important;
}

body.woocommerce-cart form.woocommerce-cart-form table.cart td.product-remove a.remove {
    display: inline-flex !important;
    align-items: center !important;
    background: transparent !important;
    color: #c0392b !important;
    text-decoration: none !important;
    font-size: 0 !important;
    white-space: nowrap !important;
    padding: 0 !important;
    margin: 0 !important;
}

body.woocommerce-cart form.woocommerce-cart-form table.cart td.product-remove a.remove::after {
    content: "حذف از سبد خرید";
    font-size: 13px;
    font-weight: 500;
    color: #c0392b;
    cursor: pointer;
    white-space: nowrap;
}

body.woocommerce-cart form.woocommerce-cart-form table.cart td.product-remove a.remove:hover::after {
    text-decoration: underline;
}

/* کوپن و اکشن‌ها */
body.woocommerce-cart form.woocommerce-cart-form table.cart td.actions {
    border: 0 !important;
    padding: 16px 24px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    border-top: 1px solid var(--ksn-border, #e5e7eb) !important;
}

body.woocommerce-cart form.woocommerce-cart-form .coupon {
    display: flex !important;
    gap: 8px !important;
}

body.woocommerce-cart form.woocommerce-cart-form .coupon input.input-text {
    border: 1px solid var(--ksn-border, #e5e7eb) !important;
    border-radius: 8px !important;
    padding: 0 12px !important;
    height: 42px !important;
    font-size: 13px !important;
}

body.woocommerce-cart form.woocommerce-cart-form .coupon button.button,
body.woocommerce-cart form.woocommerce-cart-form table.cart td.actions button.button {
    background: var(--ksn-primary, #8b0000) !important;
    color: #fff !important;
    border: 0 !important;
    border-radius: 8px !important;
    height: 42px !important;
    padding: 0 20px !important;
    font-size: 14px !important;
    cursor: pointer !important;
}

/* ==========================================================================
   ۲. سایدبار فاکتور (cart-collaterals)
   ========================================================================== */

body.woocommerce-cart .cart-collaterals {
    grid-area: sidebar !important;
    width: 100% !important;
    max-width: 380px !important;
    float: none !important;
    background: #fff !important;
    border: 1px solid var(--ksn-border, #e5e7eb) !important;
    border-radius: 12px !important;
    padding: 24px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
    position: sticky !important;
    top: 90px !important;
    box-sizing: border-box !important;
}

body.woocommerce-cart .cart-collaterals .cart_totals {
    width: 100% !important;
    float: none !important;
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

body.woocommerce-cart .cart-collaterals .cart_totals h2 {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: var(--ksn-text-main, var(--ksn-text-main)) !important;
    margin: 0 0 16px !important;
    padding-bottom: 12px !important;
    border-bottom: 1px solid var(--ksn-border, var(--ksn-bg-subtle)) !important;
    text-align: right !important;
}

body.woocommerce-cart .cart-collaterals .cart_totals table.shop_table {
    display: block !important;
    width: 100% !important;
    border: 0 !important;
    margin: 0 !important;
    background: transparent !important;
}

body.woocommerce-cart .cart-collaterals .cart_totals table.shop_table tbody {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 14px !important;
}

body.woocommerce-cart .cart-collaterals .cart_totals table.shop_table tr {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
    float: none !important;
    margin: 0 !important;
    padding-bottom: 12px !important;
    border: 0 !important;
    border-bottom: 1px dashed var(--ksn-border, #e5e7eb) !important;
}

body.woocommerce-cart .cart-collaterals .cart_totals table.shop_table tr.order-total {
    border-bottom: 0 !important;
    padding-bottom: 0 !important;
    margin-top: 4px !important;
}

body.woocommerce-cart .cart-collaterals .cart_totals th {
    display: inline-block !important;
    width: auto !important;
    border: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: var(--ksn-text-muted, var(--ksn-text-muted)) !important;
    text-align: right !important;
    float: none !important;
}

body.woocommerce-cart .cart-collaterals .cart_totals td {
    display: inline-block !important;
    width: auto !important;
    border: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    font-size: 14px !important;
    text-align: left !important;
    float: none !important;
}

body.woocommerce-cart .cart-collaterals .cart_totals .amount {
    font-weight: 700 !important;
    color: var(--ksn-text-main, var(--ksn-text-main)) !important;
}

body.woocommerce-cart .cart-collaterals .cart_totals .order-total th {
    font-size: 15px !important;
    font-weight: 700 !important;
    color: var(--ksn-text-main, var(--ksn-text-main)) !important;
}

body.woocommerce-cart .cart-collaterals .cart_totals .order-total td .amount {
    font-size: 18px !important;
    font-weight: 800 !important;
    color: var(--ksn-primary, #8b0000) !important;
}

body.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout {
    margin-top: 24px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    padding: 0 !important;
    width: 100% !important;
}

body.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout a.checkout-button:nth-of-type(n+2) {
    display: none !important;
}

body.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout a.checkout-button:first-of-type {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 46px !important;
    background: var(--ksn-primary, #8b0000) !important;
    color: #fff !important;
    border: 0 !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    text-decoration: none !important;
    cursor: pointer !important;
}

body.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout a:not(.checkout-button),
body.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout button:not(.checkout-button) {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 44px !important;
    background: var(--ksn-bg-subtle) !important;
    color: var(--ksn-text-main, var(--ksn-text-main)) !important;
    border: 1px solid var(--ksn-border, var(--ksn-text-sub)) !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
}

/* ریسپانسیو */
@media (max-width: 992px) {
    body.woocommerce-cart .entry-content > .woocommerce,
    body.woocommerce-cart main > .woocommerce,
    body.woocommerce-cart #primary .woocommerce {
        grid-template-columns: 1fr !important;
        grid-template-areas:
            "notices"
            "cartform"
            "sidebar" !important;
    }
    body.woocommerce-cart .cart-collaterals {
        position: static !important;
        max-width: 100% !important;
    }
}

.ksn-row-discount {
    display: block;
    margin-top: 4px;
    color: #ef394e;
    font-size: 12px;
    font-weight: 500;
}
.ksn-total-before th, .ksn-total-before td {
    color: #62666d;
}
.ksn-saving th, .ksn-saving td {
    color: #2e7d32;
    font-weight: 600;
}
.ksn-saving-badge {
    margin-right: 4px;
    font-size: 13px;
}
#ksn_step_4 .woocommerce-checkout-review-order-table tr.woocommerce-shipping-totals,
#ksn_step_4 .woocommerce-checkout-review-order-table thead {
    display: none !important;
}

.woocommerce-checkout .shop_table tr.cart-subtotal {
    display: none !important;
}

/* وضعیت زیر نام کالا در سبد خرید */
.in_stock_notification {
    color: #0a8f40;
    margin: 3px 0 0;
    font-size: 12px;
}

.backorder_notification {
    color: red;
    margin: 3px 0 0;
    font-size: 15px;
}

/* بنرهای بالای سبد خرید */
.ksn-preorder-cart-notice {
    background: #fff8e1;
    border-right: 3px solid #f0b429;
    padding: 14px;
    margin-bottom: 20px;
    border-radius: 6px;
    color: #8a5a00;
    font-size: 14px;
    line-height: 2;
}

.ksn-instock-cart-notice {
    background: #e9f7ef;
    border-right: 3px solid #2e7d32;
    padding: 14px;
    margin-bottom: 20px;
    border-radius: 6px;
    color: #1b5e20;
    font-size: 14px;
    line-height: 2;
}

.ksn-open-preorder-popup {
    color: #b26f00;
    font-weight: 700;
    border-bottom: 1px dashed #d89b2b;
    text-decoration: none;
    transition: .2s ease;
}

.ksn-open-preorder-popup:hover {
    color: #ff9800;
    border-bottom-color: #ff9800;
}

/* هشدارهای برگه تسویه حساب */
.ksn-after-details-notice {
    color: #8a5a00;
    border-right: 3px solid #f0b429;
    background: #fff8e1;
    padding: 10px 14px;
    margin: 15px 0;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.9;
}

.ksn-review-preorder-notice {
    color: #c72c2c;
    border-right: 3px solid #c72c2c;
    background: #fff5f5;
    padding: 10px 14px;
    margin: 15px 0;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.9;
}

/* مودال پاپ‌آپ استعلام کسری */
#ksn-preorder-popup {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
}

.ksn-popup-box {
    width: 90%;
    max-width: 800px;
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.2);
    line-height: 1.8;
}

.ksn-popup-close {
    position: absolute;
    top: 10px;
    left: 10px;
    background: none;
    border: none;
    font-size: 26px;
    cursor: pointer;
}
/* حذف عنوان ستون مرسوله در جدول انتخاب روش ارسال گام سوم */
.ksn-shipping-table tr.woocommerce-shipping-totals > th {
    display: none !important;
}

/* تمام‌عرض شدن سلول حاوی متدهای ارسال */
.ksn-shipping-table tr.woocommerce-shipping-totals > td {
    width: 100% !important;
    display: block !important;
    padding-right: 0 !important;
}

/* اصلاح گرید و بستن فلوت فیلدهای فرم تسویه حساب */
.ksn-checkout-box .ksn-box-content::after,
.ksn-checkout-box .woocommerce-billing-fields__field-wrapper::after {
    content: "";
    display: table;
    clear: both;
}

/* تضمین فاصله و قرارگیری صحیح باکس‌های گام تسویه */
.ksn-checkout-box {
    clear: both;
    display: block;
    width: 100%;
}

/* اگر از flexbox استفاده می‌کنی (راهکار مدرن‌تر به جای float) */
.ksn-checkout-box .ksn-box-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
}

.ksn-checkout-box .ksn-box-content p.form-row {
    float: none !important;
    margin-bottom: 15px;
}

.ksn-checkout-box .ksn-box-content p.form-row-wide {
    width: 100% !important;
}

.ksn-checkout-box .ksn-box-content p.form-row-first,
.ksn-checkout-box .ksn-box-content p.form-row-last {
    width: 48.5% !important;
}
/* نوار بالای گام‌ها (Step Wizard Indicator) */
.ksn-wizard-steps-indicator {
    display: flex;
    justify-content: space-between;
    margin-bottom: 25px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
}
.ksn-step-ind {
    flex: 1;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #6c757d;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.3s ease;
}
.ksn-step-ind span {
    display: inline-block;
    width: 22px;
    height: 22px;
    line-height: 22px;
    background: #e9ecef;
    color: #495057;
    border-radius: 50%;
    margin-left: 5px;
    font-size: 11px;
}
.ksn-step-ind.active {
    background: #ffc107;
    color: #212529;
}
.ksn-step-ind.active span {
    background: #212529;
    color: #ffc107;
}
.ksn-step-ind.completed {
    color: #28a745;
}

/* مدیریت نمایش گام‌ها (فقط گام فعال دیده می‌شود) */
.ksn-checkout-box.ksn-step-box {
    display: none !important;
}
.ksn-checkout-box.ksn-step-box.active {
    display: block !important;
}

/* دکمه‌های ناوبری مراحل */
.ksn-step-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}
.ksn-step-actions .button {
    background-color: #007bff;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
}
.ksn-step-actions .button:hover {
    background-color: #0056b3;
}
.ksn-step-actions .ksn-prev-step {
    background-color: #6c757d;
}
.ksn-step-actions .ksn-prev-step:hover {
    background-color: #5a6268;
}

/* ریسپانسیو موبایل */
@media (max-width: 768px) {
    .ksn-wizard-steps-indicator {
        flex-direction: column;
        gap: 8px;
    }
    .ksn-step-ind {
        text-align: right;
        padding: 6px 12px;
    }
}
/* اصلاح تمام‌عرض شدن کادر شهر و استان */


/* تمام‌عرض کردن و استانداردسازی بخش پرداخت مشابه روش‌های ارسال */
#payment,
#payment .wc_payment_methods {
    width: 100% !important;
    box-sizing: border-box;
}

/* استایل هر گزینه پرداخت مشابه li های حمل و نقل */
#payment .wc_payment_methods li.wc_payment_method {
    background-color: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px;
    padding: 15px !important;
    margin-bottom: 12px !important;
    list-style: none !important;
    position: relative;
    transition: all 0.2s ease;
}

/* استایل برچسب (Label) گزینه پرداخت */
#payment .wc_payment_methods li.wc_payment_method > label {
    font-weight: 600 !important;
    color: #212529 !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* استایل گزینه انتخاب شده (حالت Checked) مشابه روش ارسال */
#payment .wc_payment_methods li.wc_payment_method:has(input:checked) {
    background-color: #f0f7ff !important;
    border-color: #007bff !important;
    border-right: 4px solid #007bff !important;
}

/* باکس توضیحات زیر روش پرداخت */
#payment .wc_payment_methods li.wc_payment_method div.payment_box {
    background: transparent !important;
    border: none !important;
    padding: 10px 0 0 0 !important;
    margin-top: 10px;
    color: #495057;
    font-size: 13px;
    line-height: 1.6;
}

/* استایل دکمه نهایی ثبت سفارش در انتهای بخش پرداخت */
#payment .form-row.place-order {
    width: 100% !important;
    display: block;
    margin-top: 20px;
}

#payment .form-row.place-order button#place_order {
    width: 100% !important;
    background-color: #a81010 !important;
    font-weight: bold;
    padding: 14px !important;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    border: none;
}

#payment .form-row.place-order button#place_order:hover {
    background-color: #e0a800 !important;
}

/* محدود کردن عرض خود کادر مراحل و وسط‌چین نگه‌داشتن آن */
.ksn-checkout-box,
.woocommerce-checkout .ksn-step-content {
    max-width: 800px !important; /* عرض دلخواه باکس فرم (مثلاً 750px تا 850px) */
    width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
    float: none !important;
    box-sizing: border-box !important;
}

/* حل ریشه‌ای جمع‌شدن فیلدها به سمت راست بدون دستکاری عرض فرم */
.ksn-checkout-box .woocommerce-billing-fields__field-wrapper,
.ksn-checkout-box .woocommerce-address-fields__field-wrapper {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: space-between !important;
    float: none !important;
}

/* فیلدهای دوتایی (مثل استان / شهر یا نام / نام‌خانوادگی) */
.ksn-checkout-box .form-row-first,
.ksn-checkout-box .form-row-last {
    width: 48% !important;
    float: none !important;
    margin: 0 0 15px 0 !important;
}

/* فیلدهای تکی و سراسری (مثل آدرس دقیق / کدپستی) */
.ksn-checkout-box .form-row-wide {
    width: 100% !important;
    float: none !important;
    margin: 0 0 15px 0 !important;
}
/* فقط در صفحه تسویه حساب */
body.woocommerce-checkout .form-row.place-order {
    background-color: #fff;
    margin: 0px;
}

body.woocommerce-checkout .woocommerce form .form-row {
    padding: 0px;
    margin: 0px;
}

body.woocommerce-checkout #payment .form-row.place-order {
    margin-top: 0px;
}

body.woocommerce-checkout #payment ul.payment_methods {
    border-bottom: none !important;
}
/* انتقال دکمه مرحله بعد در گام اول به سمت چپ */
body.woocommerce-checkout #ksn-step-1 .ksn-next-step,
body.woocommerce-checkout .ksn-step-1-content .ksn-next-step,
body.woocommerce-checkout [data-step="1"] .ksn-next-step {
    float: left !important;
    display: block !important;
    margin-right: auto !important;
    margin-left: 0 !important;
}

/* پاکسازی فلوت والد گام اول برای جلوگیری از به هم ریختگی */
body.woocommerce-checkout #ksn-step-1::after,
body.woocommerce-checkout .ksn-step-1-content::after {
    content: "" !important;
    display: table !important;
    clear: both !important;
}
/* تراز کردن دکمه رادیویی و متن روش‌های پرداخت در یک ردیف */
body.woocommerce-checkout #payment ul.payment_methods li.wc_payment_method {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex-wrap: wrap !important;
}

body.woocommerce-checkout #payment ul.payment_methods li.wc_payment_method > input[type="radio"] {
    margin: 0 !important;
    float: none !important;
    vertical-align: middle !important;
    flex-shrink: 0 !important;
}

body.woocommerce-checkout #payment ul.payment_methods li.wc_payment_method > label {
    display: inline-flex !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
    cursor: pointer !important;
}

/* توضیحات بازشونده زیر هر روش پرداخت برود خط بعد */
body.woocommerce-checkout #payment ul.payment_methods li.wc_payment_method div.payment_box {
    width: 100% !important;
    margin-top: 10px !important;
}
.woocommerce-checkout #payment div.payment_box::before {
    display: none;
}
/* تنظیم ترتیب ردیف‌های سبد خرید */
body.woocommerce-cart .cart-collaterals .shop_table tr.cart-subtotal {
    order: 3;
}
body.woocommerce-cart .cart-collaterals .shop_table tr.ksn-total-before {
    order: 1;
}
body.woocommerce-cart .cart-collaterals .shop_table tr.ksn-saving {
    order: 2;
}
body.woocommerce-cart .cart-collaterals .shop_table tr.order-total {
    order: 4;
}

/* اعمال فلکس‌باکس روی جدول جمع‌های سبد خرید برای پشتیبانی از ترتیب (order) */
body.woocommerce-cart .cart-collaterals .shop_table tbody {
    display: flex;
    flex-direction: column;
}

/* مخفی‌سازی قطعی و ۱۰۰٪ سطر مجموع در سبد خرید */
body.woocommerce-cart .cart-collaterals .shop_table tr.order-total {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}
/* مخفی‌سازی تیتر جمع کل سبد خرید */
body.woocommerce-cart .cart-collaterals .cart_totals > h2 {
    display: none !important;
}

.actions, .woocommerce-additional-fields, tr.cart-subtotal, 
.woocommerce-checkout-review-order-table tbody, .woocommerce-cart .discount, 
.woocommerce-cart .sale-flash, 
.woocommerce-cart del span.woocommerce-Price-amount.amount {
    display: none;
}
        
.woocommerce-cart .actions button[name="update_cart"] {
    display: none !important;
}

/* تنظیم والد برای قرارگیری عمودی دکمه زیر اینپوت */
.woocommerce-cart-form .product-quantity {
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: max-content;
}

.ksn-cart-row-update {
    background-color: #A81010;
    color: #ffffff;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    margin-top: 5px;
    width: 100%;
    box-sizing: border-box;
    transition: background-color 0.2s ease;
}

.ksn-cart-row-update:hover {
    background-color: #005a87;
}

.ksn-cart-row-update.show {
    display: block !important;
}

tr.cart_item.is-updating {
    opacity: 0.5;
    pointer-events: none;
}
/* استایل فیلد غیرفعال/خواندنی موبایل */
.ksn-readonly-phone input {
    background-color: #f3f4f6 !important;
    color: #6b7280 !important;
    cursor: not-allowed !important;
    border-color: #e5e7eb !important;
}

/* پیش‌فرض دسکتاپ: مخفی بودن لایه‌ها */
.ksn-mobile-cart-bar,
.ksn-cart-overlay {
    display: none;
}


/* ==========================================
   مدیریت سبد خرید در موبایل
   ========================================== */
/* قفل سراسری اسکرول هنگام باز بودن مودال */
html.ksn-sheet-locked,
body.ksn-sheet-locked {
    overflow: hidden !important;
    height: 100vh !important;
    touch-action: none !important;
}

@media (max-width: 768px) {

    /* ۱. نوار دکمه‌های پایین صفحه */
    .ksn-mobile-cart-bar {
        position: fixed;
        right: 0;
        bottom: 56px;
        left: 0;
        z-index: 99990;
        display: flex;
        flex-direction: column;
        gap: 6px;
        padding: 10px 14px;
        background: #ffffff;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    }

    .ksn-btn-checkout {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 44px;
        background: #a81010;
        color: #fff !important;
        font-weight: 700;
        border-radius: 8px;
        text-decoration: none;
    }

    .ksn-btn-details {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        height: 30px;
        background: transparent;
        color: #4b5563;
        font-size: 13px;
        font-weight: 600;
        border: none;
        cursor: pointer;
    }

    body.woocommerce-cart {
        padding-bottom: 150px !important;
    }

    /* ۲. پس‌زمینه تیره (بالاتر از همه عناصر و چت) */
    .ksn-cart-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 2147483640 !important;
        display: none;
    }

    .ksn-cart-overlay.is-active {
        display: block !important;
    }

    /* ۳. مودال بازشونده (بالاترین سطح نمایش z-index حداکثری) */
    body.woocommerce-cart .cart-collaterals {
        position: fixed !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        top: auto !important;
        z-index: 2147483647 !important; /* بالاتر از آیکون و ویجت چت */
        width: 100% !important;
        max-width: 100% !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        background: #ffffff !important;
        border-radius: 20px 20px 0 0 !important;
        border: none !important;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3) !important;
        padding: 20px 16px calc(25px + env(safe-area-inset-bottom)) !important;
        box-sizing: border-box !important;
        
        transform: translateY(105%) !important;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
        visibility: hidden !important;
    }

    body.woocommerce-cart .cart-collaterals.is-sheet-open {
        transform: translateY(0) !important;
        visibility: visible !important;
    }

    body.woocommerce-cart .cart-collaterals .cart_totals {
        width: 100% !important;
        float: none !important;
        display: block !important;
    }

    body.woocommerce-cart .cart-collaterals .cart_totals table.shop_table {
        display: table !important;
        width: 100% !important;
    }

    /* چیدمان عمودی دکمه تسویه و دکمه پیش‌فاکتور داخل مودال */
    body.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        margin-top: 15px !important;
        width: 100% !important;
    }

    body.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout > * {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        min-height: 44px !important;
        border-radius: 8px !important;
        box-sizing: border-box !important;
    }

    /* استایل دکمه پیش‌فاکتور */
    body.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout a:not(.checkout-button),
    body.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout button:not(.checkout-button),
    body.woocommerce-cart .cart-collaterals .wc-proceed-to-checkout .ksn-proforma-btn {
        background: #ffffff !important;
        color: #212529 !important;
        border: 1px solid #dcdfe4 !important;
        font-weight: 600 !important;
        font-size: 14px !important;
        text-decoration: none !important;
        cursor: pointer !important;
    }

    /* ۴. باکس کوپن زیر خط‌چین */
    .ksn-cart-coupon-wrapper {
        margin-top: 18px !important;
        padding-top: 16px !important;
        border-top: 1px dashed #dcdfe4 !important;
        width: 100% !important;
    }

    .ksn-cart-coupon-form {
        margin: 0 !important;
        width: 100% !important;
    }

    .ksn-coupon-row {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        width: 100% !important;
        flex-wrap: wrap !important;
    }

    .ksn-coupon-input {
        flex: 1 1 110px !important;
        height: 42px !important;
        border: 1px solid #dcdfe4 !important;
        border-radius: 8px !important;
        padding: 0 12px !important;
        font-size: 13px !important;
        background: #fff !important;
        text-align: center;
    }

    .ksn-coupon-btn {
        background: #a81010 !important;
        color: #fff !important;
        border: none !important;
        border-radius: 8px !important;
        height: 42px !important;
        padding: 0 16px !important;
        font-size: 13px !important;
        font-weight: 700 !important;
        cursor: pointer !important;
        white-space: nowrap !important;
    }

    .ksn-coupon-row a,
    .ksn-coupon-row button:not(.ksn-coupon-btn) {
        border: 1px dashed #a81010 !important;
        background: #fff5f5 !important;
        color: #a81010 !important;
        border-radius: 8px !important;
        height: 42px !important;
        padding: 0 12px !important;
        display: inline-flex !important;
        align-items: center !important;
        font-size: 13px !important;
        font-weight: 600 !important;
        text-decoration: none !important;
        white-space: nowrap !important;
    }
}
