/* Botão flutuante */
#pvsara-botao {
	position: fixed;
	right: max(20px, env(safe-area-inset-right));
	bottom: max(20px, env(safe-area-inset-bottom));
	z-index: 99990;
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 0;
	padding: 7px 24px 7px 7px;
	border: 0;
	border-radius: 999px;
	background: linear-gradient(110deg, #17a9b8 0%, #6a7ba3 50%, #e30a6e 100%);
	box-shadow: 0 8px 28px rgba(227, 10, 110, 0.28);
	color: #fff;
	font: 800 16px/1.2 "Nunito", "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
	letter-spacing: 0;
	text-transform: none;
	cursor: pointer;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#pvsara-botao:hover,
#pvsara-botao:focus {
	background: linear-gradient(110deg, #17a9b8 0%, #6a7ba3 50%, #e30a6e 100%);
	color: #fff;
	transform: translateY(-2px);
	box-shadow: 0 12px 34px rgba(227, 10, 110, 0.38);
}

#pvsara-botao:focus-visible {
	outline: 3px solid #17243d;
	outline-offset: 3px;
}

#pvsara-botao img {
	display: block;
	width: 54px;
	height: 54px;
	max-width: none;
	margin: 0;
	border: 2px solid #fff;
	border-radius: 50%;
	object-fit: cover;
}

/* Janela modal */
#pvsara-modal {
	position: fixed;
	inset: 0;
	width: min(1200px, calc(100vw - 48px));
	height: min(820px, calc(100vh - 48px));
	height: min(820px, calc(100dvh - 48px));
	max-width: none;
	max-height: none;
	margin: auto;
	padding: 0;
	overflow: hidden;
	border: 0;
	border-radius: 22px;
	background: #fff;
	box-shadow: 0 30px 80px rgba(10, 20, 40, 0.35);
}

#pvsara-modal::backdrop {
	background: rgba(23, 36, 61, 0.62);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
}

#pvsara-modal .pvsara-janela {
	position: relative;
	width: 100%;
	height: 100%;
}

#pvsara-modal iframe {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border: 0;
}

#pvsara-modal .pvsara-estado {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
	padding: 24px;
	color: #17243d;
	text-align: center;
}

#pvsara-modal .pvsara-erro a {
	display: block;
	margin-bottom: 16px;
}

#pvsara-modal [hidden] {
	display: none;
}

html.pvsara-aberto,
html.pvsara-aberto body {
	overflow: hidden;
}

/*
 * Telemóvel: a janela ocupa o ecrã quase todo. A faixa livre no topo permite
 * fechar com um toque mesmo que a assistente não chegue a carregar.
 */
@media (max-width: 767px), (max-height: 500px) {
	#pvsara-modal {
		inset: auto 0 0 0;
		width: 100%;
		height: calc(100vh - 40px);
		height: calc(100dvh - 40px);
		margin: 0;
		border-radius: 18px 18px 0 0;
	}

	#pvsara-botao {
		right: max(12px, env(safe-area-inset-right));
		bottom: max(12px, env(safe-area-inset-bottom));
		gap: 8px;
		padding: 5px 16px 5px 5px;
		font-size: 14px;
	}

	#pvsara-botao img {
		width: 44px;
		height: 44px;
	}
}

@media (prefers-reduced-motion: reduce) {
	#pvsara-botao {
		transition: none;
	}
}

@media print {
	#pvsara-botao {
		display: none;
	}
}
