/* =============================================================================
   官网界面语言切换 —— 与 ToolPDF 网站右上角一致的下拉语言菜单
   -----------------------------------------------------------------------------
   1) 选择器用 <details> 实现，没有 JavaScript 也能展开；
   2) 颜色取中性灰，适配首页白底、产品页深色 Hero 与长念品牌的绿色调；
   3) 阿拉伯语 / 希伯来语切换到 RTL 时，镜像菜单与常用方向性间距。
   ============================================================================= */

[data-lang-switch] {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: none;
}

.lang-switch {
  position: relative;
}

.lang-switch > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid rgba(17, 17, 17, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #3d3d3d;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
  transition: border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.lang-switch > summary::-webkit-details-marker {
  display: none;
}

.lang-switch > summary::marker {
  content: "";
}

.lang-switch > summary:hover,
.lang-switch[open] > summary {
  border-color: #111111;
  color: #111111;
  box-shadow: 0 6px 18px -10px rgba(0, 0, 0, 0.35);
}

.lang-switch > summary i.fa-language {
  font-size: 14px;
}

.lang-switch > summary .lang-current {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 1280px) {
  .lang-switch > summary .lang-current {
    max-width: 240px;
  }
}

.lang-switch > summary .lang-caret {
  font-size: 10px;
  color: #8a8a8a;
  transition: transform 0.2s ease;
}

.lang-switch[open] > summary .lang-caret {
  transform: rotate(180deg);
}

.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  display: grid;
  gap: 2px;
  min-width: 190px;
  max-height: min(70vh, 560px);
  overflow-y: auto;
  padding: 6px;
  background: #ffffff;
  border: 1px solid rgba(17, 17, 17, 0.1);
  border-radius: 12px;
  box-shadow: 0 18px 44px -18px rgba(17, 17, 17, 0.38);
  text-align: left;
}

.lang-menu a {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: #222222;
  font-size: 13px;
  line-height: 1.35;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.lang-menu a:hover {
  background: #f3f5f8;
  color: #111111;
}

.lang-menu a.active {
  background: #eef4ff;
  color: #0a5bd6;
  font-weight: 600;
}

/* ---------- 从右到左（阿拉伯语 / 希伯来语 / 摩洛哥阿拉伯语） ---------- */
html[dir="rtl"] body {
  direction: rtl;
}

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

html[dir="rtl"] .ml-2 {
  margin-left: 0;
  margin-right: 0.5rem;
}

html[dir="rtl"] .mr-2 {
  margin-right: 0;
  margin-left: 0.5rem;
}

html[dir="rtl"] .mr-4 {
  margin-right: 0;
  margin-left: 1rem;
}

html[dir="rtl"] .pr-1 {
  padding-right: 0;
  padding-left: 0.25rem;
}

html[dir="rtl"] .-left-8 {
  left: auto;
  right: -2rem;
}

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

html[dir="rtl"] .space-x-8 > :not([hidden]) ~ :not([hidden]) {
  margin-left: 0;
  margin-right: 2rem;
}

html[dir="rtl"] .fa-arrow-right,
html[dir="rtl"] .fa-arrow-left {
  transform: scaleX(-1);
}

/* 窄屏/窄平板下语言按钮贴近视口边缘，菜单从按钮内侧展开，避免长语言名被裁切。
   同时隐去「手动 · 」前缀，把有限宽度留给语言名本身。 */
@media (max-width: 1023px) {
  .lang-switch > summary .lang-mode {
    display: none;
  }

  .lang-switch > summary .lang-current {
    max-width: 140px;
  }

  .lang-menu {
    min-width: 176px;
  }
}
