/* رنگ‌ها و قاب فاکتور از استایل سرمه‌ای و فیروزه‌ای مکسیش پیروی می‌کنند. */
.column-order_status .mxb-order-badge,
.column-order_total .mxb-order-paid-amount {
    display: inline-block;
    margin: 2px 0;
    margin-inline-start: 5px;
    padding: 2px 6px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 11px;
    line-height: 1.5;
    vertical-align: middle;
}

/* مبلغ مابه‌التفاوت کنار مبلغ اصلی می‌نشیند و در ستون باریک به خط بعد می‌رود. */
.column-order_total .mxb-order-paid-amount { white-space: nowrap; }

.mxb-order-badge--pending { background: #fff3db; color: #684607; }
.mxb-order-badge--paid { background: #ddf8ec; color: #095840; }
.mxb-order-badge--refund { background: #fde8e7; color: #922c2c; }

.mxb-card,
.mxb-fields {
    --mxb-navy: #080957;
    --mxb-ink: #102b43;
    --mxb-line: #cfe6f4;
    --mxb-accent: #48cae4;
    text-align: start;
}

.mxb-card {
    margin: 0 0 18px;
    padding: clamp(14px, 2vw, 24px);
    border: 1px solid var(--mxb-line);
    border-radius: 18px;
    background: linear-gradient(145deg, #fff 20%, #effaff);
    color: var(--mxb-ink);
    box-shadow: 0 4px 0 #d5f2f8;
}

.mxb-heading,
.mxb-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mxb-heading { margin-bottom: 12px; }
.mxb-heading h3,
.mxb-pay h2 { margin: 0 0 5px; color: var(--mxb-navy); font-size: 1.12em; }
.mxb-heading div > span { font-size: .86em; color: #42617a; }

.mxb-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: 11px;
    color: #fff;
    background: linear-gradient(145deg, #047e9d, #074477);
    font-size: 19px;
    font-weight: 800;
}

.mxb-row {
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 10px;
}

.mxb-invoice {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid var(--mxb-line);
    border-radius: 13px;
    background: #fff;
}

.mxb-status {
    display: inline-block;
    margin-top: 8px;
    padding: 3px 10px;
    border-radius: 999px;
    background: #fff3db;
    color: #684607;
    font-size: .85em;
    font-weight: 700;
}

.mxb-status[data-paid="yes"] { background: #ddf8ec; color: #095840; }
.mxb-status.mxb-status--refund { background: #fde8e7; color: #922c2c; }
.mxb-reason { margin: 10px 0 0; overflow-wrap: anywhere; white-space: pre-line; }

/* کنترل‌های مدیریت فاکتور و فرم عودت در همان کارت قرار می‌گیرند. */
.mxb-manage {
    margin-top: 10px;
    padding: 8px 10px;
    border: 1px solid var(--mxb-line);
    border-radius: 9px;
    background: #f6fbff;
}

.mxb-manage summary { color: #074477; cursor: pointer; font-weight: 700; }
.mxb-manage[open] summary { margin-bottom: 8px; }
.mxb-manage p { margin: 0 0 8px; }
.mxb-manage label { display: block; }
.mxb-manage input { width: 100%; max-width: 24rem; }
.mxb-manage form .mxb-button { display: flex; }
.mxb-danger summary, .mxb-danger .button { color: #a22626; }
.mxb-edit { display: block; margin-top: 8px; }
.mxb-link { display: block; margin-top: 8px; }
.mxb-link,
.mxb-fields input,
.mxb-fields textarea { box-sizing: border-box; width: 100%; }
.mxb-fields label { display: block; margin: 0 0 4px; font-weight: 600; }
.mxb-fields input,
.mxb-fields textarea { margin: 0 0 10px; border: 1px solid #aac9dc; border-radius: 8px; }
.mxb-message { color: #074477; }
.mxb-message:empty { display: none; }
.mxb-calculate {
    padding: 6px 10px;
    margin: 0 0 9px;
    border: 1px solid #b8deec;
    border-radius: 8px;
    background: #eefaff;
    color: #074477;
    font: inherit;
    cursor: pointer;
}
.mxb-calculate[aria-busy="true"] { opacity: .7; cursor: progress; }
.mxb-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    margin-top: 9px;
    padding: 7px 14px;
    border: 1px solid var(--mxb-navy);
    border-radius: 10px;
    background: var(--mxb-navy);
    box-shadow: 2px 3px 0 var(--mxb-accent);
    color: #fff;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .16s ease, transform .16s ease;
}

.mxb-button:hover { background: #075481; color: #fff; transform: translateY(-1px); }
.mxb-button:focus-visible { outline: 2px solid #0079a2; outline-offset: 4px; }
#maxish-balance-invoice .mxb-card { padding: 12px; }
#maxish-balance-invoice .mxb-button { width: 100%; }

/* دکمهٔ بستن درخواست در پنل باریک مدیریت به عرض کادر محدود می‌شود. */
#maxish-balance-invoice .mxb-close-refund {
    margin-block-start: 10px;
    padding-block-start: 10px;
    border-block-start: 1px solid #e5a6ae;
}

#maxish-balance-invoice .mxb-close-refund p { margin: 0 0 8px; }

#maxish-balance-invoice .mxb-close-refund-button {
    display: block;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: auto;
    margin: 0;
    padding: 7px 8px;
    border: 1px solid #84283a;
    border-radius: 8px;
    background: #84283a;
    color: #fff;
    font-size: 12px;
    line-height: 1.6;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
}

#maxish-balance-invoice .mxb-close-refund-button:hover { background: #681b2c; color: #fff; }
#maxish-balance-invoice .mxb-close-refund-button:focus-visible { outline: 2px solid #84283a; outline-offset: 2px; }

/* شناسهٔ پرداخت در پنل باریک بدون بیرون‌زدگی قابل انتخاب و کپی است. */
#maxish-balance-invoice .mxb-initial-reference > p { margin-block: 4px 10px; }
#maxish-balance-invoice .mxb-initial-reference input { max-width: 100%; margin-block-end: 4px; }
#maxish-balance-invoice .mxb-copy-reference { margin-block-end: 8px; }
#maxish-balance-invoice .mxb-copy-result { display: block; }

.mxb-pay { margin-inline: auto; max-width: 720px; }

/* دکمهٔ زیبال در جزئیات و فهرست سفارش‌ها از رنگ‌های پنل مکسیش استفاده می‌کند. */
#mxb-order-balance .mxb-invoice .mxb-zibal,
.woocommerce .woocommerce-orders-table a.woocommerce-button.maxish-balance-pay {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 15px;
    border: 1px solid #214e91;
    border-radius: 12px;
    background: linear-gradient(110deg, #151569, #006e85);
    box-shadow: 0 3px 0 #54d5e8;
    color: #fff;
    font-weight: 700;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    white-space: normal;
}

#mxb-order-balance .mxb-invoice .mxb-zibal:hover,
.woocommerce .woocommerce-orders-table a.woocommerce-button.maxish-balance-pay:hover {
    background: linear-gradient(110deg, #24247c, #08788b);
    color: #fff;
}

#mxb-order-balance .mxb-invoice .mxb-zibal:focus-visible,
.woocommerce .woocommerce-orders-table a.woocommerce-button.maxish-balance-pay:focus-visible {
    outline: 2px solid #0079a2;
    outline-offset: 4px;
}

/* فقط دکمه‌های ستون عملیات سفارش‌های من؛ قالب برای دکمه‌های ووکامرس اندازهٔ سراسری دارد. */
.woocommerce-account .woocommerce-orders-table .woocommerce-orders-table__cell-order-actions a.button,
.woocommerce-account .woocommerce-table--order-details .order-actions a.button,
.woocommerce-account .woocommerce-table--order-details a.button.order-actions-button,
.woocommerce-account .woocommerce-table--order-details a.button:is(.maxish-balance-pay,.maxish-balance-refund,.spxinv,.maxish-balance-invoice) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px !important;
    height: auto !important;
    min-width: 0 !important;
    width: auto !important;
    padding: 5px 10px !important;
    margin: 3px 2px !important;
    border-radius: 9px !important;
    font-size: 12px !important;
    line-height: 1.4 !important;
    text-align: center;
    white-space: normal;
}

/* عودت باید در یک نگاه از پرداخت و عملیات معمول سفارش متمایز باشد. */
.woocommerce-account :is(.woocommerce-orders-table,.woocommerce-table--order-details) a.button.maxish-balance-refund {
    border: 1px solid #e5a6ae !important;
    background: #fff1f3 !important;
    color: #8b283d !important;
    box-shadow: 0 2px 0 #efc2cb !important;
}
.woocommerce-account :is(.woocommerce-orders-table,.woocommerce-table--order-details) a.button.maxish-balance-refund:hover {
    background: #ffe0e7 !important;
    color: #761d32 !important;
}
.woocommerce-account :is(.woocommerce-orders-table,.woocommerce-table--order-details) a.button.maxish-balance-refund:focus-visible {
    outline: 2px solid #8b283d;
    outline-offset: 3px;
}
/* پیگیری عودت یک اقدام پرداخت نیست و با رنگ ملایمِ وضعیت در حال رسیدگی نمایش داده می‌شود. */
.woocommerce-account :is(.woocommerce-orders-table,.woocommerce-table--order-details) a.button.maxish-balance-refund-tracking {
    background: #fff3db !important;
    color: #684607 !important;
    border: 1px solid #e9cd93 !important;
    box-shadow: 0 2px 0 #f0dfba !important;
}
/* نتیجهٔ درخواست در مقصد برگشت و بالای فاکتور دیده می‌شود. */
#mxb-refund-form, #mxb-balance-result, #mxb-order-balance, #mxb-admin-refund { scroll-margin-top: 6rem; }
.mxb-result { padding: 10px 13px; border-radius: 10px; border: 1px solid; }
.mxb-result--success { color: #095840; background: #ddf8ec; border-color: #a2dfc9; }
.mxb-result--error { color: #84283a; background: #fff1f3; border-color: #e5a6ae; }

/* هر فاکتور مبلغ و دکمهٔ خودش را در همان سفارش دارد. */
.mxb-invoice h4 { margin: 0; font-size: 14px; color: var(--mxb-navy); }
#mxb-order-balance-invoice { scroll-margin-top: 6rem; }

/* فقط سه دکمه یا بیشتر در موبایل مرتب می‌شوند؛ حالت یک و دو دکمه هیچ تغییری نمی‌کند. */
@media (max-width: 767px) {
    .woocommerce-account .woocommerce-orders-table td.woocommerce-orders-table__cell-order-actions:has(> a.button:nth-of-type(3)) {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        align-items: stretch;
    }
    .woocommerce-account .woocommerce-orders-table td.woocommerce-orders-table__cell-order-actions:has(> a.button:nth-of-type(3))::before {
        grid-column: 1 / -1;
        width: auto;
        float: none;
        text-align: right;
        margin-block-end: 3px;
    }
    .woocommerce-account .woocommerce-orders-table td.woocommerce-orders-table__cell-order-actions:has(> a.button:nth-of-type(3)) > a.button {
        box-sizing: border-box;
        width: 100% !important;
        min-height: 38px !important;
        margin: 0 !important;
        padding: 7px 8px !important;
    }
    .woocommerce-account .woocommerce-orders-table td.woocommerce-orders-table__cell-order-actions:has(> a.button:nth-of-type(3)) > a.button:last-of-type:nth-of-type(odd) {
        grid-column: 1 / -1;
    }
}

@media (max-width: 480px) {
    .mxb-card .mxb-button { width: 100%; }
}

/* رسید خصوصی در همان سفارش قابل مشاهده است؛ تصویر کامل فقط با دسترسی صاحب سفارش یا مدیر باز می‌شود. */
#mxb-refund-receipt { scroll-margin-top: 6rem; }
.mxb-receipt-preview { display: block; width: fit-content; max-width: 100%; margin: 12px auto; }
.mxb-receipt-preview img { display: block; max-width: 100%; width: auto; height: auto; max-height: 360px; object-fit: contain; border: 1px solid #b6dbe7; border-radius: 12px; background: #fff; }
.mxb-receipt-date { font-size: 12px; color: #526d83; }
.mxb-card .mxb-reason { white-space: normal; overflow-wrap: anywhere; }
/* کادر کناری مدیریت باریک است؛ دکمهٔ رسید باید کامل و بدون بیرون‌زدگی در همان کادر جا بگیرد. */
#maxish-balance-invoice .mxb-receipt-preview img { max-height: 180px; }
#maxish-balance-invoice .mxb-proof-submit { display: block; box-sizing: border-box; width: 100%; max-width: 100%; height: auto; min-height: 32px; padding: 5px 8px; font-size: 11px; line-height: 1.7; white-space: normal; text-align: center; margin: 8px 0 0; }
.woocommerce-account a.button.maxish-balance-refund-receipt { background: #ddf8ec !important; color: #095840 !important; border-color: #a2dfc9 !important; box-shadow: 0 2px 0 #a2dfc9 !important; }

/* تنظیم کاهش حرکت سیستم‌عامل رعایت می‌شود. */
@media (prefers-reduced-motion: reduce) {
    .mxb-button { transition: none; }
    .mxb-button:hover { transform: none; }
}

/* پرداخت و عودت کنار هم، با اندازهٔ یکسان و رنگ متمایز. */
.mxb-card .mxb-balance-actions { display:flex;align-items:stretch;flex-wrap:wrap;gap:8px;margin-top:10px; }
.mxb-card .mxb-balance-actions > form { display:flex;margin:0;padding:0; }
.mxb-card .mxb-balance-actions .mxb-button { box-sizing:border-box;margin:0;min-height:40px;padding:7px 12px;font-size:12px;line-height:1.8;text-align:center;white-space:normal; }
.mxb-card .mxb-balance-actions .mxb-refund-link { background:#fff1f3!important;color:#9b2847!important;border-color:#f1b0be;box-shadow:2px 3px 0 #f8d4dc; }
.mxb-card .mxb-balance-actions .mxb-refund-link:hover { background:#ffe3e9!important;color:#7e1834!important; }
.mxb-card .mxb-balance-actions .mxb-refund-link:focus-visible { outline:2px solid #9b2847;outline-offset:3px; }
@media(max-width:480px){
 .mxb-card .mxb-balance-actions { display:grid;grid-template-columns:repeat(2,minmax(0,1fr)); }
 .mxb-card .mxb-balance-actions > form { min-width:0; }
 .mxb-card .mxb-balance-actions .mxb-button { width:100%;min-width:0;padding:7px 8px;font-size:11px; }
}
