/* ========== GLOBAL POPUP STYLE ========== */

/* الأوفرلاي (خلفية البوب أب) */
.overlay {
  display: none; /* مخفي افتراضياً */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.45);
  justify-content: center;
  align-items: center;
  z-index: 2001;
  animation: fadeIn 0.3s ease-in-out;
}

/* المحتوى */
.overlay .popup {
  width: 90%;
  max-width: 650px;
  background: #fff;
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.15);
  position: relative;
  box-sizing: border-box;
  max-height: 85vh;
  overflow-y: auto;
  z-index: 2002;
  animation: slideUp 0.3s ease-in-out;
}

/* الهيدر */
.popup-header {
  font-weight: 600;
  font-size: 1.2rem;
  margin-bottom: 20px;
  color: #333;
}

/* محتوى النص */
.popup-content {
  font-size: 0.95rem;
  color: #555;
  line-height: 1.6;
}

/* الأزرار */
.popup-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

.popup button {
  padding: 10px 24px;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease-in-out;
}

.popup .cancel {
  background: #f1f1f1;
  color: #333;
}

.popup .cancel:hover {
  background: #e0e0e0;
}

.popup .add {
  background: #8865e1;
  color: white;
  font-weight: 500;
}

.popup .add:hover {
  background: #6f4fd2;
}

/* أيقونة الإغلاق */
.close-icon {
  position: absolute;
  top: 14px;
  right: 16px;
  font-size: 1.3rem;
  cursor: pointer;
  color: #666;
  transition: color 0.2s;
}

.close-icon:hover {
  color: #000;
}

/* الجداول */
.popup-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.popup-table td {
  padding: 8px 10px;
  vertical-align: top;
}

.popup-table td:first-child {
  width: 35%;
  font-weight: 600;
  color: #333;
}

.popup-table td:last-child {
  width: 65%;
  color: #555;
}

/* RTL adjustments */
[lang="ar"] .popup-table td {
  text-align: right;
}
[lang="ar"] .popup-buttons {
  justify-content: flex-start;
}
[lang="ar"] .close-icon {
  right: auto;
  left: 16px;
}

/* ========== Animations ========== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ========== CUSTOM ALERT POPUPS ========== */

/* Success Popup */
.popup.success .popup-header {
  color: #10b981;
}

.popup.success .popup-header::before {
  content: "✓ ";
  font-size: 1.4rem;
  margin-right: 8px;
}

/* Error Popup */
.popup.error .popup-header {
  color: #ef4444;
}

.popup.error .popup-header::before {
  content: "✗ ";
  font-size: 1.4rem;
  margin-right: 8px;
}

/* Warning Popup */
.popup.warning .popup-header {
  color: #f59e0b;
}

.popup.warning .popup-header::before {
  content: "⚠ ";
  font-size: 1.4rem;
  margin-right: 8px;
}

/* Info Popup */
.popup.info .popup-header {
  color: #3b82f6;
}

.popup.info .popup-header::before {
  content: "ℹ ";
  font-size: 1.4rem;
  margin-right: 8px;
}

/* Single button popup */
.popup-buttons.single {
  justify-content: center;
}

.popup-buttons.single button {
  min-width: 120px;
}

/* RTL adjustments */
[lang="ar"] .popup-table td {
  text-align: right;
}

[lang="ar"] .popup-buttons {
  justify-content: flex-start; /* الأزرار تصير ببداية السطر (يمين) */
}

[lang="ar"] .close-icon {
  right: auto;
  left: 16px; /* الأيقونة تصير على الشمال */
}

/* عكس اتجاه الأيقونات قبل العنوان */
[lang="ar"] .popup-header::before {
  margin-right: 0;
  margin-left: 8px; /* بدل ما تكون عاليمين تصير عاليسار */
}

/* لو حاب تخلي النص كله RTL */
[lang="ar"] .popup,
[lang="ar"] .popup-content {
  direction: rtl;
}