/* ============================================================
   Region + Language selector
   - Self-isolated from site-wide `.block-with-menu__right-elem > *` styles
   - Works on any header background (light or dark)
   ============================================================ */

/* Reset inherited styles from site container */
.block-with-menu__right-elem > #region-selector,
#region-selector {
  margin: 0 0 0 5px;
  padding: 0;
  font-size: 14px;
  line-height: 1.2;
  float: right;
  display: inline-block;
  cursor: default;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Open Sans', Roboto, sans-serif;
  color: #1A1A1A;
}

.rs-wrap,
.rs-wrap * {
  box-sizing: border-box;
}
.rs-wrap {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  line-height: 1;
  cursor: default;
}

/* ============================================================
   Trigger button — dark pill with white text, visible on light header
   ============================================================ */
.rs-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #1A1A1A;
  color: #ffffff;
  border: 1px solid #1A1A1A;
  border-radius: 8px;
  padding: 7px 10px 7px 8px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
  height: 34px;
  margin: 8px 0;
}
.rs-trigger:hover {
  background: #2A2A2A;
  border-color: #2A2A2A;
}
.rs-wrap--open .rs-trigger,
.rs-wrap--open .rs-trigger:hover {
  background: #F07A1E;
  border-color: #F07A1E;
  color: #ffffff;
}
.rs-trigger:focus-visible {
  outline: 2px solid rgba(240, 122, 30, 0.6);
  outline-offset: 2px;
}
.rs-trigger__label { color: inherit; font-weight: 600; }
.rs-trigger__dot   { opacity: 0.4; margin: 0 -2px; font-weight: 400; }
.rs-trigger__lang  { opacity: 0.85; font-weight: 500; letter-spacing: 0.3px; }
.rs-trigger__chev {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 2px;
  color: inherit;
  opacity: 0.9;
  transform: rotate(0deg);
  transition: transform 0.2s ease;
}
.rs-wrap--open .rs-trigger__chev {
  transform: rotate(180deg);
}

/* ============================================================
   Icons (common)
   ============================================================ */
.rs-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  color: inherit;
  flex-shrink: 0;
}
.rs-ico svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ============================================================
   Flags
   ============================================================ */
.rs-flag {
  display: inline-block;
  flex-shrink: 0;
  background-size: 150% 150%;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #f5f5f5;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  vertical-align: middle;
}

/* ============================================================
   Panel
   ============================================================ */
.rs-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  background: #FFFFFF;
  color: #1A1A1A;
  border-radius: 12px;
  box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.25),
              0 0 0 1px rgba(0, 0, 0, 0.04);
  display: none;
  flex-direction: column;
  max-height: 520px;
  z-index: 1050;
  cursor: default;
  font-size: 14px;
  line-height: 1.3;
  text-align: left;
  overflow: visible; /* picker is absolute inside footer */
}
.rs-wrap--open .rs-panel {
  display: flex;
  animation: rs-drop-in 0.18s ease-out;
}
@keyframes rs-drop-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Mobile header inside panel (hidden on desktop) */
.rs-mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid #E5E5E3;
  flex-shrink: 0;
}
.rs-mobile-header__title {
  font-size: 15px;
  font-weight: 600;
  color: #1A1A1A;
}
.rs-mobile-header__close {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #F5F5F3;
  border: none;
  cursor: pointer;
  color: #1A1A1A;
  padding: 0;
}
.rs-mobile-header__close:hover { background: #EDEDEB; }

/* ---- Search ---- */
.rs-search {
  padding: 10px 10px 8px;
  border-bottom: 1px solid #E5E5E3;
  flex-shrink: 0;
}
.rs-search__field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #F5F5F3;
  border-radius: 8px;
  padding: 0 10px;
  height: 36px;
}
.rs-search__icon  { color: #9A9A9A; }
.rs-search__input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13.5px;
  color: #1A1A1A;
  font-family: inherit;
  padding: 0;
  cursor: text;
  line-height: 1;
  height: 100%;
}
.rs-search__input::placeholder { color: #9A9A9A; opacity: 1; }
.rs-search__clear {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: transparent;
  border: none;
  color: #6B6B6B;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.rs-search__clear:hover { background: #EDEDEB; color: #1A1A1A; }

/* ---- List ---- */
.rs-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 6px 6px;
  cursor: default;
  overscroll-behavior: contain;
}
.rs-list__header {
  padding: 10px 10px 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #9A9A9A;
  cursor: default;
  user-select: none;
}
.rs-list__header--hidden { display: none; }
.rs-list__empty {
  padding: 24px 14px;
  text-align: center;
  color: #6B6B6B;
  font-size: 13px;
  cursor: default;
}
.rs-list__empty[hidden] { display: none; }
.rs-list__empty strong { color: #1A1A1A; font-weight: 600; }

.rs-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  height: 36px;
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.1s ease;
  position: relative;
}
.rs-item--hidden { display: none; }
.rs-item--hover {
  background: #F5F5F3;
}
.rs-item--selected {
  background: #FFF3E8;
}
.rs-item--selected.rs-item--hover {
  background: #FFE9D4;
}
.rs-item__text {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  overflow: hidden;
}
.rs-item__name {
  font-size: 13.5px;
  font-weight: 500;
  color: #1A1A1A;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rs-item--selected .rs-item__name { font-weight: 600; }
.rs-item__en {
  font-size: 11.5px;
  color: #9A9A9A;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
}
.rs-item__tick { color: #F07A1E; }

/* ---- Language footer ---- */
.rs-lang {
  border-top: 1px solid #E5E5E3;
  background: #FAFAF8;
  padding: 10px 12px 12px;
  position: relative;
  flex-shrink: 0;
  border-radius: 0 0 12px 12px;
}
.rs-lang__header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #6B6B6B;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-bottom: 6px;
  cursor: default;
  user-select: none;
}
.rs-lang__title { letter-spacing: 0.4px; }
.rs-lang__auto {
  font-size: 9.5px;
  font-weight: 700;
  color: #F07A1E;
  background: rgba(240, 122, 30, 0.12);
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  line-height: 1;
}
.rs-lang__auto[hidden] { display: none; }

.rs-lang__btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  background: #FFFFFF;
  border: 1px solid #E5E5E3;
  border-radius: 7px;
  padding: 7px 10px;
  cursor: pointer;
  color: #1A1A1A;
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  transition: background-color 0.12s ease, border-color 0.12s ease;
  height: 36px;
  text-align: left;
}
.rs-lang__btn:hover { background: #F9F9F7; border-color: #D6D6D3; }
.rs-lang__native { font-weight: 600; flex: 1; }
.rs-lang__chev {
  color: #9A9A9A;
  transform: rotate(0deg);
  transition: transform 0.2s ease;
}
.rs-lang--picker-open .rs-lang__chev {
  transform: rotate(180deg);
}

/* Picker — persistent in DOM, toggled via class */
.rs-lang__picker {
  position: absolute;
  bottom: calc(100% - 6px);
  left: 12px;
  right: 12px;
  background: #FFFFFF;
  border: 1px solid #E5E5E3;
  border-radius: 10px;
  box-shadow: 0 16px 36px -8px rgba(0, 0, 0, 0.22);
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
  z-index: 10;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.rs-lang--picker-open .rs-lang__picker {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.rs-lang__item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  color: #1A1A1A;
  transition: background-color 0.1s ease;
}
.rs-lang__item:hover { background: #F5F5F3; }
.rs-lang__item--active,
.rs-lang__item--active:hover { background: #FFF3E8; }
.rs-lang__item-native { font-size: 13px; font-weight: 500; }
.rs-lang__item-alias  { font-size: 11.5px; color: #9A9A9A; }
.rs-lang__item-tick   { margin-left: auto; color: #F07A1E; }

/* ============================================================
   Mobile — bottom sheet
   ============================================================ */
@media (max-width: 640px) {
  .rs-trigger {
    padding: 6px 8px 6px 6px;
    font-size: 12.5px;
    height: 32px;
  }
  .rs-trigger__label { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }

  .rs-panel {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 40px -8px rgba(0, 0, 0, 0.3);
    animation: rs-slide-up 0.22s ease-out;
  }
  .rs-wrap--open .rs-panel { display: flex; }

  @keyframes rs-slide-up {
    from { opacity: 0; transform: translateY(100%); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .rs-mobile-header { display: flex; }

  .rs-search { padding: 10px 14px 8px; }
  .rs-search__field { height: 40px; }
  .rs-search__input { font-size: 14px; }

  .rs-list { padding: 4px 10px 6px; }
  .rs-item { height: 42px; padding: 0 12px; }
  .rs-item__name { font-size: 14px; }

  .rs-lang { padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px)); }
  .rs-lang__btn { height: 40px; font-size: 14px; }

  /* Picker on mobile: drop a bit higher so it doesn't spill above screen */
  .rs-lang__picker {
    left: 14px;
    right: 14px;
    max-height: 50vh;
  }

  /* Backdrop behind the bottom sheet */
  .rs-wrap--open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1049;
    animation: rs-fade-in 0.2s ease-out;
  }
  @keyframes rs-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  body.rs-body-locked { overflow: hidden; }
}
