/* ============================================================
   MODALS - N-Home Smart Home Builder
   ============================================================ */

/* Modal Backdrop */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-backdrop.active { 
  display: flex; 
}

/* Modal Container */
.modal {
  background: var( --nh-body-bg);
  border: 1px solid #4b5563;
  border-radius: 10px;
  padding: 20px;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 { 
  margin-top: 0; 
  margin-bottom: 12px; 
  color: #e5e7eb; 
}

/* Modal Actions */
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* Large Modal */
.modal.large {
  max-width: 500px;
}

/* Modal Form Elements */
.modal input[type="text"],
.modal input[type="number"],
.modal select {
}

/* Modal Section Dividers */
.modal .card {
}

/* Zone Detail Modal Specific */
.modal .zone-devices {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal .zone-devices label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
}

.modal .zone-devices label span:last-child {
  color: #9ca3af;
  margin-left: auto;
}
/* ================================
   GLOBAL MODAL SYSTEM
   ================================ */

/* Backdrop */
#global-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: none;                  /* Hidden by default */
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55); /* Dim background */
  z-index: 9999;                   /* Above everything */
  padding: 24px;
  backdrop-filter: blur(2px);
}

/* Modal Container */
#global-modal {
  background: var(--nh-body-bg);            /* Match your dark theme */
  color: #e5e7eb;
  width: 100%;
  max-width: 520px;               /* Similar to Bootstrap md modal */
  border-radius: 12px;
  padding: 24px;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.6),
    0 4px 12px rgba(0, 0, 0, 0.4);
  animation: modalFadeIn 0.2s ease-out;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Title */
#global-modal-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  color: #f3f4f6;
}

/* Body */
#global-modal-body {
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.45;
  color: #d1d5db;
}

/* Actions Row */
#global-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

/* Close Button */
#global-modal-close-btn {
  font-size: 22px;
  line-height: 1;
  padding: 0 6px;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  transition: background 0.15s ease, color 0.15s ease;
}

#global-modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

/* Scroll handling for large content */
#global-modal-body {
  max-height: 60vh;
  overflow-y: auto;
}

/* Animation */
@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Responsive */
@media (max-width: 480px) {
  #global-modal {
    padding: 18px;
    max-width: 90%;
  }

  #global-modal-body {
    max-height: 50vh;
  }
}
