/* ═══════════════════════════════════════════════════════════════════════════
   الشهادة — A4 أفقي، بترسم في المتصفح وتتصدّر صورة أو تتطبع PDF
   ───────────────────────────────────────────────────────────────────────────
   ⚠️ الورقة بمقاسات ثابتة بالبكسل (1123×794 = A4 أفقي عند 96dpi) عشان
      التصدير يطلع نفس الشكل على أي شاشة. العرض على الموبايل بيتم بـ
      `transform: scale()` على الغلاف — مش بتغيير المقاسات، عشان اللي
      المستخدم بيشوفه هو بالظبط اللي هيتصدّر.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ⚠️ الملف ده لازم يبقى **مكتفي بنفسه**: الشهادة بتترسم كمان في مضيف
   الطباعة وفي صفحة المعاينة، والاتنين مش شايلين app.css. من غير السطر ده
   الحشو بيتزوّد على الارتفاع فالمحتوى بيفيض بره الورقة. */
.cert-sheet, .cert-sheet * { box-sizing: border-box; }

.cert-stage {
  overflow: hidden;
  display: flex;
  justify-content: center;
}

.cert-scaler { transform-origin: top center; }

.cert-sheet {
  position: relative;
  width: 794px;
  height: 1123px;
  background: #fdfcf9;
  color: #14213d;
  font-family: 'Cairo', 'Tajawal', sans-serif;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(10, 37, 64, .18);
  /* لازم تفضل ثابتة مهما كان حجم الشاشة */
  flex: 0 0 auto;
}

/* ── الخلفية: شبكة إسلامية باهتة + وردة مركزية ── */

.cert-lattice {
  position: absolute; inset: 0;
  opacity: .05;
  background-image:
    repeating-linear-gradient(45deg,  #0a2540 0 1px, transparent 1px 26px),
    repeating-linear-gradient(-45deg, #0a2540 0 1px, transparent 1px 26px);
}

.cert-rosette {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 420px; height: 420px;
  color: #c59b27;
  opacity: .07;
}

/* ── الإطارات الذهبية المتعددة ── */

.cert-border-gold {
  position: absolute; inset: 14px;
  border: 9px solid transparent;
  border-image: linear-gradient(135deg,
    #bf953f 0%, #fcf6ba 25%, #b38728 50%, #fbf5b7 75%, #aa771c 100%) 1;
}
.cert-border-navy {
  position: absolute; inset: 27px;
  border: 2px solid #0a2540;
}
.cert-border-dots {
  position: absolute; inset: 34px;
  border: 1px dashed #c59b27;
  opacity: .65;
}

/* ── زخارف الأركان ── */

.cert-corner {
  position: absolute;
  width: 92px; height: 92px;
}
.cert-corner.tr { top: 30px; right: 30px; }
.cert-corner.tl { top: 30px; left: 30px;  transform: scaleX(-1); }
.cert-corner.br { bottom: 30px; right: 30px; transform: scaleY(-1); }
.cert-corner.bl { bottom: 30px; left: 30px;  transform: scale(-1, -1); }

/* ── المحتوى ── */

.cert-content {
  position: relative;
  height: 100%;
  padding: 44px 48px 36px;
  display: flex;
  flex-direction: column;
}

/* الترويسة: الجهة يمين · اللوجو وسط · الآية شمال */
.cert-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.cert-head-col { flex: 1; min-width: 0; }
.cert-head-col.mid { flex: 0 0 auto; text-align: center; }
.cert-head-col.end { text-align: left; }

.cert-org {
  font-size: 22px; font-weight: 800;
  color: #0a2540;
  line-height: 1.25;
}
.cert-circle {
  display: inline-block;
  margin-top: 5px;
  padding: 4px 13px;
  border-radius: 999px;
  background: #fef7e4;
  border: 1px solid #e6d19a;
  color: #876206;
  font-size: 12.5px; font-weight: 700;
}

.cert-logo {
  width: 76px; height: 76px;
  object-fit: contain;
  filter: drop-shadow(0 3px 8px rgba(10, 37, 64, .22));
}

.cert-pill {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #bf953f, #fcf6ba, #b38728);
  color: #3b2800;
  font-size: 12px; font-weight: 800;
  box-shadow: 0 2px 6px rgba(197, 155, 39, .35);
}
.cert-ayah {
  margin-top: 6px;
  font-family: 'Amiri', 'Cairo', serif;
  font-size: 14px;
  color: #4e5f73;
  line-height: 1.5;
}

/* ── العنوان ── */

.cert-title-wrap {
  text-align: center;
  margin-top: 8px;
}
.cert-title-row {
  display: flex; align-items: center; justify-content: center; gap: 16px;
}
.cert-wing { width: 82px; height: 20px; color: #c59b27; flex: 0 0 auto; }
.cert-wing.flip { transform: scaleX(-1); }

.cert-title {
  font-family: 'Amiri', 'Cairo', serif;
  font-size: 33px; font-weight: 700;
  color: #0a2540;
  margin: 0;
  /* ⚠️ ممنوع letter-spacing هنا: بيكسّر اتصال الحروف ويعزل التشكيل عند تصدير Canvas */
}
.cert-subline {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-top: 6px;
}
.cert-subline .bar {
  width: 96px; height: 2px;
  background: linear-gradient(90deg, transparent, #c59b27, transparent);
}
.cert-subline .star { color: #c59b27; font-size: 13px; letter-spacing: 3px; }

/* ── اسم الطالب ── */

.cert-testify {
  text-align: center;
  margin-top: 9px;
  font-size: 14px;
  color: #4e5f73;
}

.cert-name-plaque {
  margin: 7px auto 0;
  max-width: 78%;
  padding: 7px 28px;
  text-align: center;
  background: linear-gradient(180deg, #ffffff, #fdf8ec);
  border: 2px solid transparent;
  border-image: linear-gradient(135deg, #bf953f, #fcf6ba, #b38728) 1;
  box-shadow: 0 4px 14px rgba(10, 37, 64, .07);
}
.cert-name {
  font-family: 'Amiri', 'Cairo', serif;
  font-size: 28px; font-weight: 700;
  color: #0a2540;
  line-height: 1.25;
}

/* ── شرائط التفاصيل ── */

.cert-chips {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  margin-top: 9px;
}
.cert-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #f4f7fb;
  border: 1px solid #dfe6ef;
  font-size: 13px;
  color: #14213d;
}
.cert-chip b { color: #0a2540; }
.cert-chip.gold {
  background: linear-gradient(135deg, #fdf3d4, #fef9e8);
  border-color: #e6cf90;
  color: #6d4f04;
}

/* ── ملخص ما تم إنجازه (بطاقة الإنجاز) ── */

.cert-summary-box {
  margin-top: 14px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #ffffff;
  border: 1.5px solid #dfd5be;
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: 0 4px 18px rgba(10, 37, 64, .04);
}

.cert-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 800;
  color: #0a2540;
  padding-bottom: 8px;
  border-bottom: 1.5px dashed #e2d8c3;
}

.cert-summary-badge {
  font-size: 12px;
  padding: 3px 12px;
  border-radius: 999px;
  background: #fef7e4;
  color: #795705;
  border: 1px solid #ebd498;
  font-weight: 700;
}

.cert-items-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
  min-height: 0;
}

.cert-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 13px;
  border-radius: 10px;
  background: #fdfbf7;
  border: 1px solid #f0e9dc;
}

.cert-item-card:nth-child(even) {
  background: #f8fafc;
  border-color: #e5edf5;
}

.cert-item-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.cert-item-icon {
  font-size: 19px;
  flex: 0 0 auto;
  width: 28px;
  text-align: center;
}

.cert-item-texts {
  min-width: 0;
}

.cert-item-label {
  font-size: 13.5px;
  font-weight: 700;
  color: #0a2540;
  line-height: 1.25;
}

.cert-item-detail {
  font-size: 12.5px;
  color: #52667d;
  line-height: 1.3;
  margin-top: 2px;
}

.cert-item-eval {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cert-item-score-num {
  font-weight: 800;
  color: #0a2540;
  font-size: 13.5px;
}

.cert-item-stars {
  color: #c59b27;
  letter-spacing: 1px;
  font-size: 14px;
}

.cert-comment-card {
  margin-top: auto;
  padding: 9px 14px;
  border-radius: 10px;
  background: #fcf9ee;
  border: 1px solid #ebd9a8;
  font-size: 13px;
  color: #634b07;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.5;
}

/* ── الدعاء ── */

.cert-blessing {
  margin-top: 10px;
  padding: 8px 22px;
  text-align: center;
  background: linear-gradient(90deg, transparent, #fdf6e3 18%, #fdf6e3 82%, transparent);
  font-family: 'Amiri', 'Cairo', serif;
  font-size: 14.5px;
  color: #6d4f04;
  line-height: 1.6;
}

/* ── التذييل ── */

.cert-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-top: 10px;
}
.cert-foot-col { flex: 1; min-width: 0; font-size: 12.5px; color: #4e5f73; }
.cert-foot-col.mid { flex: 0 0 auto; text-align: center; }
.cert-foot-col.end { text-align: left; }
.cert-foot-row { margin-bottom: 3px; }
.cert-foot-val { color: #0a2540; font-weight: 700; }

.cert-seal { width: 74px; height: 74px; }

.cert-sign-label { display: block; font-size: 12px; color: #4e5f73; }
.cert-sign-name {
  display: block;
  font-size: 15px; font-weight: 800;
  color: #0a2540;
  margin-top: 2px;
}
.cert-sign-line {
  display: block;
  margin-top: 5px;
  border-top: 1.5px solid #c59b27;
  width: 156px;
  margin-inline-start: auto;
}

/* ═══════════════════════════════════════════════════════════════════════════
   الطباعة — الشهادة لوحدها على الورقة
   ═══════════════════════════════════════════════════════════════════════════ */

@media print {
  @page { size: A4 portrait; margin: 0; }

  /* نخفي التطبيق كله ونسيب الشهادة بس */
  body > *:not(.cert-print-host) { display: none !important; }

  .cert-print-host {
    display: block !important;
    position: static !important;
    inset: auto !important;
    background: #fff !important;
  }
  .cert-stage { overflow: visible; display: block; }
  .cert-scaler { transform: none !important; }
  /* المتصفح بيطبع الـ px على 96dpi، يعني 794px ≈ 210mm = عرض A4 رأسي بالظبط */
  .cert-sheet { box-shadow: none; }
}
