/* --- Modal Base --- */
.webinar-modal {
  display: none;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1050;
  overflow: hidden; /* Prevent any scrolling on modal itself */
}

.webinar-modal[aria-hidden="false"] {
  display: block;
}

.webinar-modal__overlay {
  background: rgba(33, 37, 41, 0.7);
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1051;
  overflow: hidden; /* Prevent scrolling on overlay */
  box-sizing: border-box;
  /* Ensure perfect centering even with dynamic height */
  padding: 20px;
}

/* --- Container --- */
.webinar-modal__container {
  background: #fff;
  max-width: 750px;
  width: 100%;
  max-height: calc(95vh - 40px); /* Account for overlay padding */
  min-height: 300px; /* Minimum height for usability */
  height: auto; /* Allow dynamic height growth */
  display: flex;
  flex-direction: column;
  margin: 0; /* Remove auto margin since overlay centers it */
  border-radius: 12px;
  padding: 0px 0px 0px 0px !important;
  box-shadow: 0 8px 32px rgba(60, 60, 60, 0.18),
              0 1.5px 4px rgba(0, 0, 0, 0.08);
  position: relative;
  overflow: visible; /* Allow content to be fully visible */
  animation: modal-fade-in 0.25s cubic-bezier(.4, 0, .2, 1);
  /* Ensure content scales properly and stays centered */
  transform-origin: center;
  /* Ensure modal stays centered even with dynamic height */
  align-self: center;
  justify-self: center;
}

/* --- Header/Footer inline, not sticky --- */
.webinar-modal__header,
.webinar-modal__footer {
  flex: none;
  background: transparent;
  border: none;
}

.webinar-modal__header {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.webinar-modal__header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #212529;
}

.webinar-modal__footer {
  font-size: 0.85rem;
  color: #6c757d;
  text-align: center;
  padding: 1rem 1.25rem;
}

.webinar-modal__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 0.8rem; /* Much smaller font size */
  color: #6c757d;
  cursor: pointer;
  padding: 0.5rem; /* Increased padding to maintain hitbox size */
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
  width: 2rem; /* Fixed width for consistent hitbox */
  height: 2rem; /* Fixed height for consistent hitbox */
  display: flex;
  align-items: center;
  justify-content: center;
}
.webinar-modal__close:hover,
.webinar-modal__close:focus {
  background: #e9ecef;
  color: #212529;
  outline: none;
}

/* --- Content flows inline with header/footer --- */
.webinar-modal__content {
  flex: 1;
  padding: 0px 0px 0px 0px !important;
  color: #343a40;
  font-size: 1rem;
  background: #fff;
  overflow: visible; /* Allow content to be visible */
  display: block;
}

/* Prevent WebinarFuel content from overflowing the modal content area */
.webinar-modal__content .wf_target,
.webinar-modal__content .wf_target > *,
.webinar-modal__content iframe {
  max-width: 100% !important;
  box-sizing: border-box !important;
  height: auto !important;
  max-height: none !important;
  display: block !important;
  overflow: visible !important;
}

/* Fix any potential WebinarFuel iframe issues */
.webinar-modal__content iframe {
  width: 100% !important;
  height: auto !important;
  max-height: none !important;
  border: none !important;
  display: block !important;
  overflow: visible !important;
}

/* --- Animation --- */
@keyframes modal-fade-in {
  from {
    transform: translateY(40px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* ===================================================== */
/*                    MOBILE BREAKPOINTS                 */
/* ===================================================== */

/* Tablet-down tweaks */
@media (max-width: 768px) {
  .webinar-modal__overlay {
    padding: 8px; /* Smaller padding on tablets */
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .webinar-modal__container {
    width: 100%;
    max-height: calc(95vh - 16px); /* Account for overlay padding */
    margin: 0 auto !important;
  }

  .webinar-modal__header h2 {
    font-size: 1.1rem;
  }

  .webinar-modal__footer {
    font-size: 10px;
    line-height: 0.95;
    padding: 0.5rem 0.5rem;
    background: transparent;
    border: none;
  }
  
}

/* Phone-down tweaks */
@media (max-width: 480px) {
  .webinar-modal__overlay {
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .webinar-modal__container {
    width: 100%;
    max-height: calc(95vh - 10px); /* Account for overlay padding */
    margin: 0 auto; /* Center horizontally */
    border-radius: 8px; /* Slightly rounded corners on mobile */
    /* Dynamic scaling will be handled by JavaScript */
  }

  .webinar-modal__header {
    padding: 0.75rem 1rem;
  }

  .webinar-modal__header h2 {
    font-size: 1rem;
    line-height: 0.7;
  }

  .webinar-modal__footer {
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: none;
  }

  .webinar-modal__close {
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.7rem; /* Smaller on mobile too */
    width: 1.8rem; /* Slightly smaller hitbox on mobile */
    height: 1.8rem;
  }
  
}

/* Extra small screens - let JavaScript handle dynamic scaling */
@media (max-width: 360px) {
  .webinar-modal__overlay {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .webinar-modal__container {
    max-height: calc(95vh - 10px);
    margin: 0 auto;
    /* Transform will be handled by JavaScript */
  }
  
  .webinar-modal__header h2 {
    font-size: 0.9rem;
    line-height: 1.2;
  }
  
  .webinar-modal__footer {
    font-size: 0.7rem;
    padding: 0.4rem 0.5rem;
  }
}

/* Very small screens - let JavaScript handle dynamic scaling */
@media (max-width: 320px) {
  .webinar-modal__overlay {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .webinar-modal__container {
    max-height: calc(95vh - 10px);
    margin: 0 auto;
    /* Transform will be handled by JavaScript */
  }
  
  .webinar-modal__header h2 {
    font-size: 0.8rem;
    line-height: 1.1;
  }
  
  .webinar-modal__footer {
    font-size: 0.65rem;
    padding: 0.3rem 0.4rem;
  }
}
