:root {
  --ifx-green: #16bf8a;
  --ifx-ink: #071b15;
  --ifx-muted: #66756f;
  --ifx-line: rgba(7, 27, 21, .12);
  --ifx-surface: #fff;
}

.ifx-currency {
  position: relative;
  z-index: 99991;
  display: inline-flex;
  align-items: center;
  margin-right: 14px;
  font-family: inherit;
}

.ifx-currency__trigger {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 92px;
  height: 42px;
  padding: 0 12px 0 9px;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 12px;
  color: #fff;
  background: rgba(255, 255, 255, .09);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
}

.ifx-currency__trigger:hover,
.ifx-currency__trigger:focus-visible,
.ifx-currency.is-open .ifx-currency__trigger {
  border-color: rgba(22, 191, 138, .8);
  background: rgba(22, 191, 138, .14);
  outline: none;
}

.ifx-currency__trigger:active {
  transform: translateY(1px);
}

/* WooCommerce utiliza una cabecera clara. En tienda, categorías, fichas,
   carrito, checkout y cuenta el selector cambia a una variante de alto
   contraste sin alterar el estilo transparente del Home. */
body.woocommerce-page:not(.home) #ast-desktop-header .ifx-currency__trigger,
body.post-type-archive-product #ast-desktop-header .ifx-currency__trigger,
body.tax-product_cat #ast-desktop-header .ifx-currency__trigger,
body.tax-product_tag #ast-desktop-header .ifx-currency__trigger {
  color: var(--ifx-ink);
  border-color: rgba(7, 27, 21, .16);
  background: #fff;
  box-shadow: 0 4px 14px rgba(7, 27, 21, .06);
}

body.woocommerce-page:not(.home) #ast-desktop-header .ifx-currency__trigger:hover,
body.woocommerce-page:not(.home) #ast-desktop-header .ifx-currency__trigger:focus-visible,
body.woocommerce-page:not(.home) #ast-desktop-header .ifx-currency.is-open .ifx-currency__trigger,
body.post-type-archive-product #ast-desktop-header .ifx-currency__trigger:hover,
body.tax-product_cat #ast-desktop-header .ifx-currency__trigger:hover,
body.tax-product_tag #ast-desktop-header .ifx-currency__trigger:hover {
  color: #045b42;
  border-color: rgba(22, 191, 138, .65);
  background: #eaf8f3;
}

.ifx-currency__flag {
  display: inline-flex;
  flex: 0 0 auto;
  width: 27px;
  height: 19px;
  overflow: hidden;
  border: 1px solid rgba(7, 27, 21, .14);
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .16);
}

.ifx-currency__flag svg {
  display: block;
  width: 100%;
  height: 100%;
}

.ifx-currency__code {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .07em;
  line-height: 1;
}

.ifx-currency__chevron {
  width: 10px;
  height: 7px;
  margin-left: auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transition: transform .2s ease;
}

.ifx-currency.is-open .ifx-currency__chevron {
  transform: rotate(180deg);
}

.ifx-currency__menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 282px;
  padding: 10px;
  visibility: hidden;
  opacity: 0;
  transform: translateY(-6px) scale(.98);
  transform-origin: top right;
  border: 1px solid var(--ifx-line);
  border-radius: 16px;
  background: var(--ifx-surface);
  box-shadow: 0 18px 50px rgba(2, 18, 13, .2);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
}

.ifx-currency.is-open .ifx-currency__menu {
  visibility: visible;
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.ifx-currency__heading {
  padding: 5px 9px 9px;
  color: var(--ifx-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.ifx-currency__option {
  appearance: none;
  display: grid;
  grid-template-columns: 29px 1fr 20px;
  gap: 11px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 9px 10px;
  border: 0;
  border-radius: 11px;
  color: var(--ifx-ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.ifx-currency__option:hover,
.ifx-currency__option:focus-visible {
  background: #f1f8f5;
  outline: none;
}

.ifx-currency__option.is-active {
  background: #eaf8f3;
}

.ifx-currency__copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.ifx-currency__copy strong {
  color: var(--ifx-ink);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
  line-height: 1.1;
}

.ifx-currency__copy small {
  overflow: hidden;
  color: var(--ifx-muted);
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ifx-currency__check {
  color: var(--ifx-green);
  font-size: 15px;
  font-weight: 900;
  opacity: 0;
}

.ifx-currency__option.is-active .ifx-currency__check {
  opacity: 1;
}

.ifx-currency__note {
  margin-top: 6px;
  padding: 10px 9px 5px;
  border-top: 1px solid var(--ifx-line);
  color: var(--ifx-muted);
  font-size: 10px;
  line-height: 1.45;
}

.ifx-currency.is-loading .ifx-currency__trigger::after {
  width: 13px;
  height: 13px;
  margin-left: 1px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  content: '';
  animation: ifx-spin .7s linear infinite;
}

.ifx-currency.is-loading .ifx-currency__chevron {
  display: none;
}

@keyframes ifx-spin {
  to { transform: rotate(360deg); }
}

/* Respaldo deliberado: el selector legado solo desaparece si JS confirma
   que la interfaz nueva quedó correctamente montada. */
.ifx-currency-ready .woocs_auto_switcher {
  display: none !important;
}

@media (max-width: 921px) {
  /* La cabecera móvil queda limpia: el selector vive dentro del panel
     hamburguesa y no compite con el logo o el carrito. */
  #ast-mobile-header > .ast-main-header-wrap .ifx-currency {
    display: none !important;
  }

  .ifx-currency-menu-item {
    display: block !important;
    width: 100%;
    margin-top: 10px !important;
    padding: 10px 20px 18px !important;
    border-top: 1px solid rgba(7, 27, 21, .12);
  }

  .ifx-currency--mobile-menu {
    display: block;
    width: 100%;
    margin: 0;
    color: var(--ifx-ink);
  }

  .ifx-currency--mobile-menu .ifx-currency__trigger {
    display: grid;
    grid-template-columns: 30px 1fr 12px;
    gap: 12px;
    width: 100%;
    height: 58px;
    min-width: 0;
    padding: 0 14px;
    border: 1px solid rgba(7, 27, 21, .12);
    border-radius: 12px;
    color: var(--ifx-ink);
    background: #f4f8f6;
    box-shadow: none;
    text-align: left;
  }

  .ifx-currency--mobile-menu .ifx-currency__trigger:hover,
  .ifx-currency--mobile-menu .ifx-currency__trigger:focus-visible,
  .ifx-currency--mobile-menu.is-open .ifx-currency__trigger {
    border-color: rgba(22, 191, 138, .55);
    background: #eaf8f3;
  }

  .ifx-currency__mobile-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .ifx-currency__mobile-label small {
    color: var(--ifx-muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .14em;
    line-height: 1;
    text-transform: uppercase;
  }

  .ifx-currency__mobile-label strong {
    color: var(--ifx-ink);
    font-size: 14px;
    font-weight: 800;
    letter-spacing: .05em;
    line-height: 1.1;
  }

  .ifx-currency--mobile-menu .ifx-currency__menu {
    position: static;
    width: 100%;
    max-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    visibility: hidden;
    opacity: 0;
    transform: none;
    border: 0;
    border-radius: 0 0 12px 12px;
    background: transparent;
    box-shadow: none;
    pointer-events: none;
    transition: max-height .24s ease, opacity .18s ease, padding .24s ease;
  }

  .ifx-currency--mobile-menu.is-open .ifx-currency__menu {
    max-height: 230px;
    padding: 7px 0 0;
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }

  .ifx-currency--mobile-menu .ifx-currency__option {
    min-height: 52px;
    padding: 7px 14px;
    border-bottom: 1px solid rgba(7, 27, 21, .08);
    border-radius: 0;
  }

  .ifx-currency--mobile-menu .ifx-currency__option:last-child {
    border-bottom: 0;
  }

  .ifx-currency--mobile-menu .ifx-currency__option.is-active {
    background: #eaf8f3;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ifx-currency *,
  .ifx-currency *::before,
  .ifx-currency *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
