/* =========================================
   CHECKOUT - CLEAN FULL CSS
========================================= */
/* جلوگیری از پرش استایل موقع لود */
.woocommerce-checkout .custom-checkout-page {
    opacity: 0;
    transition: opacity 0.2s ease-in;
}

/* به محض اینکه کلاس کامل لود شد */
.woocommerce-checkout.custom-checkout-page-loaded .custom-checkout-page {
    opacity: 1;
}

/* حذف خط قرمز و استایل‌های مزاحم پیش‌فرض قبل از لود */
.woocommerce-checkout .form-row.woocommerce-invalid input.input-text {
    border-color: #dbe3ea !important; /* رنگ خنثی جایگزین قرمز */
    outline: none !important;
}



.custom-checkout-page .woocommerce{
    max-width:1240px;
    margin:40px auto;
    padding:0 20px;
}

/* -----------------------------------------
   LAYOUT
----------------------------------------- */

.custom-checkout-page form.checkout{
    display:grid;
    grid-template-columns:minmax(0,1fr) 390px;
    gap:28px;
    align-items:start;
}

.custom-checkout-page .col2-set,
.custom-checkout-page #order_review_heading,
.custom-checkout-page #order_review{
    float:none !important;
    width:auto !important;
}

.custom-checkout-page .col2-set{
    grid-column:1;
}

.custom-checkout-page #order_review{
    grid-column:2;
}

/* -----------------------------------------
   LEFT SIDE CARDS
----------------------------------------- */

.custom-checkout-page .woocommerce-billing-fields,
.custom-checkout-page .woocommerce-shipping-fields,
.custom-checkout-page .woocommerce-additional-fields{
    background:#fff;
    border:1px solid #e8edf3;
    border-radius:22px;
    padding:24px;
    margin-bottom:20px;
    box-shadow:0 10px 30px rgba(15,23,42,.05);
}

/* -----------------------------------------
   ORDER REVIEW CARD
----------------------------------------- */

.custom-checkout-page #order_review_heading{
    display:none !important;
}

.custom-checkout-page #order_review{
    background:#fff !important;
    border:1px solid #dbe3ea !important;
    border-radius:22px !important;
    padding:0 !important;
    overflow:hidden !important;
    position:sticky;
    top:24px;
    box-shadow:0 10px 30px rgba(15,23,42,.06);
    box-sizing:border-box;
}

/* عنوان سفارش شما */
.custom-checkout-page #order_review::before{
    content:"سفارش شما";
    display:block;
    padding:22px 24px 16px;
    font-size:20px;
    font-weight:900;
    color:#0f172a;
    background:#fff;
    border-bottom:1px solid #f1f5f9;
    line-height:1.4;
}

/* -----------------------------------------
   TABLE RESET
----------------------------------------- */

.custom-checkout-page table.woocommerce-checkout-review-order-table,
.custom-checkout-page table.shop_table{
    width:100%;
    margin:0 !important;
    border:none !important;
    border-collapse:collapse !important;
    border-spacing:0 !important;
    box-shadow:none !important;
    background:transparent !important;
}

.custom-checkout-page table.woocommerce-checkout-review-order-table thead,
.custom-checkout-page table.woocommerce-checkout-review-order-table tbody,
.custom-checkout-page table.woocommerce-checkout-review-order-table tfoot,
.custom-checkout-page table.shop_table thead,
.custom-checkout-page table.shop_table tbody,
.custom-checkout-page table.shop_table tfoot{
    background:transparent !important;
}

.custom-checkout-page table.woocommerce-checkout-review-order-table th,
.custom-checkout-page table.woocommerce-checkout-review-order-table td,
.custom-checkout-page table.shop_table th,
.custom-checkout-page table.shop_table td{
    border:none !important;
    background:transparent !important;
    padding:14px 24px !important;
    font-size:14px;
    font-weight:700;
    color:#334155;
    vertical-align:middle;
    box-sizing:border-box;
}

/* جلوگیری از هر border بالایی */
.custom-checkout-page table.woocommerce-checkout-review-order-table tr,
.custom-checkout-page table.shop_table tr{
    border:none !important;
}

.custom-checkout-page table.woocommerce-checkout-review-order-table th,
.custom-checkout-page table.shop_table th{
    text-align:right;
}

.custom-checkout-page table.woocommerce-checkout-review-order-table td,
.custom-checkout-page table.shop_table td{
    text-align:left;
}

/* خطوط فقط بین ردیف‌ها */
.custom-checkout-page table.woocommerce-checkout-review-order-table tbody tr + tr td,
.custom-checkout-page table.shop_table tbody tr + tr td{
    border-top:1px solid #edf2f7 !important;
}

/* header table */
.custom-checkout-page table.woocommerce-checkout-review-order-table thead th,
.custom-checkout-page table.shop_table thead th{
    font-weight:900;
    color:#0f172a;
    font-size:13px;
    border-bottom:1px solid #f1f5f9 !important;
}

/* totals */
.custom-checkout-page .order-total th,
.custom-checkout-page .order-total td{
    font-size:16px !important;
    font-weight:900 !important;
    color:#0f172a !important;
}

/* -----------------------------------------
   PAYMENT AREA FIX
   این بخش مهم‌ترین قسمت برای حذف خط سفید است
----------------------------------------- */

.custom-checkout-page #payment{
    margin:0 !important;
    padding:0 !important;
    background:#fff !important;
    border:none !important;
    box-shadow:none !important;
}

/* حذف wrapperهای داخلی که نوار سفید/فاصله می‌سازند */
.custom-checkout-page #payment > *,
.custom-checkout-page #payment .wc_payment_methods,
.custom-checkout-page #payment ul.payment_methods,
.custom-checkout-page #payment .woocommerce-terms-and-conditions-wrapper,
.custom-checkout-page #payment .form-row{
    background:#fff !important;
}

/* لیست روش‌های پرداخت */
.custom-checkout-page #payment ul.payment_methods{
    list-style:none !important;
    margin:0 !important;
    padding:18px 24px 8px !important;
}

.custom-checkout-page #payment ul.payment_methods li{
    border:1px solid #e5e7eb !important;
    border-radius:14px !important;
    padding:12px 14px !important;
    margin-bottom:10px !important;
    background:#fff !important;
}

.custom-checkout-page #payment ul.payment_methods li:last-child{
    margin-bottom:0 !important;
}

.custom-checkout-page #payment div.payment_box{
    margin-top:10px;
    padding:12px 14px;
    border-radius:12px;
    background:#eff6ff;
    color:#1e3a8a;
    border:none;
    box-shadow:none;
}

/* ناحیه terms و دکمه */
.custom-checkout-page .woocommerce-terms-and-conditions-wrapper{
    margin:0 !important;
    padding:0 24px 10px !important;
}

.custom-checkout-page .place-order{
    margin:0 !important;
    padding:0 24px 24px !important;
    background:#fff !important;
}

/* دکمه خرید */
.custom-checkout-page #place_order{
    margin-top:14px;
    width:100%;
    min-height:56px;
    border:none;
    border-radius:16px;
    background:linear-gradient(135deg,#16a34a,#22c55e);
    color:#fff;
    font-size:16px;
    font-weight:900;
    box-shadow:0 14px 30px rgba(34,197,94,.25);
    transition:.2s;
}

.custom-checkout-page #place_order:hover{
    transform:translateY(-2px);
    box-shadow:0 18px 34px rgba(34,197,94,.3);
}

/* -----------------------------------------
   FIELDS
----------------------------------------- */

.custom-checkout-page h3{
    margin:0 0 16px;
    color:#0f172a;
    font-size:20px;
    font-weight:900;
}

.custom-checkout-page .form-row{
    margin-bottom:16px;
}

.custom-checkout-page .form-row label{
    display:block;
    margin-bottom:8px;
    color:#334155;
    font-size:14px;
    font-weight:800;
}

.custom-checkout-page input.input-text,
.custom-checkout-page textarea,
.custom-checkout-page select,
.custom-checkout-page .select2-selection--single{
    width:100%;
    min-height:52px;
    border:1px solid #dbe3ea !important;
    border-radius:16px !important;
    background:#fff;
    padding:0 16px;
    font-size:14px;
    font-weight:700;
    transition:.2s;
    box-shadow:none !important;
}

.custom-checkout-page textarea{
    min-height:120px;
    padding:14px 16px;
}

.custom-checkout-page input:focus,
.custom-checkout-page textarea:focus,
.custom-checkout-page select:focus,
.custom-checkout-page .select2-container--focus .select2-selection--single{
    border-color:#2563eb !important;
    box-shadow:0 0 0 4px rgba(37,99,235,.12) !important;
    outline:none;
}

.custom-checkout-page input::placeholder,
.custom-checkout-page textarea::placeholder{
    color:#94a3b8;
}

/* -----------------------------
   Privacy policy box
------------------------------*/

.custom-checkout-page .woocommerce-privacy-policy-text{
    text-align:center;
    background:#f8fafc;
    border:1px solid #dbeafe;
    border-radius:16px;
    padding:16px 18px;
    margin-top:10px;
    margin-bottom:10px;
    margin-right:0px;
    margin-left:0px;
    box-shadow:0 4px 14px rgba(15,23,42,.04);
    line-height:1.9;
    color:#334155;
    font-size:14px;
    font-weight:600;
}

.custom-checkout-page .woocommerce-privacy-policy-text p{
    margin:0;
}

.custom-checkout-page .woocommerce-privacy-policy-text a{
    color:#2563eb;
    font-weight:800;
    text-decoration:none;
}

.custom-checkout-page .woocommerce-privacy-policy-text a:hover{
    text-decoration:underline;
}

/* -----------------------------------------
   NOTICES
----------------------------------------- */

.custom-checkout-page .woocommerce-message,
.custom-checkout-page .woocommerce-error,
.custom-checkout-page .woocommerce-info{
    padding:16px 18px;
    border-radius:16px;
    margin-bottom:18px;
    font-size:14px;
    font-weight:700;
    text-align:center;
    border:1px solid transparent;
}

.custom-checkout-page .woocommerce-message::before,
.custom-checkout-page .woocommerce-error::before,
.custom-checkout-page .woocommerce-info::before{
    display:none !important;
}

.custom-checkout-page .woocommerce-message{
    background:#ecfdf5;
    border-color:#bbf7d0;
    color:#166534;
}

.custom-checkout-page .woocommerce-error{
    background:#fef2f2;
    border-color:#fecaca;
    color:#991b1b;
}

.custom-checkout-page .woocommerce-info{
    background:#eff6ff;
    border-color:#bfdbfe;
    color:#1e3a8a;
}

/* -----------------------------------------
   COUPON SECTION (TOP OF CHECKOUT) - CLEAN VERSION
----------------------------------------- */

/* نوار پیغام کوپن (باکس بالایی) */
.custom-checkout-page .woocommerce-form-coupon-toggle .woocommerce-info {
    background: #f8fafc;
    border: 1px solid #cbd5e1; /* اینجا از dashed به solid تغییر کرد */
    color: #334155;
    padding: 16px 22px;
    border-radius: 16px;
    margin-bottom: 20px;
    text-align: center; /* وسط چین کردن متن */
    display: flex;
    justify-content: center;
    align-items: center;
}

.custom-checkout-page .woocommerce-form-coupon-toggle .showcoupon {
    color: #2563eb;
    font-weight: 800;
    text-decoration: none;
    margin-right: 5px;
    display: inline-block;
}

/* فرمی که بعد از کلیک باز می‌شود */
/* فرمی که بعد از کلیک باز می‌شود */
.custom-checkout-page form.checkout_coupon {
    background: #fff;
    border: 1px solid #e8edf3;
    border-radius: 22px;
    padding: 8px; /* پدینگ کلی را کم کن */
    margin: 0 auto 28px auto; /* وسط‌چین کردن باکس */
    max-width: 600px; /* عرض باکس را محدود کن */
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
    display: flex;
    gap: 8px; /* فاصله بین فیلد و دکمه */
    align-items: center;
    text-align:center;
    justify-content:center;
    margin-left: auto;
    margin-right: auto;
}

/* فیلد ورودی کد تخفیف */
.custom-checkout-page form.checkout_coupon .form-row-first {
    margin: 0;
    width: auto;
    float: none;
    flex: 1;
}

.custom-checkout-page form.checkout_coupon input#coupon_code {
    width: 100%;
    min-height: 26px;
    border: 1px solid #dbe3ea !important;
    border-radius: 16px !important;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 700;
}

/* دکمه اعمال تخفیف */
.custom-checkout-page form.checkout_coupon .form-row-last {
    margin: 0;
    width: auto;
    float: none;
    flex:0 0 auto;
}

.custom-checkout-page form.checkout_coupon button[name="apply_coupon"] {
    min-height: 38px;
    padding: 0 28px;
    background: #0f172a !important; /* رنگ تیره شیک */
    color: #fff !important;
    border: none !important;
    border-radius: 16px !important;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    transition: 0.3s;
    white-space: nowrap;
}

.custom-checkout-page form.checkout_coupon button[name="apply_coupon"]{
    transition: background 0.25s ease, box-shadow 0.25s ease;
}

.custom-checkout-page form.checkout_coupon button[name="apply_coupon"]:hover{
    background: #1e293b !important; /* کمی تیره‌تر */
    box-shadow: 0 6px 15px rgba(15, 23, 42, 0.15);
}

/* واکنش‌گرا برای موبایل */
@media (max-width: 600px) {
    .custom-checkout-page form.checkout_coupon {
        flex-direction: column;
        align-items: stretch;
        margin: 0 15px 28px 15px;
    }
    .custom-checkout-page form.checkout_coupon .form-row-first {
        flex: 1;
    }
}






/* -----------------------------------------
   Terms Box
----------------------------------------- */

/* باکس قوانین و مقررات */
.woocommerce-terms-and-conditions{
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px;
    margin-top: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.04);
    line-height: 1.8;
}

/* اسکرول زیباتر */
.woocommerce-terms-and-conditions::-webkit-scrollbar{
    width: 6px;
}

.woocommerce-terms-and-conditions::-webkit-scrollbar-thumb{
    background: #cbd5e1;
    border-radius: 10px;
}

.woocommerce-terms-and-conditions::-webkit-scrollbar-thumb:hover{
    background: #94a3b8;
}

/* تیتر قوانین */
.woocommerce-terms-and-conditions h2{
    font-size: 18px;
    margin-top: 18px;
    margin-bottom: 8px;
    color: #0f172a;
}

/* متن قوانین */
.woocommerce-terms-and-conditions p{
    font-size: 14px;
    color: #0f172a;
    margin-bottom: 12px;
}

/* متن بالای قوانین */
.woocommerce-terms-and-conditions .has-text-align-center{
    font-weight: 600;
    color: #1e293b;
}

/* -----------------------------------------
   MOBILE OPTIMIZATION (Fixing Columns)
----------------------------------------- */

@media (max-width: 991px) {

    .custom-checkout-page .woocommerce {
        margin: 15px auto;
        padding: 0 10px;
    }

    /* ۱. تبدیل گرید به تک ستون واقعی */
    .custom-checkout-page form.checkout {
        display: flex !important; /* روی موبایل فلکس راحت‌تره برای چیدن زیر هم */
        flex-direction: column !important;
        gap: 20px;
    }

    /* ۲. آزاد کردن المان‌ها از قید ستون‌های دسکتاپ */
    .custom-checkout-page .col2-set,
    .custom-checkout-page #order_review {
        grid-column: auto !important; /* لغو کردن تنظیمات دسکتاپ */
        width: 100% !important;
        max-width: 100% !important;
        float: none !important;
    }

    /* ۳. اصلاح ترتیب نمایش (اول فرم‌ها، بعد فاکتور سفارش) */
    .custom-checkout-page .col2-set {
        order: 1;
    }
    
    .custom-checkout-page #order_review {
        order: 2;
        position: static !important; /* برداشتن حالت چسبنده در موبایل */
    }

    /* ۴. اصلاح پدینگ کارت‌ها در موبایل برای فضای بیشتر */
    .custom-checkout-page .woocommerce-billing-fields,
    .custom-checkout-page .woocommerce-shipping-fields,
    .custom-checkout-page .woocommerce-additional-fields,
    .custom-checkout-page #order_review {
        padding: 16px !important;
        border-radius: 16px !important;
    }

    /* ۵. فیکس کردن فیلدهای دوتایی (مثل نام و نام خانوادگی) در موبایل */
    .custom-checkout-page .form-row-first, 
    .custom-checkout-page .form-row-last {
        width: 100% !important;
        float: none !important;
    }

    /* ۶. اصلاح جدول بازبینی در موبایل (جلوگیری از اسکرول خوردن افقی) */
    .custom-checkout-page table.shop_table th, 
    .custom-checkout-page table.shop_table td {
        padding: 12px 15px !important;
        font-size: 13px !important;
    }
}

/* ===== تنظیم دقیق فاصله بالای کارت سفارش شما در دسکتاپ =====*/
@media (min-width: 992px) {
    body.woocommerce-checkout #order_review,
    body.woocommerce-checkout .woocommerce-checkout-review-order {
        margin-top: -24px !important;
        transform: translateY(-24px) !important;
    }
}
