/* Dark background overlay */
.mfp-bg {
  background: rgba(0,0,0,0.6);
  z-index: 200000 !important;
  top: 0;
}

.mfp-wrap {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  z-index: 300000 !important; /* higher than Divi header */
}

/* Popup wrapper */
.mfp-ajax-holder .mfp-content,
.mfp-inline-holder .mfp-content {
  background: #fff !important;
  width: 90% !important;
  //max-width: 900px !important;
  margin: 40px auto !important;
  border: 2px solid #444 !important;
  border-radius: 10px !important;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6) !important;
  padding: 20px !important;
  overflow-y: auto !important;
  max-height: 100vh !important;

  z-index: 400000 !important;
  position: relative !important;
}

/* Scroll inside */
.mfp-content::-webkit-scrollbar {
  width: 10px;
}
.mfp-content::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 5px;
}

/* Force white popup box */
.mfp-content {
  background: #fff !important;
  border: 2px solid #444 !important;
  border-radius: 10px !important;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6) !important;
  padding: 20px !important;
  width: 85% !important;

  margin: 40px auto !important;
  max-height: 85vh !important;
  overflow-y: auto !important;
}

/* Extra safety if the loaded HTML is bare */
.mfp-content > * {
  background: #fff !important;
  padding-top: 24px !important;
}

.mfp-content .et_pb_section_0.et_pb_section {
  background-color: #ffffff !important;
  background-image: none !important;
}

/* Ensure popup page content itself is boxed */
.popup-content-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  height: 100%;
}

.popup-inner {
  background: #fff !important;                 /* force white background */
  border: 2px solid #444 !important;           /* border */
  border-radius: 10px !important;              /* rounded corners */
  box-shadow: 0 12px 40px rgba(0,0,0,0.6) !important; /* shadow */
  width: 100% !important;                       /* responsive width */
  max-width: 1920px !important;
  max-height: 85vh !important;
  overflow-y: auto !important;                 /* scroll if needed */
  padding: 20px !important;
}

.popup-body {
  flex-grow: 1;      /* takes all available vertical space */
  overflow-y: auto;  /* scroll if content is tall */
}

.popup-footer {
  flex-shrink: 0;    /* keeps footer from shrinking */
  margin-top: auto;  /* pushes it to the bottom */
}

img.mfp-img {
  padding-top: 10px !important;
}

button.mfp-close {
  font-size: 24px !important;
  top: 0 !important;
  color: #005bac !important;
  right: 0 !important;
}
button.mfp-close::before {
  font-size: 24px !important;
  content: 'Close ';
}
button.mfp-close.btn.btn-secondary {
  width: auto !important;
}

.pagename-grant-listing button.mfp-close.btn.btn-secondary {
  margin-right: 5px;
  font-size: 22px;
  top: -50px !important;
  width: 100px;
}
.pagename-grant-listing  button.mfp-close::before {
  content: none !important;
}


/* Base popup overlay */
.mfp-wrap {
  position: fixed !important;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  overflow-y: auto;
}

/* Popup content */
.mfp-content {
  width: 80%;           /* desktop width */
  max-width: 1000px;    /* max width on large screens */
  margin: auto;
  background: #fff;
  border-radius: 8px;
  padding: 20px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .mfp-content {
    width: 95%;
    max-width: none;
    height: 90%;
    overflow-y: auto;
    border-radius: 0;
    margin: auto;
  }
}
