/* إصلاح موضع النوافذ المنبثقة لتظهر في منتصف الشاشة */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  /* إضافة Flexbox للمحاذاة المركزية */
  display: none;
  align-items: center;
  justify-content: center;
}

/* عند فتح النافذة، نغير display إلى flex بدلاً من block */
.modal[style*="display: block"],
.modal[style*="display:block"] {
  display: flex !important;
}

.modal-content {
  background-color: white;
  /* إزالة margin القديم */
  margin: 0;
  padding: 30px;
  border-radius: 15px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease;
  /* إضافة position relative للتأكد من الموضع الصحيح */
  position: relative;
}

/* تحديث الأنيميشن ليبدأ من الأعلى للمنتصف */
@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-100px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* التأكد من أن جميع أنواع النوافذ المنبثقة تستخدم نفس المحاذاة */
/* القواعد مطبقة على كل نافذة بشكل منفصل أدناه */

/* إصلاح نافذة الملاحظات */
.note-modal-content {
  background-color: white;
  margin: 0;
  padding: 30px;
  border-radius: 15px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease;
  position: relative;
}

/* إصلاح نافذة الاستطلاعات */
.poll-modal,
.poll-view-modal {
  background-color: white;
  margin: 0;
  padding: 30px;
  border-radius: 15px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease;
  position: relative;
}

/* إصلاح نافذة عرض الصور */
.image-view-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10001 !important; /* أعلى من target-details-modal (10000) */
  align-items: center;
  justify-content: center;
}

.image-view-modal[style*="display: block"],
.image-view-modal[style*="display: flex"] {
  display: flex !important;
}

/* إصلاح نافذة الشات */
.chat-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.chat-modal-overlay[style*="display: block"],
.chat-modal-overlay[style*="display: flex"] {
  display: flex !important;
}

.chat-modal {
  background: white;
  border-radius: 15px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease;
}

/* إصلاح نافذة تأكيد الملاحظات */
.note-confirm-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
}

.note-confirm-modal[style*="display: block"],
.note-confirm-modal[style*="display: flex"] {
  display: flex !important;
}

.note-confirm-content {
  background: white;
  padding: 30px;
  border-radius: 15px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease;
  position: relative;
}

/* التأكد من أن النوافذ تظهر فوق كل شيء آخر */
.modal {
  z-index: 9999 !important;
}

/* image-view-modal يجب أن يكون أعلى من جميع المودالات الأخرى */
.image-view-modal {
  z-index: 10001 !important;
}

.chat-modal-overlay,
.note-confirm-modal {
  z-index: 9999 !important;
}

/* إصلاحات للشاشات الصغيرة */
@media (max-width: 768px) {
  .modal-content,
  .note-modal-content,
  .poll-modal,
  .poll-view-modal,
  .chat-modal,
  .note-confirm-content {
    width: 95%;
    max-height: 90vh;
    padding: 20px;
  }
}

/* التأكد من عدم تأثر العناصر الأخرى */
body.modal-open {
  overflow: hidden;
}
