/* ===== مولّد البوسترات — تنسيقات عامة ===== */
* { box-sizing: border-box; }
body { margin: 0; }

#dropzone.dragover {
  background: #e0f2fe;
  border-color: #1c6ca0;
}

/* ============================================================
   تصميم البوستر الجديد — مطابق لهوية تجمع مكة المكرمة الصحي
   ------------------------------------------------------------
   الخلفية: مبنى مستشفى الملك عبدالعزيز الحقيقي (شبحي خفيف) +
   تدرّج أزرق عميق + إطار فضي معدني بخمس خلايا + شعار أعلى اليسار
   القياس الأساسي 1080 × 1341 بكسل (نسبة 4:5)، يُصدّر بدقة 2x
   ------------------------------------------------------------
   حدود الإطار الفضي (بمقياس 1080):
     يسار 62 — يمين 1017 — أعلى 798 — أسفل 1281
   الحافة الفضية بسُمك ~22px، لذا المنطقة الداخلية للخلايا:
     يسار ~88 — يمين ~991 — أعلى ~824 — أسفل ~1255
   ------------------------------------------------------------
   الهوية اللونية:
     • الأزرق الداكن  #0d3a5e   (خلفية)
     • الأبيض         #ffffff   (النصوص الأساسية)
     • السماوي الفاتح #cfe6fa   (نصوص ثانوية)
     • الذهبي/الفضي   لإطار الخلايا والعناوين
   ============================================================ */
.poster {
  position: relative;
  width: 1080px;
  height: 1341px;
  /* استخدام الخلفية النظيفة (بدون الشعار القديم) — الشعار الجديد يُضاف فوقها كـ <img> */
  background-image: url('/static/assets/poster_bg_clean.png?v=20260607g');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  font-family: 'Tajawal', 'Cairo', sans-serif;
  direction: rtl;
  overflow: hidden;
  color: #ffffff;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "liga" 1, "calt" 1, "rlig" 1;
  font-variant-ligatures: common-ligatures contextual;
}
.poster * {
  letter-spacing: 0 !important;
  word-spacing: normal;
  font-variant-ligatures: common-ligatures contextual;
}

/* ---------- شارة "محاضرة" مع أيقونة الميكروفون ---------- */
.poster .badge {
  position: absolute;
  /* وضعها أسفل النص الترويسي مباشرة وفوق العنوان — وسط بصري متوازن */
  top: 310px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 14px 42px;
  background: linear-gradient(135deg, #1c6ca0 0%, #0d3a5e 100%);
  border: 2px solid rgba(255,255,255,0.55);
  border-radius: 999px;
  box-shadow: 0 8px 26px rgba(0,0,0,0.42), inset 0 1px 2px rgba(255,255,255,0.25);
  /* نضمن ارتفاع متناسق وعدم انفلات النص */
  min-height: 64px;
  box-sizing: border-box;
  white-space: nowrap;
  line-height: 1;
}
.poster .badge i {
  font-size: 28px;
  color: #ffffff;
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
}
.poster .badge span {
  font-size: 32px;
  font-weight: 900;
  color: #ffffff;
  line-height: 1;
  text-shadow: 0 2px 5px rgba(0,0,0,0.3);
  /* نضمن المحاذاة الرأسية المثالية مع الأيقونة */
  display: inline-block;
  vertical-align: middle;
}

/* ---------- الشعار الرسمي (يُوضع فوق موقع الشعار المدموج في الخلفية لاستبداله) ---------- */
/* الشعار الجديد داخل كتلة تصميمية متعمَّدة (شريط داكن أنيق بحدود ناعمة)
   تغطي تماماً أي بقايا من منطقة الشعار القديم في الخلفية الأصلية،
   مع مظهر احترافي يبدو جزءاً أصيلاً من التصميم. */
.poster .brand-logo {
  position: absolute;
  top: 36px;
  left: 36px;
  width: 480px;
  height: 200px;
  z-index: 2;
  /* خلفية تدرّج رأسي داكنة بنفس روح ألوان البوستر — أزرق ليلي → كحلي */
  background:
    linear-gradient(135deg,
      rgba(8, 28, 56, 0.96) 0%,
      rgba(11, 38, 72, 0.94) 50%,
      rgba(15, 48, 88, 0.92) 100%);
  border-radius: 14px;
  /* حد رفيع أنيق يفصله بصرياً عن الخلفية */
  border: 1px solid rgba(125, 175, 230, 0.28);
  /* ظل خفيف لإبراز الكتلة */
  box-shadow:
    0 6px 24px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 22px;
  box-sizing: border-box;
}
.poster .brand-logo img {
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}
/* في الستوري نُكبّر الكتلة قليلاً */
.poster.story .brand-logo {
  top: 48px;
  left: 48px;
  width: 560px;
  height: 240px;
  border-radius: 18px;
  padding: 18px 26px;
}

/* ---------- النص الترويسي ---------- */
.poster .intro {
  position: absolute;
  top: 380px;
  left: 90px;
  right: 90px;
  text-align: center;
}
.poster .intro .line1 {
  display: block;
  font-size: 27px;
  font-weight: 600;
  line-height: 1.5;
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(0,0,0,0.55);
}
.poster .intro .line2 {
  display: block;
  font-size: 27px;
  font-weight: 800;
  line-height: 1.5;
  margin-top: 4px;
  color: #ffffff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.poster .intro.sm .line1 { font-size: 24px; }
.poster .intro.sm .line2 { font-size: 24px; }

/* ---------- عنوان البرنامج ---------- */
.poster .title-wrap {
  position: absolute;
  top: 488px;
  left: 70px;
  right: 70px;
  bottom: 565px;             /* ينتهي قبل أعلى الإطار (798) بهامش مريح */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.poster .title {
  font-size: 50px;
  font-weight: 900;
  line-height: 1.32;
  color: #ffffff;
  text-shadow: 0 3px 10px rgba(0,0,0,0.45);
  margin: 0;
}
.poster .title.sm { font-size: 40px; }
.poster .title.xs { font-size: 33px; }
.poster .title.lg { font-size: 58px; }
.poster .title-divider {
  margin: 20px auto 0;
  width: 170px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(207,230,250,0) 0%, #cfe6fa 50%, rgba(207,230,250,0) 100%);
}

/* ============================================================
   الإطار الفضي — خمس خلايا أفقية
   نضع طبقة overlay شفافة فوق المنطقة الداخلية للإطار الفضي،
   ونقسمها إلى 5 خلايا متساوية عبر flexbox لمحاذاة مثالية.
   ترتيب الخلايا (RTL، من اليمين لليسار):
     1) الوقت  2) التاريخ  3) الموقع  4) الفئة المستهدفة  5) المتحدث
   ============================================================ */
.poster .frame {
  position: absolute;
  left: 88px;
  right: 89px;     /* 1080 - 991 = 89 */
  top: 824px;
  bottom: 86px;    /* 1341 - 1255 = 86 */
  display: flex;
  flex-direction: row;
  direction: rtl;
}
.poster .cell {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding: 22px 8px 18px;
  position: relative;
}
/* فاصل رأسي رفيع بين الخلايا (يحاكي فواصل الإطار) */
.poster .cell + .cell::after {
  content: "";
  position: absolute;
  right: 0;
  top: 12%;
  height: 76%;
  width: 1px;
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(200,220,240,0.35) 50%, rgba(255,255,255,0) 100%);
}

/* أيقونة الخلية داخل قرص دائري فاتح */
.poster .cell .cicon {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #eaf4fc 0%, #c8def1 70%, #a9cbe6 100%);
  border: 2px solid rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 14px rgba(0,0,0,0.35), inset 0 1px 3px rgba(255,255,255,0.6);
  margin-bottom: 14px;
  flex: 0 0 auto;
}
.poster .cell .cicon img,
.poster .cell .cicon svg {
  width: 46px;
  height: 46px;
  object-fit: contain;
}
.poster .cell .cicon i {
  font-size: 40px;
  color: #0d4d7a;
}

/* عنوان الخلية (المتحدث/الموقع/...) */
.poster .cell .clabel {
  font-size: 24px;
  font-weight: 900;
  color: #ffffff;
  line-height: 1.2;
  margin-bottom: 8px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
/* قيمة الخلية */
.poster .cell .cvalue {
  font-size: 21px;
  font-weight: 600;
  color: #eaf4fc;
  line-height: 1.4;
  width: 100%;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.poster .cell .cvalue .note {
  display: block;
  font-size: 16px;
  font-weight: 500;
  color: #b9d6ee;
  margin-top: 5px;
  line-height: 1.35;
}

/* ---------- مستويات تكثيف لكل خلية حسب طول المحتوى ---------- */
.poster .cell.dense .cicon { width: 74px; height: 74px; margin-bottom: 11px; }
.poster .cell.dense .cicon img, .poster .cell.dense .cicon svg { width: 40px; height: 40px; }
.poster .cell.dense .cicon i { font-size: 35px; }
.poster .cell.dense .clabel { font-size: 22px; margin-bottom: 6px; }
.poster .cell.dense .cvalue { font-size: 18px; line-height: 1.32; }
.poster .cell.dense .cvalue .note { font-size: 14px; margin-top: 4px; }

.poster .cell.xdense .cicon { width: 64px; height: 64px; margin-bottom: 9px; }
.poster .cell.xdense .cicon img, .poster .cell.xdense .cicon svg { width: 34px; height: 34px; }
.poster .cell.xdense .cicon i { font-size: 30px; }
.poster .cell.xdense .clabel { font-size: 20px; margin-bottom: 5px; }
.poster .cell.xdense .cvalue { font-size: 16px; line-height: 1.28; }
.poster .cell.xdense .cvalue .note { font-size: 13px; margin-top: 3px; }

/* ============================================================
   صيغة Story (9:16) — 1080 × 1920
   نستخدم نفس عناصر البوستر مع تكبير وإعادة توزيع رأسي
   ============================================================ */
.poster.story {
  width: 1080px;
  height: 1920px;
  /* خلفية story مولّدة بـ CSS gradient لتعويض انحصار البوستر 4:5 */
  background-image:
    linear-gradient(180deg,
      rgba(13, 58, 94, 0.95) 0%,
      rgba(13, 58, 94, 0.75) 40%,
      rgba(13, 58, 94, 0.95) 100%),
    url('/static/assets/poster_bg.png?v=20260607a');
  background-size: cover, 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
}
/* في وضع Story: نُكبّر الشارة والعنوان ونعيد توزيع الإطار رأسياً ليأخذ مساحة أكبر */
.poster.story .badge { top: 380px; padding: 14px 44px; font-size: 28px; }
.poster.story .badge i { font-size: 32px; }
.poster.story .intro {
  top: 470px; font-size: 30px;
}
.poster.story .intro .line2 { font-size: 26px; }
.poster.story .title-wrap {
  top: 600px; width: 920px; left: 80px;
}
.poster.story .title { font-size: 64px; line-height: 1.25; }
.poster.story .title.sm { font-size: 54px; }
.poster.story .title.xs { font-size: 44px; }
.poster.story .title.lg { font-size: 78px; }
.poster.story .title-divider {
  width: 200px; height: 5px; margin: 22px auto 0;
}
/* الإطار الفضي يمتدّ ليملأ النصف السفلي من الستوري */
.poster.story .frame {
  top: 1080px;
  bottom: 90px;
  left: 60px;
  right: 60px;
  width: auto;
  height: auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
.poster.story .cell .cicon { width: 96px; height: 96px; margin-bottom: 16px; }
.poster.story .cell .cicon i { font-size: 46px; }
.poster.story .cell .clabel { font-size: 28px; margin-bottom: 10px; }
.poster.story .cell .cvalue { font-size: 24px; line-height: 1.4; }
.poster.story .cell .cvalue .note { font-size: 20px; margin-top: 7px; }

/* ============================================================
   أزرار تبديل صيغة التوليد (بوستر / ستوري)
   ============================================================ */
.fmt-btn {
  color: #475569;
  background: transparent;
  transition: all .15s ease;
  cursor: pointer;
}
.fmt-btn:hover { color: #1e293b; background: rgba(255,255,255,0.6); }
.fmt-btn.fmt-active {
  background: #1c6ca0;
  color: #fff;
  box-shadow: 0 2px 6px rgba(28, 108, 160, 0.35);
}
.fmt-btn.fmt-active:hover { background: #0d4d7a; color: #fff; }

/* ============================================================
   عناصر القوالب والأرشيف
   ============================================================ */
.tpl-row {
  display: flex; align-items: center; gap: 10px;
  background: #f8fafc; border: 1px solid #e2e8f0;
  padding: 10px 12px; border-radius: 10px;
}
.tpl-row .swatch {
  width: 30px; height: 30px; border-radius: 8px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #cbd5e1;
}
.tpl-row .dept-name {
  flex: 1; font-weight: 700; color: #334155; font-size: 14px;
}
.tpl-row button {
  background: #fee2e2; color: #b91c1c;
  padding: 5px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 700;
}
.tpl-row button:hover { background: #fecaca; }

.arch-batch {
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 12px; padding: 14px;
}
.arch-batch-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 10px;
}
.arch-batch-title {
  font-weight: 800; color: #1e293b; font-size: 15px;
  display: flex; align-items: center; gap: 8px;
}
.arch-batch-title .meta {
  font-weight: 500; color: #64748b; font-size: 12px;
}
.arch-batch .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.arch-batch .actions button {
  padding: 6px 12px; border-radius: 8px;
  font-size: 12px; font-weight: 700;
}
.arch-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}
.arch-thumbs img {
  width: 100%; aspect-ratio: 4/5; object-fit: cover;
  border-radius: 6px; border: 1px solid #cbd5e1; cursor: pointer;
}
