@import url("/css/design_v2/color.css");
@import url("/css/design_v2/font.css");
@import url("/css/design_v2/standards.css");

.ui-modal-overlay {
  position: fixed;
  inset: 0;
  display: none; /* hidden by default; shown via inline style or JS */
  place-items: end center; /* align to bottom, center horizontally */
  width: 100vw;
  height: 100vh;
  z-index: 20000; /* ensure above navbar/header */
  background: rgba(0, 0, 0, 0.5); /* darkened backdrop */
}

.ui-modal-overlay--top-third {
  place-items: start center; /* align to top region, center horizontally */
  padding-top: 16.67vh; /* roughly center within top third of viewport */
}

/* Mobile: reduce top padding for top-third placement */
@media (max-width: 599px) {
  .ui-modal-overlay--top-third {
    padding-top: var(--Space-L);
  }
}

.ui-modal-overlay--hidden {
  display: none;
}

.ui-modal-overlay__backdrop {
  position: fixed;
  inset: 0;
  background: transparent; /* backdrop color handled by overlay */
  border: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
  z-index: 20000;
}

.ui-modal {
  position: relative; /* positioned by parent grid */
  background: var(--Color-Primary-White);
  border-radius: var(--Radius-200);
  padding: var(--Space-L);
  padding-right: calc(var(--Space-L) + 10px); /* extra space for close button */
  width: min(90vw, 560px);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 0 6px 12px rgba(0, 0, 0, 0.06);
  z-index: 20001;
  margin-bottom: var(--Space-L); /* padding from bottom of screen */
}

.ui-modal--with-image {
  display: flex;
  padding: 0;
  overflow-x: hidden; /* prevent horizontal overflow */
  overflow-y: visible; /* don't force scrollbar, let content determine */
  width: min(90vw, 840px); /* wider to accommodate image */
}

/* Mobile: stack image and content vertically */
@media (max-width: 599px) {
  .ui-modal--with-image {
    flex-direction: column;
    max-height: 90vh;
    overflow-y: auto;
  }
}

.ui-modal--size-wide {
  width: min(90vw, 779px);
}

.ui-modal--with-image.ui-modal--size-wide {
  width: min(90vw, 779px);
}

/* Desktop: dimensions for wide auth modals */
@media (min-width: 1240px) {
  .ui-modal--size-wide {
    width: 779px;
    min-height: 461px;
    max-height: 90vh; /* allow modal to grow but cap at viewport */
  }

  .ui-modal--with-image.ui-modal--size-wide {
    width: 779px;
    min-height: 461px;
    max-height: 90vh; /* allow modal to grow but cap at viewport */
    overflow-y: auto; /* show scrollbar only when content exceeds max-height */
  }

  /* Ensure image container fills available height on desktop */
  .ui-modal--with-image.ui-modal--size-wide .ui-modal__image {
    min-height: 461px; /* minimum height, can grow */
    align-self: stretch; /* ensure it fills the full height */
  }
}

.ui-modal--with-image .ui-modal__content {
  flex: 1; /* takes up 1/2 of the width */
  padding: var(--Space-Gap-XLarge);
  padding-right: calc(var(--Space-Gap-XLarge) + 10px); /* extra space for close button */
  overflow-y: visible; /* let modal grow instead of scrolling content area */
  min-height: 0; /* allow flex item to shrink below content size */
}

/* Mobile: adjust content padding when stacked */
@media (max-width: 599px) {
  .ui-modal--with-image .ui-modal__content {
    padding: var(--Space-L);
    padding-right: calc(var(--Space-L) + 10px);
    flex: none; /* don't flex on mobile */
  }
}

.ui-modal__alert-banner {
  margin-bottom: var(--Space-M); /* spacing between alert banner and title */
}

.ui-modal__alert-banner .pp-alert-banner {
  width: fit-content;
  max-width: calc(100% - 40px); /* constrain width to leave 40px less space */
}

.ui-modal--with-image .ui-modal__image {
  flex: 1; /* takes up 1/2 of the width */
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--Color-Primary-White);
  padding: var(--Space-L);
  padding-left: 0;
}

/* Mobile: adjust image container when stacked */
@media (max-width: 599px) {
  .ui-modal--with-image .ui-modal__image {
    flex: none; /* don't flex on mobile */
    padding: var(--Space-M);
    min-height: 200px; /* ensure image has space */
    max-height: 300px; /* prevent image from taking too much space */
    order: -1; /* show image above content on mobile */
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.ui-modal--with-image .ui-modal__image img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Mobile: adjust image sizing when stacked */
@media (max-width: 599px) {
  .ui-modal--with-image .ui-modal__image img {
    max-width: 100%;
    max-height: 250px;
    width: auto;
    height: auto;
    object-fit: contain;
  }
}

.ui-modal--error {
  border-top: 4px solid var(--Color-Primary-Red-600, #E04C26);
}

.ui-modal__close {
  position: absolute;
  top: var(--Space-S);
  right: var(--Space-S);
  background: transparent;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: transform 150ms ease;
  transform: translateZ(0);
  outline: none; /* remove default blue outline */
  padding: var(--Space-XS); /* clickable area larger than visual button */
}

.ui-modal__content {
  text-align: left; /* forms should be left-aligned */
  width: 100%;
}

.ui-modal__content > *:first-child:not(h2):not(.ui-modal__subtitle) {
  margin-top: var(--Space-M); /* additional space after subtitle if no subtitle exists */
}

.ui-modal__content fieldset:first-of-type {
  margin-top: 0; /* remove default margin if fieldset is first after subtitle */
}

.ui-modal__content h2 {
  font-weight: var(--Font-Weight-400);
  margin-bottom: var(--Space-S); /* spacing between title and subtitle */
  margin-top: 0; /* ensure no extra top margin */
}

.ui-modal__content h2.typography-h2-m {
  font-size: var(--Text-Sizes-Heading-M); /* 32px - ensure typography class takes precedence */
  white-space: normal; /* allow title to wrap */
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.ui-modal__subtitle {
  color: var(--Color-Text-Navy-700);
  font-family: var(--Font-Family-Sans);
  font-size: var(--Text-Sizes-Text-Regular);
  font-style: normal;
  font-weight: var(--Font-Weight-300);
  line-height: var(--Text-LineHeight-Standard);
  margin-top: 0;
  margin-bottom: var(--Space-M); /* more space before form content */
}

.ui-modal__close:hover,
.ui-modal__close:focus-visible {
  transform: scale(1.2);
  outline: 2px solid #ffffff; /* white focus ring as requested */
  outline-offset: 2px;
}

/* Remove inner focus padding in Firefox */
.ui-modal__close::-moz-focus-inner {
  border: 0;
}

.ui-modal__details {
  margin-top: var(--Space-S);
}


