/* 门户语言切换下拉 —— 由 PortalI18nElementProcessor 注入，模板零改动。
 *
 * 结构：
 *   details.portal-lang
 *     summary.portal-lang__trigger  → span.portal-lang__current（当前语言）+ CSS 箭头
 *     div.portal-lang__menu         → a.portal-lang__item × 3（当前项 .is-active）
 *
 * 定位：默认固定右下（无页头页面的兜底），脚本把它搬进页头操作区后加
 *       .portal-lang--inline 改为普通流内元素，避免浮层压住导航。
 */

.portal-lang {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 9999;
  font: 500 13px/1 "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
}

.portal-lang--inline {
  position: relative;
  top: auto;
  right: auto;
  z-index: 6;
}

/* ── 触发器：与相邻次级按钮同一视觉层级，不做高饱和填充 ───────────────── */
.portal-lang__trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 9px 0 10px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: #14231b;
  cursor: pointer;
  white-space: nowrap;
  list-style: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.portal-lang__trigger::-webkit-details-marker {
  display: none;
}

.portal-lang__trigger:hover {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.24);
}

.portal-lang__trigger:focus-visible {
  outline: 2px solid #1f6b4a;
  outline-offset: 2px;
}

/* 下拉箭头：纯 CSS 三角，展开时翻转 */
.portal-lang__trigger::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.6;
  transition: transform 0.18s ease;
}

.portal-lang[open] > .portal-lang__trigger::after {
  margin-top: 2px;
  transform: rotate(-135deg);
}

/* ── 菜单 ─────────────────────────────────────────────────────────────── */
.portal-lang__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  min-width: 148px;
  padding: 4px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16);
}

.portal-lang__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  color: #24352c;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

.portal-lang__item:hover {
  background: #f3f7f4;
  color: #123c29;
}

.portal-lang__item:focus-visible {
  outline: 2px solid #1f6b4a;
  outline-offset: -2px;
}

.portal-lang__item.is-active {
  background: #f1f7f3;
  color: #1f6b4a;
  font-weight: 600;
}

/* 当前项勾选标记 */
.portal-lang__item.is-active::after {
  content: "";
  width: 9px;
  height: 5px;
  margin-top: -3px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}

/* ── 移动端：与旁边「菜单」按钮同一形状，留在页头而非塞进面板 ─────────── */
@media (max-width: 860px) {
  .header-inner > .portal-lang .portal-lang__trigger {
    height: 34px;
    border-radius: 999px;
  }
  /* 后台页头没有「菜单」按钮，换行后把语言切换靠右放，不留在行首显得孤立 */
  .admin-body .header-inner > .portal-lang {
    margin-left: auto;
  }
}

/* 固定兜底位置在窄屏下让位给页脚，避免遮挡操作按钮 */
@media (max-width: 640px) {
  .portal-lang--floating {
    top: auto;
    bottom: 12px;
    right: 12px;
  }
}
