/* Site popup (Vex) — fit viewport; only inner form body scrolls */

/* Page must not scroll under the dialog */
html.vex-open,
html.vex-open body,
body.vex-open {
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: none;
}

/*
 * Root cause of "modal in a scrollable window":
 * Vex sets `.vex { overflow: auto }` and themes add huge padding (e.g. OS: 160px).
 */
.vex:has(.wayapp-popup-dialog),
.vex.vex-theme-os:has(.wayapp-popup-dialog),
.vex.vex-theme-default:has(.wayapp-popup-dialog),
.vex.vex-theme-plain:has(.wayapp-popup-dialog),
.vex.vex-theme-wireframe:has(.wayapp-popup-dialog),
.vex.vex-theme-flat-attack:has(.wayapp-popup-dialog),
.vex.vex-theme-top:has(.wayapp-popup-dialog),
.vex.vex-theme-bottom-right-corner:has(.wayapp-popup-dialog) {
  overflow: hidden !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 16px !important;
  box-sizing: border-box !important;
}

/* Dialog shell: fit viewport, never scroll itself */
.vex:has(.wayapp-popup-dialog) .vex-content,
.vex-content:has(.wayapp-popup-dialog) {
  box-sizing: border-box !important;
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  margin: 0 auto !important;
  max-width: min(520px, calc(100vw - 32px)) !important;
  width: 100% !important;
  max-height: calc(100vh - 32px) !important;
  max-height: calc(100dvh - 32px) !important;
  height: auto !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 24px !important;
  background: #fff !important;
  color: inherit !important;
  font-family: inherit !important;
  font-size: 1rem !important;
  line-height: 1.45 !important;
  border-top: 0 !important;
  border-radius: 12px !important;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18) !important;
}

.wayapp-popup-dialog {
  text-align: left;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  max-height: 100%;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden !important;
  box-sizing: border-box;
}

.wayapp-popup-title {
  margin: 0 0 12px;
  font-size: 1.15rem;
  flex-shrink: 0;
}

/* ONLY scrollable region */
.wayapp-popup-body {
  margin-bottom: 0;
  line-height: 1.5;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.wayapp-popup-body a { word-break: break-word; }
.wayapp-popup-body img,
.wayapp-popup-body video { max-width: 100%; height: auto; }
.wayapp-popup-body video { display: block; }

.wayapp-cf-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.wayapp-cf-form .wayapp-popup-body {
  margin-bottom: 12px;
}

.wayapp-popup-form .wayapp-cf-field {
  margin-bottom: 12px;
  text-align: left;
}
.wayapp-popup-form .wayapp-cf-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 13px;
}
.wayapp-popup-form .wayapp-cf-field input,
.wayapp-popup-form .wayapp-cf-field select {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-sizing: border-box;
  background: #fff;
  color: inherit;
  font-family: inherit;
  font-size: 16px; /* avoid iOS zoom on focus */
  font-weight: 400;
  line-height: 1.3;
  appearance: none;
  -webkit-appearance: none;
}
.wayapp-popup-form .wayapp-cf-field input:focus,
.wayapp-popup-form .wayapp-cf-field select:focus {
  outline: 0;
  border-color: var(--tpl-accent, #3288e6);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tpl-accent, #3288e6) 22%, transparent);
}
.wayapp-popup-form .wayapp-cf-error {
  color: #b02a37;
  font-size: 13px;
  margin: 8px 0;
}
.wayapp-popup-form .wayapp-cf-success {
  color: #0f5132;
  font-size: 14px;
  margin: 8px 0;
}

.wayapp-popup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
  flex-shrink: 0;
}

.wayapp-popup-cta {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
  border: 2px solid transparent;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: inherit;
}
.wayapp-popup-actions .wayapp-popup-cta {
  flex: 1 1 100%;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.wayapp-popup-cta--solid {
  background: var(--tpl-accent, #0d6efd);
  color: var(--tpl-text-on-accent, #fff);
  border-color: var(--tpl-accent, #0d6efd);
}
.wayapp-popup-cta--outline {
  background: transparent;
  color: var(--tpl-accent, #0d6efd);
  border-color: var(--tpl-accent, #0d6efd);
}
.wayapp-popup-cta--ghost { background: transparent; color: #333; border-color: transparent; }

/* Theme overrides that stretch .vex-content vertically */
.vex-theme-os .vex-content:has(.wayapp-popup-dialog),
.vex-theme-default .vex-content:has(.wayapp-popup-dialog),
.vex-theme-plain .vex-content:has(.wayapp-popup-dialog),
.vex-theme-wireframe .vex-content:has(.wayapp-popup-dialog),
.vex-theme-flat-attack .vex-content:has(.wayapp-popup-dialog),
.vex-theme-top .vex-content:has(.wayapp-popup-dialog),
.vex-theme-bottom-right-corner .vex-content:has(.wayapp-popup-dialog) {
  max-height: calc(100vh - 32px) !important;
  max-height: calc(100dvh - 32px) !important;
  overflow: hidden !important;
}
