/* Settings Modal Styles */
.settings-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2000;
  display: none;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.settings-modal-overlay.active {
  display: flex;
  opacity: 1;
}

.settings-modal {
  background: white;
  border-radius: 20px;
  padding: 0;
  max-width: 370px; /* نفس عرض نافذة الاعتمادات */
  width: 90%;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

/* عند التفعيل: تعود لمكانها الطبيعي */
.settings-modal-overlay.active .settings-modal {
  transform: translateY(0);
}

.settings-header {
  background: linear-gradient(135deg, #4caf50, #2e7d32);
  color: white;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-header h3 {
  margin: 0;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-close {
  position: absolute;
  top: 15px;
  right: 15px;
  margin: 0;
  background: rgba(0, 0, 0, 0.05);
  border: none;
  color: var(--text-tertiary);
  width: 35px;
  height: 35px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  font-size: 1.2rem;
  z-index: 100;
}

.settings-close:hover {
  transform: rotate(90deg);
}

.settings-body {
  padding: 25px 30px 15px 30px;
  overflow-y: auto;
  flex: 1;
}

.settings-section {
  margin-bottom: 15px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e0e0e0;
}

.settings-section-title i {
  color: #4caf50;
}

.settings-option {
  margin-bottom: 15px;
}

.settings-option-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.settings-option-label {
  font-weight: 500;
  color: #555;
  font-size: 0.9rem;
}

.settings-option-description {
  font-size: 0.85rem;
  color: #888;
  line-height: 1.4;
  margin-top: 5px;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 50px;
  height: 26px;
  background: #ccc;
  border-radius: 13px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.toggle-switch.active {
  background: #4caf50;
}

.toggle-switch-slider {
  position: absolute;
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active .toggle-switch-slider {
  left: 26px;
}

/* Radio Group */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-option {
  display: flex;
  align-items: center;
  padding: 8px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.radio-option:hover {
  border-color: #4caf50;
  background: #f9fff9;
}

.radio-option.selected {
  border-color: #4caf50;
  background: #e8f5e9;
}

.radio-circle {
  width: 18px;
  height: 18px;
  border: 2px solid #ccc;
  border-radius: 50%;
  margin-right: 10px;
  position: relative;
  transition: all 0.3s ease;
}

.radio-option.selected .radio-circle {
  border-color: #4caf50;
}

.radio-circle::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  background: #4caf50;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.3s ease;
}

.radio-option.selected .radio-circle::after {
  transform: translate(-50%, -50%) scale(1);
}

.radio-label {
  flex: 1;
}

.radio-title {
  font-weight: 600;
  color: #333;
  margin-bottom: 0;
  font-size: 0.95rem;
}

.radio-description {
  font-size: 0.85rem;
  color: #888;
}

/* Dark Mode Support */
.dark-mode .settings-modal {
  background: #2c2c2c;
  color: white;
}

.dark-mode .settings-section-title {
  color: #e0e0e0;
  border-bottom-color: #444;
}

.dark-mode .settings-option-label {
  color: #d0d0d0;
}

.dark-mode .settings-option-description {
  color: #999;
}

.dark-mode .radio-option {
  border-color: #444;
  background: #333;
}

.dark-mode .radio-option:hover {
  border-color: #4caf50;
  background: #2a4a2a;
}

.dark-mode .radio-option.selected {
  background: #2d5a2d;
}

.dark-mode .radio-title {
  color: #e0e0e0;
}

.dark-mode .toggle-switch {
  background: #555;
}

#contact-selector-modal {
  position: fixed !important;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9999 !important; /* رفعه جداً ليكون فوق الهيدر والتبويبات */
  display: none;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

#contact-selector-modal.active {
  display: flex;
  opacity: 1;
}

/* تنسيق المحتوى الداخلي ليطابق الإعدادات */
#contact-selector-modal .modal-content {
  background: var(--bg-card);
  border-radius: 20px;
  width: 90%;
  max-width: 500px; /* عرض أوسع قليلاً من الاعتمادات لاستيعاب الأسماء */
  max-height: 85vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  position: relative;
  transform: translateY(20px); /* البدء من الأسفل قليلاً */
  transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
  opacity: 0;
  margin: 0; /* إزالة الهوامش */
}

/* عند التفعيل: تعود لمكانها الطبيعي (وسط الشاشة) */
#contact-selector-modal.active .modal-content {
  transform: translateY(0);
  opacity: 1;
}

/* Dark Mode Support */
.dark-mode #contact-selector-modal .modal-content {
  background: #2c2c2c;
  color: white;
}

/* المحدد المحدد للنافذة فقط */
#contact-selector-modal .close-modal {
  width: 35px !important;
  height: 35px !important;
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(0, 0, 0, 0.05); /* خلفية شفافة داكنة خفيفة */
  color: lightgray; /* لون النص خفيف */
  font-size: 1.2rem;
  line-height: 1;
  z-index: 2; /* لضمان ظهوره فوق المحتوى */
}

/* تأثير عند المرور (Hover) - مطابق للإعدادات */
#contact-selector-modal .close-modal:hover {
  transform: rotate(90deg);
}

/* الوضع الليلي */
.dark-mode #contact-selector-modal .close-modal {
  background: rgba(255, 255, 255, 0.05); /* خلفية فاتحة خفيفة */
}

/* --- إزالة الهيدر وجعل زر الإغلاق عائماً مثل الاعتمادات --- */

/* 1. إخفاء خلفية الهيدر ومساحته */
.settings-header {
  background: transparent !important;
  background-image: none !important; /* إزالة التدرج الأخضر */
  padding: 0 !important; /* إزالة الحشو */
  height: auto;
  min-height: auto;
  border-bottom: none;
}

/* 2. إخفاء نص "Settings" */
.settings-header h3 {
  display: none;
}

/* الوضع الليلي */
.dark-mode .settings-close {
  background: rgba(255, 255, 255, 0.05);
}

/* Responsive */
@media (max-width: 768px) {
  .settings-modal {
    width: 90%;
    max-width: 370px;
    max-height: 90vh;
    border-radius: 20px;
    margin: 0 auto;
  }

  .settings-header h3 {
    font-size: 1.1rem;
  }

  .settings-body {
    padding: 25px 30px 15px 30px !important;
  }

  .settings-close {
    top: 15px;
    right: 15px;
    width: 35px !important;
    height: 35px !important;
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .settings-modal {
    width: 90%;
    max-width: 370px;
    border-radius: 20px;
    max-height: 95vh;
    margin: 0 auto;
  }

  .settings-header {
    padding: 12px;
  }

  .settings-body {
    padding: 12px;
  }

  .radio-option {
    padding: 10px;
  }

  .settings-close {
    top: 12px;
    right: 12px;
    width: 35px !important;
    height: 35px !important;
    font-size: 1.2rem;
  }
}
