/*
 * Launcher do AgileChat no subheader (usuário não master).
 *
 * Ocupa o mesmo lugar do launcher do Agente IA (que é só de master) e alterna em
 * loop entre o botão e um composer que "digita" uma pergunta, envia e volta a
 * ser botão. A marca segue `agilechat-ecosystem/docs/marca`: logotipo oficial sem
 * cor (#0d0d0d / branco) e, como cor de destaque, só o verde-azulado da Agile B2B.
 * O composer reproduz o do AgileChat: fundo branco, borda #e0e0e0 e botão de
 * enviar #0d0d0d (tema escuro: #303030 e enviar branco).
 *
 * Posição e largura do composer vêm de assets/js/components/agilechat-launcher.js
 * (variáveis --agilechat-launcher-left e --agilechat-launcher-composer-width).
 */
#agilechat-launcher {
	--agilechat-ink: #0d0d0d;
	--agilechat-teal: #1f9f95;
	--agilechat-teal-claro: #2dd4bf;
	--agilechat-largura: 176px;
	position: fixed;
	left: var(--agilechat-launcher-left, 50%);
	top: calc(73px + var(--billing-upgrade-banner-height, 0px));
	z-index: 2147483545;
	width: var(--agilechat-largura);
	height: 40px;
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
	font-family: Poppins, Helvetica, sans-serif;
	transform: translateX(-50%);
	transition: width 0.55s cubic-bezier(0.65, 0, 0.25, 1), opacity 0.18s ease;
}

#agilechat-launcher.agilechat-launcher--abaixo-breadcrumb {
	top: calc(118px + var(--billing-upgrade-banner-height, 0px));
}

#agilechat-launcher:focus {
	outline: none;
}

/* Contorno com um feixe verde-azulado percorrendo a borda. */
.agilechat-launcher-contorno {
	position: absolute;
	inset: -1.5px;
	overflow: hidden;
	border-radius: 13.5px;
	background: #2a2a2a;
	transition: background 0.45s ease;
}

.agilechat-launcher-contorno::before {
	content: "";
	position: absolute;
	inset: -150%;
	background: conic-gradient(from 0deg, transparent 0 62%, var(--agilechat-teal) 78%, var(--agilechat-teal-claro) 86%, transparent 92%);
	animation: agilechatLauncherGiro 3s linear infinite;
}

.agilechat-launcher-brilho {
	position: absolute;
	inset: 6px 10px;
	z-index: -1;
	border-radius: 14px;
	background: var(--agilechat-teal);
	filter: blur(16px);
	opacity: 0.35;
	animation: agilechatLauncherRespiro 2.6s ease-in-out infinite;
}

.agilechat-launcher-corpo {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	overflow: hidden;
	border-radius: 12px;
	background: var(--agilechat-ink);
	transition: background 0.45s ease;
}

/* Estado botão: logotipo oficial branco + selo. */
.agilechat-launcher-botao {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	transition: opacity 0.25s ease, transform 0.35s ease;
}

.agilechat-launcher-logotipo {
	display: block;
	width: auto;
	height: 17px;
}

.agilechat-launcher-selo {
	padding: 2px 6px;
	border-radius: 6px;
	background: var(--agilechat-teal);
	color: #fff;
	font-size: 9px;
	font-weight: 700;
	letter-spacing: 0.6px;
	line-height: 1.4;
	text-transform: uppercase;
}

.agilechat-launcher-reflexo {
	position: absolute;
	inset: 0;
	background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, 0.14) 50%, transparent 65%);
	transform: translateX(-120%);
	pointer-events: none;
}

#agilechat-launcher.agilechat-launcher--botao .agilechat-launcher-reflexo {
	animation: agilechatLauncherReflexo 2.8s ease-in-out 0.3s infinite;
}

/* Estado composer: igual ao composer do AgileChat. */
.agilechat-launcher-composer {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 0 5px 0 12px;
	opacity: 0;
	transform: translateY(6px);
	transition: opacity 0.3s ease 0.1s, transform 0.35s ease 0.1s;
	pointer-events: none;
}

.agilechat-launcher-icone {
	flex: none;
	width: 18px;
	height: auto;
}

.agilechat-launcher-pergunta {
	position: relative;
	flex: 1;
	min-width: 0;
	overflow: hidden;
	color: var(--agilechat-ink);
	font-size: 13px;
	text-align: left;
	white-space: nowrap;
	transition: opacity 0.3s ease, transform 0.3s ease;
}

.agilechat-launcher-cursor {
	display: inline-block;
	width: 1.5px;
	height: 16px;
	margin-left: 1px;
	background: var(--agilechat-ink);
	vertical-align: -3px;
	animation: agilechatLauncherCursor 0.9s steps(1) infinite;
}

.agilechat-launcher-enviar {
	display: grid;
	flex: none;
	place-items: center;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: #c4c4c4;
	color: #fff;
	font-size: 12px;
	transition: background 0.25s ease, transform 0.15s ease;
}

.agilechat-launcher-enviar--pronto {
	background: var(--agilechat-ink);
}

.agilechat-launcher-enviar--pressionado {
	transform: scale(0.82);
}

.agilechat-launcher-analise {
	position: absolute;
	top: 0;
	right: 44px;
	bottom: 0;
	left: 42px;
	display: flex;
	align-items: center;
	gap: 8px;
	color: #6b6b6b;
	font-size: 12.5px;
	opacity: 0;
	transition: opacity 0.25s ease;
	white-space: nowrap;
	overflow: hidden;
}

.agilechat-launcher-pontos span {
	display: inline-block;
	width: 5px;
	height: 5px;
	margin-right: 3px;
	border-radius: 50%;
	background: var(--agilechat-teal);
	animation: agilechatLauncherPonto 1s infinite;
}

.agilechat-launcher-pontos span:nth-child(2) {
	animation-delay: 0.15s;
}

.agilechat-launcher-pontos span:nth-child(3) {
	animation-delay: 0.3s;
}

#agilechat-launcher.agilechat-launcher--composer {
	--agilechat-largura: var(--agilechat-launcher-composer-width, 480px);
}

#agilechat-launcher.agilechat-launcher--composer .agilechat-launcher-contorno {
	background: #e0e0e0;
}

#agilechat-launcher.agilechat-launcher--composer .agilechat-launcher-corpo {
	background: #fff;
}

#agilechat-launcher.agilechat-launcher--composer .agilechat-launcher-botao {
	opacity: 0;
	transform: scale(0.92);
}

#agilechat-launcher.agilechat-launcher--composer .agilechat-launcher-composer {
	opacity: 1;
	transform: none;
}

#agilechat-launcher.agilechat-launcher--analisando .agilechat-launcher-pergunta {
	opacity: 0;
	transform: translateY(-10px);
}

#agilechat-launcher.agilechat-launcher--analisando .agilechat-launcher-analise {
	opacity: 1;
}

/* Dica embaixo, no hover e no foco. */
.agilechat-launcher-dica {
	position: absolute;
	top: 50px;
	left: 50%;
	padding: 7px 11px;
	border-radius: 10px;
	background: var(--agilechat-ink);
	box-shadow: 0 14px 30px rgba(0, 0, 0, 0.2);
	color: #fff;
	font-size: 11.5px;
	font-weight: 500;
	white-space: nowrap;
	opacity: 0;
	pointer-events: none;
	transform: translateX(-50%) translateY(-4px);
	transition: opacity 0.2s ease, transform 0.2s ease;
}

#agilechat-launcher:hover .agilechat-launcher-dica,
#agilechat-launcher:focus-visible .agilechat-launcher-dica {
	opacity: 1;
	transform: translateX(-50%) translateY(0);
}

#agilechat-launcher:focus-visible .agilechat-launcher-contorno {
	inset: -3px;
}

.agilechat-launcher-pulso {
	position: absolute;
	inset: -4px;
	border: 2px solid rgba(31, 159, 149, 0.5);
	border-radius: 16px;
	opacity: 0;
	pointer-events: none;
}

#agilechat-launcher.agilechat-launcher--pulso .agilechat-launcher-pulso {
	animation: agilechatLauncherPulso 1s ease-out;
}

/* Clique em andamento (agilechat-entrada.js marca aria-busy). */
#agilechat-launcher[aria-busy="true"] {
	cursor: progress;
	opacity: 0.75;
}

/* Cede para modais, como o launcher do Agente IA. */
body.modal-open #agilechat-launcher {
	opacity: 0;
	pointer-events: none;
}

/* Tema escuro: composer do AgileChat no tema escuro. */
body.dark-theme #agilechat-launcher.agilechat-launcher--composer .agilechat-launcher-contorno {
	background: #3a3a3a;
}

body.dark-theme #agilechat-launcher.agilechat-launcher--composer .agilechat-launcher-corpo {
	background: #303030;
}

body.dark-theme #agilechat-launcher .agilechat-launcher-pergunta {
	color: #fff;
}

body.dark-theme #agilechat-launcher .agilechat-launcher-cursor {
	background: #fff;
}

body.dark-theme #agilechat-launcher .agilechat-launcher-analise {
	color: #a8a8a8;
}

body.dark-theme #agilechat-launcher .agilechat-launcher-enviar {
	background: #5a5a5a;
}

body.dark-theme #agilechat-launcher .agilechat-launcher-enviar--pronto {
	background: #fff;
	color: var(--agilechat-ink);
}

body.dark-theme #agilechat-launcher .agilechat-launcher-icone--escuro,
#agilechat-launcher .agilechat-launcher-icone--branco {
	display: none;
}

body.dark-theme #agilechat-launcher .agilechat-launcher-icone--branco {
	display: block;
}

/* No celular o subheader não comporta o launcher: o acesso fica no menu do usuário. */
@media (max-width: 767.98px) {
	#agilechat-launcher {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.agilechat-launcher-contorno::before,
	.agilechat-launcher-brilho,
	#agilechat-launcher.agilechat-launcher--botao .agilechat-launcher-reflexo {
		animation: none;
	}
}

@keyframes agilechatLauncherGiro {
	to {
		transform: rotate(360deg);
	}
}

@keyframes agilechatLauncherRespiro {
	0%,
	100% {
		opacity: 0.22;
		transform: scale(0.95);
	}
	50% {
		opacity: 0.45;
		transform: scale(1.03);
	}
}

@keyframes agilechatLauncherReflexo {
	0% {
		transform: translateX(-120%);
	}
	55%,
	100% {
		transform: translateX(120%);
	}
}

@keyframes agilechatLauncherCursor {
	50% {
		opacity: 0;
	}
}

@keyframes agilechatLauncherPonto {
	0%,
	80%,
	100% {
		opacity: 0.4;
		transform: translateY(0);
	}
	40% {
		opacity: 1;
		transform: translateY(-4px);
	}
}

@keyframes agilechatLauncherPulso {
	0% {
		opacity: 0.7;
		transform: scale(0.97);
	}
	100% {
		opacity: 0;
		transform: scale(1.22, 1.5);
	}
}

/* Capturas de tela e QA (?sem_widgets=1): some como os demais widgets flutuantes. */
.agile-hide-floating-widgets #agilechat-launcher {
	display: none !important;
}
