/* WordPress.org does not allow "@" in file names, so the bundled 2x flag
   sprite is renamed from flags@2x.webp. */
:root {
  --iti-path-flags-2x: url(../img/flags-2x.webp);
}

/* [intelebox_input] shortcode field (.itb-* kept for markup from 1.0.x) */
.intelebox-container,
.itb-container {
  position: relative;
  display: inline-block;
  width: 100%;
  max-width: 300px;
}
.intelebox-container .iti,
.itb-container .iti {
  width: 100%;
}
.intelebox-phone-input,
.itb-phone-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1.5;
  transition: border-color 0.15s ease-in-out;
}
.intelebox-phone-input:focus,
.itb-phone-input:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}
.intelebox-phone-input.error,
.itb-phone-input.error {
  border-color: #dc3545;
}
.intelebox-phone-input.error:focus,
.itb-phone-input.error:focus {
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* Everything below targets .intelebox-iti, the class this plugin gives its own
   fields and lists, so other plugins' copies of intl-tel-input are untouched. */

/* Keep the country list above theme headers and Elementor popups. */
.intelebox-iti.iti--detached-country-selector,
.intelebox-iti .iti__country-selector {
  z-index: 2147483647 !important;
}

/* Keep the field inside narrow containers: the dial code padding is added
   to inputs sized by their size attribute (e.g. Contact Form 7). */
.intelebox-iti,
.intelebox-iti input.iti__tel-input {
  max-width: 100%;
}

/* Fix Style forms: the selected country is a <button> since intl-tel-input
   v21, so undo the button styles that themes and form plugins add. */
.intelebox-iti button.iti__selected-country,
.intelebox-iti button.iti__selected-country:hover,
.intelebox-iti button.iti__selected-country:focus {
  width: auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none;
  color: inherit;
  font-size: inherit;
  letter-spacing: normal;
  line-height: inherit;
  text-transform: none;
}

/* Form themes that restyle everything inside the form (e.g. Gravity Forms'
   Orbital theme) collapse the flag and reveal the list's screen-reader text.
   Restore the library's own values on our fields and lists. */
.intelebox-iti .iti__flag:not(.iti__globe) {
  width: var(--iti-flag-width) !important;
  height: var(--iti-flag-height) !important;
  background-image: image-set(var(--iti-path-flags-1x) 1x, var(--iti-path-flags-2x) 2x) !important;
}
.intelebox-iti .iti__a11y-text {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(1px, 1px, 1px, 1px) !important;
}

/* Fields that filled their row before being enhanced stay full width. */
.intelebox-iti.intelebox-iti--full {
  display: block;
  width: 100%;
}

/* WooCommerce Checkout block: move the floating label off the country box.
   The width is set by intelebox-layout.js (0 when they sit on opposite sides). */
.wc-block-components-text-input:has(.intelebox-iti) > label {
  margin-inline-start: var(--intelebox-box-width, 0px);
}

/* Right-to-left sites (setting "Country box on RTL sites: right"): put the
   country box on the right, flag at the outer edge. intl-tel-input forces its
   container to LTR and positions with physical left/right, so mirror that here.
   The digits stay LTR, aligned next to the box. */
.intelebox-rtl .iti__country-container {
  left: auto;
  right: 0;
}
.intelebox-rtl .iti__selected-country,
.intelebox-rtl .iti__selected-country-primary {
  flex-direction: row-reverse;
}
.intelebox-rtl .iti__selected-country-primary {
  padding: 0 var(--iti-spacer-horizontal) 0 var(--iti-arrow-padding);
}
.intelebox-rtl .iti__selected-dial-code {
  margin-left: 0;
  margin-right: 4px;
}
.intelebox-rtl .iti__arrow {
  margin-left: 0;
  margin-right: var(--iti-arrow-padding);
}
.intelebox-rtl.iti--inline-country-selector:not(.iti--detached-country-selector) .iti__country-selector {
  left: auto;
  right: 0;
}
.intelebox-rtl input.iti__tel-input {
  text-align: right;
}
