/*
 * TextCRM Floating WhatsApp Widget
 * Color palette aligned with the rest of the TextCRM widgets:
 *   - WhatsApp green:  #25D366 (button, instantly recognisable)
 *   - Dark surface:    #131b2e (popup header)
 *   - Brand accent:    #00f5a0 (avatar ring, online dot)
 */

.textcrm-whatsapp,
.textcrm-whatsapp * {
	box-sizing: border-box;
}

.textcrm-whatsapp {
	--tcrm-wa-offset-bottom: 28px;
	--tcrm-wa-offset-side: 28px;
	--tcrm-wa-btn-bg: #25D366;
	--tcrm-wa-popup-gap: 18px;
	--tcrm-wa-tooltip-gap: 14px;

	position: fixed;
	bottom: var(--tcrm-wa-offset-bottom);
	z-index: 9998;
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	pointer-events: none;
	line-height: 1.4;
	/* Slides up smoothly when the Scroll-to-Top button appears (see below). */
	transition: transform 0.4s cubic-bezier( 0.22, 1, 0.36, 1 );
}

.textcrm-whatsapp > * {
	pointer-events: auto;
}

.textcrm-whatsapp--bottom-right {
	right: var(--tcrm-wa-offset-side);
}

.textcrm-whatsapp--bottom-left {
	left: var(--tcrm-wa-offset-side);
}

/* When the floating Scroll-to-Top button is showing, lift the WhatsApp button
 * above it. The Scroll-to-Top widget toggles the body class and publishes its
 * height (+gap) as --tcrm-wa-shift, so this self-adjusts to the button size.
 * When it hides, the WhatsApp button drops back into the corner — no bottom gap. */
body.tcrm-scrolltop-active .textcrm-whatsapp {
	transform: translateY( calc( -1 * var( --tcrm-wa-shift, 68px ) ) );
}

/* -------------------------------------------------------------------------
 * Floating Button
 * ---------------------------------------------------------------------- */
.textcrm-whatsapp__btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 64px;
	height: 64px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background-color: #25D366;
	color: #ffffff;
	cursor: pointer;
	text-decoration: none;
	transition: transform 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease;
	-webkit-tap-highlight-color: transparent;
	appearance: none;
	-webkit-appearance: none;
}

.textcrm-whatsapp__btn:focus {
	outline: none;
}

.textcrm-whatsapp__btn:focus-visible {
	outline: 3px solid rgba(0, 245, 160, 0.6);
	outline-offset: 4px;
}

.textcrm-whatsapp__btn:hover {
	transform: translateY(-2px) scale(1.04);
}

.textcrm-whatsapp__btn:active {
	transform: translateY(0) scale(0.98);
}

.textcrm-whatsapp__btn-icon {
	display: inline-flex;
	width: 30px;
	height: 30px;
	color: #ffffff;
	transition: transform 0.3s ease, opacity 0.2s ease;
}

.textcrm-whatsapp__btn-icon svg {
	width: 100%;
	height: 100%;
	display: block;
}

.textcrm-whatsapp[data-open="true"] .textcrm-whatsapp__btn-icon {
	transform: rotate(90deg) scale(0.85);
	opacity: 0;
}

/* Close glyph that appears when the popup is open */
.textcrm-whatsapp__btn::after {
	content: "";
	position: absolute;
	inset: 0;
	margin: auto;
	width: 22px;
	height: 22px;
	background-color: currentColor;
	-webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><line x1='18' y1='6' x2='6' y2='18'/><line x1='6' y1='6' x2='18' y2='18'/></svg>") center / contain no-repeat;
	        mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><line x1='18' y1='6' x2='6' y2='18'/><line x1='6' y1='6' x2='18' y2='18'/></svg>") center / contain no-repeat;
	opacity: 0;
	transform: rotate(-45deg) scale(0.85);
	transition: opacity 0.25s ease, transform 0.3s ease;
	pointer-events: none;
}

.textcrm-whatsapp[data-open="true"] .textcrm-whatsapp__btn::after {
	opacity: 1;
	transform: rotate(0deg) scale(1);
}

/* -------------------------------------------------------------------------
 * Pulse rings
 * ---------------------------------------------------------------------- */
.textcrm-whatsapp__pulse {
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background-color: rgba(37, 211, 102, 0.4);
	animation: textcrm-wa-pulse 2.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
	pointer-events: none;
	z-index: -1;
}

.textcrm-whatsapp__pulse--delayed {
	animation-delay: 1.2s;
}

.textcrm-whatsapp[data-open="true"] .textcrm-whatsapp__pulse {
	animation-play-state: paused;
	opacity: 0;
}

@keyframes textcrm-wa-pulse {
	0% {
		transform: scale(1);
		opacity: 0.7;
	}
	75%, 100% {
		transform: scale(1.8);
		opacity: 0;
	}
}

/* -------------------------------------------------------------------------
 * Unread badge
 * ---------------------------------------------------------------------- */
.textcrm-whatsapp__badge {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 999px;
	background-color: #ff3b30;
	color: #ffffff;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.02em;
	box-shadow: 0 4px 10px rgba(255, 59, 48, 0.35), 0 0 0 2px #ffffff;
	animation: textcrm-wa-pop 0.4s ease-out 0.6s both;
}

.textcrm-whatsapp--bottom-left .textcrm-whatsapp__badge {
	right: auto;
	left: -4px;
}

@keyframes textcrm-wa-pop {
	from {
		transform: scale(0);
		opacity: 0;
	}
	to {
		transform: scale(1);
		opacity: 1;
	}
}

/* -------------------------------------------------------------------------
 * Tooltip
 * ---------------------------------------------------------------------- */
.textcrm-whatsapp__tooltip {
	position: absolute;
	bottom: 50%;
	transform: translateY(50%);
	padding: 10px 14px;
	border: 1px solid rgba(0, 245, 160, 0.25);
	border-radius: 12px;
	background-color: #131b2e;
	color: #ffffff;
	font-size: 13px;
	font-weight: 600;
	white-space: nowrap;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.25s ease, transform 0.25s ease;
	box-shadow: 0 12px 30px rgba(6, 14, 32, 0.35);
}

.textcrm-whatsapp--bottom-right .textcrm-whatsapp__tooltip {
	right: calc(100% + var(--tcrm-wa-tooltip-gap));
	transform: translate(8px, 50%);
}

.textcrm-whatsapp--bottom-left .textcrm-whatsapp__tooltip {
	left: calc(100% + var(--tcrm-wa-tooltip-gap));
	transform: translate(-8px, 50%);
}

.textcrm-whatsapp__tooltip::after {
	content: "";
	position: absolute;
	top: 50%;
	width: 8px;
	height: 8px;
	background-color: inherit;
	border: inherit;
	border-width: 0 1px 1px 0;
	transform: translateY(-50%) rotate(-45deg);
}

.textcrm-whatsapp--bottom-right .textcrm-whatsapp__tooltip::after {
	right: -5px;
}

.textcrm-whatsapp--bottom-left .textcrm-whatsapp__tooltip::after {
	left: -5px;
	transform: translateY(-50%) rotate(135deg);
}

.textcrm-whatsapp:hover .textcrm-whatsapp__tooltip {
	opacity: 1;
}

.textcrm-whatsapp--bottom-right:hover .textcrm-whatsapp__tooltip {
	transform: translate(0, 50%);
}

.textcrm-whatsapp--bottom-left:hover .textcrm-whatsapp__tooltip {
	transform: translate(0, 50%);
}

.textcrm-whatsapp--tooltip-always .textcrm-whatsapp__tooltip,
.textcrm-whatsapp--tooltip-auto.is-tip-visible .textcrm-whatsapp__tooltip {
	opacity: 1;
	transform: translate(0, 50%) !important;
}

.textcrm-whatsapp[data-open="true"] .textcrm-whatsapp__tooltip {
	opacity: 0 !important;
}

/* -------------------------------------------------------------------------
 * Popup card
 * ---------------------------------------------------------------------- */
.textcrm-whatsapp__popup {
	position: absolute;
	bottom: calc(100% + var(--tcrm-wa-popup-gap));
	width: 340px;
	max-width: calc(100vw - 32px);
	border-radius: 20px;
	overflow: hidden;
	background-color: #ffffff;
	box-shadow: 0 28px 70px rgba(6, 14, 32, 0.35);
	opacity: 0;
	transform: translateY(16px) scale(0.96);
	transform-origin: bottom right;
	transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
	pointer-events: none;
	visibility: hidden;
}

.textcrm-whatsapp--bottom-right .textcrm-whatsapp__popup {
	right: 0;
	transform-origin: bottom right;
}

.textcrm-whatsapp--bottom-left .textcrm-whatsapp__popup {
	left: 0;
	transform-origin: bottom left;
}

.textcrm-whatsapp[data-open="true"] .textcrm-whatsapp__popup {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
	visibility: visible;
}

.textcrm-whatsapp__popup-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 18px 18px 18px 20px;
	background-color: #131b2e;
	color: #ffffff;
	position: relative;
	overflow: hidden;
}

.textcrm-whatsapp__popup-header::before {
	content: "";
	position: absolute;
	inset: 0;
	background:
		radial-gradient(80% 120% at 0% 0%, rgba(0, 245, 160, 0.15) 0%, transparent 60%),
		radial-gradient(60% 90% at 100% 100%, rgba(37, 211, 102, 0.12) 0%, transparent 60%);
	pointer-events: none;
}

.textcrm-whatsapp__popup-identity {
	display: flex;
	align-items: center;
	gap: 12px;
	flex: 1;
	min-width: 0;
	position: relative;
}

.textcrm-whatsapp__avatar {
	position: relative;
	width: 44px;
	height: 44px;
	flex-shrink: 0;
	/* No overflow:hidden here — the online-dot needs to sit on top of the ring. */
}

.textcrm-whatsapp__avatar-figure {
	display: flex;
	width: 100%;
	height: 100%;
	border-radius: 50%;
	overflow: hidden;
	background: linear-gradient(135deg, #00f5a0 0%, #00a884 100%);
	color: #ffffff;
	align-items: center;
	justify-content: center;
	box-shadow: 0 0 0 2px #00f5a0;
}

.textcrm-whatsapp__avatar-figure img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.textcrm-whatsapp__avatar-default {
	display: inline-flex;
	width: 64%;
	height: 64%;
	align-items: center;
	justify-content: center;
}

.textcrm-whatsapp__avatar-default svg {
	width: 100%;
	height: 100%;
	display: block;
}

.textcrm-whatsapp__online-dot {
	position: absolute;
	bottom: 1px;
	right: 1px;
	width: 11px;
	height: 11px;
	border-radius: 50%;
	background-color: #00f5a0;
	box-shadow: 0 0 0 2.5px #131b2e;
	z-index: 1;
}

.textcrm-whatsapp__popup-meta {
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
	position: relative;
}

.textcrm-whatsapp__popup-title {
	font-size: 15px;
	font-weight: 700;
	color: #ffffff;
	line-height: 1.2;
}

.textcrm-whatsapp__popup-subtitle {
	font-size: 12px;
	font-weight: 500;
	color: #9ca3af;
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.textcrm-whatsapp__popup-online {
	color: #00f5a0;
	font-size: 8px;
	line-height: 1;
}

.textcrm-whatsapp__close {
	position: relative;
	width: 32px;
	height: 32px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 0;
	border-radius: 50%;
	background-color: rgba(255, 255, 255, 0.08);
	color: #ffffff;
	cursor: pointer;
	padding: 0;
	flex-shrink: 0;
	transition: background-color 0.2s ease, transform 0.2s ease;
}

.textcrm-whatsapp__close:hover {
	background-color: rgba(255, 255, 255, 0.16);
	transform: rotate(90deg);
}

.textcrm-whatsapp__close:focus {
	outline: none;
}

.textcrm-whatsapp__close:focus-visible {
	outline: 2px solid #00f5a0;
	outline-offset: 2px;
}

.textcrm-whatsapp__close svg {
	width: 16px;
	height: 16px;
}

/* ----- Body ----- */
.textcrm-whatsapp__popup-body {
	padding: 22px 18px 18px;
	background-color: #e5ded1;
	background-image:
		repeating-radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.45) 0px, rgba(255, 255, 255, 0.45) 1px, transparent 1px, transparent 22px),
		repeating-radial-gradient(circle at 80% 70%, rgba(0, 0, 0, 0.03) 0px, rgba(0, 0, 0, 0.03) 1px, transparent 1px, transparent 18px);
	min-height: 130px;
}

.textcrm-whatsapp__bubble {
	--tcrm-wa-bubble-bg: #ffffff;
	position: relative;
	background-color: var(--tcrm-wa-bubble-bg);
	border-radius: 0 14px 14px 14px;
	padding: 12px 14px;
	max-width: 86%;
	margin-left: 9px;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
	animation: textcrm-wa-bubble 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.18s both;
}

/* WhatsApp-style tail on the top-left corner — fills the same colour as the bubble. */
.textcrm-whatsapp__bubble::before {
	content: "";
	position: absolute;
	top: 0;
	left: -9px;
	width: 0;
	height: 0;
	border-style: solid;
	border-width: 0 9px 12px 0;
	border-color: transparent var(--tcrm-wa-bubble-bg) transparent transparent;
	filter: drop-shadow(-1px 1px 1px rgba(0, 0, 0, 0.04));
}

@keyframes textcrm-wa-bubble {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.textcrm-whatsapp__bubble-meta {
	display: flex;
	align-items: baseline;
	gap: 6px;
	margin-bottom: 4px;
	font-size: 12px;
}

.textcrm-whatsapp__bubble-name {
	font-weight: 700;
	color: #00a884;
}

.textcrm-whatsapp__bubble-role {
	color: #6b7280;
	font-weight: 500;
}

.textcrm-whatsapp__bubble-text {
	margin: 0;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.5;
	color: #1f2937;
	word-break: break-word;
}

.textcrm-whatsapp__bubble-time {
	display: block;
	margin-top: 6px;
	font-size: 10px;
	font-weight: 500;
	color: #9ca3af;
	text-align: right;
}

/* ----- Footer ----- */
.textcrm-whatsapp__popup-footer {
	padding: 14px 18px 18px;
	background-color: #ffffff;
}

.textcrm-whatsapp__cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	padding: 12px 18px;
	border-radius: 12px;
	background-color: #25D366;
	color: #ffffff;
	font-size: 14px;
	font-weight: 700;
	text-decoration: none;
	transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.25s ease;
	box-shadow: 0 8px 24px rgba(37, 211, 102, 0.35);
}

.textcrm-whatsapp__cta:hover {
	background-color: #1ebe5d;
	transform: translateY(-1px);
	box-shadow: 0 12px 30px rgba(37, 211, 102, 0.45);
}

.textcrm-whatsapp__cta:focus {
	outline: none;
}

.textcrm-whatsapp__cta:focus-visible {
	outline: 2px solid #00f5a0;
	outline-offset: 3px;
}

.textcrm-whatsapp__cta-icon,
.textcrm-whatsapp__cta-arrow {
	display: inline-flex;
	width: 18px;
	height: 18px;
}

.textcrm-whatsapp__cta-icon svg,
.textcrm-whatsapp__cta-arrow svg {
	width: 100%;
	height: 100%;
}

.textcrm-whatsapp__cta-arrow {
	transition: transform 0.25s ease;
}

.textcrm-whatsapp__cta:hover .textcrm-whatsapp__cta-arrow {
	transform: translateX(2px);
}

/* -------------------------------------------------------------------------
 * Responsive
 * ---------------------------------------------------------------------- */
@media ( max-width: 480px ) {
	.textcrm-whatsapp__popup {
		width: calc(100vw - 32px);
	}

	.textcrm-whatsapp__tooltip {
		display: none;
	}
}

@media ( max-width: 1024px ) {
	.textcrm-whatsapp--hide-tablet {
		display: none;
	}
}

@media ( max-width: 767px ) {
	.textcrm-whatsapp--hide-mobile {
		display: none;
	}
}

@media ( min-width: 1025px ) {
	.textcrm-whatsapp--hide-desktop {
		display: none;
	}
}

/* -------------------------------------------------------------------------
 * Reduced-motion
 * ---------------------------------------------------------------------- */
@media ( prefers-reduced-motion: reduce ) {
	.textcrm-whatsapp__pulse,
	.textcrm-whatsapp__badge,
	.textcrm-whatsapp__bubble {
		animation: none;
	}

	.textcrm-whatsapp,
	.textcrm-whatsapp__btn,
	.textcrm-whatsapp__cta,
	.textcrm-whatsapp__popup,
	.textcrm-whatsapp__tooltip,
	.textcrm-whatsapp__close,
	.textcrm-whatsapp__cta-arrow {
		transition: none;
	}
}

/* -------------------------------------------------------------------------
 * Site-rendered wrapper (when injected via Site Parts)
 * ---------------------------------------------------------------------- */
.textcrm-site-floating {
	/* Holds only the position:fixed button. Keep the wrapper out of normal flow
	 * (width/height 0) so it never adds page height — otherwise the empty,
	 * transparent wrapper reveals the body background as a blank strip below
	 * the footer. The fixed button still positions against the viewport. */
	position: fixed;
	bottom: 0;
	right: 0;
	width: 0;
	height: 0;
	z-index: 9998;
}

.textcrm-site-floating .elementor-section,
.textcrm-site-floating .elementor-container,
.textcrm-site-floating .elementor-column,
.textcrm-site-floating .elementor-widget-wrap,
.textcrm-site-floating .elementor-element {
	background: transparent !important;
	margin: 0 !important;
	padding: 0 !important;
	box-shadow: none !important;
}
