/* ==========================================================================
 * i18n.css — 语言切换器 + 阿拉伯语 RTL 适配
 * 全部规则仅作用于 .lang-switcher 与 [dir="rtl"] 状态，不影响原有布局。
 * ========================================================================== */

/* ---------- 字体栈：中文 / 阿拉伯语 ---------- */
:root{
  --font-cjk: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  --font-ar:  "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
}
html[lang^="zh"] body,
html[lang^="zh"] input,
html[lang^="zh"] button,
html[lang^="zh"] select,
html[lang^="zh"] textarea{ font-family:"Inter","Noto Sans SC","PingFang SC","Microsoft YaHei",sans-serif; }
html[lang="ar"] body,
html[lang="ar"] input,
html[lang="ar"] button,
html[lang="ar"] select,
html[lang="ar"] textarea{ font-family:"Noto Sans Arabic","Inter",Tahoma,sans-serif; }

/* ---------- 语言切换器 ---------- */
.lang-switcher{ position:relative; margin-right:0.5rem; -webkit-user-select:none; user-select:none; }
.lang-switcher-btn{
  display:inline-flex; align-items:center; gap:5px;
  background:var(--bg); border:1px solid var(--border-light); border-radius:8px;
  padding:0.35rem 0.5rem; cursor:pointer;
  font-size:0.7rem; font-weight:600; color:var(--text-secondary);
  font-family:inherit; transition:border-color 0.2s, color 0.2s;
}
.lang-switcher-btn:hover{ border-color:var(--navy); color:var(--text); }
.lang-switcher-btn svg{ opacity:0.6; }
.lang-switcher.btn .lang-switcher-btn{ }
.lang-switcher-menu{
  position:absolute; top:calc(100% + 8px); right:0;
  min-width:150px; background:var(--bg);
  border:1px solid var(--border-light); border-radius:8px;
  box-shadow:0 12px 32px rgba(10,16,26,0.14);
  padding:0.35rem; display:flex; flex-direction:column; gap:2px;
  opacity:0; pointer-events:none; visibility:hidden; z-index:120;
  transform:translateY(-4px);
  transition:opacity 0.16s ease, transform 0.16s ease, visibility 0s linear 0.16s;
}
.lang-switcher.open .lang-switcher-menu{
  opacity:1; pointer-events:auto; visibility:visible;
  transform:translateY(0); transition:opacity 0.16s ease, transform 0.16s ease, visibility 0s linear 0s;
}
.lang-switcher-item{
  display:flex; align-items:center; gap:8px;
  padding:0.5rem 0.7rem; border-radius:6px;
  font-size:0.78rem; color:var(--text-secondary);
  text-decoration:none; cursor:pointer;
  transition:background 0.15s, color 0.15s;
}
.lang-switcher-item:hover{ background:rgba(15,30,46,0.05); color:var(--text); }
.lang-switcher-item.is-active{ color:var(--navy); font-weight:600; }
.lang-switcher-item .lang-native{ margin-left:auto; font-size:0.68rem; color:var(--text-muted); font-weight:400; }
.lang-switcher-item.is-active .lang-native{ color:var(--navy); }
.lang-switcher .lang-code{
  font-size:0.62rem; font-weight:700; letter-spacing:0.04em;
  color:var(--text-muted); min-width:20px; text-align:center;
}
.lang-switcher-item.is-active .lang-code{ color:var(--navy); }

/* 移动端菜单内呈现（无需额外处理，随 header-right 显示） */
@media(max-width:768px){
  .lang-switcher{ margin-right:0.25rem; }
  .lang-switcher-btn span.lang-switcher-btn-text{ display:none; }
}

/* ---------- RTL 通用修正 ---------- */
[dir="rtl"] .header-search{ margin-right:0; margin-left:0.5rem; }
[dir="rtl"] .nav-dropdown-panel{ left:auto; right:50%; transform:translateX(50%) translateY(-4px); }
[dir="rtl"] .nav-dropdown:hover .nav-dropdown-panel,
[dir="rtl"] .nav-dropdown:focus-within .nav-dropdown-panel,
[dir="rtl"] .nav-dropdown.open .nav-dropdown-panel{ transform:translateX(50%) translateY(0); }
[dir="rtl"] nav .nav-cta{ margin-left:0; margin-right:0.5rem; }
[dir="rtl"] .nav-caret{ transform:rotate(180deg); }
[dir="rtl"] .nav-dropdown:hover .nav-caret,
[dir="rtl"] .nav-dropdown:focus-within .nav-caret,
[dir="rtl"] .nav-dropdown.open .nav-caret{ transform:rotate(0deg); }

/* 轮播箭头镜像 */
[dir="rtl"] .hero-arrow-next{ right:auto; left:clamp(1rem,3vw,2rem); }
[dir="rtl"] .hero-arrow-prev{ left:auto; right:clamp(1rem,3vw,2rem); }

/* 滚动指示 / 返回顶部 / 阅读进度条 */
[dir="rtl"] .back-to-top{ right:auto; left:20px; }
[dir="rtl"] .reading-progress{ left:auto; right:0; }
[dir="rtl"] .hero-scroll svg{ transform:scaleX(-1); }

/* 面包屑分隔符（PbootCMS 渲染 "/" 会自动按 dir 对齐，无需处理） */

/* 侧边栏 / 内容布局镜像（sticky 侧栏在 RTL 下自动换边） */
[dir="rtl"] .article-layout{ direction:rtl; }
[dir="rtl"] .article-pager .pager-prev span.pager-label,
[dir="rtl"] .article-pager .pager-next span.pager-label{ unicode-bidi:isolate; }

/* 表单电话区号 select 与输入框保持 LTR（号码方向） */
[dir="rtl"] input[type="tel"],
[dir="rtl"] input[type="email"]{ direction:ltr; text-align:right; }

/* 浮动按钮（Telegram）位置镜像 */
[dir="rtl"] .whatsapp-float{ right:auto; left:1.25rem; }

/* 详情页弹窗 */
[dir="rtl"] .quote-modal-close{ right:auto; left:12px; }
[dir="rtl"] .lightbox-nav.prev{ left:auto; right:8px; }
[dir="rtl"] .lightbox-nav.next{ right:auto; left:8px; }
[dir="rtl"] .lightbox-close{ right:auto; left:20px; }

/* 通用文本方向 */
[dir="rtl"] .breadcrumb ol{ padding:0; }
[dir="rtl"] .timeline{ padding-inline-start:0; }
[dir="rtl"] ol.breadcrumb, [dir="rtl"] ul, [dir="rtl"] ol{ padding-inline-start:1.25rem; }

/* 数字与型号保持 LTR */
[dir="rtl"] .stat-num,
[dir="rtl"] .trust-stat-value,
[dir="rtl"] .product-spec-value,
[dir="rtl"] .series-card-stats,
[dir="rtl"] .series-chapter-stats,
[dir="rtl"] .fact-list dd,
[dir="rtl"] .hero-floating-spec{ unicode-bidi:isolate; direction:ltr; }

/* 首页旗舰产品卡：箭头与代码徽章镜像 */
[dir="rtl"] .product-featured-cta svg,
[dir="rtl"] .product-featured-cta{ flex-direction:row-reverse; }
[dir="rtl"] .product-featured-code{ letter-spacing:0; }

/* 移动端导航抽屉在 RTL 下 */
@media(max-width:900px){
  [dir="rtl"] #mainNav.open{ transform:translateX(0); }
}