.memo{
/* ============================================================
   Print Styles — أنماط CSS للطباعة وتوليد PDF
   يُستخدم من pdfGenerator.ts مع Puppeteer
   ============================================================ */

/* ⚠ لا @import من CDN هنا إطلاقاً: Puppeteer ينتظر `load`، فأي استيراد بعيد
   يجعل زمن كل PDF (وتوقّفه عند 30s) مرهوناً بشبكة مركز البيانات.
   Amiri/Cairo يُضمَّنان data: URIs عبر loadDocumentFontCss()، وKaTeX عبر
   loadKatexCss() — كلاهما يُحقَن في pdfEngine قبل هذا الملفّ. */

/* ---- إعداد الصفحة ---- */
@page {
  size: A4;
  margin: 10mm;

  /* لا @bottom-center هنا عمداً (حُذف 2026-08-07):
     Puppeteer (Chromium ~140) كان يتجاهل صناديق هوامش @page فلم يُصيَّر قطّ —
     أُثبت بصفر مطابقة لـ«صفحة N من M» في نصّ PDF مستخرَج عبر صفحتين. أمّا
     Chromium 148 في Electron فيدعمها، فظهر الذيل فجأة **فوق** ذيل الثيمة
     (`footerTemplate`) ومعه مؤشّر صفحة مزدوج. كل ثيمة تريد ترقيماً توفّره في
     قالبها، فهذه القاعدة كانت زائدة حتى لو عملت. */
}

/* ---- الأساس ---- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

body {
  font-family: 'Cairo', 'Amiri', 'Sakkal Majalla', 'Arial', sans-serif;
  font-size: 11pt;
  line-height: 1.6;
  direction: rtl;
  text-align: right;
  color: #000000;
  background: white;
  /* يمنع سطراً/سطرين يتيمين عند حدود الصفحة (يقلّل الفراغ أسفل الصفحة الأولى) */
  orphans: 3;
  widows: 3;
}

/* ---- ترويسات الجداول الإدارية والبطاقات ---- */
.moudakira-header {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  border: 2px solid var(--memo-primary,#0062ac);
  border-radius: 12px;
  margin-bottom: 12px;
  font-family: 'Cairo', sans-serif;
  overflow: hidden;
  background-color: #ffffff;
}

.moudakira-header > div {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.moudakira-header .header-logo {
  width: 35%;
  border-left: 2px solid var(--memo-primary,#0062ac);
  align-items: flex-start;
  text-align: right;
  padding-left: 15px;
}

.moudakira-header .header-logo .logo-title {
  font-size: 15pt;
  font-weight: bold;
  color: var(--memo-primary,#0062ac);
}

.moudakira-header .header-logo .logo-subtitle {
  font-size: 9pt;
  color: #666;
  margin-top: 1px;
}

.moudakira-header .header-teacher {
  width: 32%;
  border-left: 2px solid var(--memo-primary,#0062ac);
}

.moudakira-header .header-year {
  width: 33%;
}

.moudakira-header .header-label {
  font-size: 9pt;
  font-weight: bold;
  color: #555;
  margin-bottom: 2px;
}

.moudakira-header .header-value {
  font-size: 11pt;
  font-weight: bold;
  color: var(--memo-primary,#0062ac);
}

/* ---- بطاقة البيانات البيداغوجية ---- */
.pedagogy-card {
  border: 2px solid var(--memo-primary,#0062ac);
  border-radius: 12px;
  margin-bottom: 12px;
  padding: 10px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  background-color: #ffffff;
  font-family: 'Cairo', sans-serif;
}

.pedagogy-card .card-column {
  width: 45%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pedagogy-card .card-column.right-col {
  border-left: 1.5px dashed var(--memo-primary,#0062ac);
  padding-left: 10px;
}

.pedagogy-card .card-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10pt;
}

.pedagogy-card .card-item .item-icon {
  font-size: 12pt;
  color: var(--memo-primary,#0062ac);
  width: 22px;
  text-align: center;
}

.pedagogy-card .card-item .item-label {
  font-weight: bold;
  color: #444;
}

.pedagogy-card .card-item .item-value {
  color: var(--memo-primary,#0062ac);
  font-weight: bold;
}

.pedagogy-card .card-illustrations {
  width: 10%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  font-size: 10.5pt;
  color: var(--memo-primary,#0062ac);
  opacity: 0.85;
  border-left: 1.5px dashed var(--memo-primary,#0062ac);
  padding-left: 5px;
  font-weight: bold;
}

/* ---- بطاقة المكتسبات والكفاءة (عمودان) ---- */
.objectives-card {
  border: 2px solid var(--memo-primary,#0062ac);
  background-color: #ffffff;
  border-radius: 12px;
  padding: 10px 15px;
  margin-bottom: 15px;
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 12px;
  font-family: 'Cairo', sans-serif;
}

.objectives-card .obj-column {
  width: 45%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.objectives-card .obj-column.right-col {
  border-left: 1.5px dashed var(--memo-primary,#0062ac);
  padding-left: 12px;
}

.objectives-card .obj-title {
  font-size: 10.5pt;
  font-weight: bold;
  color: var(--memo-primary,#0062ac);
}

.objectives-card .obj-body {
  font-size: 10pt;
  color: #333;
  line-height: 1.6;
}

.objectives-card .obj-indicators {
  color: #555;
}

.objectives-card .card-icon-container {
  width: 44px;
  height: 44px;
  border: 2px solid var(--memo-primary,#0062ac);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #ffffff;
  flex-shrink: 0;
  align-self: center;
}

.objectives-card .card-icon-container span {
  font-size: 16pt;
  color: var(--memo-primary,#0062ac);
}

/* ---- جدول سيرورة الحصة ---- */
.stages-table {
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0;
  font-family: 'Cairo', sans-serif;
  border: 2px solid var(--memo-primary,#0062ac) !important;
  border-radius: 8px;
  /* ponytail: أزلنا overflow:hidden لأنه يمنع Puppeteer من كسر الجدول عبر الصفحات
     (يدفعه كاملاً للصفحة التالية → فراغ كبير أسفل الأولى). المقابل: زوايا الجدول
     المستديرة لن تُقصّ الخلايا — تجميلي فقط. */
  page-break-inside: auto;
}

/* السماح بكسر صفوف السيرورة الطويلة (خلية المرحلة بـ rowspan) عبر الصفحات لملء الأولى */
.stages-table tr,
.stages-table td {
  page-break-inside: auto;
}

.stages-table th {
  border: 1.5px solid var(--memo-primary,#0062ac);
  background-color: var(--memo-primary-dark,#00509d);
  color: #ffffff !important;
  padding: 8px;
  font-weight: bold;
  text-align: center;
  font-size: 11pt;
}

.stages-table td {
  border: 1.5px solid var(--memo-primary,#0062ac);
  padding: 8px 10px;
  vertical-align: top;
  font-size: 10pt;
}

.stages-table .stage-cell {
  text-align: center;
  vertical-align: middle;
  font-weight: bold;
  color: var(--memo-primary-dark,#00509d);
  background-color: #f7fafc;
  font-size: 10.5pt;
  width: 12%;
}

.stages-table .duration-cell {
  text-align: center;
  vertical-align: middle;
  font-weight: bold;
  color: var(--memo-primary-dark,#00509d);
  background-color: #f7fafc;
  font-size: 10.5pt;
  width: 12%;
}

.stages-table .situation-cell {
  text-align: right;
  line-height: 1.6;
  width: 76%;
}

/* ---- العناوين والفقرات الملونة ---- */
h1, h2, h3, h4, h5, h6 {
  color: #c0392b !important; /* أحمر للعناوين */
  page-break-after: avoid;
  margin-top: 15px;
  margin-bottom: 8px;
  font-family: 'Cairo', sans-serif;
  font-weight: 700;
}

h1 { font-size: 14pt; border-bottom: 2px solid #c0392b; padding-bottom: 4px; }
h2 { font-size: 12.5pt; border-bottom: 1px solid #f9d5d5; padding-bottom: 2px; }
h3 { font-size: 11.5pt; }
h4 { font-size: 11pt; }

p {
  margin-bottom: 8px;
  text-align: justify;
  text-align-last: right;
}

/* متن الشروحات أسود؛ الكلمات المفتاحية والعناوين الفرعية الغامقة ملوّنة */
.explanation-block {
  color: #000000 !important;
}

/* الغامق = كلمة مفتاحية/عنوان فرعي (الفكرة العامة، أعود إلى قاموسي…) → أزرق واضح */
.explanation-block strong,
tbody td strong,
li strong,
p strong,
.situation-cell strong {
  color: #0056b3 !important;
}

/* ألوان التعريفات باللون الأحمر */
.definition-block {
  color: #c0392b !important;
}

.definition-block strong {
  color: #c0392b !important;
}

/* ---- بنية الأسطر داخل الخلايا (تسميات ملوّنة + عودة سطر) ---- */
.ln-label {
  color: var(--memo-primary-dark,#00509d) !important;
  font-weight: 700;
}

/* تحسين قراءة خلايا سيرورة الحصة (أسطر متباعدة) */
.stages-table td,
tbody td {
  line-height: 1.75;
}

/* ---- تصيير الرياضيات (KaTeX) ---- */
.katex {
  direction: ltr;
  unicode-bidi: isolate;
  font-size: 1.02em;
}

.katex-display {
  margin: 6px 0;
  text-align: center;
}

/* تقويم مدمج داخل المحتوى */
.evaluation-inline {
  margin-top: 8px;
  padding: 6px 10px;
  border-right: 3px solid #27ae60;
  background-color: #f4fbf7;
  border-radius: 4px;
  color: #27ae60 !important;
  font-size: 9.5pt;
}

.evaluation-inline .eval-title {
  font-weight: bold;
  color: #27ae60 !important;
  margin-left: 5px;
}

/* ---- الجداول العامة داخل الدرس ---- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  page-break-inside: auto;
  border: 1.5px solid var(--memo-primary,#0062ac);
}

tr {
  page-break-inside: avoid;
  page-break-after: auto;
}

thead {
  display: table-header-group;
}

thead th {
  background-color: #f1f8ff;
  color: var(--memo-primary,#0062ac);
  border: 1.5px solid var(--memo-primary,#0062ac);
  font-weight: bold;
  padding: 6px 10px;
  text-align: center;
  font-size: 10pt;
}

tbody td {
  padding: 6px 10px;
  border: 1.5px solid var(--memo-primary,#0062ac);
  vertical-align: top;
  color: #000000; /* متن الخلايا أسود */
}

/* ---- القوائم ---- */
ul, ol {
  margin: 6px 20px 6px 0;
  padding-right: 10px;
  color: #000000; /* متن القوائم أسود */
}

li {
  margin-bottom: 4px;
  page-break-inside: avoid;
  color: #000000;
}

/* أرقام/نقاط القوائم ملوّنة (تمييز الترقيم عن المتن الأسود) */
ol > li::marker,
ul > li::marker {
  color: #0056b3;
  font-weight: 700;
}

li.definition-block {
  color: #c0392b !important;
}

blockquote {
  border-right: 4px solid #c0392b;
  background-color: #fff9f9;
  padding: 8px 12px;
  margin: 8px 0;
  page-break-inside: avoid;
  color: #c0392b;
}

code {
  background-color: #f5f5f5;
  padding: 2px 4px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 9.5pt;
  direction: ltr;
  text-align: left;
  color: #c0392b; /* الكود يظهر بلون أحمر للتمييز */
}

pre {
  background-color: #f5f5f5;
  padding: 10px;
  border-radius: 5px;
  overflow-x: auto;
  margin: 8px 0;
  page-break-inside: avoid;
  direction: ltr;
  text-align: left;
}

pre code {
  background: none;
  padding: 0;
  color: #333;
}

hr {
  border: none;
  border-top: 1.5px solid var(--memo-primary,#0062ac);
  margin: 12px 0;
}

.section {
  page-break-inside: avoid;
}

.page-break {
  page-break-after: always;
}

@media print {
  body {
    background: white;
  }
  .no-print {
    display: none !important;
  }
  table {
    page-break-inside: auto;
  }
  tr {
    page-break-inside: avoid;
  }
  .svg-figure {
    page-break-inside: avoid;
  }
}

/* رسوم متجهة (SVG) مدرَجة من المحتوى العلمي */
.svg-figure {
  text-align: center;
  margin: 10px 0;
}
.svg-figure svg {
  max-width: 100%;
  height: auto;
}
/* رسم الدرس: عرض معتدل مركزي بدل تمدّده لكامل العمود */
.svg-figure svg.lesson-diagram {
  width: 230px;
  max-width: 60%;
  border: 1px solid #e2e2ea;
  border-radius: 6px;
  background: #fff;
  padding: 4px;
}
/* أيقونة/رسم من المكتبة المُوجَّهة: مضمّنة في مكانها بحجم متواضع */
.illustration-figure {
  page-break-inside: avoid;
}
.illustration-figure svg.lesson-illustration {
  width: 120px;
  max-width: 45%;
  height: auto;
  vertical-align: middle;
}
/* داخل خلية «عناصر الدرس» في جدول السيرورة: أصغر لئلا تزحم النص */
.situation-cell .illustration-figure svg.lesson-illustration {
  width: 96px;
  max-width: 38%;
}
/* شكل معلَمي (دارة…): أعرض من الأيقونة لوضوح الرمز الاصطلاحي */
.figure-block {
  page-break-inside: avoid;
}
.figure-block svg.lesson-figure {
  width: 240px;
  max-width: 70%;
  height: auto;
  vertical-align: middle;
}
.situation-cell .figure-block svg.lesson-figure {
  width: 190px;
  max-width: 55%;
}

/* ── تجميع الرسومات بجانب بعض (2-3 كتل بصرية متتالية) ── */
.figure-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: flex-start;
  margin: 12px 0;
  page-break-inside: avoid;
}
.figure-group > figure,
.figure-group > .image-block,
.figure-group > .svg-figure {
  flex: 1 1 calc(33.333% - 12px);
  max-width: calc(33.333% - 8px);
  margin: 0;
}
/* كتلتان فقط: يتوسّطان أكثر */
.figure-group > figure:only-child,
.figure-group > .image-block:only-child,
.figure-group > .svg-figure:only-child {
  flex: 1 1 50%;
  max-width: 70%;
}
/* داخل خلية الجدول: أصغر لئلا تزحم النص */
.situation-cell .figure-group {
  gap: 8px;
}
.situation-cell .figure-group > figure svg.lesson-figure,
.situation-cell .figure-group > .svg-figure svg.lesson-illustration {
  width: 120px;
  max-width: 90%;
}

/* ============================================================
   memo/classic — أنماط خاصة بهذا الـtheme (فوق baseStyles المشتركة)
   ============================================================
   تُحمَّل بعد baseStyles.css فتَغلِبها عند التعارض (classic فقط). */

/* ---- حدّ حجم الخط: لا يتعدى 14pt في هذا القالب ---- */
.moudakira-header .header-logo .logo-title { font-size: 14pt; }
.objectives-card .card-icon-container span { font-size: 14pt; }

/* ---- فواصل جدول المراحل ----
   خطوط أفقية فقط بين المراحل الأربع (الانطلاق / بناء التعلمات /
   الاستثمار / الختامي)، لا بين الصفوف الفرعية داخل المرحلة الواحدة.
   الحدود العمودية (بين الأعمدة) والإطار الخارجي تبقى كما هي. */
.stages-table td {
  border-top: none;
  border-bottom: none;
}
.stages-table tbody tr.phase-start > td {
  border-top: 1.5px solid #0062ac;
}

}