/* ASEF Modal System */

:root {
  --modal-z-index: 9999;
  --modal-bg-overlay: rgba(0, 0, 0, 0.6);
  --modal-radius: 16px;
  --modal-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --modal-transition-duration: 0.3s;
}

/* Container Wrapper */
.asef-modal {
  position: fixed;
  inset: 0;
  z-index: var(--modal-z-index);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;

  /* Hidden State */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* Open State */
.asef-modal.is-open {
  opacity: 1;
  visibility: visible;
}

/* Overlay / Backdrop */
.asef-modal-overlay {
  position: absolute;
  inset: 0;
  background-color: var(--modal-bg-overlay);
  backdrop-filter: blur(4px);
  z-index: -1;
}

/* Actual Modal Box */
.asef-modal-container {
  background: white;
  width: 100%;
  max-width: 500px;
  /* Default width, can be overriden */
  border-radius: var(--modal-radius);
  box-shadow: var(--modal-shadow);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  /* Prevent overflow on small screens */
  position: relative;

  /* Animation */
  transform: translateY(20px) scale(0.95);
  transition: transform var(--modal-transition-duration) cubic-bezier(0.16, 1, 0.3, 1);
}

.asef-modal.is-open .asef-modal-container {
  transform: translateY(0) scale(1);
}

/* Header */
.asef-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.asef-modal-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #1f2937;
  font-family: inherit;
  /* Inherit global font */
}

.asef-modal-close {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  color: #6b7280;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.asef-modal-close:hover {
  color: #1f2937;
  background-color: #f3f4f6;
}

/* Content Body */
.asef-modal-content {
  padding: 1.5rem;
  overflow-y: auto;
  color: #4b5563;
  line-height: 1.5;
}

/* Footer (Actions) */
.asef-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid #e5e7eb;
  background-color: #f9fafb;
  /* Slight grey background for footer */
  border-bottom-left-radius: var(--modal-radius);
  border-bottom-right-radius: var(--modal-radius);
}

/* Responsive */
@media (max-width: 640px) {
  .asef-modal-container {
    width: 90%;
    /* Prevent touching edges */
    max-width: 95%;
    margin: auto;
    /* Center it */
    border-radius: 12px;
  }

  /* Center Title on Mobile */
  .asef-modal-header {
    justify-content: center;
    position: relative;
    padding: 1rem;
  }

  .asef-modal-title {
    text-align: center;
    width: 100%;
    padding: 0 2rem;
    /* Avoid overlap with close button */
  }

  .asef-modal-close {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.5rem;
  }

  .asef-modal-content {
    padding: 1rem;
    /* Slightly less padding */
    text-align: center;
    /* Center content like labels if desired, though usually left is better for forms. Keeping inputs block. */
  }

  /* Ensure buttons are centered and touch-friendly */
  .asef-modal-content .btn-primary,
  .asef-modal-footer .btn-primary {
    width: 100%;
    /* Keep full width for touch targets */
    justify-content: center;
  }
}