/* VibeCut i18n 语言选择器样式 + RTL 覆盖 */

/* ── 语言选择器 ── */
.i18n-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.i18n-switcher-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
  line-height: 1.4;
}

.i18n-switcher-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.i18n-switcher-btn .i18n-switcher-arrow {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid currentColor;
  transition: transform 0.2s ease;
}

.i18n-switcher-btn.open .i18n-switcher-arrow {
  transform: rotate(180deg);
}

/* ── 下拉菜单 ── */
.i18n-switcher-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  display: flex;
  width: 148px;
  max-height: calc(100vh - 80px);
  max-height: calc(100dvh - 80px);
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 4px;
  overflow-x: hidden;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.08);
  border: 0.5px solid rgba(139, 139, 139, 0.44);
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  box-sizing: border-box;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  scrollbar-width: thin;
  scrollbar-color: rgba(150, 159, 171, 0.55) transparent;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px) scale(0.96);
  transition: all 0.2s ease;
}

.i18n-switcher-menu::-webkit-scrollbar { width: 4px; }
.i18n-switcher-menu::-webkit-scrollbar-thumb {
  background: rgba(150, 159, 171, 0.55);
  border-radius: 4px;
}

.i18n-switcher-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.i18n-switcher-item {
  display: flex;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  flex: 0 0 36px;
  align-items: center;
  gap: 6px;
  border-radius: 8px;
  box-sizing: border-box;
  cursor: pointer;
  color: #f5f8ff;
  font: 500 14px/14px Geist, "Noto Sans SC", sans-serif;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.i18n-switcher-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.i18n-switcher-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #645ffc;
}

.i18n-switcher-item .i18n-switcher-code {
  display: inline-flex;
  width: 25px;
  height: 22px;
  padding: 0 6px;
  flex: 0 0 25px;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  box-sizing: border-box;
  font: 500 10px/10px Geist, "Noto Sans SC", sans-serif;
}

.i18n-switcher-item.active .i18n-switcher-code {
  background: rgba(100, 95, 252, 0.12);
  color: #645ffc;
}

.i18n-switcher-item .i18n-switcher-label {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}

/*
 * Locale-aware overflow repair. Grow within the parent allocation first;
 * shrink control text only after reaching the available width.
 */
.i18n-adaptive-container {
  min-inline-size: min(var(--i18n-fit-inline-size), calc(100vw - 24px)) !important;
  max-inline-size: calc(100vw - 24px);
  box-sizing: border-box;
}

/* Apply the semantic rule before a popup measures and positions its contents.
 * Composite cards/forms keep their own layout; JS fits only their text slots. */
:where(button, [role="button"], [role="menuitem"], [role="tab"], [role="option"], label, legend, th, nav a, a[data-i18n]):not(:has(p, small, [role="note"], input, textarea, select, button, [role="button"], [role="listbox"])),
.i18n-single-line-control,
.i18n-single-line-control :is(span, strong, em, small, b, i, [data-i18n]) {
  white-space: nowrap !important;
  overflow-wrap: normal !important;
  word-break: normal;
}

.i18n-fit-text {
  font-size: var(--i18n-fit-font-size) !important;
}

.i18n-fit-truncated {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* Measure and commit one final layout, never animated intermediate font sizes. */
.i18n-layout-measuring .i18n-single-line-control,
.i18n-layout-measuring .i18n-single-line-control *,
.i18n-layout-measuring [data-i18n-adaptive] {
  transition: none !important;
}

/* 首页与 Dashboard 顶部导航共享同一套语言选择器外观与展开动效。 */
.i18n-switcher--navbar {
  width: 57px;
  flex: 0 0 57px;
}

.i18n-switcher--navbar .i18n-switcher-btn {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  gap: 4px;
  border: 0;
  border-radius: 41px;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  box-shadow: none;
  font: 400 14px/14px Geist, "Noto Sans SC", "PingFang SC", sans-serif;
}

.i18n-switcher--navbar .i18n-switcher-btn .i18n-switcher-arrow {
  display: block;
  width: 14px;
  height: 14px;
  border: 0;
  background: url('/static/dashboard/assets/topbar/language-chevron.svg') center / 14px 14px no-repeat;
  transform: rotate(90deg);
}

.i18n-switcher--navbar .i18n-switcher-btn.open .i18n-switcher-arrow {
  transform: rotate(270deg);
}

.i18n-switcher--navbar .i18n-switcher-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border: 0;
}

.i18n-switcher--navbar .i18n-switcher-btn.open {
  color: rgba(255, 255, 255, 0.6);
  background: rgba(70, 74, 79, 0.8);
}

.i18n-switcher--navbar .i18n-switcher-menu {
  top: calc(100% + 8px);
  left: 0;
  right: auto;
  margin-top: 0;
  transform-origin: top left;
}

@media (max-width: 720px) {
  .i18n-switcher--navbar .i18n-switcher-btn {
    padding: 0 8px;
  }
}
