/**
 * MODAL COMPONENT
 *
 * Styles for the reusable modal
 */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7); /* Slightly darker overlay */
  display: none; /* Initially hidden */
  justify-content: center;
  align-items: center;
  z-index: 1000; /* On top of other content */
  padding: var(--spacing-sm); /* Basic padding for overlay on small screens */
}

.modal {
  background-color: var(--card-bg);
  border-radius: var(--border-radius-md);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15); /* Enhanced shadow */
  width: 90%; /* Default width, overridden by max-width */
  max-width: 1000px; /* Increased max-width */
  height: 90vh; /* Use height instead of max-height for more control with flex children */
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden; /* Ensures border-radius clips iframe */
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding: var(--spacing-sm) var(--spacing-md); /* Adjusted padding */
  flex-shrink: 0; /* Prevent header from shrinking */
}

.modal-title {
  font-size: 1.3rem; /* Adjusted size */
  margin: 0;
  color: var(--text-color);
  font-weight: 600;
  line-height: 1.4;
  flex-grow: 1; /* Add this line */
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 2rem; /* Adjusted size */
  cursor: pointer;
  color: var(--text-color-light);
  padding: 0 var(--spacing-xs);
  line-height: 1;
  transition: color var(--transition-fast);
  margin-left: 0.5em; /* Add this line */
}

.modal-close-btn:hover {
  color: var(--text-color);
}

.modal-body {
  flex-grow: 1; /* Allows the body to expand and fill space */
  overflow: hidden; /* iframe will handle its own scroll */
  padding: 0; /* Remove padding for edge-to-edge iframe */
  min-height: 0; /* Override previous min-height if not needed with flex-grow */
}

.modal-body iframe {
  width: 100%;
  height: 100%; /* Fills the modal-body */
  border: none;
  display: block; /* Removes potential space underneath */
}

/* Active state for the overlay */
.modal-overlay.active {
  display: flex;
}

/* Style the open button specifically */
.modal-open-btn {
  background: none;
  border: none;
  font-size: 1rem; /* Adjusted size */
  cursor: pointer;
  color: var(--text-color-light);
  padding: 0 var(--spacing-xs);
  line-height: 1;
  transition: color var(--transition-fast);
  margin-left: 0.5em; /* Add this line */
}

.modal-open-btn:hover {
  color: var(--text-color);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  /* Adjust breakpoint for larger tablets */
  .modal {
    max-width: 90%;
    height: 88vh;
  }
}

@media (max-width: 768px) {
  .modal-overlay {
    padding: var(--spacing-xs); /* Less padding on mobile overlay */
  }
  .modal {
    width: 95%;
    height: 95vh; /* Take more height on mobile */
    padding: 0; /* Remove modal padding, header/body will handle it */
  }

  .modal-header {
    padding: var(--spacing-sm) var(--spacing-sm);
  }

  .modal-title {
    font-size: 1.1rem; /* Smaller title for mobile */
  }

  .modal-close-btn {
    font-size: 1.8rem; /* Smaller close button */
  }
}

@media (max-width: 576px) {
  .modal {
    width: 100%;
    height: 100vh; /* Full height on very small screens */
    border-radius: 0; /* Edge-to-edge */
  }
  .modal-header {
    padding: var(--spacing-sm) var(--spacing-sm);
    border-radius: 0;
  }
  .modal-title {
    font-size: 1rem;
  }
}