/**
 * AI 翻译 Pro · 前端样式：语言切换器（v2.0.2 全新卡片式外观）/ loading
 * 配色通过 CSS 变量注入：--wtp-c 主色 / --wtp-ch 悬浮色 / --wtp-c-soft 主色浅底
 */

:root {
	--wtp-c: #2c6ecf;
	--wtp-ch: #1e56b0;
	--wtp-c-soft: rgba(44, 110, 207, .12);
	--wtp-ink: #1f2937;
	--wtp-mute: #9ca3af;
	--wtp-line: #eef0f3;
	--wtp-card-shadow: 0 12px 32px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .06);
}

/* ==========================================================
   语言切换器 · 卡片式下拉
   主题兼容加固：切换器会嵌入主题导航菜单，主题对 li/a 的样式
   （display:block、边框分隔线、当前项高亮等）会渗透进面板，
   因此组件内部关键属性使用作用域限定 + !important 防覆盖。
   ========================================================== */

.wtp-sw,
.wtp-sw * {
	box-sizing: border-box;
}

.wtp-sw ul,
.wtp-sw li {
	list-style: none !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	background: transparent !important;
	float: none !important;
}

/* ---------- 旗帜 ---------- */

.wtp-sw .wtp-sw-flag {
	display: block !important;
	width: 24px !important;
	height: 18px !important;
	object-fit: cover;
	border-radius: 4px;
	border: 1px solid rgba(16, 24, 40, .1);
	box-shadow: 0 0 0 1px rgba(255, 255, 255, .6) inset;
	flex-shrink: 0;
	float: none !important;
	margin: 0 !important;
}

.wtp-sw .wtp-sw-flag-globe {
	color: var(--wtp-mute);
	background: #f6f7f8;
	border-radius: 50%;
	border: 0;
}

/* ---------- 列表项 ---------- */

.wtp-sw a.wtp-sw-link {
	display: flex !important;
	align-items: center !important;
	gap: 9px !important;
	padding: 9px 10px;
	font-size: 14px;
	line-height: 1.35 !important;
	color: var(--wtp-ink) !important;
	text-decoration: none !important;
	border-radius: 9px;
	border: 0 !important;
	box-shadow: none !important;
	float: none !important;
	width: 100%;
	min-width: 0;
	white-space: nowrap;
	transition: background .15s ease, color .15s ease;
}

.wtp-sw .wtp-sw-name {
	flex: 1 1 auto;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.wtp-sw .wtp-sw-mark {
	flex-shrink: 0;
	color: var(--wtp-c);
}

.wtp-sw .wtp-sw-mark.wtp-sw-ext {
	color: var(--wtp-mute);
	transition: color .15s ease, transform .15s ease;
}

.wtp-sw a.wtp-sw-link:hover,
.wtp-sw a.wtp-sw-link:focus-visible {
	background: #f4f5f7 !important;
	color: var(--wtp-ink) !important;
	text-decoration: none !important;
	outline: none !important;
}

.wtp-sw a.wtp-sw-link:hover .wtp-sw-mark.wtp-sw-ext {
	color: var(--wtp-c);
	transform: translate(1px, -1px);
}

/* 当前语言：浅色高亮 + 主题色文字 + 对勾（防主题"当前菜单项"实心底色渗透） */
.wtp-sw a.wtp-sw-link.wtp-cur,
.wtp-sw a.wtp-sw-link.wtp-cur:hover,
.wtp-sw a.wtp-sw-link.wtp-cur:focus-visible {
	background: var(--wtp-c-soft) !important;
	color: var(--wtp-c) !important;
	font-weight: 600;
}

/* ---------- 下拉容器 ---------- */

.wtp-sw-dropdown {
	position: relative;
	display: inline-block;
}

.wtp-sw-dropdown .wtp-sw-list {
	display: none;
	position: absolute;
	z-index: 99999;
	top: 100%;
	left: 0;
	width: 384px;
	max-width: calc(100vw - 32px);
	margin-top: 8px;
	padding: 6px;
	background: #fff !important;
	border: 1px solid var(--wtp-line) !important;
	border-radius: 14px !important;
	box-shadow: var(--wtp-card-shadow) !important;
	transform-origin: top left;
	animation: wtp-pop .16s ease;
	/* 两列网格：20 种语言折半高度，天然容纳于视口 */
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 2px 8px;
	/* 限高滚动兜底（防主题覆盖 overflow/max-height） */
	max-height: min(460px, calc(100vh - 140px)) !important;
	overflow-y: auto !important;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	scrollbar-color: #d0d3d8 transparent;
}

.wtp-sw-dropdown .wtp-sw-list::-webkit-scrollbar {
	width: 6px;
}

.wtp-sw-dropdown .wtp-sw-list::-webkit-scrollbar-thumb {
	background: #d0d3d8;
	border-radius: 3px;
}

.wtp-sw-dropdown:hover > .wtp-sw-list,
.wtp-sw-dropdown:focus-within > .wtp-sw-list,
.wtp-sw-dropdown.wtp-open > .wtp-sw-list {
	display: grid !important;
}

/* 窄屏退化为单列 */
@media (max-width: 520px) {
	.wtp-sw-dropdown .wtp-sw-list {
		grid-template-columns: 1fr;
		width: 264px;
	}
}

@keyframes wtp-pop {
	from { opacity: 0; transform: translateY(-5px) scale(.98); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* 菜单内靠右展开，避免溢出屏幕 */
.wtp-sw-menu-item .wtp-sw-dropdown > .wtp-sw-list {
	left: auto;
	right: 0;
	transform-origin: top right;
}

/* 防主题导航容器 overflow:hidden 裁剪面板：
   仅对「直接包含切换器菜单项」的菜单容器放行 overflow（:has() 旧浏览器自动忽略，优雅降级） */
ul:has(> li.wtp-sw-menu-item) {
	overflow: visible !important;
}

/* ---------- 触发按钮（当前语言） ---------- */

.wtp-sw .wtp-sw-btn {
	display: inline-flex !important;
	align-items: center !important;
	gap: 9px !important;
	padding: 8px 12px;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.3 !important;
	color: var(--wtp-ink) !important;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
	cursor: pointer;
	white-space: nowrap;
	transition: border-color .15s ease, box-shadow .15s ease;
}

.wtp-sw .wtp-sw-btn:hover,
.wtp-sw .wtp-sw-btn:focus-visible {
	border-color: var(--wtp-c);
	box-shadow: 0 0 0 3px var(--wtp-c-soft);
	outline: none;
}

.wtp-sw .wtp-sw-btn .wtp-sw-name {
	white-space: nowrap;
}

.wtp-sw .wtp-sw-btn .wtp-sw-flag {
	width: 22px !important;
	height: 17px !important;
}

.wtp-sw .wtp-sw-caret {
	color: var(--wtp-mute);
	flex-shrink: 0;
	transition: transform .18s ease;
}

.wtp-sw-dropdown.wtp-open .wtp-sw-caret,
.wtp-sw-dropdown:hover .wtp-sw-caret {
	transform: rotate(180deg);
}

/* ---------- 横排样式 ---------- */

.wtp-sw-inline .wtp-sw-list {
	position: static;
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	align-items: center;
	min-width: 0;
	padding: 0;
	background: transparent;
	border: 0;
	box-shadow: none;
	animation: none;
}

.wtp-sw-inline .wtp-sw-link {
	padding: 7px 11px;
	border: 1px solid transparent;
}

.wtp-sw-inline .wtp-sw-mark {
	display: none;
}

/* ---------- 页脚位 ---------- */

.wtp-sw-footer-wrap {
	text-align: center;
	padding: 8px 0;
}

/* 面板左对齐（translateX 居中会与展开动画的 transform 冲突） */
.wtp-sw-footer-wrap .wtp-sw-dropdown .wtp-sw-list {
	left: 0;
	right: auto;
}

/* ==========================================================
   悬浮球
   ========================================================== */

.wtp-float {
	position: fixed;
	bottom: 24px;
	z-index: 99998;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.wtp-float-right { right: 24px; }
.wtp-float-left { left: 24px; }

.wtp-float-btn {
	width: 54px;
	height: 54px;
	display: flex !important;
	align-items: center !important;
	justify-content: center;
	background: #fff;
	border: 1px solid var(--wtp-line);
	border-radius: 50%;
	box-shadow: 0 8px 24px rgba(16, 24, 40, .18);
	cursor: pointer;
	padding: 0;
	transition: transform .15s ease, box-shadow .15s ease;
}

.wtp-float-btn:hover,
.wtp-float-btn:focus-visible {
	transform: scale(1.06);
	box-shadow: 0 10px 28px rgba(16, 24, 40, .24);
	outline: none;
}

.wtp-float-btn .wtp-sw-flag {
	width: 28px !important;
	height: 21px !important;
}

.wtp-float-panel {
	display: none;
	position: absolute;
	bottom: 64px;
	right: 0;
	min-width: 200px;
}

.wtp-float.wtp-flip-v .wtp-float-panel {
	bottom: auto !important;
	top: 64px !important;
}

.wtp-float.wtp-flip-h .wtp-float-panel {
	right: auto !important;
	left: 0 !important;
}

.wtp-float.wtp-dragging,
.wtp-float.wtp-dragging .wtp-float-btn {
	transition: none !important;
}

.wtp-float.wtp-dragging .wtp-float-btn {
	cursor: grabbing !important;
	user-select: none !important;
}

.wtp-float:hover .wtp-float-panel,
.wtp-float:focus-within .wtp-float-panel,
.wtp-float.wtp-open .wtp-float-panel {
	display: block;
}

/* 面板内的列表恢复静态布局（覆盖 dropdown 的 absolute）+ 两列网格 + 限高滚动 */
.wtp-float-panel .wtp-sw-list {
	position: static !important;
	display: grid !important;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	width: 384px;
	max-width: calc(100vw - 48px);
	min-width: 0 !important;
	margin: 0 !important;
	box-shadow: var(--wtp-card-shadow) !important;
	animation: none !important;
	max-height: min(460px, calc(100vh - 170px)) !important;
	overflow-y: auto !important;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	scrollbar-color: #d0d3d8 transparent;
}

@media (max-width: 520px) {
	.wtp-float-panel .wtp-sw-list {
		grid-template-columns: 1fr;
		width: 264px;
	}
}

/* ==========================================================
   （v2.3 起前台完全静默直读数据表，翻译 loading UI 已移除）
   ========================================================== */

/* ==========================================================
   RTL（阿拉伯语等从右向左）下切换器自适应
   ========================================================== */

html[dir="rtl"] .wtp-sw-link {
	flex-direction: row;
}

html[dir="rtl"] .wtp-sw-dropdown > .wtp-sw-list {
	left: auto;
	right: 0;
	transform-origin: top right;
}

html[dir="rtl"] .wtp-sw-menu-item .wtp-sw-dropdown > .wtp-sw-list {
	right: auto;
	left: 0;
}

html[dir="rtl"] .wtp-sw-footer-wrap .wtp-sw-dropdown .wtp-sw-list {
	left: 50%;
	right: auto;
}

html[dir="rtl"] .wtp-float-right {
	right: auto;
	left: 24px;
}

html[dir="rtl"] .wtp-float-left {
	left: auto;
	right: 24px;
}

html[dir="rtl"] .wtp-float-panel {
	right: auto;
	left: 0;
}
