/* ==========================================================================
   多语言组件样式：语言切换下拉 + 阿拉伯语 RTL 基础适配
   独立文件，避免改动主题主样式，升级主题时不受影响
   ========================================================================== */

/* ---------- 语言切换 ---------- */
.lang-switch {
  position: relative;
  flex: 0 0 auto;
  /* 与左侧 .head-list 的 item（40px 高）取同一高度并强制居中，
     否则 38px 的按钮在 flex 行里会因 logo 图片的基线差看起来整体偏上 3~4px */
  display: flex;
  align-items: center;
  align-self: center;
  height: 40px;
  margin-left: 14px;
  line-height: 1;
  /* 主题的 .head-nav 是 position:absolute;z-index:9999999 且正好压在下拉框位置，
     不抬高这一层的话菜单会被导航条挡住 */
  z-index: 10000000;
}

.lang-current {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #e6e8ec;
  border-radius: 8px;
  background: #fff;
  color: #1f2d3d;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .18s ease, color .18s ease, box-shadow .18s ease;
}

.lang-current:hover {
  border-color: #f08519;
  color: #f08519;
}

.lang-current:focus-visible {
  outline: 2px solid rgba(240, 133, 25, .45);
  outline-offset: 2px;
}

/* 国旗：内联 SVG，外包一层做圆角与描边，避免各系统 emoji 国旗渲染不一致 */
.lang-flag {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 15px;
  overflow: hidden;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(15, 22, 28, .14);
  background: #eef1f4;
}

.lang-flag-svg {
  display: block;
  width: 22px;
  height: 15px;
}

.lang-current-name {
  letter-spacing: .02em;
}

/* 注意：这个类不能叫 .lang-arrow —— 主题 style.css 里已有 .lang-arrow
   （语言下拉气泡的白色尖角，position:absolute;top:-6px），会把箭头顶到按钮外面 */
.lang-caret {
  width: 6px;
  height: 6px;
  margin-left: 1px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform .2s ease;
}

.lang-switch.open .lang-caret {
  transform: rotate(225deg) translate(-1px, -1px);
}

.lang-list {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1200;
  min-width: 196px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #fff;
  border: 1px solid #eceef2;
  border-radius: 10px;
  box-shadow: 0 20px 44px -24px rgba(19, 20, 21, .42), 0 2px 6px rgba(19, 20, 21, .05);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}

.lang-switch.open .lang-list {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-list li {
  margin: 0;
}

.lang-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  color: #2b3644;
  font-size: 13px;
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}

.lang-list a:hover {
  background: #f7f8fa;
  color: #f08519;
}

.lang-list li.active a {
  background: #fff5ea;
  color: #f08519;
  font-weight: 600;
}

.lang-name {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
}

.lang-code {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  color: #9aa4b0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.lang-list li.active .lang-code {
  color: #d97a12;
}

/* ---------- 阿拉伯语：从右到左 ---------- */
html[dir="rtl"] body {
  direction: rtl;
  text-align: right;
}

html[dir="rtl"] .lang-switch {
  margin-left: 0;
  margin-right: 14px;
}

html[dir="rtl"] .lang-list {
  right: auto;
  left: 0;
}

html[dir="rtl"] .head-list .item .info {
  padding-left: 0;
  padding-right: 10px;
}

html[dir="rtl"] .head-logo a span {
  padding-left: 0;
  padding-right: 10px;
}

/* 图标类箭头在 RTL 下翻转 */
html[dir="rtl"] .icon-xiangyoujiantou,
html[dir="rtl"] .icon-xiangzuojiantou {
  transform: scaleX(-1);
  display: inline-block;
}

/* 数字、邮箱、电话保持从左到右，避免出现 "8102" 这种阅读顺序错乱 */
html[dir="rtl"] .head-list .info p,
html[dir="rtl"] a[href^="tel:"],
html[dir="rtl"] a[href^="mailto:"],
html[dir="rtl"] .lang-code {
  direction: ltr;
  unicode-bidi: embed;
}

/* ---------- 移动端 ---------- */
@media (max-width: 1024px) {
  .lang-switch {
    height: 36px;
    margin-left: 8px;
  }

  .lang-current {
    height: 36px;
    padding: 0 8px;
    gap: 6px;
    font-size: 12px;
    border-radius: 7px;
  }

  .lang-flag,
  .lang-flag-svg {
    width: 20px;
    height: 14px;
  }

  .lang-list {
    right: -4px;
    min-width: 176px;
  }
}
