/**
 * Crisp Extender launcher presentation.
 *
 * The replacement-ready class is added only after JavaScript has mounted a
 * working native button and confirmed base Crisp's command queue. Until then,
 * every base Crisp launcher remains visible and interactive.
 */

.crisp-extender-chat-button {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	width: auto;
	min-width: 200px;
	height: 60px;
	margin: 0;
	padding: 0;
	overflow: visible;
	color: #222;
	font: inherit;
	text-align: inherit;
	background: transparent;
	border: 0;
	border-radius: 30px;
	cursor: pointer;
	appearance: none;
}

.crisp-extender-chat-button:focus {
	outline: 3px solid #0b57d0;
	outline-offset: 4px;
}

.crisp-extender-chat-button:focus:not(:focus-visible) {
	outline: none;
}

.crisp-extender-chat-button:focus-visible {
	outline: 3px solid #0b57d0;
	outline-offset: 4px;
}

.crisp-extender-avatar {
	position: relative;
	z-index: 2;
	width: 60px;
	height: 60px;
	background-color: #1972f5;
	background-position: center;
	background-size: cover;
	border-radius: 50%;
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
	transition: transform 0.3s ease;
}

.crisp-extender-avatar img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: inherit;
}

.crisp-extender-bubble {
	position: absolute;
	right: 70px;
	z-index: 1;
	max-width: 200px;
	padding: 8px 12px;
	overflow: hidden;
	color: #222;
	font-size: 14px;
	font-weight: 600;
	text-align: right;
	text-overflow: ellipsis;
	white-space: nowrap;
	background-color: #fff;
	border-radius: 16px;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
	opacity: 1;
	transform: translateX(0);
	transition: opacity 0.3s ease, transform 0.3s ease;
	pointer-events: none;
}

.crisp-extender-bubble::after {
	position: absolute;
	top: 50%;
	right: -8px;
	border-color: transparent transparent transparent #fff;
	border-style: solid;
	border-width: 8px 0 8px 8px;
	transform: translateY(-50%);
	content: "";
}

@keyframes crisp-extender-bounce {
	0%,
	100% {
		transform: translateY(0);
	}

	40% {
		transform: translateY(-10px);
	}

	60% {
		transform: translateY(-5px);
	}
}

@keyframes crisp-extender-bubble-in {
	0% {
		opacity: 0;
		transform: translateX(20px);
	}

	100% {
		opacity: 1;
		transform: translateX(0);
	}
}

.crisp-extender-chat-button.animate .crisp-extender-avatar {
	animation: crisp-extender-bounce 0.5s ease;
}

.crisp-extender-chat-button.animate .crisp-extender-bubble {
	animation: crisp-extender-bubble-in 0.3s ease forwards;
}

/*
 * These selectors intentionally become effective only after the replacement
 * is fully usable. Removing the class synchronously restores the base launcher
 * after an enrichment error or a base Crisp command failure.
 */
.crisp-extender-replacement-ready .crisp-client [data-id="chat_opened"],
.crisp-extender-replacement-ready .crisp-client [data-id="chat_closed"],
.crisp-extender-replacement-ready .crisp-client span [data-id="chat_closed"],
.crisp-extender-replacement-ready .crisp-client span[data-has-unread] {
	opacity: 0 !important;
	pointer-events: none !important;
}

.crisp-extender-replacement-ready .crisp-client a[href*="crisp.chat/en/livechat/?ref=chatbox"],
.crisp-extender-replacement-ready .crisp-client div a[href*="crisp.chat/en/livechat/?ref=chatbox"] {
	visibility: hidden !important;
	pointer-events: none !important;
}

@media (prefers-reduced-motion: reduce) {
	.crisp-extender-chat-button,
	.crisp-extender-avatar,
	.crisp-extender-bubble {
		animation: none !important;
		transition: none !important;
	}
}

@media (max-width: 768px) {
	.crisp-extender-chat-button {
		right: 15px;
		bottom: 15px;
		min-width: 150px;
		height: 50px;
	}

	.crisp-extender-avatar {
		width: 50px;
		height: 50px;
	}

	.crisp-extender-bubble {
		right: 60px;
		max-width: 150px;
		padding: 6px 10px;
		font-size: 12px;
	}
}
