/* ============================================================
   مصمم كروت الدعوات — واجهة المستخدم (mobile-first، ثيم داكن)
   ملاحظة: هذا التنسيق خاص بواجهة التطبيق (المعرض/اللوحة/الأزرار) فقط.
   ألوان الكرت نفسه (الخلفية/الخط) تبقى كما ضبطها المشرف لكل قالب.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

.icd-app {
  /* ------ رموز الثيم الداكن ------ */
  --icd-bg:          #15171c;
  --icd-surface:     #1c1f26;
  --icd-surface-2:   #262a34;
  --icd-border:      #323744;
  --icd-text:        #f3f4f6;
  --icd-text-muted:  #9aa1af;
  --icd-accent:      #cda550;
  --icd-accent-ink:  #1a1408;
  --icd-danger:      #e5615f;
  --icd-radius-lg: 18px;
  --icd-radius-md: 12px;
  --icd-radius-sm: 8px;

  max-width: 480px;
  margin: 0 auto;
  padding: 0 0 88px;
  font-family: 'Tajawal', system-ui, sans-serif;
  direction: rtl;
  background: var(--icd-bg);
  color: var(--icd-text);
}

/* تحميل */
.icd-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--icd-text-muted);
  font-size: 15px;
}

/* رأس */
.icd-header {
  padding: 22px 16px 12px;
  text-align: center;
}
.icd-title {
  font-size: 21px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--icd-text);
  letter-spacing: .2px;
}
.icd-subtitle {
  font-size: 13px;
  color: var(--icd-text-muted);
  margin: 0;
}

/* تصنيفات */
.icd-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 16px 14px;
  justify-content: center;
}
.icd-cat-chip {
  background: var(--icd-surface-2);
  border: 1px solid var(--icd-border);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  color: var(--icd-text-muted);
  transition: background .15s, color .15s, border-color .15s;
}
.icd-cat-chip.is-active,
.icd-cat-chip:hover {
  background: var(--icd-accent);
  border-color: var(--icd-accent);
  color: var(--icd-accent-ink);
}

/* معرض القوالب */
.icd-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 4px 16px 16px;
}
.icd-card {
  border-radius: var(--icd-radius-md);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--icd-border);
  transition: border-color .15s, transform .12s, box-shadow .15s;
  background: var(--icd-surface);
}
.icd-card:hover {
  border-color: var(--icd-accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,.35);
}
.icd-card-img {
  aspect-ratio: 2/3;
  overflow: hidden;
  background: var(--icd-surface-2);
}
.icd-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.icd-card-foot {
  padding: 7px 6px;
  background: var(--icd-surface);
  border-top: 1px solid var(--icd-border);
}
.icd-card-name {
  font-size: 11px;
  font-weight: 600;
  display: block;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--icd-text);
}

/* منطقة عرض الكرت */
.icd-stage {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px 14px 6px;
  background: transparent;
}

.icd-canvas-holder {
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0,0,0,.45);
}

/* الكرت الفعلي (340×510 — يُحجَّم بـ transform scale) */
.icd-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 340px;
  height: 510px;
  overflow: hidden;
  direction: rtl;
  transform-origin: top left;
}

/* صورة الخلفية */
.icd-canvas .icd-bg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 0;
  display: block;
}
.icd-canvas-bg-fill {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
}

/* إطار داخلي زخرفي — إحساس "الكرت المطبوع" */
.icd-frame {
  position: absolute;
  inset: 14px;
  border: 1.5px solid;
  opacity: .55;
  border-radius: 2px;
  z-index: 1;
  pointer-events: none;
}

/* صف الزخرفة: خط — رمز — خط */
.icd-ornament-row {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 74%;
}
.icd-ornament-line { flex: 1; height: 1px; opacity: .5; }
.icd-ornament-char { font-size: 20px; line-height: 1; flex-shrink: 0; }

/* حقول النص — على الكرت نفسه، تتبع ألوان القالب لا ألوان التطبيق */
.icd-field-text {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  line-height: 1.3;
  max-width: 94%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* حقول الصورة */
.icd-field-img {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -50%);
  object-fit: cover;
  display: block;
}

/* Placeholder رفع صورة المستخدم */
.icd-field-photo-ph {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(255,255,255,.55);
  border-radius: 6px;
  color: rgba(255,255,255,.8);
  font-size: 13px;
  text-align: center;
  gap: 4px;
  cursor: pointer;
}

/* لوحة الحقول */
.icd-panel {
  padding: 22px 16px 6px;
}
.icd-panel-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 14px;
  color: var(--icd-text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.icd-panel-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 15px;
  border-radius: 2px;
  background: var(--icd-accent);
}

.icd-field-row { margin-bottom: 14px; }
.icd-field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--icd-text-muted);
  margin-bottom: 6px;
}
.icd-field-input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--icd-border);
  border-radius: var(--icd-radius-sm);
  font-family: inherit;
  font-size: 14px;
  direction: rtl;
  outline: none;
  background: var(--icd-surface-2);
  color: var(--icd-text);
  transition: border-color .15s, box-shadow .15s;
}
.icd-field-input::placeholder { color: var(--icd-text-muted); opacity: .8; }
.icd-field-input:focus {
  border-color: var(--icd-accent);
  box-shadow: 0 0 0 3px rgba(205,165,80,.18);
}

/* زر رفع صورة المستخدم */
.icd-photo-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border: 2px dashed var(--icd-border);
  border-radius: var(--icd-radius-sm);
  background: var(--icd-surface-2);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--icd-text-muted);
  transition: border-color .15s, color .15s;
  direction: rtl;
}
.icd-photo-btn:hover { border-color: var(--icd-accent); color: var(--icd-accent); }
.icd-photo-btn.has-photo { border-color: #4caf7d; color: #7bd4a4; background: rgba(76,175,125,.08); }
.icd-photo-btn .icd-photo-thumb {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

/* حقل رابط الخريطة */
.icd-map-hint {
  font-size: 11.5px;
  color: var(--icd-text-muted);
  margin-top: 4px;
}

/* شريط الأزرار الثابت */
.icd-actions {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  z-index: 100;
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  background: rgba(21,23,28,.92);
  border-top: 1px solid var(--icd-border);
  backdrop-filter: blur(10px);
  max-width: 480px;
  margin: 0 auto;
}
.icd-btn {
  flex: 1;
  padding: 13px 10px;
  border: 1px solid transparent;
  border-radius: var(--icd-radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s, transform .1s, filter .15s;
  text-align: center;
}
.icd-btn:active { transform: scale(.97); }
.icd-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.icd-btn-primary {
  background: var(--icd-accent);
  color: var(--icd-accent-ink);
}
.icd-btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.icd-btn-ghost {
  background: var(--icd-surface-2);
  color: var(--icd-text);
  border-color: var(--icd-border);
}
.icd-btn-ghost:hover { border-color: var(--icd-accent); color: var(--icd-accent); }

/* المودال / معاينة */
.icd-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,.82);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: icd-fade-in .2s ease;
}
@keyframes icd-fade-in { from { opacity: 0 } to { opacity: 1 } }

.icd-modal-inner {
  background: var(--icd-surface, #1c1f26);
  border: 1px solid var(--icd-border, #323744);
  border-radius: var(--icd-radius-lg, 18px);
  overflow: hidden;
  max-width: 380px;
  width: 100%;
  display: flex;
  flex-direction: column;
  max-height: 92vh;
  direction: rtl;
  color: #f3f4f6;
}
.icd-modal-img-wrap {
  overflow: auto;
  text-align: center;
  background: #0e0f13;
  flex: 1;
}
.icd-modal-img {
  max-width: 100%;
  max-height: 56vh;
  display: block;
  margin: 0 auto;
}
.icd-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid #323744;
}
.icd-modal-actions-row { display: flex; gap: 10px; }
.icd-modal-actions-row .icd-btn { flex: 1; }

/* بطاقة "الدفع مطلوب قبل التحميل" داخل المودال */
.icd-purchase-gate {
  padding: 4px 2px 2px;
}
.icd-purchase-gate-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 4px;
  color: #f3f4f6;
}
.icd-purchase-gate-desc {
  font-size: 12.5px;
  color: #9aa1af;
  margin: 0 0 10px;
  line-height: 1.7;
}
.icd-purchase-price {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  background: rgba(205,165,80,.12);
  border: 1px solid rgba(205,165,80,.35);
  color: #cda550;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
}

/* طبقة تحميل */
.icd-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(10,11,14,.82);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: #f3f4f6;
  font-size: 15px;
  text-align: center;
  padding: 20px;
}
.icd-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(205,165,80,.25);
  border-top-color: #cda550;
  border-radius: 50%;
  animation: icd-spin .8s linear infinite;
}
@keyframes icd-spin { to { transform: rotate(360deg) } }

/* فارغ */
.icd-empty {
  text-align: center;
  color: var(--icd-text-muted);
  padding: 40px 16px;
  font-size: 15px;
}

/* شاشة عريضة — إطار */
@media (min-width: 540px) {
  .icd-app {
    border: 1px solid var(--icd-border);
    border-radius: var(--icd-radius-lg);
    box-shadow: 0 10px 44px rgba(0,0,0,.4);
    margin-top: 20px;
    overflow: hidden;
  }
  .icd-actions {
    border-radius: 0 0 var(--icd-radius-lg) var(--icd-radius-lg);
    position: sticky;
    bottom: 0;
  }
}
