/* StruXure Form Enhancements
   ================================================================ */

/* ---- ITI wrapper ---- */
.gform_wrapper .iti,
.iti {
  width: 100%;
  position: relative !important;
  display: block !important;
}

/* Country flag button — absolutely positioned inside the input */
.iti .iti__country-container {
  position: absolute !important;
  top: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  padding: 1px !important;
  z-index: 2 !important;
}

.gform_wrapper input.iti__tel-input,
.gform_wrapper .iti input.iti__tel-input,
.iti input.iti__tel-input {
  width: 100% !important;
  padding-left: 42px !important;
}

/* ---- Google Places autocomplete ---- */
.pac-container {
  z-index: 10000;
}

/* ================================================================
   INLINE-DROPDOWN MODE FIX
   In v23, .iti--inline-dropdown renders .iti__dropdown-content as a
   child of .iti (no separate .iti--container). The theme overrides
   position:absolute on .iti__dropdown-content, causing it to render
   in normal flow and overlap the fields below.
   ================================================================ */

.iti--inline-dropdown .iti__dropdown-content {
  position: absolute !important;
  top: 100% !important;
  left: 0 !important;
  z-index: 10000 !important;
  background: #fff !important;
  border: 1px solid #ccc !important;
  border-radius: 3px !important;
  box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.2) !important;
  display: flex !important;
  flex-direction: column !important;
  max-height: 250px !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

/* When the dropdown is closed, intl-tel-input adds .iti__hide */
.iti__dropdown-content.iti__hide {
  display: none !important;
}

/* Search input */
.iti__dropdown-content .iti__search-input {
  display: block !important;
  width: 100% !important;
  padding: 9px 12px !important;
  margin: 0 !important;
  border: none !important;
  border-bottom: 1px solid #ccc !important;
  border-radius: 0 !important;
  outline: none !important;
  font-size: 14px !important;
  box-sizing: border-box !important;
  background: #fff !important;
  color: #333 !important;
  flex-shrink: 0 !important;
}

/* Screen-reader-only text — the button already has aria-label and
   title attributes for accessibility, so display:none is safe here */
.iti .iti__a11y-text,
.iti__a11y-text {
  display: none !important;
}

/* Country list */
.iti__dropdown-content ul.iti__country-list {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  background: #fff !important;
  max-height: 200px !important;
  flex: 1 !important;
}

/* Each country row */
.iti__dropdown-content li.iti__country {
  display: flex !important;
  align-items: center !important;
  padding: 8px 10px !important;
  cursor: pointer !important;
  list-style: none !important;
  margin: 0 !important;
  background: #fff !important;
  color: #333 !important;
  font-size: 14px !important;
  line-height: 1.4 !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
}

.iti__dropdown-content li.iti__country:hover,
.iti__dropdown-content li.iti__highlight {
  background-color: rgba(0, 0, 0, 0.05) !important;
}

/* Flag sprite — v23 uses CSS custom properties (--iti-flag-offset per
   country, --iti-path-flags-1x for the sprite URL). The theme's global
   "background: none" reset overrides background-image, background-position,
   and background-size, but it can't touch the custom properties themselves.
   Re-declaring everything with !important + var() references restores the
   flags without needing 244 individual position overrides. */
.iti__flag {
  background-image: url("https://cdn.jsdelivr.net/npm/intl-tel-input@23/build/img/flags.webp") !important;
  background-position: var(--iti-flag-offset, 0px) 0 !important;
  background-size: 5762px 15px !important;
  background-repeat: no-repeat !important;
  display: inline-block !important;
  width: var(--iti-flag-width, 20px) !important;
  height: var(--iti-flag-height, 15px) !important;
  box-shadow: 0 0 1px 0 #888 !important;
  overflow: hidden !important;
}

@media (min-resolution: 2x) {
  .iti__flag {
    background-image: url("https://cdn.jsdelivr.net/npm/intl-tel-input@23/build/img/flags@2x.webp") !important;
  }
}

.iti__flag-box {
  display: inline-flex !important;
  align-items: center !important;
  margin-right: 8px !important;
  width: 20px !important;
  flex-shrink: 0 !important;
}

.iti__country-name {
  margin-right: 8px !important;
  flex: 1 !important;
}

.iti__dial-code {
  color: #999 !important;
}

/* ---- Prevent GF wrappers from clipping the dropdown ---- */
.gform_wrapper .gfield,
.gform_wrapper .ginput_container,
.gform_wrapper .ginput_container_phone,
.gform_wrapper .gfield .ginput_container {
  overflow: visible !important;
}

/* ================================================================
   SELECTED-COUNTRY BUTTON — prevent theme button styles bleeding in
   ================================================================ */
.iti__selected-country {
  background-color: transparent !important;
  background: none !important;
  border: none !important;
  padding: 0 5px 0 5px !important;
  box-shadow: none !important;
  display: flex !important;
  align-items: center !important;
  height: 100% !important;
}

.iti__selected-country-primary {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  background: transparent !important;
}

.iti__arrow {
  margin-left: 4px !important;
}

.iti__selected-country:hover,
.iti__selected-country:focus {
  background-color: transparent !important;
}

/* ---- GF error state — keep brand orange ---- */
.gform_wrapper .gfield_error input.iti__tel-input,
.gform_wrapper .gfield_error .iti input {
  border-color: #e2874a !important;
}
