/*
 * WhatsApp pre-chat chat bubble (includes/whatsapp-gate.php).
 * Opens right above the floating WhatsApp button (sana-whatsapp-float.css:
 * 56px at 20px from the corner, 52px at 16px on phones).
 * Palette B "Wild Water"; WhatsApp green only on the send button.
 */
.sana-wa-gate {
	position: fixed;
	inset: auto calc(20px + env(safe-area-inset-right, 0px)) calc(20px + 56px + 14px + env(safe-area-inset-bottom, 0px)) auto;
	z-index: 9991; /* above the floating button (9990) */
	box-sizing: border-box;
	display: none;
	flex-direction: column;
	width: 360px;
	max-width: calc(100vw - 40px);
	max-height: calc(100vh - 20px - 56px - 14px - 24px);
	max-height: calc(100dvh - 20px - 56px - 14px - 24px);
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 16px;
	background: #F2EDE2;
	color: #0B262B;
	box-shadow: 0 12px 40px rgba(11, 38, 43, 0.28), 0 2px 8px rgba(11, 38, 43, 0.12);
	overflow: hidden;
	font-family: Manrope, system-ui, sans-serif;
	font-size: 15px;
	line-height: 1.45;
	transform-origin: calc(100% - 28px) calc(100% + 42px);
}

.sana-wa-gate:focus {
	outline: none;
}

.sana-wa-gate[open] {
	display: flex;
	animation: sana-wa-pop 0.18s ease-out;
}

@keyframes sana-wa-pop {
	from {
		opacity: 0;
		transform: translateY(8px) scale(0.96);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.sana-wa-gate *,
.sana-wa-gate *::before,
.sana-wa-gate *::after {
	box-sizing: border-box;
}

/* Header, like a chat app. */
.sana-wa-gate__head {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	gap: 12px;
	padding: 12px 8px 12px 14px;
	background: #123F46;
	color: #F2EDE2;
}

.sana-wa-gate__avatar {
	position: relative;
	display: flex;
	flex: 0 0 40px;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: #F2EDE2;
	color: #123F46;
	font-family: "Barlow Condensed", system-ui, sans-serif;
	font-size: 22px;
	font-weight: 700;
}

.sana-wa-gate__avatar img {
	display: block;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	object-fit: cover;
}

.sana-wa-gate__avatar::after {
	content: "";
	position: absolute;
	right: 0;
	bottom: 0;
	width: 11px;
	height: 11px;
	border: 2px solid #123F46;
	border-radius: 50%;
	background: #25D366;
}

.sana-wa-gate__who {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	min-width: 0;
}

.sana-wa-gate__name {
	font-size: 16px;
	font-weight: 700;
	line-height: 1.25;
}

.sana-wa-gate__status {
	color: #82C6C9;
	font-size: 13px;
	line-height: 1.3;
}

.sana-wa-gate__close {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #F2EDE2;
	cursor: pointer;
}

.sana-wa-gate__close:hover {
	background: rgba(242, 237, 226, 0.12);
	color: #FFFFFF;
}

/* Chat area. */
.sana-wa-gate__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 12px;
	margin: 0;
	padding: 14px 14px 12px;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.sana-wa-gate__msg {
	position: relative;
	align-self: flex-start;
	max-width: 92%;
	margin: 0 0 2px 8px;
	padding: 9px 12px;
	border-radius: 0 12px 12px 12px;
	background: #FFFFFF;
	color: #0B262B;
	box-shadow: 0 1px 1px rgba(11, 38, 43, 0.12);
}

/* Bubble tail. */
.sana-wa-gate__msg::before {
	content: "";
	position: absolute;
	top: 0;
	left: -8px;
	border-top: 10px solid #FFFFFF;
	border-left: 8px solid transparent;
}

.sana-wa-gate__field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.sana-wa-gate__label {
	padding: 0;
	color: #0B262B;
	font-size: 13px;
	font-weight: 700;
}

fieldset.sana-wa-gate__field .sana-wa-gate__label {
	margin-bottom: 6px;
}

.sana-wa-gate__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.sana-wa-gate__chip {
	position: relative;
	display: inline-flex;
	margin: 0;
	cursor: pointer;
}

.sana-wa-gate__chip input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	margin: 0;
	pointer-events: none;
}

.sana-wa-gate__chip span {
	display: inline-flex;
	align-items: center;
	min-height: 34px;
	padding: 6px 11px;
	border: 1px solid #D8CFBD;
	border-radius: 999px;
	background: #FFFFFF;
	color: #0B262B;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.2;
}

.sana-wa-gate__chip:hover span {
	border-color: #267D89;
}

.sana-wa-gate__chip input:checked + span {
	border-color: #216D77;
	background: #216D77;
	color: #FFFFFF;
}

.sana-wa-gate__chip input:focus-visible + span {
	outline: 3px solid #E3A64C;
	outline-offset: 2px;
}

.sana-wa-gate__row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

/* Keep both selects on one line when a label wraps. */
.sana-wa-gate__row .sana-wa-gate__field {
	justify-content: flex-end;
}

.sana-wa-gate select {
	width: 100%;
	min-height: 44px;
	margin: 0;
	padding: 8px 10px;
	border: 1px solid #D8CFBD;
	border-radius: 10px;
	background-color: #FFFFFF;
	color: #0B262B;
	font-family: inherit;
	font-size: 16px; /* 16px stops iOS zooming in on focus */
	line-height: 1.3;
	box-shadow: none;
}

.sana-wa-gate select:focus {
	border-color: #267D89;
	outline: 2px solid #267D89;
	outline-offset: 0;
}

.sana-wa-gate__error {
	margin: 0;
	color: #A3322A;
	font-size: 14px;
	font-weight: 700;
}

.sana-wa-gate__error[hidden] {
	display: none;
}

.sana-wa-gate__submit {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	min-height: 48px;
	margin: 2px 0 0;
	padding: 10px 16px;
	border: 0;
	border-radius: 999px;
	background: #25D366;
	color: #0B262B; /* ink on WhatsApp green: 9:1 */
	font-family: inherit;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.2;
	text-transform: none;
	letter-spacing: 0;
	cursor: pointer;
}

.sana-wa-gate__submit:hover {
	background: #1EBE5A;
	color: #0B262B;
}

.sana-wa-gate__submit:focus-visible,
.sana-wa-gate__close:focus-visible {
	outline: 3px solid #E3A64C;
	outline-offset: 2px;
}

.sana-wa-gate__note {
	margin: 0;
	color: #587378;
	font-size: 13px;
	text-align: center;
}

.sana-wa-gate__note a {
	color: #216D77;
	text-decoration: underline;
}

/* Floating button shows a close icon while the bubble is open. */
.sana-wa-float__x {
	display: none;
}

html.sana-wa-gate-open .sana-wa-float__icon {
	display: none;
}

html.sana-wa-gate-open .sana-wa-float__x {
	display: block;
}

/* Phones: full width above the button. */
@media (max-width: 767px) {
	.sana-wa-gate {
		inset: auto calc(12px + env(safe-area-inset-right, 0px)) calc(16px + 52px + 12px + env(safe-area-inset-bottom, 0px)) calc(12px + env(safe-area-inset-left, 0px));
		width: auto;
		max-width: none;
		max-height: calc(100vh - 16px - 52px - 12px - 16px);
		max-height: calc(100dvh - 16px - 52px - 12px - 16px);
		transform-origin: calc(100% - 26px) calc(100% + 38px);
	}
}

/* Hide while the Kadence mobile menu is open, like the button. */
.showing-popup-drawer-from-right .sana-wa-gate,
.showing-popup-drawer-from-left .sana-wa-gate,
.showing-popup-drawer-from-full .sana-wa-gate {
	display: none;
}

@media (prefers-reduced-motion: reduce) {
	.sana-wa-gate[open] {
		animation: none;
	}
}

@media print {
	.sana-wa-gate {
		display: none !important;
	}
}
