/* ============================================================================
   published-results.css — معاينة النتيجة النهائية وإعلان النتيجة.
   جدول عريض داخل Scroll Container خاص (لا min-width على body ولا كسر
   للتنقل السفلي) + إطار خارجي مدوّر + Sticky للرؤوس المدمجة ولأعمدة هوية
   الطالب من ناحية اليمين (RTL). ألوان القواعد البصرية نفسها المستخدمة في الطباعة.
   ============================================================================ */

.pub-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 8px; }
.pub-toolbar > div { min-width: 140px; }
.pub-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }

/* اختيار التوقيعات */
.pub-sig-controls { margin: 4px 0 10px; padding: 8px 10px; border: 1px solid var(--line, rgba(128,128,128,.25)); border-radius: 10px; }
.pub-sig-master { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.pub-sig-options { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; }
.pub-sig-options label { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; }

/* Legend الألوان */
.pub-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; margin: 4px 0 10px; color: var(--muted, #8a93a6); }
.pub-legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.pub-legend .sw { display: inline-block; width: 13px; height: 13px; border-radius: 3px; border: 1px solid rgba(128,128,128,.4); }
.pub-legend .sw-orig { background: #111; }
.pub-legend .sw-eas { background: #e03131; }  /* أحمر = «درجة التيسير» */
.pub-legend .sw-adj { background: #0f9b6b; }  /* أخضر = «الجبر التلقائي/التعديل الآلي» */
.pub-legend .sw-circle { border: 2px solid #e03131; border-radius: 50%; background: transparent; }
.pub-legend .sw-slash { background: linear-gradient(to top left, transparent 44%, #0f9b6b 44%, #0f9b6b 56%, transparent 56%); }
.pub-legend .sw-locked { background: transparent; border-bottom: 2.5px solid currentColor; border-top: 0; border-left: 0; border-right: 0; border-radius: 0; }

/* تحذيرات الإدارة (Diagnostics) */
.pub-admin-warn {
  background: var(--danger-soft, rgba(224,49,49,.12)); border: 1px solid rgba(224,49,49,.4);
  border-radius: 10px; padding: 9px 12px; font-size: 12.5px; line-height: 1.7; margin: 6px 0 10px;
}

/* حاوية التمرير + الإطار الخارجي المدوّر (التمرير الأفقي هنا فقط) — ارتفاعات الرؤوس
   الثابتة تُستخدم لحساب إزاحات Sticky بعد الدمج (لا top ثابت مبعثر).
   --pub-hr0 = ارتفاع صف الرأس الأول (يحتوي أسماء المقررات الرأسية E:V كاملة). */
.pub-scroll {
  --pub-hr0: 112px; --pub-hr1: 22px;
  overflow: auto; max-height: 72vh;
  border: 1px solid var(--line, rgba(128,128,128,.25));
}
.pub-table-frame { border-radius: 12px; }

table.pub-table { border-collapse: separate; border-spacing: 0; direction: rtl; font-size: 12px; }
table.pub-table th, table.pub-table td {
  border-bottom: 1px solid var(--line, rgba(128,128,128,.25));
  border-left: 1px solid var(--line, rgba(128,128,128,.25));
  padding: 3px 6px; text-align: center; white-space: nowrap; background: var(--card, #0d1524);
}

/* رؤوس متعددة الصفوف مثبتة أعلى الحاوية — الإزاحات من ارتفاعات ثابتة (تتوافق مع الرؤوس الرأسية) */
table.pub-table thead th { position: sticky; z-index: 3; background: var(--card2, #101a2e); font-weight: 800; white-space: normal; }
table.pub-table thead th.pub-hrow-0 { top: 0; height: var(--pub-hr0); }
table.pub-table thead th.pub-hrow-1 { top: var(--pub-hr0); height: var(--pub-hr1); }
table.pub-table thead th.pub-hrow-2 { top: calc(var(--pub-hr0) + var(--pub-hr1)); }

/* رؤوس رأسية — أسماء المقررات الضيقة كاملة بلا قص (لا ellipsis) */
th.pub-head-vertical { vertical-align: middle; padding: 2px; }
th.pub-head-vertical .pub-vhead {
  writing-mode: vertical-rl; transform: rotate(180deg); text-orientation: mixed;
  display: inline-block; max-height: calc(var(--pub-hr0, 112px) - 6px); line-height: 1.15;
  white-space: normal; overflow: visible; text-overflow: clip; font-size: 11px; text-align: center;
}

/* قيم الجسم الرأسية داخل الخلايا المدمجة عبر الصفوف الأربعة:
   AB/AD (اسما مادتي التخلف) · AF:AI (مجاميع السنوات) · AK:AO —
   الاسم/القيمة كاملة بلا قص، يلتف النص رأسيًا عند الطول */
td.pub-vbody { vertical-align: middle; text-align: center; padding: 1px; white-space: normal; }
td.pub-vbody .pub-vtext {
  writing-mode: vertical-rl; transform: rotate(180deg); text-orientation: mixed;
  display: inline-block; white-space: normal; line-height: 1.15;
  overflow: visible; text-overflow: clip; text-align: center;
}
td.pub-final-makeup-name .pub-vtext { font-weight: 700; }

/* مجاميع السنوات AF:AI — Stack أفقي مكدّس ملوّن حسب الصف المصدر (لا فقد قيمة) */
td.pub-final-year-total { vertical-align: middle; text-align: center; padding: 1px; }
.pub-year-total-stack { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; line-height: 1.1; }
.pub-year-total-line { display: block; white-space: normal; }
.pub-year-total-original { color: #eef1f6; font-weight: 700; }
.pub-year-total-easing { color: #e03131; font-weight: 700; }
.pub-year-total-adjustment { color: #12b374; font-weight: 700; }
.pub-year-total-estimate { font-weight: 700; }
.pub-year-total-line.pub-fail { color: #e03131; font-weight: 800; }

/* أعمدة هوية الطالب مثبتة يمينًا (RTL) — عروض ثابتة للإزاحات */
table.pub-table .pub-idn { position: sticky; z-index: 2; background: var(--card2, #101a2e); font-weight: 700; }
table.pub-table thead th.pub-idn { z-index: 4; }
.pub-idn-0 { right: 0; min-width: 34px; max-width: 34px; }
.pub-idn-1 { right: 34px; min-width: 64px; max-width: 64px; }
.pub-idn-2 { right: 98px; min-width: 190px; max-width: 190px; }
.pub-idn-3 { right: 288px; min-width: 44px; max-width: 44px; }
td.pub-name { text-align: right; white-space: normal; line-height: 1.35; }
/* اسم الطالب في الإعلان: يلتف داخل خليته (لا تسرّب للمجاور) والخط يصغر مع الطول */
table.pub-ann td.pub-name { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: break-word; }
table.pub-ann td.pub-ann-name-medium { font-size: .88em; }
table.pub-ann td.pub-ann-name-long { font-size: .78em; }
/* قيم الخلايا (درجات وعلامات) في سطر واحد — «ض ج»/«ج ج» لا تنكسر */
table.pub-table td.pub-cell .pub-v { white-space: nowrap; }

/* الملاحظات AE — أفقية، تمتد على الصفوف الأربعة، بلا قص */
td.pub-notes { text-align: right; white-space: normal; line-height: 1.35; vertical-align: middle; min-width: 150px; }

/* حدود Block الطالب + تناوب خلفية خفيف */
tbody.pub-block > tr:first-child td { border-top: 2px solid var(--accent, #d9a62e); }
tbody.pub-alt td { background: color-mix(in srgb, var(--card, #0d1524) 88%, var(--accent, #d9a62e) 12%); }
tbody.pub-alt td.pub-idn { background: color-mix(in srgb, var(--card2, #101a2e) 86%, var(--accent, #d9a62e) 14%); }

/* ألوان الصفوف الأربعة (pub-eas = الصف الثاني «التيسير» أحمر · pub-adj = الصف الثالث
   «الجبر التلقائي/التعديل الآلي» أخضر — متسقة مع الأسماء الداخلية والألوان لا تتغيّر) */
tr.pub-eas td.pub-cell { color: #e03131; font-weight: 700; }
tr.pub-adj td.pub-cell { color: #12b374; font-weight: 700; }
tr.pub-est td.pub-cell { font-weight: 700; }
td.pub-fail { color: #e03131 !important; font-weight: 800 !important; }

/* القيمة داخل .pub-v — الرقم فوق الخط المائل */
.pub-v { position: relative; display: inline-block; z-index: 1; }

/* الخط الأخضر المائل: رفيع، على القيمة فقط لا كامل الخلية، لا يحرك الرقم.
   .pub-after-orig = غلاف الأصل في بحث «بعد التيسير» — نفس الـHelpers (لا تكرار Engine) */
td.pub-has-adj .pub-v::after,
.pub-after-orig.pub-has-adj .pub-v::after {
  content: ''; position: absolute; left: -2px; right: -2px; top: 50%; height: 0;
  border-top: 1.4px solid #79b995; transform: rotate(-18deg); transform-origin: center;
  opacity: .85; pointer-events: none;
}

/* دائرة الرسوب الحمراء حول القيمة الأصلية */
td.pub-circled, .pub-after-orig.pub-circled { position: relative; }
td.pub-circled::before,
.pub-after-orig.pub-circled::before {
  content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 2em; height: 1.7em; border: 2px solid #e03131; border-radius: 50%; pointer-events: none;
}

/* ناجح عام سابق */
td.pub-locked-orig .pub-v,
.pub-after-orig.pub-locked-orig .pub-v { text-decoration: underline; text-underline-offset: 2px; }
td.pub-locked-est { color: #e03131 !important; }
td.pub-locked-est .pub-v { text-decoration: underline; text-underline-offset: 2px; font-weight: 800; }

/* ----------------------- بحث «بعد التيسير» (1.14) -----------------------
   طبقات خلية المجموع: الأصل (أسود) داخل .pub-after-orig · التيسير أحمر ·
   الجبر/التعديل الآلي أخضر · التقدير أسفلها — نفس دلالات ألوان النتيجة المنشورة. */
td.pub-after-cell { white-space: nowrap; }
.pub-after-orig { display: inline-block; padding: 0 .5em; }
.pub-after-eas { color: #e03131; font-weight: 700; }
.pub-after-adj { color: #12b374; font-weight: 700; }
.pub-after-est { font-size: .85em; font-weight: 700; margin-top: 2px; }
.pub-after-est.pub-fail { color: #e03131; font-weight: 800; }
.pub-after-est.pub-after-locked { color: #e03131; text-decoration: underline; text-underline-offset: 2px; }

/* بطاقة ملاحظات النتيجة النهائية (AE) — نص كامل RTL بلا قص */
.pub-notes-card {
  margin-top: 10px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line, rgba(128,128,128,.25));
  background: color-mix(in srgb, var(--card, #0d1524) 92%, var(--accent, #d9a62e) 8%);
}
.pub-notes-card .pnc-title { font-weight: 800; font-size: 12.5px; margin-bottom: 5px; }
.pub-notes-card .pnc-body { white-space: normal; overflow-wrap: break-word; line-height: 1.8; font-size: 13px; }

/* شريط الصفحات */
.pub-pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.pub-pageinfo { font-size: 12.5px; color: var(--muted, #8a93a6); font-weight: 600; }

/* موبايل: التمرير داخل الحاوية فقط — لا عرض قسري على الصفحة */
@media (max-width: 860px) {
  .pub-scroll { max-height: 64vh; -webkit-overflow-scrolling: touch; }
  .pub-idn-2 { min-width: 130px; max-width: 130px; }
  .pub-idn-3 { right: 228px; }
  .pub-toolbar > div { min-width: 120px; flex: 1 1 40%; }
}
