/**
 * Smart WhatsApp Floating Button - front-end styles.
 *
 * Isolation strategy:
 * 1. Every selector is namespaced with .swfb-.
 * 2. The container is reset with `all: initial`, so nothing the theme sets on
 *    body, a, button, svg or wildcard selectors leaks in.
 * 3. Structural declarations are doubled (.swfb-container.swfb-container) and
 *    marked !important so aggressive theme or page-builder rules cannot win.
 * 4. Animation properties are deliberately left without !important, because an
 *    !important declaration would outrank the running animation itself.
 * Custom properties are untouched by `all`, so the inline values the plugin
 * prints from the saved settings still apply.
 */

/* ---------- Tokens (overridden by the inline CSS from settings) ---------- */

.swfb-container {
	--swfb-size: 56px;
	--swfb-icon: 30px;
	--swfb-color: #25d366;
	--swfb-surface: #ffffff;
	--swfb-text: #1f2a30;
	--swfb-bottom: 20px;
	--swfb-side: 20px;
	--swfb-anim: 420ms;
	--swfb-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Container ---------- */

.swfb-container.swfb-container {
	all: initial;

	position: fixed !important;
	bottom: var(--swfb-bottom) !important;
	top: auto !important;
	z-index: 2147482000 !important;

	display: flex !important;
	flex-direction: column !important;
	gap: 10px !important;
	width: auto !important;
	height: auto !important;
	min-width: 0 !important;
	min-height: 0 !important;
	max-width: calc(100vw - (var(--swfb-side) * 2)) !important;
	max-height: none !important;

	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 0 !important;
	background: none !important;
	box-shadow: none !important;
	outline: none !important;

	float: none !important;
	clear: none !important;
	clip-path: none !important;
	transform: none !important;
	filter: none !important;
	opacity: 1 !important;
	visibility: visible !important;
	overflow: visible !important;
	isolation: isolate !important;
	contain: none !important;

	font-family: var(--swfb-font) !important;
	font-size: 14px !important;
	font-weight: 400 !important;
	font-style: normal !important;
	line-height: 1.45 !important;
	letter-spacing: normal !important;
	word-spacing: normal !important;
	text-transform: none !important;
	text-align: left !important;
	text-indent: 0 !important;
	white-space: normal !important;

	box-sizing: border-box !important;

	/* The container spans the greeting area even while it is hidden, so it must
	   never swallow clicks meant for the page underneath. */
	pointer-events: none !important;
}

.swfb-container.swfb-container *,
.swfb-container.swfb-container *::before,
.swfb-container.swfb-container *::after {
	box-sizing: border-box !important;
	font-family: inherit !important;
	letter-spacing: inherit !important;
	text-transform: none !important;
	text-shadow: none !important;
	float: none !important;
}

.swfb-container.swfb-container > * {
	pointer-events: auto !important;
}

.swfb-container.swfb-pos-bottom-right {
	right: var(--swfb-side) !important;
	left: auto !important;
	align-items: flex-end !important;
}

.swfb-container.swfb-pos-bottom-left {
	left: var(--swfb-side) !important;
	right: auto !important;
	align-items: flex-start !important;
}

/* ---------- Button ---------- */

.swfb-container.swfb-container .swfb-button {
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	flex: 0 0 auto !important;

	width: var(--swfb-size) !important;
	height: var(--swfb-size) !important;
	min-width: var(--swfb-size) !important;
	min-height: var(--swfb-size) !important;
	max-width: none !important;
	max-height: none !important;

	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 50% !important;
	background: var(--swfb-color) !important;
	background-image: none !important;
	color: #fff !important;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18) !important;

	font-size: 0 !important;
	line-height: 1 !important;
	text-decoration: none !important;
	text-align: center !important;

	position: relative !important;
	overflow: visible !important;
	opacity: 1 !important;
	visibility: visible !important;
	cursor: pointer !important;
	transition: transform 180ms ease, box-shadow 180ms ease !important;
	-webkit-tap-highlight-color: transparent;
}

.swfb-container.swfb-container .swfb-button::before,
.swfb-container.swfb-container .swfb-button::after {
	content: none !important;
	display: none !important;
}

.swfb-container.swfb-container .swfb-button:hover,
.swfb-container.swfb-container .swfb-button:focus-visible {
	background: var(--swfb-color) !important;
	color: #fff !important;
	text-decoration: none !important;
	transform: translateY(-2px) !important;
	box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22) !important;
}

.swfb-container.swfb-container .swfb-button:focus-visible {
	outline: 3px solid rgba(0, 0, 0, 0.35) !important;
	outline-offset: 3px !important;
}

.swfb-container.swfb-container .swfb-icon {
	display: block !important;
	width: var(--swfb-icon) !important;
	height: var(--swfb-icon) !important;
	min-width: 0 !important;
	max-width: none !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	background: none !important;
	vertical-align: middle !important;
}

.swfb-container.swfb-container .swfb-icon path {
	fill: currentColor !important;
	stroke: none !important;
}

/* ---------- Greeting ---------- */

.swfb-container.swfb-container .swfb-greeting {
	display: flex !important;
	align-items: flex-start !important;
	gap: 10px !important;
	flex: 0 0 auto !important;

	width: auto !important;
	min-width: 0 !important;
	max-width: min(280px, calc(100vw - (var(--swfb-side) * 2) - 16px)) !important;

	margin: 0 !important;
	padding: 11px 12px 11px 15px !important;
	border: 0 !important;
	border-radius: 14px !important;
	background: var(--swfb-surface) !important;
	background-image: none !important;
	color: var(--swfb-text) !important;
	box-shadow: 0 8px 26px rgba(0, 0, 0, 0.16) !important;

	font-size: 14px !important;
	font-weight: 400 !important;
	line-height: 1.45 !important;
	text-align: left !important;

	/* Left without !important on purpose: the animation drives these. */
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	animation-fill-mode: forwards;
	animation-timing-function: cubic-bezier(0.22, 0.61, 0.36, 1);
	animation-iteration-count: 1;
}

.swfb-container.swfb-pos-bottom-right .swfb-greeting {
	border-bottom-right-radius: 4px !important;
}

.swfb-container.swfb-pos-bottom-left .swfb-greeting {
	border-bottom-left-radius: 4px !important;
}

.swfb-container.swfb-container .swfb-greeting-text {
	flex: 1 1 auto !important;
	display: block !important;
	margin: 0 !important;
	padding: 0 !important;
	color: inherit !important;
	font-size: inherit !important;
	font-weight: inherit !important;
	line-height: inherit !important;
	word-break: break-word !important;
}

.swfb-container.swfb-container .swfb-close {
	flex: 0 0 auto !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;

	width: 20px !important;
	height: 20px !important;
	min-width: 20px !important;
	min-height: 20px !important;

	margin: -2px -2px 0 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 50% !important;
	background: transparent !important;
	background-image: none !important;
	box-shadow: none !important;
	color: #7c8b92 !important;

	font-size: 0 !important;
	line-height: 1 !important;
	-webkit-appearance: none !important;
	appearance: none !important;
	cursor: pointer !important;
	opacity: 1 !important;
	transition: background-color 160ms ease, color 160ms ease !important;
}

.swfb-container.swfb-container .swfb-close:hover,
.swfb-container.swfb-container .swfb-close:focus-visible {
	background: rgba(0, 0, 0, 0.07) !important;
	color: var(--swfb-text) !important;
}

.swfb-container.swfb-container .swfb-close svg {
	display: block !important;
	width: 12px !important;
	height: 12px !important;
}

.swfb-container.swfb-container .swfb-close path {
	fill: currentColor !important;
}

/* ---------- Animation states ---------- */

.swfb-container.swfb-container .swfb-greeting.swfb-in {
	visibility: visible;
	pointer-events: auto;
	animation-duration: var(--swfb-anim);
}

.swfb-container.swfb-container .swfb-greeting.swfb-out {
	visibility: visible;
	pointer-events: none;
	animation-name: swfb-leave;
	animation-duration: 240ms;
	animation-timing-function: ease-in;
}

.swfb-container.swfb-container .swfb-anim-fade.swfb-in {
	animation-name: swfb-fade;
}

.swfb-container.swfb-container .swfb-anim-slide-up.swfb-in {
	animation-name: swfb-slide-up;
}

.swfb-container.swfb-container .swfb-anim-slide-right.swfb-in {
	animation-name: swfb-slide-right;
}

.swfb-container.swfb-pos-bottom-left .swfb-anim-slide-right.swfb-in {
	animation-name: swfb-slide-left;
}

.swfb-container.swfb-container .swfb-anim-pop.swfb-in {
	animation-name: swfb-pop;
}

.swfb-container.swfb-container .swfb-anim-bounce.swfb-in {
	animation-name: swfb-bounce;
}

@keyframes swfb-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes swfb-slide-up {
	from { opacity: 0; transform: translate3d(0, 14px, 0); }
	to   { opacity: 1; transform: none; }
}

@keyframes swfb-slide-right {
	from { opacity: 0; transform: translate3d(28px, 0, 0); }
	to   { opacity: 1; transform: none; }
}

@keyframes swfb-slide-left {
	from { opacity: 0; transform: translate3d(-28px, 0, 0); }
	to   { opacity: 1; transform: none; }
}

@keyframes swfb-pop {
	from { opacity: 0; transform: scale(0.82); }
	60%  { opacity: 1; transform: scale(1.03); }
	to   { opacity: 1; transform: scale(1); }
}

@keyframes swfb-bounce {
	0%   { opacity: 0; transform: translate3d(0, 20px, 0); }
	55%  { opacity: 1; transform: translate3d(0, -7px, 0); }
	78%  { transform: translate3d(0, 3px, 0); }
	100% { opacity: 1; transform: none; }
}

@keyframes swfb-leave {
	from { opacity: 1; }
	to   { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
	.swfb-container.swfb-container .swfb-greeting.swfb-in,
	.swfb-container.swfb-container .swfb-greeting.swfb-out {
		animation-name: swfb-fade;
		animation-duration: 160ms;
	}

	.swfb-container.swfb-container .swfb-greeting.swfb-out {
		animation-direction: reverse;
	}

	.swfb-container.swfb-container .swfb-button {
		transition: none !important;
	}
}

@media (max-width: 600px) {
	.swfb-container.swfb-container .swfb-greeting {
		font-size: 13.5px !important;
		max-width: calc(100vw - (var(--swfb-side) * 2) - 12px) !important;
	}
}
