/*
 * کیت رابط مشترک سایت و داشبورد (روی Bootstrap 5.3 RTL): توست، هشدار درون‌خطی، مودال، فرم، جدول واکنش‌گرا.
 * توکن‌ها در :root؛ رنگ اصلی برند = قرمز پیمنت استیت.
 */
:root {
  --ps-primary: #b8061f;
  --ps-primary-rgb: 184, 6, 31;
  --ps-primary-dark: #8f0418;
  --ps-accent: #ffd500;
  --ps-success: #0a9d58;
  --ps-info: #0b6fd1;
  --ps-warning: #e58a00;
  --ps-danger: #d11414;
  --ps-text: #222;
  --ps-muted: #6b7280;
  --ps-border: #e6e8ec;
  --ps-surface: #fff;
  --ps-bg: #f5f6f8;
  --ps-radius: 14px;
  --ps-radius-sm: 10px;
  --ps-shadow: 0 6px 24px rgba(17, 24, 39, .08);
  --ps-shadow-lg: 0 18px 50px rgba(17, 24, 39, .18);
  --bs-primary: var(--ps-primary);
  --bs-primary-rgb: var(--ps-primary-rgb);
  --bs-link-color: var(--ps-primary);
  --bs-link-hover-color: var(--ps-primary-dark);
  --bs-link-color-rgb: var(--ps-primary-rgb);
  --bs-link-hover-color-rgb: 143, 4, 24;
  --bs-border-radius: var(--ps-radius-sm);
  --bs-border-radius-lg: var(--ps-radius);
  --bs-body-font-family: iran, Yekan, Tahoma, system-ui, sans-serif;
}
.btn-primary { --bs-btn-bg: var(--ps-primary); --bs-btn-border-color: var(--ps-primary); --bs-btn-hover-bg: var(--ps-primary-dark); --bs-btn-hover-border-color: var(--ps-primary-dark); --bs-btn-active-bg: var(--ps-primary-dark); --bs-btn-active-border-color: var(--ps-primary-dark); --bs-btn-disabled-bg: var(--ps-primary); --bs-btn-disabled-border-color: var(--ps-primary); --bs-btn-focus-shadow-rgb: var(--ps-primary-rgb); }
.btn-outline-primary { --bs-btn-color: var(--ps-primary); --bs-btn-border-color: var(--ps-primary); --bs-btn-hover-bg: var(--ps-primary); --bs-btn-hover-border-color: var(--ps-primary); --bs-btn-active-bg: var(--ps-primary); --bs-btn-active-border-color: var(--ps-primary); --bs-btn-focus-shadow-rgb: var(--ps-primary-rgb); }
.btn-success { --bs-btn-bg: var(--ps-success); --bs-btn-border-color: var(--ps-success); --bs-btn-hover-bg: #087f47; --bs-btn-hover-border-color: #087f47; }
.btn-info { --bs-btn-bg: var(--ps-info); --bs-btn-border-color: var(--ps-info); --bs-btn-color: #fff; --bs-btn-hover-bg: #0958a8; --bs-btn-hover-border-color: #0958a8; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff; }
.btn-danger { --bs-btn-bg: var(--ps-danger); --bs-btn-border-color: var(--ps-danger); }
.btn { --bs-btn-border-radius: 999px; --bs-btn-padding-x: 1.1rem; --bs-btn-font-weight: 600; }
.btn-sm { --bs-btn-padding-x: .85rem; }
.form-control, .form-select { --bs-border-color: var(--ps-border); border-radius: var(--ps-radius-sm); padding: .6rem .9rem; min-height: 44px; }
.form-control:focus, .form-select:focus { border-color: rgba(var(--ps-primary-rgb), .6); box-shadow: 0 0 0 .25rem rgba(var(--ps-primary-rgb), .12); }
.form-label { font-size: .9rem; color: #374151; margin-bottom: .3rem; }
.form-text { color: var(--ps-muted); }
.ltr, .latin, [dir=ltr] { direction: ltr; unicode-bidi: isolate; }
.form-control.ltr, .form-control.latin { text-align: left; }

/* ---- توست‌ها ---- */
.ps-toasts { position: fixed; inset-inline: 0; bottom: max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 11000; pointer-events: none; padding: 0 12px; }
.ps-toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; max-width: 460px; width: 100%; background: #1f2937; color: #fff; padding: 12px 14px; border-radius: 12px; box-shadow: var(--ps-shadow-lg); font-size: 14px; line-height: 1.7; transform: translateY(16px); opacity: 0; transition: transform .22s ease, opacity .22s ease; border-inline-start: 4px solid #9ca3af; }
.ps-toast.show { transform: none; opacity: 1; }
.ps-toast.success { border-color: var(--ps-success); }
.ps-toast.error { border-color: var(--ps-danger); }
.ps-toast.warning { border-color: var(--ps-accent); }
.ps-toast.info { border-color: var(--ps-info); }
.ps-toast .ic { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: rgba(255,255,255,.15); }
.ps-toast.success .ic { background: var(--ps-success); }
.ps-toast.error .ic { background: var(--ps-danger); }
.ps-toast.warning .ic { background: var(--ps-accent); color: #222; }
.ps-toast.info .ic { background: var(--ps-info); }
.ps-toast .tx { flex: 1; }
.ps-toast .tx b { display: block; }
.ps-toast .x { flex: 0 0 auto; background: none; border: 0; color: #cbd5e1; font-size: 18px; line-height: 1; padding: 0 2px; cursor: pointer; }
.ps-toast .x:hover { color: #fff; }

/* ---- هشدار درون‌خطی ---- */
.ps-alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--ps-radius-sm); font-size: 14px; line-height: 1.8; margin: 10px 0; border: 1px solid transparent; }
.ps-alert .ic { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; margin-top: 3px; }
.ps-alert .tx { flex: 1; }
.ps-alert.ok, .ps-alert.success { background: #ecfdf3; color: #065f46; border-color: #bbf7d0; }
.ps-alert.ok .ic, .ps-alert.success .ic { background: var(--ps-success); }
.ps-alert.err, .ps-alert.error, .ps-alert.danger { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.ps-alert.err .ic, .ps-alert.error .ic, .ps-alert.danger .ic { background: var(--ps-danger); }
.ps-alert.warn, .ps-alert.warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.ps-alert.warn .ic, .ps-alert.warning .ic { background: var(--ps-warning); }
.ps-alert.info { background: #eff6ff; color: #1e3a8a; border-color: #bfdbfe; }
.ps-alert.info .ic { background: var(--ps-info); }
.ps-alert a { color: inherit; text-decoration: underline; }
.ps-alert ul { margin: 4px 0 0; padding-inline-start: 18px; }
.alert { border-radius: var(--ps-radius-sm); }

/* ---- مودال ---- */
.modal-content { border: 0; border-radius: var(--ps-radius); box-shadow: var(--ps-shadow-lg); }
.modal-header { border-bottom: 0; padding: 18px 22px 6px; }
.modal-header .modal-title { font-weight: 700; font-size: 1.05rem; }
.modal-body { padding: 10px 22px 18px; line-height: 1.9; }
.modal-footer { border-top: 0; padding: 0 22px 20px; gap: 8px; }
.modal-footer > * { margin: 0; }
.modal .btn-close { margin: 0; opacity: .55; }
.modal .close { position: absolute; inset-inline-end: 14px; top: 12px; float: none; width: 34px; height: 34px; border-radius: 50%; background: #f3f4f6; opacity: 1; display: grid; place-items: center; font-size: 22px; color: #374151; text-shadow: none; }
.modal .close:hover { background: #e5e7eb; }
.ps-modal-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 6px auto 12px; font-size: 30px; font-weight: 700; color: #fff; }
.ps-modal-icon.success { background: var(--ps-success); }
.ps-modal-icon.error { background: var(--ps-danger); }
.ps-modal-icon.warning { background: var(--ps-accent); color: #222; }
.ps-modal-icon.info { background: var(--ps-info); }
.ps-modal-center .modal-body { text-align: center; }
.ps-modal-center .modal-footer { justify-content: center; }
.modal-backdrop.show { opacity: .45; backdrop-filter: blur(1px); }
@media (max-width: 575.98px) {
  .modal-dialog:not(.modal-fullscreen) { margin: 0; position: fixed; bottom: 0; inset-inline: 0; max-width: none; }
  .modal-dialog:not(.modal-fullscreen) .modal-content { border-radius: var(--ps-radius) var(--ps-radius) 0 0; }
  .modal.fade .modal-dialog:not(.modal-fullscreen) { transform: translateY(30px); }
  .modal.show .modal-dialog:not(.modal-fullscreen) { transform: none; }
}

/* ---- جدول واکنش‌گرا (نمای کارتی روی موبایل برای جدول‌هایی که data-label دارند) ---- */
.table-responsive { -webkit-overflow-scrolling: touch; }
@media (max-width: 767.98px) {
  table.ps-stack thead { display: none; }
  table.ps-stack, table.ps-stack tbody, table.ps-stack tr, table.ps-stack td { display: block; width: 100%; }
  table.ps-stack tr { border: 1px solid var(--ps-border); border-radius: var(--ps-radius-sm); margin-bottom: 10px; padding: 6px 10px; background: #fff; }
  table.ps-stack td { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0 !important; border: 0 !important; border-bottom: 1px dashed #eef0f3 !important; text-align: right; }
  table.ps-stack td:last-child { border-bottom: 0 !important; }
  table.ps-stack td::before { content: attr(data-label); color: var(--ps-muted); font-size: 12px; flex: 0 0 auto; }
  table.ps-stack td:not([data-label])::before { content: none; }
}

/* ---- وضعیت‌ها ---- */
.ps-state { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #fff; background: #6b7280; white-space: nowrap; line-height: 1.7; }
.ps-state.awaiting_payment, .ps-state.open, .ps-state.pending, .ps-state.warn { background: var(--ps-warning); }
.ps-state.paid, .ps-state.answered, .ps-state.info { background: var(--ps-info); }
.ps-state.fulfilled, .ps-state.closed, .ps-state.ok, .ps-state.success { background: var(--ps-success); }
.ps-state.rejected, .ps-state.expired, .ps-state.cancelled, .ps-state.danger { background: var(--ps-danger); }

/* ---- اسکلت / خالی / بارگذاری ---- */
.ps-empty { text-align: center; color: var(--ps-muted); padding: 44px 12px; font-size: 14px; }
.ps-empty .ic { font-size: 34px; opacity: .35; margin-bottom: 6px; }
.ps-loading { text-align: center; padding: 40px; color: #9ca3af; }
.ps-spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: ps-spin .7s linear infinite; vertical-align: -0.15em; }
@keyframes ps-spin { to { transform: rotate(360deg); } }
.ps-skel { background: linear-gradient(90deg, #eef0f3 25%, #f6f7f9 37%, #eef0f3 63%); background-size: 400% 100%; animation: ps-skel 1.2s ease infinite; border-radius: 8px; height: 14px; margin: 8px 0; }
@keyframes ps-skel { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.ps-offline { position: fixed; top: 0; inset-inline: 0; background: var(--ps-danger); color: #fff; text-align: center; font-size: 12px; padding: 4px; z-index: 99999; }
@media (prefers-reduced-motion: reduce) { .ps-toast, .ps-skel, .ps-spinner { transition: none; animation: none; } }
