/* Aipogeo Context Translate —— 后台样式 */

/* 五个页面的标题统一挂上插件图标，认页面比读标题快 */
.apgt-wrap h1::before {
	content: "";
	display: inline-block;
	width: 28px;
	height: 28px;
	margin-right: 9px;
	vertical-align: -6px;
	background: url(../images/logo-64.png) no-repeat center / contain;
}

.apgt-wrap .description {
	max-width: 900px;
}

.apgt-nav {
	margin-bottom: 16px;
}

/* 数字输入：WP 的 small-text 只有 50px，六位数的 max_tokens 会被数字微调箭头挤没 */
.apgt-wrap input.apgt-number {
	width: 130px;
}

.apgt-wrap input.apgt-number-sm {
	width: 80px;
}

/* 输入框 + 右侧按钮同一行：large-text 是 100% 宽，不这样按钮会被挤到下一行 */
.apgt-field-row {
	display: flex;
	align-items: center;
	gap: 6px;
	max-width: 900px;
}

.apgt-field-row input {
	flex: 1 1 auto;
}

.apgt-field-row .button {
	flex: 0 0 auto;
}

/* 接口地址定不出来时的提示（模型名认不出平台又没填地址） */
.apgt-endpoint-error {
	color: #b32d2e;
}

/* 勾选项下面缩进一级的子选项 */
.apgt-sub-option {
	display: inline-block;
	margin: 6px 0 0 24px;
}

/* 设置页里的旗帜示例 */
.apgt-flag-demo img {
	width: 22px;
	height: auto;
	margin-right: 4px;
	vertical-align: middle;
	border-radius: 2px;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, .08);
}

/* 跟在勾选项后面的行内小字段 */
.apgt-inline-field {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-left: 16px;
	padding-left: 16px;
	border-left: 1px solid #dcdcde;
}

.apgt-inline-field label {
	font-weight: 400;
}

/* 隐藏的表单字段（内容由 Ace 编辑器同步） */
.apgt-hidden-field {
	display: none;
}

/* 整块隐藏：URL 指令只在「翻译 URL 路径」开着时才显示 */
.apgt-hidden-block {
	display: none;
}

/* Ace 编辑区通用外观 */
.apgt-editor {
	border: 1px solid #c3c4c7;
	border-radius: 3px 3px 0 0;
	background: #fff;
	height: 420px;
}

.apgt-editor-prompt,
.apgt-editor-url-prompt {
	max-width: 900px;
}

/* 底部拖拽条：按住上下拖动改编辑区高度 */
.apgt-resizer {
	height: 12px;
	cursor: ns-resize;
	background: #f0f0f1;
	border: 1px solid #c3c4c7;
	border-top: 0;
	border-radius: 0 0 3px 3px;
	user-select: none;
}

.apgt-resizer::before {
	content: "";
	display: block;
	width: 42px;
	height: 2px;
	margin: 5px auto;
	background: #b0b3b8;
	border-radius: 1px;
}

.apgt-resizer:hover {
	background: #e6e7e8;
}

.apgt-resizer:hover::before,
.apgt-resizing .apgt-resizer::before {
	background: #2271b1;
}

/* 拖动过程中别让鼠标划过时选中页面文字 */
body.apgt-resizing {
	user-select: none;
	cursor: ns-resize;
}

/* ---------- 语言包管理 ---------- */

/* 下拉与「添加」按钮同一行居中对齐：Choices 的外层比原生 select 高一点，
   不对齐的话按钮会掉下去半行 */
.apgt-add-language {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 12px 0 24px;
}

.apgt-lang-table input[type="text"] {
	width: 100%;
}

.apgt-lang-table .apgt-col-lang {
	width: 140px;
}

.apgt-lang-table .apgt-col-dir,
.apgt-lang-table .apgt-col-hreflang {
	width: 110px;
}

.apgt-lang-table .apgt-col-area {
	width: 160px;
}

.apgt-lang-table .apgt-col-sort {
	width: 70px;
}

.apgt-lang-table .apgt-col-mode {
	width: 120px;
}

.apgt-lang-table .apgt-col-op {
	width: 70px;
	text-align: center;
}

.apgt-lang-table td {
	vertical-align: top;
}

/* ---------- 替换规则编辑窗口 ---------- */

body.apgt-modal-open {
	overflow: hidden;
}

.apgt-modal {
	position: fixed;
	inset: 0;
	z-index: 100100;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.apgt-modal[hidden] {
	display: none;
}

.apgt-modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, .5);
}

.apgt-modal-box {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 900px;
	max-height: 90vh;
	background: #fff;
	border-radius: 4px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, .3);
}

.apgt-modal-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 16px;
	border-bottom: 1px solid #dcdcde;
}

.apgt-modal-head h2 {
	margin: 0;
	font-size: 15px;
}

.apgt-modal-close {
	border: 0;
	background: none;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	color: #646970;
	padding: 0 4px;
}

.apgt-modal-close:hover {
	color: #d63638;
}

.apgt-modal-body {
	padding: 16px;
	overflow-y: auto;
}

.apgt-modal-foot {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 8px;
	padding: 12px 16px;
	border-top: 1px solid #dcdcde;
}

.apgt-modal-msg {
	margin-right: auto;
	font-size: 12px;
	color: #50575e;
}

.apgt-modal-msg-error {
	color: #d63638;
	font-weight: 600;
}

.apgt-rules-table .apgt-col-rtype {
	width: 130px;
}

.apgt-rules-table .apgt-col-rop {
	width: 60px;
	text-align: center;
}

.apgt-rules-table input[type="text"],
.apgt-rules-table select {
	width: 100%;
}

.apgt-rules-table td {
	vertical-align: middle;
}

.apgt-rules-table .apgt-rule-search {
	font-family: Consolas, Monaco, monospace;
}

.apgt-rule-check {
	display: none;
	margin-left: 6px;
	font-weight: 700;
}

.apgt-rule-check.is-ok {
	color: #00a32a;
}

.apgt-rule-check.is-bad {
	color: #d63638;
}

.apgt-rules-empty {
	color: #646970;
}

/* ---------- 译文数据 ---------- */

.apgt-filters {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 10px 14px;
	padding: 12px;
	margin: 12px 0;
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 3px;
}

.apgt-filters label {
	display: flex;
	flex-direction: column;
	gap: 3px;
	font-size: 12px;
	color: #50575e;
}

.apgt-filters label span {
	font-weight: 600;
}

.apgt-filters input[type="search"] {
	width: 180px;
}

.apgt-filters .apgt-filter-check {
	flex-direction: row;
	align-items: center;
	gap: 5px;
	font-size: 13px;
	color: #1d2327;
}

.apgt-filters .apgt-filter-actions {
	display: flex;
	gap: 6px;
	margin-left: auto;
}

/* paginate_links 生成的是裸 <a>，默认点击区只有文字那么大，这里放大成按钮 */
.apgt-data-wrap .tablenav {
	height: auto;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin: 8px 0;
	padding: 0;
}

.apgt-data-wrap .tablenav .actions {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0;
	float: none;
}

.apgt-data-wrap .tablenav-pages {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px;
	float: none;
	margin: 0;
	height: auto;
}

.apgt-data-wrap .tablenav-pages .displaying-num {
	margin-right: 6px;
	color: #50575e;
}

.apgt-data-wrap .tablenav-pages .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-width: 34px;
	height: 34px;
	padding: 0 10px;
	border: 1px solid #c3c4c7;
	border-radius: 3px;
	background: #fff;
	color: #2271b1;
	font-size: 13px;
	line-height: 1;
	text-decoration: none;
}

.apgt-data-wrap .tablenav-pages a.page-numbers:hover,
.apgt-data-wrap .tablenav-pages a.page-numbers:focus {
	background: #f0f0f1;
	border-color: #8c8f94;
	color: #135e96;
}

.apgt-data-wrap .tablenav-pages a.page-numbers:focus {
	box-shadow: 0 0 0 1px #2271b1;
	outline: 2px solid transparent;
}

.apgt-data-wrap .tablenav-pages .page-numbers.current {
	background: #2271b1;
	border-color: #2271b1;
	color: #fff;
	font-weight: 600;
}

.apgt-data-wrap .tablenav-pages .page-numbers.dots {
	border-color: transparent;
	background: none;
	color: #646970;
	min-width: 20px;
	padding: 0 2px;
}

/* 底部只有分页，靠右排 */
.apgt-data-wrap .tablenav.bottom {
	justify-content: flex-end;
}

.apgt-data-table td {
	vertical-align: top;
}

.apgt-data-table .apgt-col-id {
	width: 60px;
}

.apgt-data-table .apgt-col-lang {
	width: 130px;
}

.apgt-data-table .apgt-col-engine,
.apgt-data-table .apgt-col-type {
	width: 80px;
}

.apgt-data-table .apgt-col-src {
	width: 180px;
}

.apgt-data-table .apgt-col-op {
	width: 60px;
	text-align: center;
}

/* height:1px 让单元格里的 height:100% 有个可参照的基准——表格单元格会把
   height 当成 min-height，实际仍由内容撑开，于是 textarea 正好填满整格。 */
.apgt-data-table td.apgt-cell-text {
	height: 1px;
}

.apgt-data-table textarea {
	display: block;
	width: 100%;
	height: 100%;
	/* 两行：18px 行高 × 2 + 上下内边距 6px + 边框 2px */
	min-height: 44px;
	box-sizing: border-box;
	font-size: 12px;
	line-height: 1.5;
	resize: vertical;
	transition: height .15s ease;
}

.apgt-data-table textarea.apgt-data-source {
	background: #f6f7f7;
	color: #50575e;
	resize: none;
}

/* 编辑时临时撑高的那一对，别再跟着单元格走 */
.apgt-data-table textarea.is-expanded {
	height: auto;
}

.apgt-data-table .apgt-arrow {
	color: #a7aaad;
}

.apgt-badge {
	display: inline-block;
	padding: 1px 7px;
	font-size: 11px;
	border-radius: 9px;
	background: #f0f0f1;
	color: #50575e;
}

.apgt-badge-ai {
	background: #e8f0fb;
	color: #2271b1;
}

.apgt-badge-manual {
	background: #edfaef;
	color: #007017;
}

.apgt-save-status {
	display: inline-block;
	margin-top: 2px;
	font-size: 11px;
	color: #646970;
}

.apgt-save-status.is-ok {
	color: #00a32a;
}

.apgt-save-status.is-bad {
	color: #d63638;
}

.apgt-muted {
	color: #a7aaad;
}

/* ---------- 页面翻译 ---------- */

.apgt-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 12px;
	margin-bottom: 10px;
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 3px;

	/* 工具栏在编辑区之前，默认会被后面的 Ace 盖住；
	   抬到 Ace 之上，展开的下拉才不会被行号列挡掉 */
	position: relative;
	z-index: 20;
}

/* 左区吃掉所有剩余宽度，页面下拉跟着变宽；标签与勾选项不参与压缩，避免换行 */
.apgt-toolbar-left {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	gap: 8px;
	flex: 1 1 auto;
	min-width: 0;
}

.apgt-toolbar-left label {
	font-weight: 600;
	flex: 0 0 auto;
	white-space: nowrap;
}

.apgt-toolbar-left select {
	flex: 0 0 auto;
	max-width: 240px;
}

.apgt-toolbar-left .apgt-skip {
	font-weight: 400;
	margin-left: 4px;
}

.apgt-toolbar-right {
	display: flex;
	gap: 8px;
	flex: 0 0 auto;
}

/* 窄屏放开换行，宁可折行也别把下拉挤成一条缝 */
@media screen and (max-width: 960px) {
	.apgt-toolbar-left {
		flex-wrap: wrap;
	}
}

/* Choices 的 CSS 假设全局 border-box；WP 后台没给普通 div 设，
   width:100% 加上 padding/border 会撑出容器，右边框看不见 */
.apgt-wrap .choices,
.apgt-wrap .choices * {
	box-sizing: border-box;
}

/* Choices 默认是 16px/44px 的独立控件尺寸，压到 WP 后台的表单密度 */
.apgt-wrap .choices {
	margin-bottom: 0;
	font-size: 13px;
}

/* 页面翻译页的工具条是 flex 行，下拉占满剩余宽度 */
.apgt-toolbar .choices {
	flex: 1 1 auto;
	min-width: 220px;
}

/* 设置页 / 语言管理页的语言下拉：定宽，Choices 的外层是块级 div，
   不套一层就会铺满整行 */
.apgt-select-search {
	display: inline-block;
	vertical-align: middle;
	width: 320px;
	max-width: 100%;
}

.apgt-select-search .choices,
.apgt-select-search select {
	width: 100%;
}

.apgt-wrap .choices__inner {
	width: 100%;
	min-height: 30px;
	padding: 3px 6px;
	background: #fff;
	border: 1px solid #8c8f94;
	border-radius: 3px;
	font-size: 13px;
}

.apgt-wrap .choices[data-type*="select-one"] .choices__inner {
	padding-bottom: 3px;
}

.apgt-wrap .choices__list--single {
	padding: 2px 16px 2px 4px;
}

/* 选中的长标题截断，别把控件顶宽 */
.apgt-wrap .choices__list--single .choices__item {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.apgt-wrap .choices.is-focused .choices__inner,
.apgt-wrap .choices.is-open .choices__inner {
	border-color: #2271b1;
	box-shadow: 0 0 0 1px #2271b1;
}

/* Choices 自带的是 z-index:1，压不过 Ace 的行号列 */
.apgt-wrap .choices__list--dropdown {
	border-color: #8c8f94;
	z-index: 30;
}

/* 语言下拉的菜单按最长的那一项展开，不跟着控件的 320px 走：Choices 自带的是
   width:100%，语言名一长就只能挤在里面。控件多窄菜单都不会更窄，最宽到 480px
   为止。滚动条那一条宽度先留出来，免得内容被挤出一条横向滚动条来。

   滚动从里层的列表挪到菜单本身：里层一旦是滚动容器，它对宽度的贡献就算 0，
   外面的 max-content 只会量到搜索框那么宽，等于没写。搜索框改为吸顶，
   滚动条挪出去之后它照样留在原地。 */
.apgt-select-search .choices__list--dropdown {
	width: max-content;
	min-width: 100%;
	max-width: min(480px, 90vw);
	max-height: 340px;
	overflow-x: hidden;
	overflow-y: auto;
	scrollbar-gutter: stable;
}

.apgt-select-search .choices__list--dropdown .choices__list {
	max-height: none;
	overflow: visible;
}

.apgt-select-search .choices__list--dropdown .choices__input {
	position: sticky;
	top: 0;
	z-index: 1;
}

.apgt-wrap .choices__list--dropdown .choices__item {
	padding: 6px 10px;
	font-size: 13px;
	word-break: normal;
}

/* itemSelectText 已置空，把给它预留的右侧空白收回来 */
.apgt-wrap .choices__list--dropdown .choices__item--selectable {
	padding-right: 10px;
}

.apgt-wrap .choices__list--dropdown .choices__item--selectable.is-highlighted {
	background-color: #f0f6fc;
}

.apgt-wrap .choices__heading {
	padding: 6px 10px;
	font-size: 12px;
	color: #646970;
	border-bottom-color: #f0f0f1;
}

.apgt-wrap .choices[data-type*="select-one"] .choices__input {
	padding: 6px 8px;
	font-size: 13px;
	background: #fff;
	border-bottom-color: #dcdcde;
}

/* 打开原页面 / 译文页面的图标按钮 */
.apgt-page-links {
	display: inline-flex;
	gap: 4px;
	flex: 0 0 auto;
}

.apgt-icon-button {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	width: 30px;
	padding: 0 !important;
	line-height: 1;
}

.apgt-icon-button .dashicons {
	width: 16px;
	height: 16px;
	font-size: 16px;
}

.apgt-icon-button.disabled {
	pointer-events: none;
	opacity: .5;
}

/* 全部翻译的进度区 */
.apgt-progress {
	padding: 10px 12px;
	margin-bottom: 10px;
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 3px;
}

.apgt-progress-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 6px;
}

.apgt-progress-text {
	font-weight: 600;
}

.apgt-progress-bar {
	height: 10px;
	background: #f0f0f1;
	border-radius: 5px;
	overflow: hidden;
}

.apgt-progress-fill {
	display: block;
	width: 0;
	height: 100%;
	background: #2271b1;
	transition: width .2s ease;
}

.apgt-progress-current {
	margin-top: 6px;
	color: #50575e;
	font-size: 12px;
}

/* 同时翻译的几个页面各占一行。 */
.apgt-progress-line {
	padding: 2px 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.apgt-progress-errors {
	margin: 8px 0 0;
	max-height: 160px;
	overflow-y: auto;
	font-size: 12px;
}

.apgt-progress-errors li {
	margin: 0 0 4px;
	padding: 4px 8px;
	background: #fcf0f1;
	border-left: 3px solid #d63638;
	color: #50575e;
	word-break: break-word;
}

.apgt-status {
	display: flex;
	align-items: center;
	min-height: 24px;
	margin-bottom: 8px;
}

.apgt-status .apgt-status-text {
	color: #50575e;
}

.apgt-status .apgt-status-text.apgt-status-error {
	color: #b32d2e;
	font-weight: 600;
}

.apgt-status .spinner {
	float: none;
	margin: 0 0 0 8px;
}

.apgt-panes {
	display: flex;
	gap: 12px;
	align-items: stretch;
}

.apgt-pane {
	flex: 1 1 50%;
	min-width: 0;
	display: flex;
	flex-direction: column;
}

.apgt-pane-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px;
	padding: 6px 8px;
	background: #f0f0f1;
	border: 1px solid #c3c4c7;
	border-bottom: 0;
	border-radius: 3px 3px 0 0;
	font-weight: 600;
}

.apgt-pane-hint {
	font-weight: 400;
	font-size: 12px;
	color: #646970;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 60%;
}

.apgt-pane .apgt-editor {
	border-radius: 0;
	height: 460px;
}

/* 窄屏改为上下排列 */
@media screen and (max-width: 1100px) {
	.apgt-panes {
		flex-direction: column;
	}

	.apgt-panes .apgt-pane:first-child {
		margin-bottom: 12px;
	}
}

/* 使用说明页 */
.apgt-help {
	max-width: 1000px;
}

.apgt-help h2 {
	margin: 28px 0 8px;
	padding-bottom: 6px;
	border-bottom: 1px solid #dcdcde;
	font-size: 16px;
}

.apgt-help h3 {
	margin: 22px 0 6px;
	font-size: 14px;
}

.apgt-help-lead {
	max-width: 860px;
	color: #50575e;
}

.apgt-help-table {
	margin: 8px 0 4px;
}

.apgt-help-table td,
.apgt-help-table th {
	vertical-align: top;
	line-height: 1.7;
}

.apgt-help-table code {
	white-space: nowrap;
}

.apgt-help-list {
	max-width: 860px;
	list-style: disc;
	margin-left: 20px;
	line-height: 1.8;
}

.apgt-help-code {
	margin: 8px 0;
	padding: 12px 14px;
	background: #f6f7f7;
	border: 1px solid #dcdcde;
	border-left: 3px solid #2271b1;
	border-radius: 3px;
	overflow-x: auto;
	line-height: 1.6;
}

/* ── AI 服务：按「翻译请求走哪里」只留下相关的那组配置 ──────────────
   四种选择要填的东西完全不一样：订阅服务只要一个访问密钥；站点级 AI 的
   提供方与密钥在 WordPress 自己那儿；只有走自己的 AI 账号才需要模型、
   接口地址、API Key 这一串。全摆出来对新手是噪音，按当前选择收起来。

   显隐走 data-provider 而不是 JS 直接改 style：PHP 渲染时就带着正确的值，
   页面不会先闪一下无关的表单项，JS 只负责在切换时更新这个属性。 */
#apgt-ai-table[data-provider="service"] .apgt-row--own-ai,
#apgt-ai-table[data-provider="service"] .apgt-row--ai-param,
#apgt-ai-table[data-provider="core"] .apgt-row--own-ai,
#apgt-ai-table[data-provider="core"] .apgt-row--service,
#apgt-ai-table[data-provider=""] .apgt-row--service,
#apgt-ai-table[data-provider="plugin"] .apgt-row--service {
	display: none;
}
