/* v24/Stage 3 — جدول‌های هوشمندِ فهرست: اسکرولِ افقی فقط روی خودِ جدول (نه صفحه)،
 * سرستونِ چسبان + ستونِ نخستِ چسبان، تراکمِ فشرده، ظاهرِ یکدستِ ax-table. */

/* v127/A2 (AX-A0BC — ریشه‌ی واقعی) — سطحِ جدولِ محتوا دیگر از متغیرِ «جعبه‌ی جست‌وجوی
 * نوارِ کناری» (--ax-search-bg) رنگ نمی‌گیرد: آن متغیر با پالتِ هر کاربر عوض می‌شود و
 * دو خرابیِ قرینه می‌ساخت — پالتِ پیش‌فرضِ ذغالی: سرستون و ردیف‌های زوج تقریباً سیاه
 * (متنِ تیره‌ی Unfold رویش ناخوانا)؛ پالتِ روشن: سرستونِ سفید زیرِ متنِ سفیدِ سرستونِ
 * صفحه‌ی گردشِ حساب = برچسب‌های نامرئی. سطحِ جدولِ محتوا متغیرِ خودش را دارد. */
:root { --ax-table-surface: #fff; }
html.dark { --ax-table-surface: #171A1F; }

/* کانتینرِ نتایجِ changelist اسکرولِ افقی می‌گیرد؛ صفحه هرگز افقی اسکرول نمی‌شود. */
#changelist .results {
  overflow-x: auto;
  overflow-y: visible;
  max-width: 100%;
}

/* تراکمِ فشرده + خطوطِ ملایم */
#result_list th,
#result_list td {
  padding: 8px 10px !important;
  white-space: nowrap;
}

/* v140/D1 — «وقتی طولانی است باید برود ردیفِ بعدی — این بنیادی در طراحی است» (مالک، جدولِ کالای در راه).
 * سلولِ متنی هرگز روی همسایه نمی‌افتد: شکستنِ خط + شکستنِ واژه‌ی بلند + سقفِ عرض. ستون‌های عددی/کد
 * nowrap می‌مانند (تراز و ارقامِ جدول‌بندی). ستونِ گونه فقط مقادیرِ ویژگی را می‌آورد (نه نامِ کالا) — inventory/sale_value. */
#result_list td:not(.num):not(.ax-num):not(.field-amount):not(.field-grand_total):not(.field-grand_total_cached):not(.field-total):not(.field-balance):not(.field-code):not(.action-checkbox) {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 34ch;
  vertical-align: top;
}
#result_list thead th { white-space: normal; overflow-wrap: anywhere; }

/* ⚠️ v158/D3 — جاروبِ دوباره‌ی v154/D1، این‌بار «با بج‌ها». سلول شکستنی بود ولی بجِ داخلش
 * white-space:nowrap داشت و همان می‌ماند تک‌خطی: در فهرستِ مناقصات ستونِ عنوان می‌شکست و
 * «شرکت کردیم، منتظر» نمی‌شکست و روی همسایه می‌افتاد. دو لایه: (۱) کلاسِ مشترکِ ax-chip
 * (status_chips.status_chip)، (۲) هر spanِ گردگوشه‌ی درونِ سلولِ شکستنی — چون ده‌ها بجِ
 * درون‌خطیِ قدیمی در ادمین‌های مختلف هست و «یک فایل» نمی‌تواند همه را عوض کند بدونِ
 * رگرسیون. عدد/کد دست‌نخورده (تراز و ارقامِ جدول‌بندی). */
.ax-chip,
#result_list td:not(.num):not(.ax-num):not(.field-code) span[style*="border-radius"] {
  white-space: normal !important;
  overflow-wrap: anywhere;
  max-width: 100%;
}

/* عرضِ ستون متناسب با محتوا: شناسه‌های بلندِ عددی (شماره‌ی ستادِ ۱۶رقمی) جا می‌خواهند و
 * شکستنشان وسطِ رقم بدتر از سرریز است. */
#result_list td.field-external_tender_number,
#result_list th.column-external_tender_number,
#result_list td.field-doc_number,
#result_list td.field-guarantee_no,
#result_list td.field-national_id,
#result_list td.field-legacy_number {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  max-width: none;
}

/* سرستونِ چسبان هنگامِ اسکرولِ عمودی */
#result_list thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--ax-table-surface, #fff);
}

/* ستونِ نخست (چک‌باکسِ اکشن یا نخستین ستون) هنگامِ اسکرولِ افقی چسبان بماند */
#result_list thead th:first-child,
#result_list tbody th:first-child,
#result_list tbody td:first-child {
  position: sticky;
  inset-inline-start: 0;
  z-index: 2;
  background: var(--ax-table-surface, #fff);
}
#result_list thead th:first-child { z-index: 4; }

/* زبراسازیِ خوانا */
#result_list tbody tr:nth-child(even) td,
#result_list tbody tr:nth-child(even) th {
  background-color: color-mix(in srgb, var(--ax-table-surface, #fff) 96%, #808080);
}

/* اعداد راست‌چین با جداکننده‌ی هزارگان (کلاسِ کمکیِ اختیاری برای ستون‌های عددی/مبلغ) */
#result_list td.ax-num,
#result_list td.field-amount,
#result_list td.field-grand_total,
#result_list td.field-grand_total_cached,
#result_list td.field-total,
#result_list td.field-balance {
  text-align: end;
  font-variant-numeric: tabular-nums;
}

/* متنِ بلند در سلول‌ها با «…» کوتاه شود (tooltip از title می‌آید) */
#result_list td.ax-ellipsis {
  max-width: 22ch;
  overflow: hidden;
  text-overflow: ellipsis;
}
