/**
 * Walter Lang Switcher v5 — custom rendered, clean DOM
 * No hover gap, click-to-toggle, right-aligned footer
 */

/* ============================================
   BASE — applies to both .walter-ls-header and .walter-ls-footer
   ============================================ */
.walter-ls {
  position: relative !important;
  display: inline-flex !important;
  align-items: center !important;
  /* CRITICAL: enlarge hover hit area so menu and toggle are one hover zone */
}

/* Bridge — fills the gap between toggle and menu to keep hover continuous */
.walter-ls::before {
  content: "";
  position: absolute;
  pointer-events: none;
  inset: 0;
}

.walter-ls.is-open::before {
  pointer-events: auto;
  /* expand the bridge to cover toggle + menu fully */
}

/* THE TOGGLE BUTTON */
.walter-ls-toggle {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 8px 12px !important;
  border-radius: 8px !important;
  background: transparent !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  color: inherit !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  font-family: inherit !important;
  transition: background 140ms ease, border-color 140ms ease !important;
  line-height: 1 !important;
}

.walter-ls-toggle:hover,
.walter-ls.is-open .walter-ls-toggle {
  background: rgba(0, 0, 0, 0.04) !important;
  border-color: rgba(0, 0, 0, 0.14) !important;
}

.walter-ls-toggle .walter-ls-globe,
.walter-ls-toggle .walter-ls-flag {
  display: inline-flex !important;
  align-items: center !important;
}

.walter-ls-toggle .walter-ls-flag {
  width: 20px !important;
  height: auto !important;
  border-radius: 3px !important;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04) !important;
}

.walter-ls-toggle .walter-ls-label {
  font-weight: 500 !important;
}

.walter-ls-toggle .walter-ls-chevron {
  display: inline-flex !important;
  align-items: center !important;
  opacity: 0.6 !important;
  transition: transform 180ms ease, opacity 140ms ease !important;
}

.walter-ls.is-open .walter-ls-toggle .walter-ls-chevron {
  transform: rotate(-180deg) !important;
  opacity: 1 !important;
}

/* THE MENU CARD */
.walter-ls-menu {
  list-style: none !important;
  margin: 0 !important;
  padding: 8px 0 !important;
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  border-radius: 12px !important;
  box-shadow: 0 14px 36px -10px rgba(0, 0, 0, 0.2),
              0 4px 10px -2px rgba(0, 0, 0, 0.08),
              0 0 0 1px rgba(0, 0, 0, 0.03) !important;
  min-width: 220px !important;
  max-width: 280px !important;
  position: absolute !important;
  z-index: 99999 !important;
  opacity: 0 !important;
  visibility: hidden !important;
  transform: translateY(-4px) !important;
  pointer-events: none !important;
  transition: opacity 180ms ease, transform 180ms ease, visibility 0s 180ms !important;
}

/* Visible state */
.walter-ls.is-open .walter-ls-menu,
.walter-ls:hover .walter-ls-menu {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) !important;
  pointer-events: auto !important;
  transition: opacity 180ms ease, transform 180ms ease, visibility 0s !important;
}

/* MENU ROWS */
.walter-ls-item {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.walter-ls-item a {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 10px 16px !important;
  font-size: 15px !important;
  font-weight: 500 !important;
  color: #1a1a1a !important;
  background: #ffffff !important;
  text-decoration: none !important;
  line-height: 1.4 !important;
  transition: background-color 140ms ease, padding 140ms ease !important;
  position: relative !important;
}

.walter-ls-item a:hover,
.walter-ls-item a:focus {
  background: #f5f5f7 !important;
  color: #000 !important;
  padding-left: 18px !important;
  outline: none !important;
}

.walter-ls-item .walter-ls-flag {
  width: 22px !important;
  height: auto !important;
  flex-shrink: 0 !important;
  border-radius: 3px !important;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04) !important;
}

.walter-ls-item .walter-ls-label {
  flex: 1 1 auto !important;
}

/* CURRENT — checkmark */
.walter-ls-item.is-current a {
  font-weight: 600 !important;
}

.walter-ls-item.is-current {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important;
  margin-bottom: 4px !important;
}

.walter-ls-item .walter-ls-check {
  margin-left: auto !important;
  color: #4f46e5 !important;
  font-weight: 700 !important;
  font-size: 16px !important;
  flex-shrink: 0 !important;
}

/* ============================================
   HEADER VARIANT — globe icon toggle, dropdown below
   ============================================ */
.walter-ls-header .walter-ls-toggle {
  padding: 8px 10px !important;
}

.walter-ls-header .walter-ls-globe {
  color: #1a1a1a !important;
}

.walter-ls-header .walter-ls-menu {
  /* Dropdown opens BELOW with NO gap (avoids hover-gap bug) */
  top: 100% !important;
  right: 0 !important;
  margin-top: 6px !important;
}

/* When open: extend a transparent bridge above the menu to keep hover continuous */
.walter-ls-header.is-open::after,
.walter-ls-header:hover::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  top: 100%;
  height: 10px;
  background: transparent;
}

/* ============================================
   FOOTER VARIANT — pill toggle with flag + label, dropdown ABOVE
   ============================================ */
.walter-ls-footer {
  /* Right-align in footer — push to end */
  margin: 0 !important;
}

.walter-ls-footer .walter-ls-toggle {
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.16) !important;
  color: rgba(255, 255, 255, 0.92) !important;
  padding: 7px 12px !important;
  font-size: 13px !important;
}

.walter-ls-footer .walter-ls-toggle:hover,
.walter-ls-footer.is-open .walter-ls-toggle {
  background: rgba(255, 255, 255, 0.14) !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
  color: #fff !important;
}

.walter-ls-footer .walter-ls-toggle .walter-ls-flag {
  width: 18px !important;
}

.walter-ls-footer .walter-ls-menu {
  /* Dropdown opens UPWARD (we're at bottom of page) */
  bottom: 100% !important;
  right: 0 !important;
  margin-bottom: 6px !important;
  min-width: 220px !important;
  box-shadow: 0 -14px 36px -10px rgba(0, 0, 0, 0.4),
              0 -4px 10px -2px rgba(0, 0, 0, 0.2),
              0 0 0 1px rgba(0, 0, 0, 0.05) !important;
}

.walter-ls-footer.is-open .walter-ls-menu,
.walter-ls-footer:hover .walter-ls-menu {
  transform: translateY(0) !important;
}

/* Footer bridge — fills the gap UPWARD between toggle and menu */
.walter-ls-footer.is-open::after,
.walter-ls-footer:hover::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  bottom: 100%;
  height: 10px;
  background: transparent;
}

/* ============================================
   FOOTER BOTTOM-BAR LAYOUT — right-align lang next to Privacy/Terms
   ============================================ */
.site-below-footer-wrap {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  flex-wrap: wrap !important;
  gap: 16px !important;
  padding: 20px 0 !important;
}

.site-below-footer-section-1 {
  flex: 0 1 auto !important;
}

.site-below-footer-section-2 {
  display: inline-flex !important;
  align-items: center !important;
  gap: 16px !important;
  flex: 0 0 auto !important;
  margin-left: auto !important;
}

/* The lang switcher we inject — first child of section-2 */
.site-below-footer-section-2 .walter-ls-footer {
  order: 1 !important; /* explicit ordering */
}

.site-below-footer-section-2 .site-primary-footer-section-5 {
  order: 2 !important;
  display: inline-flex !important;
  align-items: center !important;
}

/* Hide the original WPML widget output (we render custom) */
.wpml_switcher_wrap .widget_icl_lang_sel_widget,
.wpml_switcher_wrap .wpml_switcher_btn,
.site-primary-footer-section-1 .widget_icl_lang_sel_widget {
  display: none !important;
}

/* ============================================
   MOBILE
   ============================================ */
@media (max-width: 768px) {
  .walter-ls-item a {
    padding: 14px 18px !important;
    font-size: 15px !important;
  }

  .site-below-footer-wrap {
    flex-direction: column !important;
    align-items: flex-start !important;
  }

  .site-below-footer-section-2 {
    margin-left: 0 !important;
  }

  .walter-ls-menu {
    min-width: 240px !important;
  }
}
