/**
 * Achol WhatsApp Floating Chat
 *
 * Site-wide floating support button.
 * Uses design tokens. Safe-area aware. Reduced-motion friendly.
 */

.achol-whatsapp-float {
	position: fixed;
	bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
	z-index: var(--achol-z-whatsapp, 450);
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 0.5rem;
	pointer-events: none; /* container ignores clicks; children re-enable */
}

.achol-whatsapp-float--bottom-right {
	right: max(1.25rem, env(safe-area-inset-right, 0px));
	left: auto;
}

.achol-whatsapp-float--bottom-left {
	left: max(1.25rem, env(safe-area-inset-left, 0px));
	right: auto;
	align-items: flex-start;
}

/* Device visibility */
@media (min-width: 768px) {
	.achol-whatsapp-float--hide-desktop {
		display: none !important;
	}
}

@media (max-width: 767px) {
	.achol-whatsapp-float--hide-mobile {
		display: none !important;
	}
}

/* Delayed state */
.achol-whatsapp-float--delayed.is-hidden {
	opacity: 0;
	visibility: hidden;
	transform: translateY(12px);
	pointer-events: none;
}

.achol-whatsapp-float--delayed:not(.is-hidden) {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
	transition: opacity var(--achol-transition-base, 250ms ease),
		transform var(--achol-transition-base, 250ms ease),
		visibility var(--achol-transition-base, 250ms ease);
}

/* Greeting bubble */
.achol-whatsapp-float__greeting {
	pointer-events: auto;
	display: flex;
	align-items: flex-start;
	gap: 0.5rem;
	max-width: 240px;
	padding: 0.75rem 0.875rem;
	background: var(--achol-color-bg, #fff);
	color: var(--achol-color-text, #000);
	border-radius: 12px;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
	font-size: 0.875rem;
	line-height: 1.4;
}

.achol-whatsapp-float__greeting-text {
	flex: 1;
}

.achol-whatsapp-float__greeting-close {
	pointer-events: auto;
	flex-shrink: 0;
	width: 1.5rem;
	height: 1.5rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	background: transparent;
	color: inherit;
	font-size: 1.125rem;
	line-height: 1;
	cursor: pointer;
	border-radius: 4px;
	opacity: 0.6;
}

.achol-whatsapp-float__greeting-close:hover,
.achol-whatsapp-float__greeting-close:focus-visible {
	opacity: 1;
	outline: 2px solid var(--achol-color-primary, #FF751F);
	outline-offset: 2px;
}

/* Main button */
.achol-whatsapp-float__button {
	pointer-events: auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	min-width: 56px;
	min-height: 56px;
	padding: 0.75rem 1rem;
	background-color: #25D366; /* Official WhatsApp green */
	color: #ffffff;
	border: none;
	border-radius: 999px;
	box-shadow: 0 4px 16px rgba(37, 211, 102, 0.4);
	text-decoration: none;
	font-family: inherit;
	font-size: 0.9375rem;
	font-weight: 500;
	line-height: 1;
	cursor: pointer;
	transition: transform var(--achol-transition-fast, 150ms ease),
		box-shadow var(--achol-transition-fast, 150ms ease),
		background-color var(--achol-transition-fast, 150ms ease);
}

.achol-whatsapp-float__button:hover {
	background-color: #1ebe57;
	box-shadow: 0 6px 20px rgba(37, 211, 102, 0.5);
	transform: translateY(-2px);
	color: #ffffff;
}

.achol-whatsapp-float__button:active {
	transform: translateY(0);
	box-shadow: 0 2px 10px rgba(37, 211, 102, 0.35);
}

.achol-whatsapp-float__button:focus-visible {
	outline: 3px solid var(--achol-color-primary, #FF751F);
	outline-offset: 3px;
}

.achol-whatsapp-float__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	flex-shrink: 0;
}

.achol-whatsapp-float__icon svg {
	display: block;
	width: 28px;
	height: 28px;
}

.achol-whatsapp-float__label {
	white-space: nowrap;
}

/* Icon-only when no label */
.achol-whatsapp-float__button:not(:has(.achol-whatsapp-float__label)) {
	padding: 0.875rem;
	border-radius: 50%;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	.achol-whatsapp-float--delayed:not(.is-hidden),
	.achol-whatsapp-float__button {
		transition: none;
	}

	.achol-whatsapp-float__button:hover {
		transform: none;
	}
}

/*
 * Avoid collision with sticky purchase bar / cookie banners.
 * Theme or Core can adjust via CSS variables if needed.
 */
body.woocommerce-checkout .achol-whatsapp-float,
body.woocommerce-order-received .achol-whatsapp-float {
	/* Extra safety – PHP already hides on checkout when configured */
}


/* -------------------------------------------------------------------------- */
/* 1.13.93/94 — WhatsApp follows bottom nav show/hide                          */
/* -------------------------------------------------------------------------- */
@media (max-width: 767px) {
	body.achol-has-bottom-nav .achol-whatsapp-float {
		/* Slightly above bottom nav (tight gap) */
		bottom: calc(3.85rem + env(safe-area-inset-bottom, 0px)) !important;
		z-index: 600 !important;
		transition: bottom 0.28s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
	}

	/* Nav hidden on scroll down → restore original low position */
	body.achol-has-bottom-nav.achol-bottom-nav-hidden .achol-whatsapp-float {
		bottom: max(1.25rem, env(safe-area-inset-bottom, 0px)) !important;
	}
}


/* Guest login page — keep float above bottom nav, clear of form */
@media (max-width: 767px) {
	body.achol-account--guest.achol-has-bottom-nav .achol-whatsapp-float {
		bottom: calc(4.15rem + env(safe-area-inset-bottom, 0px)) !important;
	}
}
