﻿/* ============================================================
 * TrxNo 多语言切换器 + RTL 适配
 * 依赖：static/js/i18n.js
 * ============================================================ */

/* ---------- 首屏防闪烁：i18n 引擎应用译文前隐藏正文 ---------- */
html.i18n-boot body { visibility: hidden !important; }

/* ---------- 切换器容器 ---------- */
.lang-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.lang-switch .lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 6px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  line-height: 1.3;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.lang-switch .lang-btn:hover,
.lang-switch.open .lang-btn {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.06);
}

.lang-switch .lang-globe { color: var(--accent); flex-shrink: 0; }
.lang-switch .lang-caret { opacity: 0.65; flex-shrink: 0; transition: transform 180ms ease; }
.lang-switch.open .lang-caret { transform: rotate(180deg); }

.lang-switch .lang-cur {
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 下拉菜单 ---------- */
.lang-switch .lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1000;
  min-width: 216px;
  max-height: 344px;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms;
}

.lang-switch.open .lang-menu {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.lang-switch .lang-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.lang-switch .lang-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.lang-switch .lang-item.active {
  background: rgba(46, 204, 113, 0.12);
  color: var(--accent);
}

.lang-switch .lang-code {
  min-width: 24px;
  font-family: var(--font-num);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.lang-switch .lang-item.active .lang-code { color: var(--accent); }
.lang-switch .lang-name { flex: 1; }

/* 滚动条（WebKit） */
.lang-switch .lang-menu::-webkit-scrollbar { width: 6px; }
.lang-switch .lang-menu::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 3px;
}

/* ---------- 移动菜单内的切换器 ---------- */
.mobile-menu-foot .lang-switch {
  display: flex;
  width: 100%;
  margin-top: 0;
}

.mobile-menu-foot .lang-switch .lang-btn {
  width: 100%;
  justify-content: center;
  min-height: 42px;
  font-size: 14px;
}

.mobile-menu-foot .lang-switch .lang-menu {
  left: 0;
  right: 0;
  min-width: 0;
  max-height: 52vh;
}

/* ---------- 移动端尺寸 ---------- */
@media (max-width: 640px) {
  .site-nav-actions .lang-switch .lang-btn {
    gap: 5px;
    min-height: 30px;
    padding: 4px 9px;
    font-size: 12px;
  }
  .site-nav-actions .lang-switch .lang-cur { max-width: 62px; }
  .site-nav-actions .lang-switch .lang-globe { width: 13px; height: 13px; }
  .site-nav-actions .lang-switch .lang-menu {
    min-width: 190px;
    max-height: 58vh;
  }
}

/* ---------- RTL（阿拉伯语）适配 ---------- */
html[dir="rtl"] body { direction: rtl; }

html[dir="rtl"] .lang-switch .lang-menu {
  right: auto;
  left: 0;
}

html[dir="rtl"] .lang-switch .lang-item { text-align: right; }

/* 钱包地址、数字、金额一律保持 LTR，避免被镜像 */
html[dir="rtl"] .addr,
html[dir="rtl"] .num,
html[dir="rtl"] .pay-number-big,
html[dir="rtl"] .price-item .value,
html[dir="rtl"] .rental-detail b,
html[dir="rtl"] .custom-note {
  direction: ltr;
  unicode-bidi: isolate;
}

/* 输入框数字保持 LTR */
html[dir="rtl"] input.input { direction: ltr; text-align: right; }

/* 代码块 / 二维码提示保持居中 */
html[dir="rtl"] .qr-tip p { text-align: center; }

/* 列表与卡片内的图标顺序不镜像 */
html[dir="rtl"] .feature-item,
html[dir="rtl"] .price-item,
html[dir="rtl"] .radio-option {
  direction: rtl;
}

/* 导航图标在 RTL 下保持视觉对称 */
html[dir="rtl"] .site-nav-links a,
html[dir="rtl"] .mobile-menu-body a { flex-direction: row; }

/* 页脚与正文默认对齐 */
html[dir="rtl"] .site-footer p { text-align: center; }
