/* تِجار — طبقة تحسين تجربة الاستخدام وإمكانية الوصول */

/* التركيز الظاهر للوحة المفاتيح */
:focus-visible { outline: 2px solid var(--green-700, #1E6B49); outline-offset: 2px; border-radius: 4px; }
.sidebar :focus-visible { outline-color: #E7C468; }
button:focus:not(:focus-visible), [role=button]:focus:not(:focus-visible) { outline: none; }

/* رابط تخطي للمحتوى */
.ux-skip { position: absolute; top: -60px; right: 12px; background: #0B1B16; color: #fff; padding: 10px 16px; border-radius: 0 0 8px 8px; z-index: 1000; text-decoration: none; font-weight: 700; }
.ux-skip:focus { top: 0; }

/* الإشعارات */
.ux-toasts { position: fixed; bottom: 20px; left: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.ux-toast { pointer-events: auto; cursor: pointer; padding: 12px 16px; border-radius: 10px; font-size: 13.5px; line-height: 1.6; color: #fff; background: #1f2a26; box-shadow: 0 10px 30px rgba(0,0,0,0.25); border-inline-start: 4px solid #6b7c74; animation: ux-in .22s ease-out; }
.ux-toast-success { background: #14532d; border-color: #4ade80; }
.ux-toast-error   { background: #7f1d1d; border-color: #f87171; }
.ux-toast-warn    { background: #78350f; border-color: #fbbf24; }
.ux-toast.ux-out  { opacity: 0; transform: translateY(8px); transition: all .25s; }
@keyframes ux-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* هياكل التحميل */
[aria-busy="true"] { display: block; }
td[aria-busy="true"] { display: table-cell; }
.ux-skel { display: block; height: 14px; margin: 10px auto; width: 70%; border-radius: 6px;
  background: linear-gradient(90deg, rgba(0,0,0,0.06) 25%, rgba(0,0,0,0.12) 37%, rgba(0,0,0,0.06) 63%); background-size: 400% 100%; animation: ux-shimmer 1.3s ease infinite; }
.ux-skel.s2 { width: 55%; }
.ux-skel.s3 { width: 40%; }
@keyframes ux-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* حالات الفراغ */
.ux-empty::before { content: ""; display: block; width: 44px; height: 44px; margin: 0 auto 10px; opacity: .45;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 13l2.5-7.5A2 2 0 018.4 4h7.2a2 2 0 011.9 1.5L20 13'/%3E%3Cpath d='M4 13v5a2 2 0 002 2h12a2 2 0 002-2v-5h-4.5l-1 2h-5l-1-2H4z'/%3E%3C/svg%3E") center/contain no-repeat; }

/* رسائل التحقق من الحقول */
.ux-field-msg { display: none; font-size: 12px; margin-top: 5px; color: #b91c1c; }
.ux-field-msg.ok { color: #15803d; }
input[aria-invalid="true"] { border-color: #dc2626 !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ───────── الجوال ───────── */
@media (max-width: 860px) {
  html, body { overflow-x: hidden; }
  input, select, textarea { font-size: 16px !important; }            /* يمنع تكبير iOS التلقائي */
  .btn, .icon-btn, .tab { min-height: 40px; }
  .btn-xs { min-height: 36px; padding-inline: 12px; }
  .topbar { padding-top: env(safe-area-inset-top); }
  .page { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .ux-toasts { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); max-width: none; }
}

/* الجداول تتحول إلى بطاقات على الشاشات الصغيرة */
@media (max-width: 640px) {
  .card { overflow-x: visible; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; min-width: 0 !important; }
  .tbl thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tbl tbody tr { border: 1px solid var(--ink-10, #e5e7e5); border-radius: 12px; margin: 0 0 12px; padding: 6px 0; background: var(--white, #fff); }
  .tbl tbody td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 14px; border-bottom: 1px dashed var(--ink-10, #e5e7e5); text-align: end; }
  .tbl tbody td:last-child { border-bottom: none; }
  .tbl tbody td[data-label]::before { content: attr(data-label); flex: 0 0 auto; font-size: 11.5px; font-weight: 700; color: var(--ink-40, #6b7c74); text-align: start; }
  .tbl tbody td.ux-span { display: block; text-align: center; border: none; }
  .tbl tbody tr:hover { background: var(--white, #fff); }
  .tbl tbody td .fc { flex-wrap: wrap; justify-content: flex-end; }
}

/* ───────── فلاتر سوق الطلبات ───────── */
.rf-bar { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto auto; gap: 10px; align-items: center; padding: 14px 16px; }
.rf-bar .topbar-search { width: 100% !important; }
.rf-bar .select, .rf-bar .input { width: 100%; padding: 9px 12px; font-size: 13px; }
.rf-check { display: flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; cursor: pointer; }
.rf-result { padding: 0 16px 12px; }
.rf-count { display: inline-block; min-width: 18px; padding: 0 5px; margin-inline-start: 3px; font-size: 11px; border-radius: 9px; background: var(--ink-05, #f0f2f1); color: var(--ink-40, #6b7c74); }
.tab.active .rf-count { background: var(--green-50, #e8f3ee); color: var(--green-700, #1E6B49); }
.rf-tag { display: inline-block; margin-inline-start: 6px; padding: 1px 7px; border-radius: 8px; font-size: 10.5px; font-weight: 700; }
.rf-tag.late { background: #fee2e2; color: #b91c1c; }
.rf-tag.soon { background: #fef3c7; color: #92400e; }
.rf-tag.mine { background: #dbeafe; color: #1d4ed8; }
@media (max-width: 1100px) { .rf-bar { grid-template-columns: 1fr 1fr 1fr; } .rf-bar .rf-q { grid-column: 1 / -1; } }
@media (max-width: 640px) { .rf-bar { grid-template-columns: 1fr 1fr; } #rfq-status-tabs { overflow-x: auto; max-width: 100%; } }
