/* Modal System - Mobile-first, Reusable */

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
}

.modal-container {
  position: relative;
  background: white;
  border-radius: var(--border-radius, 8px);
  max-width: 90%;
  width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  transform: scale(0.9);
  transition: transform 0.3s ease;
  margin: 1rem;
}

.modal-overlay.active .modal-container {
  transform: scale(1);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--dark-text, #333);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #666;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  transition: color 0.2s;
}

.modal-close:hover {
  color: #333;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* Form styles inside modal */
.modal-body .form-group {
  margin-bottom: 1rem;
}

.modal-body label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--dark-text, #333);
}

.modal-body input[type='text'],
.modal-body input[type='email'],
.modal-body input[type='tel'],
.modal-body input[type='url'],
.modal-body textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

.modal-body input:focus,
.modal-body textarea:focus {
  outline: none;
  border-color: var(--primary-color, #f39200);
}

.modal-body textarea {
  min-height: 100px;
  resize: vertical;
}

.modal-body .form-error {
  color: #d32f2f;
  font-size: 0.875rem;
  margin-top: 0.25rem;
  display: none;
}

.modal-body .form-group.error .form-error {
  display: block;
}

.modal-body .form-group.error input,
.modal-body .form-group.error textarea {
  border-color: #d32f2f;
}

/* Success/Error messages */
.modal-message {
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  display: none;
}

.modal-message.success {
  background-color: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #81c784;
  display: block;
}

.modal-message.error {
  background-color: #ffebee;
  color: #c62828;
  border: 1px solid #ef5350;
  display: block;
}

/* Mobile optimizations */
@media (max-width: 576px) {
  .modal-container {
    max-width: 95%;
    width: 100%;
    max-height: 95vh;
    margin: 0.5rem;
    border-radius: 12px;
  }

  .modal-header {
    padding: 1rem;
  }

  .modal-header h2 {
    font-size: 1.25rem;
  }

  .modal-body {
    padding: 1rem;
  }

  .modal-footer {
    padding: 0.75rem 1rem;
    flex-direction: column;
  }

  .modal-footer .btn {
    width: 100%;
  }
}

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

/* Loading state */
.modal-loading {
  display: none;
  text-align: center;
  padding: 1rem;
}

.modal-loading.active {
  display: block;
}

.modal-loading::after {
  content: '';
  display: inline-block;
  width: 2rem;
  height: 2rem;
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--primary-color, #f39200);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
