/* ==========================================================================
   Footer language switcher + RTL layout
   ========================================================================== */

.footer__lang {
  width: 100%;
  margin-top: 2px;
  display: flex;
  align-items: center;
}

.lang-switcher {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 100%;
}

.lang-switcher__trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 7px 10px;
  margin-inline-start: -10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  line-height: 1.3;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.lang-switcher__trigger:hover,
.lang-switcher__trigger[aria-expanded="true"] {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
}

.lang-switcher__trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lang-switcher__globe {
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lang-switcher__current {
  flex: 0 1 auto;
  min-width: 4.5em;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lang-switcher__code {
  flex: none;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  direction: ltr;
  unicode-bidi: isolate;
}

.lang-switcher__chevron {
  width: 13px;
  height: 13px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.18s ease;
}

.lang-switcher__trigger[aria-expanded="true"] .lang-switcher__chevron {
  transform: rotate(180deg);
}

.lang-switcher__panel {
  position: absolute;
  inset-inline-start: 0;
  bottom: calc(100% + 8px);
  z-index: 90;
  width: min(360px, calc(100vw - 40px));
  max-height: min(430px, 62vh);
  display: flex;
  flex-direction: column;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.lang-switcher__panel[hidden] {
  display: none;
}

.lang-switcher__search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.lang-switcher__search-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.12);
}

.lang-switcher__search-icon {
  display: inline-flex;
  flex: none;
  color: var(--text-3);
}

.lang-switcher__search-icon svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}

.lang-switcher__search {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  text-align: start;
}

.lang-switcher__search::placeholder {
  color: var(--text-3);
}

.lang-switcher__search::-webkit-search-cancel-button {
  cursor: pointer;
}

.lang-switcher__list {
  min-height: 0;
  flex: 1 1 auto;
  margin: 6px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.lang-switcher__option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "native check"
    "meta check";
  align-items: center;
  column-gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease;
}

.lang-switcher__option:hover,
.lang-switcher__option.is-active {
  background: var(--surface-2);
}

.lang-switcher__option.is-selected {
  background: rgba(14, 116, 144, 0.08);
}

.lang-switcher__native {
  grid-area: native;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.lang-switcher__meta {
  grid-area: meta;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-3);
  font-size: 10.5px;
  line-height: 1.35;
}

.lang-switcher__check {
  grid-area: check;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  visibility: hidden;
}

.lang-switcher__option.is-selected .lang-switcher__check {
  visibility: visible;
}

.lang-switcher__empty {
  margin: 12px 8px;
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.6;
  text-align: center;
}

.lang-switcher__empty[hidden] {
  display: none;
}

.lang-switcher__note {
  flex: none;
  margin: 7px 8px 1px;
  padding-top: 7px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 10.5px;
  line-height: 1.5;
}

@media (max-width: 720px) {
  .footer__lang {
    margin-top: 4px;
  }

  .lang-switcher__panel {
    width: min(340px, calc(100vw - 40px));
    max-height: min(400px, 60vh);
  }

  /* 中文标题可保持单行；译文更长，必须允许换行 */
  html:not([lang="zh-CN"]):not([lang="zh-TW"]) .hero__title,
  html:not([lang="zh-CN"]):not([lang="zh-TW"]) .section__head h2.deploy-title {
    white-space: normal;
    text-wrap: balance;
    overflow-wrap: break-word;
  }
}

/* RTL: 主要文本区与语言面板镜像；语言代码保持 LTR */
html[dir="rtl"] .footer__legal,
html[dir="rtl"] .account-card,
html[dir="rtl"] .admin-card,
html[dir="rtl"] .auth-card,
html[dir="rtl"] .plan,
html[dir="rtl"] .doc-item,
html[dir="rtl"] .checkout,
html[dir="rtl"] .hero__copy,
html[dir="rtl"] .section__head {
  text-align: start;
}

html[dir="rtl"] .order-detail__value {
  text-align: end;
}

html[dir="rtl"] .orders-table th,
html[dir="rtl"] .orders-table td,
html[dir="rtl"] .admin-table th,
html[dir="rtl"] .admin-table td {
  text-align: start;
}

/* 品牌、代码、订单号等混合方向内容强制隔离，避免 RTL 标点错序 */
bdi,
.lang-switcher__code,
.order-no,
.order-detail__value.is-mono,
.admin-table__email {
  unicode-bidi: isolate;
}

.footer__tg-link {
  margin-left: 0;
  margin-inline-start: -4px;
}

/* 长文本防护：德语/俄语/芬兰语等长译文不撑破按钮和卡片 */
.btn {
  max-width: 100%;
  min-width: 0;
  white-space: normal;
  text-align: center;
  overflow-wrap: anywhere;
}

.hero__title,
.section__head h2,
.plan__name,
.plan__desc,
.feature h3,
.feature p,
.footer__legal,
.auth-card,
.account-card,
.admin-card,
.checkout {
  overflow-wrap: anywhere;
}

.hero__stats dt,
.hero__stats dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

