/**
 * AI Auto Translator — seletor de idiomas no site.
 *
 * O seletor aparece dentro do tema de terceiros, então herda a fonte do tema
 * e evita cores fortes: ele precisa parecer parte do site, não um enxerto do
 * plugin. As únicas cores próprias são um verdigris discreto no foco e no
 * indicador, para dar identidade sem competir com o design do tema.
 */

.aat-switcher-wrapper {
	--aat-sw-ink: #16233d;
	--aat-sw-accent: #2e7166;
	--aat-sw-rule: #d5d0c7;

	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.4;
	max-width: 100%;
}

.aat-switcher-label {
	font-weight: 600;
	color: inherit;
	white-space: nowrap;
}

.aat-language-select {
	/* Seta desenhada em CSS: sem imagem externa e acompanha a cor do texto. */
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;

	font-family: inherit;
	font-size: inherit;
	line-height: 1.4;
	color: inherit;

	padding: 6px 30px 6px 12px;
	border: 1px solid var(--aat-sw-rule);
	border-radius: 3px;
	background-color: #fff;
	background-image:
		linear-gradient(45deg, transparent 50%, currentColor 50%),
		linear-gradient(135deg, currentColor 50%, transparent 50%);
	background-position:
		calc(100% - 15px) calc(50% + 1px),
		calc(100% - 11px) calc(50% + 1px);
	background-size: 4px 4px, 4px 4px;
	background-repeat: no-repeat;

	cursor: pointer;
	max-width: 100%;
}

.aat-language-select:hover {
	border-color: #b9b2a6;
}

.aat-language-select:focus-visible {
	outline: 2px solid var(--aat-sw-accent);
	outline-offset: 1px;
	border-color: var(--aat-sw-accent);
}

/* Navegadores sem :focus-visible */
.aat-language-select:focus {
	border-color: var(--aat-sw-accent);
}

/* ---------------------------------------------------------------------------
   Posições da exibição automática
   --------------------------------------------------------------------------- */

/*
 * Flutuante: fica acima do conteúdo, então precisa de sombra para se separar
 * da página. É o único lugar do plugin onde a sombra se justifica.
 */
.aat-floating-switcher {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99990;
	padding: 8px 12px;
	background: #fff;
	border: 1px solid var(--aat-sw-rule, #d5d0c7);
	border-radius: 4px;
	box-shadow: 0 2px 12px rgba(22, 35, 61, 0.14);
}

/* Topo da página: uma faixa fina, alinhada à direita. */
.aat-header-switcher {
	display: flex;
	justify-content: flex-end;
	align-items: center;
	padding: 8px 20px;
	background: #fbfaf8;
	border-bottom: 1px solid #e2ded6;
}

/* Antes e depois do conteúdo: separado por régua, como uma nota editorial. */
.aat-before-content-switcher,
.aat-after-content-switcher {
	margin: 20px 0;
	padding: 12px 0;
	border-top: 1px solid #e2ded6;
	border-bottom: 1px solid #e2ded6;
}

/* Em telas estreitas o flutuante encolhe para não cobrir o conteúdo. */
@media screen and (max-width: 600px) {
	.aat-floating-switcher {
		right: 12px;
		bottom: 12px;
		padding: 6px 10px;
	}

	.aat-floating-switcher .aat-switcher-label {
		display: none;
	}

	.aat-header-switcher {
		padding: 6px 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.aat-switcher-wrapper * {
		transition: none !important;
	}
}

/* Modo escuro: só quando o tema declara suporte, para não destoar. */
@media (prefers-color-scheme: dark) {
	.aat-floating-switcher {
		background: #1c2130;
		border-color: #3a4152;
		box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
	}

	.aat-floating-switcher .aat-language-select {
		background-color: #262c3d;
		border-color: #3a4152;
		color: #eceef3;
	}
}

/* ---------------------------------------------------------------------------
   Modelos do seletor de idiomas
   --------------------------------------------------------------------------- */

.aat-switcher-wrapper {
	--aat-sw-ink: #1e293b;
	--aat-sw-muted: #64748b;
	--aat-sw-line: #cbd5e1;
	--aat-sw-bg: #ffffff;
	--aat-sw-accent: #2f5bea;
	--aat-sw-accent-tint: #eef2ff;
	font-size: 14px;
	line-height: 1.4;
}

/* Modelo 2: botões */
.aat-switcher-buttons {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 6px;
	vertical-align: middle;
	align-items: center;
}

/* Com mais idiomas do que cabem, vira um carrossel com setas. */
.aat-switcher-buttons.has-arrows {
	flex-wrap: nowrap;
	max-width: 100%;
}

.aat-switcher-buttons.has-arrows .aat-switcher-track {
	display: flex;
	gap: 6px;
	overflow: hidden;
	scroll-behavior: smooth;
	scrollbar-width: none;
	max-width: 100%;
}

.aat-switcher-buttons.has-arrows .aat-switcher-track::-webkit-scrollbar {
	display: none;
}

.aat-switcher-buttons.has-arrows .aat-switcher-button {
	flex: 0 0 auto;
}

.aat-switcher-arrow {
	flex: 0 0 auto;
	width: 26px;
	height: 26px;
	padding: 0;
	border: 1px solid var(--aat-sw-line);
	border-radius: 50%;
	background: var(--aat-sw-bg);
	cursor: pointer;
	position: relative;
	transition: border-color 120ms ease, opacity 120ms ease;
}

.aat-switcher-arrow::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 6px;
	height: 6px;
	border-top: 2px solid var(--aat-sw-ink);
	border-right: 2px solid var(--aat-sw-ink);
}

.aat-switcher-prev::before {
	transform: translate(-35%, -50%) rotate(-135deg);
}

.aat-switcher-next::before {
	transform: translate(-65%, -50%) rotate(45deg);
}

.aat-switcher-arrow:hover:not([disabled]) {
	border-color: var(--aat-sw-accent);
}

.aat-switcher-arrow:hover:not([disabled])::before {
	border-color: var(--aat-sw-accent);
}

.aat-switcher-arrow[disabled] {
	opacity: 0.35;
	cursor: default;
}

.aat-switcher-button {
	display: inline-block;
	min-width: 44px;
	text-align: center;
	letter-spacing: 0.02em;
	padding: 6px 12px;
	border: 1px solid var(--aat-sw-line);
	border-radius: 999px;
	background: var(--aat-sw-bg);
	color: var(--aat-sw-ink);
	text-decoration: none;
	font-size: 13px;
	font-weight: 500;
	transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.aat-switcher-button:hover,
.aat-switcher-button:focus {
	border-color: var(--aat-sw-accent);
	color: var(--aat-sw-accent);
	text-decoration: none;
}

.aat-switcher-button.is-current {
	background: var(--aat-sw-accent);
	border-color: var(--aat-sw-accent);
	color: #fff;
	font-weight: 600;
}

/* Modelo 3: menu com bandeiras */
.aat-switcher-menu {
	position: relative;
	display: inline-block;
}

.aat-switcher-menu > summary {
	list-style: none;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 7px 12px;
	border: 1px solid var(--aat-sw-line);
	border-radius: 8px;
	background: var(--aat-sw-bg);
	color: var(--aat-sw-ink);
	font-size: 13.5px;
	font-weight: 500;
}

.aat-switcher-menu > summary::-webkit-details-marker {
	display: none;
}

.aat-switcher-menu > summary:hover {
	border-color: var(--aat-sw-accent);
}

.aat-switcher-caret,
.aat-switcher-menu > summary::after {
	content: "";
	width: 0;
	height: 0;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	border-top: 5px solid var(--aat-sw-muted);
	margin-left: 2px;
}

.aat-switcher-caret {
	display: none;
}

.aat-switcher-menu[open] > summary::after {
	transform: rotate(180deg);
}

.aat-switcher-list {
	position: absolute;
	z-index: 999;
	top: calc(100% + 4px);
	left: 0;
	min-width: 100%;
	margin: 0;
	padding: 6px;
	list-style: none;
	background: var(--aat-sw-bg);
	border: 1px solid var(--aat-sw-line);
	border-radius: 10px;
	box-shadow: 0 12px 28px -12px rgba(15, 23, 42, 0.35);
	max-height: 320px;
	overflow-y: auto;
}

.aat-switcher-list li {
	list-style: none;
	margin: 0;
}

.aat-switcher-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 7px 10px;
	border-radius: 6px;
	color: var(--aat-sw-ink);
	text-decoration: none;
	white-space: nowrap;
	font-size: 13.5px;
}

.aat-switcher-item:hover,
.aat-switcher-item:focus {
	background: var(--aat-sw-accent-tint);
	color: var(--aat-sw-accent);
	text-decoration: none;
}

.aat-switcher-item.is-current {
	font-weight: 600;
	background: var(--aat-sw-accent-tint);
	color: var(--aat-sw-accent);
}

/* Modelo 4: só bandeiras — bandeira atual como botão; as demais abrem ACIMA */
.aat-switcher-flags {
	position: relative;
	display: inline-block;
	vertical-align: middle;
}

.aat-switcher-flags > summary {
	list-style: none;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 32px;
	border-radius: 8px;
	border: 1px solid var(--aat-sw-line);
	background: var(--aat-sw-bg);
}

.aat-switcher-flags > summary::-webkit-details-marker {
	display: none;
}

.aat-switcher-flags > summary:hover,
.aat-switcher-flags[open] > summary {
	border-color: var(--aat-sw-accent);
	background: var(--aat-sw-accent-tint);
}

/* Painel ancorado na base do botão e crescendo para cima. */
.aat-switcher-flags-panel {
	position: absolute;
	z-index: 999;
	bottom: calc(100% + 6px);
	top: auto;
	right: 0;
	display: grid;
	grid-template-columns: repeat(5, 34px);
	gap: 4px;
	padding: 6px;
	background: var(--aat-sw-bg);
	border: 1px solid var(--aat-sw-line);
	border-radius: 10px;
	box-shadow: 0 -12px 28px -12px rgba(15, 23, 42, 0.35);
	max-height: 280px;
	overflow-y: auto;
}

/* Fora do flutuante o botão costuma ficar à esquerda do texto: alinha à esquerda. */
.aat-header-switcher .aat-switcher-flags-panel,
.aat-before-content-switcher .aat-switcher-flags-panel,
.aat-after-content-switcher .aat-switcher-flags-panel {
	right: auto;
	left: 0;
}

.aat-switcher-flag-link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 30px;
	border-radius: 7px;
	border: 1px solid transparent;
	text-decoration: none;
	transition: border-color 120ms ease, background 120ms ease;
}

.aat-switcher-flag-link:hover,
.aat-switcher-flag-link:focus {
	background: var(--aat-sw-accent-tint);
	border-color: var(--aat-sw-line);
}

.aat-switcher-flag-link.is-current {
	border-color: var(--aat-sw-accent);
	background: var(--aat-sw-accent-tint);
}

.aat-switcher-flag {
	font-size: 18px;
	line-height: 1;
}

.aat-switcher-code {
	font-size: 12px;
	font-weight: 600;
	color: var(--aat-sw-ink);
}

/* Modelo 3 flutuante no rodapé: a lista também abre para cima e alinhada à direita. */
.aat-floating-switcher .aat-switcher-list {
	top: auto;
	bottom: calc(100% + 4px);
	left: auto;
	right: 0;
	box-shadow: 0 -12px 28px -12px rgba(15, 23, 42, 0.35);
}

.aat-floating-switcher .aat-switcher-menu[open] > summary::after {
	transform: none;
}

.aat-floating-switcher .aat-switcher-menu > summary::after {
	transform: rotate(180deg);
}

/* O botão flutuante encolhe os modelos largos */
.aat-floating-switcher .aat-switcher-buttons {
	max-width: 220px;
}
