/**
 * APPLE GLASS MODAL SYSTEM
 * Soft, clean glass morphism with perfect backdrop handling
 */

/* ===== MODAL BACKDROP - DISABLED FOR DEBUG ===== */
.modal-backdrop {
  display: none !important;
}

.modal-backdrop.show,
.modal-backdrop.fade,
.modal-backdrop.fade.show {
  display: none !important;
}

/* ===== MODAL CONTAINER ===== */
.modal {
  z-index: 1055 !important;
  pointer-events: auto !important;
}

.modal-dialog {
  margin: 2rem auto !important;
  max-width: 85vw !important;
  max-height: calc(100vh - 4rem) !important;
  position: relative !important;
}

/* ===== MODAL CONTENT - ULTRA GLASS MORPHISM ===== */
.modal-content {
  /* Ultra-glassy Apple effect - maximum translucency */
  background: rgba(255, 255, 255, 0.15) !important;
  backdrop-filter: blur(40px) saturate(200%) brightness(120%) contrast(105%) !important;
  -webkit-backdrop-filter: blur(40px) saturate(200%) brightness(120%) contrast(105%) !important;

  /* Enhanced glass styling */
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  border-radius: 16px !important;
  box-shadow:
    0 25px 50px rgba(0, 0, 0, 0.15),
    0 8px 32px rgba(0, 0, 0, 0.08),
    0 2px 16px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    inset 0 0 20px rgba(255, 255, 255, 0.1) !important;

  /* Smooth animation */
  animation: modalSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);

  /* Positioning */
  z-index: 1060 !important;
  position: relative !important;
  pointer-events: auto !important;
  overflow: hidden;
  margin-top: 100px;
}

/* ===== MODAL HEADER - ULTRA GLASS STYLE ===== */
.modal-header,
.glass-modal-header {
  background: rgba(255, 255, 255, 0.05) !important;
  backdrop-filter: blur(20px) saturate(150%) brightness(105%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(150%) brightness(105%) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: 16px 16px 0 0 !important;
  padding: 20px 24px !important;
  position: relative;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
}

.modal-header::before,
.glass-modal-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.6) 50%,
    transparent 100%);
}

.modal-title {
  color: #1d1d1f !important;
  font-weight: 600 !important;
  font-size: 1.35rem !important;
  margin: 0 !important;
  line-height: 1.4 !important;
}

/* ===== MODAL BODY - CLEAN & READABLE ===== */
.modal-body,
.glass-modal-body {
  background: transparent !important;
  color: #1d1d1f !important;
  padding: 24px !important;
  line-height: 1.6;
}

.modal-body *,
.glass-modal-body * {
  color: #1d1d1f !important;
}

/* ===== MODAL FOOTER - ULTRA GLASS SEPARATION ===== */
.modal-footer,
.glass-modal-footer {
  background: rgba(255, 255, 255, 0.1) !important;
  backdrop-filter: blur(20px) saturate(150%) brightness(108%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(150%) brightness(108%) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: 0 0 16px 16px !important;
  padding: 16px 24px !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
}

/* ===== CLOSE BUTTON - APPLE STYLE ===== */
.btn-close {
  background: rgba(120, 120, 128, 0.16) !important;
  border: none !important;
  border-radius: 50% !important;
  width: 30px !important;
  height: 30px !important;
  transition: all 0.2s ease !important;
  opacity: 1 !important;
}

.btn-close:hover {
  background: rgba(120, 120, 128, 0.24) !important;
  transform: scale(1.05) !important;
}

/* ===== FORM ELEMENTS - ULTRA GLASS STYLE ===== */
.modal .form-control,
.modal .form-select,
.modal input,
.modal textarea,
.modal select {
  background: rgba(255, 255, 255, 0.2) !important;
  backdrop-filter: blur(20px) saturate(180%) brightness(110%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(180%) brightness(110%) !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
  color: #1d1d1f !important;
  border-radius: 10px !important;
  font-size: 16px;
  padding: 12px 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    0 2px 8px rgba(0, 0, 0, 0.04) !important;
}

.modal .form-control:focus,
.modal .form-select:focus,
.modal input:focus,
.modal textarea:focus,
.modal select:focus {
  background: rgba(255, 255, 255, 0.3) !important;
  border-color: rgba(0, 122, 255, 0.4) !important;
  backdrop-filter: blur(25px) saturate(200%) brightness(115%) !important;
  -webkit-backdrop-filter: blur(25px) saturate(200%) brightness(115%) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 0 0 3px rgba(0, 122, 255, 0.1),
    0 4px 20px rgba(0, 122, 255, 0.15),
    0 2px 8px rgba(0, 0, 0, 0.06) !important;
  color: #1d1d1f !important;
  transform: translateY(-1px);
}

.modal .form-control::placeholder,
.modal input::placeholder,
.modal textarea::placeholder {
  color: rgba(60, 60, 67, 0.6) !important;
}

.modal label,
.modal .form-label {
  color: #1d1d1f !important;
  font-weight: 500 !important;
  margin-bottom: 6px !important;
  font-size: 14px;
}

.modal .text-muted,
.modal small,
.modal .text-glass-muted {
  color: rgba(60, 60, 67, 0.6) !important;
}

/* ===== BUTTONS - APPLE STYLE ===== */
.modal .btn-primary {
  background: linear-gradient(135deg, #007AFF 0%, #0056CC 100%) !important;
  border: none !important;
  border-radius: 10px !important;
  font-weight: 500 !important;
  padding: 12px 24px !important;
  transition: all 0.2s ease !important;
}

.modal .btn-primary:hover {
  background: linear-gradient(135deg, #0056CC 0%, #004499 100%) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4) !important;
}

.modal .btn-outline-secondary {
  background: rgba(120, 120, 128, 0.12) !important;
  border: 1px solid rgba(120, 120, 128, 0.32) !important;
  color: #1d1d1f !important;
  border-radius: 10px !important;
  font-weight: 500 !important;
  padding: 12px 24px !important;
  transition: all 0.2s ease !important;
}

.modal .btn-outline-secondary:hover {
  background: rgba(120, 120, 128, 0.2) !important;
  border-color: rgba(120, 120, 128, 0.48) !important;
  color: #1d1d1f !important;
  transform: translateY(-1px) !important;
}

/* ===== MODAL ANIMATIONS - SMOOTH APPLE-LIKE ===== */
@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(40px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal.fade .modal-dialog {
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .modal-dialog {
    margin: 1rem !important;
    max-width: calc(100vw - 2rem) !important;
  }

  .modal-body,
  .glass-modal-body {
    padding: 20px !important;
  }

  .modal .form-control,
  .modal .form-select,
  .modal input,
  .modal textarea,
  .modal select {
    font-size: 16px; /* Prevent zoom on iOS */
  }
}

/* ===== MODAL SIZE VARIANTS ===== */
.modal-lg {
  max-width: 90vw !important;
}

.modal-xl {
  max-width: 95vw !important;
}

/* Dark mode styles removed for clean, consistent light Apple glass effect */