/**
 * Compra e Sia — estilos do widget de atendimento.
 * Marca padrão: primária #2b6cb0, fundo #fff, texto #1a202c.
 */

:root {
	--csa-primary: #2b6cb0;
	--csa-primary-dark: #1e4e82;
	--csa-bg: #ffffff;
	--csa-text: #1a202c;
	--csa-muted: #718096;
	--csa-user-bubble: #2b6cb0;
	--csa-bot-bubble: #f1f5f9;
	--csa-border: #e2e8f0;
	--csa-radius: 16px;
	--csa-shadow: 0 12px 32px rgba(26, 32, 44, 0.18);
	--csa-z: 99998;
}

/* Bolha flutuante — canto inferior direito, abaixo do admin bar (z-index controlado). */
.csa-bubble {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: var(--csa-z);
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 18px 12px 14px;
	border: 0;
	border-radius: 999px;
	background: var(--csa-primary);
	color: #fff;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
	font-size: 15px;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	box-shadow: var(--csa-shadow);
	transition: transform 0.18s ease, background 0.18s ease;
}

.csa-bubble:hover {
	background: var(--csa-primary-dark);
	transform: translateY(-2px);
}

.csa-bubble:focus-visible {
	outline: 3px solid rgba(43, 108, 176, 0.45);
	outline-offset: 2px;
}

.csa-bubble--hidden {
	display: none;
}

.csa-bubble__icon {
	flex: 0 0 auto;
}

/* Painel de chat */
.csa-panel {
	position: fixed;
	right: 20px;
	bottom: 88px;
	z-index: var(--csa-z);
	display: flex;
	flex-direction: column;
	width: 380px;
	max-width: calc(100vw - 40px);
	height: 560px;
	max-height: calc(100vh - 120px);
	background: var(--csa-bg);
	color: var(--csa-text);
	border: 1px solid var(--csa-border);
	border-radius: var(--csa-radius);
	box-shadow: var(--csa-shadow);
	overflow: hidden;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.csa-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 14px 16px;
	background: var(--csa-primary);
	color: #fff;
}

.csa-header__text {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.csa-header__title {
	font-size: 16px;
	font-weight: 700;
}

.csa-header__status {
	font-size: 12px;
	opacity: 0.9;
}

.csa-header__status::before {
	content: "";
	display: inline-block;
	width: 8px;
	height: 8px;
	margin-right: 6px;
	border-radius: 50%;
	background: #48bb78;
}

.csa-close {
	border: 0;
	background: transparent;
	color: #fff;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	padding: 2px 6px;
	border-radius: 6px;
}

.csa-close:hover {
	background: rgba(255, 255, 255, 0.18);
}

.csa-messages {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--csa-bg);
}

.csa-msg {
	display: flex;
}

.csa-msg--user {
	justify-content: flex-end;
}

.csa-msg--assistant {
	justify-content: flex-start;
}

.csa-msg__bubble {
	max-width: 82%;
	padding: 10px 14px;
	border-radius: var(--csa-radius);
	font-size: 14.5px;
	line-height: 1.45;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.csa-msg--user .csa-msg__bubble {
	background: var(--csa-user-bubble);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.csa-msg--assistant .csa-msg__bubble {
	background: var(--csa-bot-bubble);
	color: var(--csa-text);
	border-bottom-left-radius: 4px;
}

.csa-link {
	color: var(--csa-primary);
	text-decoration: underline;
	word-break: break-all;
}

.csa-msg--user .csa-link {
	color: #fff;
}

.csa-typing {
	padding: 4px 16px 8px;
	font-size: 12.5px;
	color: var(--csa-muted);
	font-style: italic;
}

.csa-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 8px 16px;
}

.csa-chip {
	border: 1px solid var(--csa-primary);
	background: #fff;
	color: var(--csa-primary);
	border-radius: 999px;
	padding: 7px 13px;
	font-size: 13px;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.csa-chip:hover {
	background: var(--csa-primary);
	color: #fff;
}

.csa-form {
	display: flex;
	gap: 8px;
	padding: 12px 16px;
	border-top: 1px solid var(--csa-border);
	background: var(--csa-bg);
}

.csa-input {
	flex: 1 1 auto;
	min-width: 0;
	padding: 10px 12px;
	border: 1px solid var(--csa-border);
	border-radius: 10px;
	font-size: 14.5px;
	color: var(--csa-text);
	background: #fff;
}

.csa-input:focus {
	outline: none;
	border-color: var(--csa-primary);
	box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.18);
}

.csa-send {
	flex: 0 0 auto;
	border: 0;
	border-radius: 10px;
	padding: 10px 16px;
	background: var(--csa-primary);
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

.csa-send:hover {
	background: var(--csa-primary-dark);
}

/* Mobile: tela cheia */
@media (max-width: 640px) {
	.csa-panel {
		right: 0;
		left: 0;
		bottom: 0;
		width: 100vw;
		max-width: 100vw;
		height: 100vh;
		max-height: 100vh;
		border-radius: 0;
		border: 0;
		/* Não cobre a admin bar do WordPress quando logado. */
		top: var(--wp-admin--admin-bar--height, 0px);
	}

	.csa-bubble {
		right: 14px;
		bottom: 14px;
	}

	.csa-bubble__label {
		display: none;
	}

	.csa-bubble {
		padding: 14px;
	}
}
