/* IvaSure Multilingual — front-end language switcher.
   Inherits the theme's font; paints with currentColor + translucent inks so
   it sits naturally on light AND dark headers. The floating variant is the
   zero-template-edit header placement. */

.ivasure-ml-switcher {
  display: inline-flex;
  font-size: 0.8125rem;
  line-height: 1;
}

.ivasure-ml-switcher__list {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 3px;
  list-style: none;
  border: 1px solid rgba(127, 127, 127, 0.35);
  border-radius: 999px;
}

.ivasure-ml-switcher__item {
  margin: 0;
  padding: 0;
}

.ivasure-ml-switcher__link {
  display: inline-block;
  padding: 5px 11px;
  border-radius: 999px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
  opacity: 0.75;
  transition: opacity 120ms ease, background-color 120ms ease;
}

.ivasure-ml-switcher__link:hover,
.ivasure-ml-switcher__link:focus-visible {
  opacity: 1;
  background: rgba(127, 127, 127, 0.16);
  text-decoration: none;
}

.ivasure-ml-switcher__link:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 1px;
}

.ivasure-ml-switcher__link.is-current {
  opacity: 1;
  font-weight: 600;
  background: rgba(127, 127, 127, 0.22);
}

/* Flags: inline SVG, 4:3, subtly rounded; the code badge is the fallback
   for unmapped locales (never a wrong flag). */
.ivasure-ml-flag {
  display: inline-flex;
  flex: 0 0 auto;
  width: 18px;
  height: 12px;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(127, 127, 127, 0.28);
}

.ivasure-ml-flag svg {
  width: 100%;
  height: 100%;
  display: block;
}

.ivasure-ml-flag--code {
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 18px;
  padding: 0 3px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(127, 127, 127, 0.2);
}

.ivasure-ml-switcher__link,
.ivasure-ml-switcher__summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

/* Dropdown variant: native <details>; the summary is the trigger. */
.ivasure-ml-switcher--dropdown .ivasure-ml-switcher__details {
  position: relative;
}

.ivasure-ml-switcher--dropdown .ivasure-ml-switcher__summary {
  list-style: none;
  cursor: pointer;
  padding: 6px 12px;
  border: 1px solid rgba(127, 127, 127, 0.35);
  border-radius: 999px;
  white-space: nowrap;
  user-select: none;
}

.ivasure-ml-switcher--dropdown .ivasure-ml-switcher__summary::-webkit-details-marker {
  display: none;
}

.ivasure-ml-switcher--dropdown .ivasure-ml-switcher__summary:hover,
.ivasure-ml-switcher--dropdown .ivasure-ml-switcher__summary:focus-visible {
  background: rgba(127, 127, 127, 0.14);
}

.ivasure-ml-switcher--dropdown .ivasure-ml-switcher__summary:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 1px;
}

.ivasure-ml-switcher__chevron {
  width: 11px;
  height: 11px;
  opacity: 0.65;
  transition: transform 140ms ease;
}

.ivasure-ml-switcher__details[open] .ivasure-ml-switcher__chevron {
  transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
  .ivasure-ml-switcher__chevron {
    transition: none;
  }
}

.ivasure-ml-switcher--dropdown .ivasure-ml-switcher__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 99991;
  display: grid;
  gap: 2px;
  min-width: max(100%, 160px);
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  color: #1f2937;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
}

.ivasure-ml-switcher--dropdown .ivasure-ml-switcher__menu .ivasure-ml-switcher__link {
  display: flex;
  width: 100%;
  padding: 7px 10px;
  border-radius: 8px;
  opacity: 1;
}

.ivasure-ml-switcher--dropdown .ivasure-ml-switcher__menu .ivasure-ml-switcher__link:hover,
.ivasure-ml-switcher--dropdown .ivasure-ml-switcher__menu .ivasure-ml-switcher__link:focus-visible {
  background: rgba(15, 23, 42, 0.07);
}

.ivasure-ml-switcher--dropdown .ivasure-ml-switcher__menu .ivasure-ml-switcher__link.is-current {
  background: rgba(15, 23, 42, 0.06);
  font-weight: 600;
}

/* Floating header placement (setting: "Show switcher in the site header").
   Fixed to the top right, below the admin bar when present. */
.ivasure-ml-switcher--floating {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 99990;
}

.ivasure-ml-switcher--floating .ivasure-ml-switcher__list:not(.ivasure-ml-switcher__menu),
.ivasure-ml-switcher--floating .ivasure-ml-switcher__summary {
  background: rgba(255, 255, 255, 0.92);
  color: #1f2937;
  border-color: rgba(15, 23, 42, 0.18);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(4px);
}

body.admin-bar .ivasure-ml-switcher--floating {
  top: 44px;
}

/* Phone-only fallback (setting: "Also show a floating switcher on phones").
   A block-theme header collapses to a menu button below its breakpoint and
   takes the switcher block inside it out of the layout entirely (measured:
   zero geometry at 390px), so the merchant's own placement owns desktop and
   this pill owns phones. Same 782px line the compact-mobile rules use. */
.ivasure-ml-switcher--mobile-only {
  display: none;
}

@media (max-width: 782px) {
  body.admin-bar .ivasure-ml-switcher--floating {
    top: 58px;
  }

  .ivasure-ml-switcher--mobile-only {
    display: inline-flex;
  }
}

@media (max-width: 480px) {
  .ivasure-ml-switcher--floating {
    top: 8px;
    right: 8px;
  }

  .ivasure-ml-switcher__link {
    padding: 5px 9px;
  }
}

/* HOVER REGRESSION FIX (owner screenshot, dark header): the generic
   summary hover swaps in a translucent background, which on the floating
   pill REPLACED its opaque white surface — leaving the pill's dark text
   on whatever the header color is. The floating pill keeps an opaque
   surface and its own text color in every state. */
.ivasure-ml-switcher--floating .ivasure-ml-switcher__summary:hover,
.ivasure-ml-switcher--floating .ivasure-ml-switcher__summary:focus-visible {
  background: #ffffff;
  color: #111827;
}

.ivasure-ml-switcher--floating .ivasure-ml-switcher__list:not(.ivasure-ml-switcher__menu) .ivasure-ml-switcher__link:hover,
.ivasure-ml-switcher--floating .ivasure-ml-switcher__list:not(.ivasure-ml-switcher__menu) .ivasure-ml-switcher__link:focus-visible {
  background: rgba(15, 23, 42, 0.08);
}

/* Short-code display mode (EN, RO, RU …). */
.ivasure-ml-switcher__code {
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* Floating corner placement. A fixed pill can always collide with theme
   chrome (owner report: it overlapped a mobile announcement bar) — the
   bottom corners clear top bars entirely, the TranslatePress default. */
.ivasure-ml-switcher--floating.ivasure-ml-switcher--top-left {
  right: auto;
  left: 12px;
}

.ivasure-ml-switcher--floating.ivasure-ml-switcher--bottom-right {
  top: auto;
  bottom: 16px;
}

.ivasure-ml-switcher--floating.ivasure-ml-switcher--bottom-left {
  top: auto;
  right: auto;
  bottom: 16px;
  left: 12px;
}

/* Bottom placements sit below the admin bar by definition — undo the
   admin-bar offsets that only make sense for top placements. */
body.admin-bar .ivasure-ml-switcher--floating.ivasure-ml-switcher--bottom-right,
body.admin-bar .ivasure-ml-switcher--floating.ivasure-ml-switcher--bottom-left {
  top: auto;
}

.ivasure-ml-switcher--floating.ivasure-ml-switcher--bottom-right .ivasure-ml-switcher__menu,
.ivasure-ml-switcher--floating.ivasure-ml-switcher--bottom-left .ivasure-ml-switcher__menu {
  top: auto;
  bottom: calc(100% + 6px);
}

/* Menu placement: the switcher is a real menu item, so it inherits the
   theme's own header layout and mobile hamburger collapse. Stay visually
   neutral — the theme owns this surface. */
.ivasure-ml-switcher-menu-item {
  display: flex;
  align-items: center;
}

.ivasure-ml-switcher--in-menu .ivasure-ml-switcher__summary,
.ivasure-ml-switcher--in-menu .ivasure-ml-switcher__list:not(.ivasure-ml-switcher__menu) {
  border-color: currentColor;
  background: transparent;
  color: inherit;
  box-shadow: none;
}

/* Compact on phones: the long language name collapses, leaving the flag
   (or a short code when the name was all there was). */
.ivasure-ml-switcher__code--mobile {
  display: none;
}

@media (max-width: 782px) {
  .ivasure-ml-switcher--compact-mobile .ivasure-ml-switcher__summary .ivasure-ml-switcher__name,
  .ivasure-ml-switcher--compact-mobile .ivasure-ml-switcher__list:not(.ivasure-ml-switcher__menu) .ivasure-ml-switcher__name {
    display: none;
  }

  .ivasure-ml-switcher--compact-mobile .ivasure-ml-switcher__code--mobile {
    display: inline;
  }
}

/* Name-less display modes (Flag only / Flag + short code / Short code
   only): the menu panel's 160px floor is sized for language NAMES, so a
   lone 24px flag sat in a wide empty gutter with the current-item
   highlight stretching across it. Hug the content instead and centre the
   rows, so the panel reads as a deliberate compact column. */
.ivasure-ml-switcher--no-names.ivasure-ml-switcher--dropdown .ivasure-ml-switcher__menu {
  min-width: 0;
  padding: 4px;
}

.ivasure-ml-switcher--no-names.ivasure-ml-switcher--dropdown .ivasure-ml-switcher__menu .ivasure-ml-switcher__link {
  justify-content: center;
  gap: 6px;
  padding: 6px 8px;
}

/* Same story for the inline list: nothing needs name-width there either. */
.ivasure-ml-switcher--no-names .ivasure-ml-switcher__list:not(.ivasure-ml-switcher__menu) .ivasure-ml-switcher__link {
  padding: 5px 8px;
}
