/* ============================================================
   多语言切换（ISSUE #49）
   - 顶栏语言按钮复用 .search-btn 圆形样式
   - 下拉面板与移动端语言列表
   - 翻译蒙层（进度 / 成功 / 失败）与自动切换提示条
   ============================================================ */

.i18n-switch { position: relative; flex-shrink: 0; }
.i18n-btn { position: relative; }

.i18n-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1000;
  min-width: 176px;
  background: #fff;
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .12);
  padding: 6px;
  display: flex;
  flex-direction: column;
}
/* hidden 属性需强制覆盖上面的 display:flex，否则面板常显 */
.i18n-panel[hidden] { display: none !important; }

/* 面板顶部「当前语言」说明 */
.i18n-panel-current {
  padding: 6px 12px 8px;
  font-size: .74rem;
  color: var(--muted, #64748b);
  border-bottom: 1px solid var(--color-border, #e2e8f0);
  margin-bottom: 4px;
  white-space: nowrap;
}

.i18n-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: .9rem;
  color: var(--color-text-primary, #0f172a);
  cursor: pointer;
  transition: background .15s ease;
  white-space: nowrap;
}
.i18n-option:hover:not(:disabled) { background: var(--bg-alt, #f1f5f9); }
.i18n-option.active {
  background: var(--color-primary-soft, #eef2ff);
  color: var(--color-primary, #1d4ed8);
  font-weight: 600;
}
/* 翻译进行中：禁用所有选项，防重复点击打多轮请求 */
.i18n-option:disabled { opacity: .45; cursor: not-allowed; }

/* 移动端全屏菜单里的语言列表 */
.i18n-mobile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border, #e2e8f0);
  width: 100%;
}
.i18n-mobile-link {
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}
.i18n-mobile-link.active { color: var(--color-primary, #1d4ed8); font-weight: 600; }
.i18n-mobile-link:disabled { opacity: .45; cursor: not-allowed; }

/* RTL 兜底：阿拉伯语时正文容器方向 */
html[dir="rtl"] body { direction: rtl; }

/* ---------------- 翻译蒙层 ---------------- */
.i18n-mask {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 1;
  transition: opacity .18s ease;
}
.i18n-mask[hidden] { display: none !important; }

.i18n-mask-box {
  width: min(340px, 86vw);
  padding: 28px 26px 24px;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .25);
  text-align: center;
  color: var(--color-text-primary, #0f172a);
}
.i18n-mask-title {
  margin-top: 14px;
  font-size: .98rem;
  font-weight: 600;
  line-height: 1.5;
}
.i18n-mask-detail {
  margin-top: 6px;
  font-size: .8rem;
  color: var(--muted, #64748b);
}
.i18n-mask-progress {
  margin-top: 16px;
  height: 5px;
  border-radius: 999px;
  background: var(--bg-alt, #e2e8f0);
  overflow: hidden;
}
.i18n-mask-progress > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--color-primary, #1d4ed8);
  transition: width .2s ease;
}
.i18n-mask-actions {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  justify-content: center;
}
.i18n-mask-actions[hidden] { display: none !important; }
.i18n-mask-btn {
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--color-primary, #1d4ed8);
  color: #fff;
}
.i18n-mask-btn-ghost {
  background: var(--bg-alt, #f1f5f9);
  color: var(--color-text-primary, #0f172a);
}

.i18n-spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid var(--bg-alt, #e2e8f0);
  border-top-color: var(--color-primary, #1d4ed8);
  animation: i18n-spin .8s linear infinite;
}
@keyframes i18n-spin { to { transform: rotate(360deg); } }

/* 失败态：隐藏 spinner 与进度，标题改红 */
.i18n-mask-error .i18n-spinner { display: none; }
.i18n-mask-error .i18n-mask-title { color: #b91c1c; margin-top: 0; }
.i18n-mask-error .i18n-mask-progress { display: none; }
.i18n-mask-done .i18n-spinner { display: none; }
.i18n-mask-done .i18n-mask-progress { display: none; }
.i18n-mask-done .i18n-mask-title { color: var(--color-primary, #1d4ed8); margin-top: 0; }
.i18n-mask-done .i18n-mask-title::before {
  content: "✓";
  display: inline-block;
  margin-right: 6px;
  font-weight: 700;
}

/* 非阻塞轻提示：页面加载时的翻译失败等，自动消失，不打断浏览 */
.i18n-notice-warn {
  background: rgba(146, 64, 14, .95);
  bottom: 28px;
}
.i18n-notice-warn button[data-i18n-toast-retry] {
  background: #fff;
  color: #92400e;
  font-weight: 600;
}
.i18n-notice-warn button[data-i18n-toast-retry]:hover { background: #fef3c7; }

/* ---------------- 自动切换提示条 ---------------- */
.i18n-notice {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 10001;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, .93);
  color: #fff;
  font-size: .84rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .3);
}
.i18n-notice button {
  border: 0;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: .8rem;
  cursor: pointer;
  font-family: inherit;
}
.i18n-notice button:hover { background: rgba(255, 255, 255, .28); }
.i18n-notice-close { padding: 4px 8px !important; }

/* 金额 / 电话 / 型号等短标识不参与翻译，避免机器翻译改写 */
.i18n-keep { unicode-bidi: isolate; }

@media (prefers-reduced-motion: reduce) {
  .i18n-spinner { animation-duration: 2s; }
}
