/* Digital Church Modal Styles */

.dgtl-modal-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background-color: rgba(0, 0, 0, 0.5) !important;
  backdrop-filter: blur(2px);
  z-index: 9999 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 1rem !important;
}

.dgtl-modal {
  position: relative;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  outline: none;
  max-width: 100%;
}

/* Modal Header */
.dgtl-modal-header {
  position: relative;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
}

.dgtl-modal-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #111827;
  text-align: center;
  flex: 1;
}

.dgtl-modal-close,
.dgtl-modal-expand {
  position: absolute;
  top: 1rem;
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  border-radius: 6px;
  color: #6b7280;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.dgtl-modal-close {
  left: 1rem;
}

.dgtl-modal-expand {
  right: 1rem;
}

.dgtl-modal-close:hover,
.dgtl-modal-expand:hover {
  background: #e5e7eb;
  color: #374151;
}

.dgtl-modal-close:focus,
.dgtl-modal-expand:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Mobile pull handle */
.dgtl-modal-pull-handle {
  position: absolute;
  top: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 4px;
  background: #d1d5db;
  border-radius: 2px;
}

/* Modal Content */
.dgtl-modal-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dgtl-modal-body {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Loading State */
.dgtl-modal-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  min-height: 200px;
  color: #6b7280;
}

.dgtl-modal-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #f3f4f6;
  border-radius: 50%;
  border-top-color: #3b82f6;
  animation: spin 1s linear infinite;
  margin-bottom: 0.5rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Error State */
.dgtl-modal-error {
  padding: 2rem;
  text-align: center;
  color: #dc2626;
}

.dgtl-modal-retry {
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.2s;
}

.dgtl-modal-retry:hover {
  background: #2563eb;
}

/* Trigger Button Styles */
.dgtl-modal-trigger {
  padding: 0.75rem 1.5rem;
  background: #3b82f6;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.dgtl-modal-trigger:hover {
  background: #2563eb;
  color: #ffffff;
  text-decoration: none;
}

.dgtl-modal-trigger:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.dgtl-modal-trigger:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.dgtl-modal-attached {
  position: absolute;
  z-index: 10000;
  min-width: min(20rem, calc(100vw - 2rem));
  max-width: calc(100vw - 2rem);
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18), 0 4px 14px rgba(15, 23, 42, 0.08);
  color: #111827;
  opacity: 0;
  transform: translateY(4px);
  animation: dgtl-attached-in 0.16s ease forwards;
}

.dgtl-modal-attached--sm {
  width: min(480px, calc(100vw - 2rem));
}

.dgtl-modal-attached--md {
  width: min(600px, calc(100vw - 2rem));
}

.dgtl-modal-attached--lg {
  width: min(800px, calc(100vw - 2rem));
}

.dgtl-modal-attached--xl,
.dgtl-modal-attached--full {
  width: min(1200px, calc(100vw - 2rem));
}

.dgtl-modal-attached-body {
  max-height: min(34rem, calc(100vh - 2rem));
  overflow: auto;
  padding: 1rem;
}

@keyframes dgtl-attached-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Scrollbar Styling */
.dgtl-modal-body::-webkit-scrollbar {
  width: 8px;
}

.dgtl-modal-body::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.dgtl-modal-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.dgtl-modal-body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Mobile Styles */
@media (max-width: 768px) {
  .dgtl-modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  
  .dgtl-modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 85vh !important;
    border-radius: 16px 16px 0 0 !important;
    margin: 0 !important;
  }
  
  .dgtl-modal-header {
    padding: 1rem 1rem 0.5rem 1rem;
  }
  
  .dgtl-modal-close,
  .dgtl-modal-expand {
    top: 1.25rem;
  }
  
  .dgtl-modal-body {
    padding: 1rem;
    padding-bottom: 2rem; /* Extra padding for iOS safe area */
  }
}

@media (max-width: 480px) {
  .dgtl-modal-header {
    padding: 0.75rem;
  }
  
  .dgtl-modal-body {
    padding: 1rem;
  }
  
  .dgtl-modal-close,
  .dgtl-modal-expand {
    top: 1rem;
  }
  
  .dgtl-modal-title {
    font-size: 1rem;
  }
  
  .dgtl-modal-trigger {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
  }
}

/* Prevent body scroll when modal is open */
body.ReactModal__Body--open {
  overflow: hidden !important;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .dgtl-modal {
    background: #1f2937;
    color: #f9fafb;
  }
  
  .dgtl-modal-header {
    background: #374151;
    border-bottom-color: #4b5563;
  }
  
  .dgtl-modal-title {
    color: #f9fafb;
  }
  
  .dgtl-modal-close,
  .dgtl-modal-expand {
    color: #d1d5db;
  }
  
  .dgtl-modal-close:hover,
  .dgtl-modal-expand:hover {
    background: #4b5563;
    color: #f9fafb;
  }
  
  .dgtl-modal-pull-handle {
    background: #6b7280;
  }
  
  .dgtl-modal-body::-webkit-scrollbar-track {
    background: #374151;
  }
  
  .dgtl-modal-body::-webkit-scrollbar-thumb {
    background: #6b7280;
  }
  
  .dgtl-modal-body::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .dgtl-modal {
    border: 2px solid #000000;
  }
  
  .dgtl-modal-close,
  .dgtl-modal-expand {
    border: 1px solid currentColor;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .dgtl-modal-close,
  .dgtl-modal-expand,
  .dgtl-modal-trigger,
  .dgtl-modal-retry {
    transition: none;
  }
  
  .dgtl-modal-spinner {
    animation: none;
  }
}

