/* GNL WhatsApp Enquiries – front end. Everything scoped under .gnlwa-*. Inherits the site font. */

:root {
	--gnlwa-green: #25d366;     /* WhatsApp brand green: floating button background */
	--gnlwa-action: #008069;    /* button colour: white text passes contrast (about 5:1) */
	--gnlwa-action-dark: #006b58;
	--gnlwa-text: #111827;
	--gnlwa-muted: #4b5563;
	--gnlwa-border: #d1d5db;
	--gnlwa-error: #b42318;
	--gnlwa-radius: 12px;
}

/* ---------- floating button ---------- */
.gnlwa-float {
	position: fixed;
	bottom: calc(20px + env(safe-area-inset-bottom, 0px));
	z-index: 100000; /* above Avada sticky headers, some of which use 99999 */
	width: 60px;
	height: 60px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--gnlwa-green);
	box-shadow: 0 6px 18px rgba(17, 24, 39, .25);
	transition: transform .15s ease;
}
.gnlwa-float:hover { transform: scale(1.05); }
.gnlwa-float:focus-visible { outline: 3px solid var(--gnlwa-text); outline-offset: 3px; }
.gnlwa-float img { width: 34px; height: 34px; display: block; }
.gnlwa-float--square { border-radius: 16px; }
.gnlwa-float--circle { border-radius: 50%; }
.gnlwa-float--circle img { width: 32px; height: 32px; }
.gnlwa-float--right { right: 16px; }
.gnlwa-float--left { left: 16px; }
@media (min-width: 1024px) {
	.gnlwa-float { bottom: 24px; }
	.gnlwa-float--right { right: 24px; }
	.gnlwa-float--left { left: 24px; }
}
/*
 * Which devices show the floating button (setting "Show floating button on").
 * MOBILE_QUERY = (hover: none) and (pointer: coarse): the main input is touch, so phones and tablets in
 * either orientation. Everything else, including touch-screen laptops used with a mouse or trackpad, is
 * desktop. The script uses the same query for the bottom sheet and the same-tab hand-off.
 * Only the floating button is affected: page buttons and links open the form on every device.
 */
.gnlwa-float--on-mobile { display: none; }
@media (hover: none) and (pointer: coarse) {
	.gnlwa-float--on-mobile { display: flex; }
	.gnlwa-float--on-desktop { display: none; }
}
@media (prefers-reduced-motion: reduce) {
	.gnlwa-float { transition: none; }
}

/* ---------- dialog: shared ---------- */
.gnlwa-dialog {
	border: 0;
	padding: 20px;
	background: #fff;
	color: var(--gnlwa-text);
	font: inherit;
	box-sizing: border-box;
	overflow-y: auto;
	overscroll-behavior: contain; /* 1.0.4: scrolling inside the form never carries on into the page */
}
.gnlwa-dialog *, .gnlwa-dialog *::before, .gnlwa-dialog *::after { box-sizing: border-box; }
.gnlwa-dialog [hidden] { display: none !important; }

/* Mobile: a floating card over a dimmed page, 12px in from the sides and the bottom (1.0.6), clear of
   the notch and the home bar. Centred and no wider than 560px on tablets. */
.gnlwa-dialog[data-device="mobile"] {
	width: calc(100% - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
	max-width: 560px;
	max-height: calc(100% - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
	margin: auto auto calc(12px + env(safe-area-inset-bottom, 0px));
	border-radius: 24px;
	box-shadow: 0 10px 40px rgba(17, 24, 39, .28);
}
.gnlwa-dialog[data-device="mobile"]::backdrop { background: rgba(17, 24, 39, .5); }

/* Desktop, opened from the floating button: corner panel above the button, page left visible.
   1.0.27: on the left when the button is (data-place corner-left). */
.gnlwa-dialog[data-device="desktop"] {
	position: fixed;
	inset: auto 24px 100px auto;
	margin: 0;
	width: 380px;
	max-width: calc(100vw - 48px);
	max-height: calc(100vh - 140px);
	border-radius: 18px;
	box-shadow: 0 18px 50px rgba(17, 24, 39, .22);
}
.gnlwa-dialog[data-device="desktop"][data-place="corner-left"] { inset: auto auto 100px 24px; }
.gnlwa-dialog[data-device="desktop"]::backdrop { background: transparent; }

/* 1.0.27, desktop, opened from a page button, text link, menu item or existing WhatsApp link: in the middle of the
   screen over a dimmed page, so it appears where the visitor is looking rather than in a corner. */
.gnlwa-dialog[data-device="desktop"][data-place="centre"] {
	inset: 0;
	margin: auto;
	width: 420px;
	max-height: calc(100vh - 48px);
	box-shadow: 0 24px 60px rgba(17, 24, 39, .3);
}
.gnlwa-dialog[data-device="desktop"][data-place="centre"]::backdrop { background: rgba(17, 24, 39, .5); }

/* ---------- header ---------- */
.gnlwa-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
/* 1.0.6: themes that style every <header> (background, padding, fixed position) must not reach the form's own. */
.gnlwa-dialog .gnlwa-head { position: static; inset: auto; width: auto; height: auto; min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; color: inherit; z-index: auto; transform: none; }
.gnlwa-logo { width: 38px; height: 38px; flex-shrink: 0; }
.gnlwa-titles { flex-grow: 1; }
.gnlwa-title { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.3; color: var(--gnlwa-text); }
.gnlwa-sub { margin: 2px 0 0; font-size: 14px; color: var(--gnlwa-muted); }
.gnlwa-close {
	width: 44px; height: 44px; flex-shrink: 0;
	border: 0; border-radius: 50%;
	background: #f3f4f6; color: #374151;
	display: flex; align-items: center; justify-content: center;
	cursor: pointer; padding: 0;
}
.gnlwa-close--corner { margin-left: auto; }

/* ---------- form ---------- */
/*
 * 1.0.9: floating labels. A label sits inside its empty field (16px, grey) and moves to the top of the box
 * (12px, bold) when the field has focus, has a value, or has been autofilled, so the field's name stays
 * visible. Done in CSS alone, so it doesn't depend on the script noticing autofill. Selectors are scoped
 * under .gnlwa-dialog .gnlwa-box so theme styles for label, input and textarea can't move things.
 */
.gnlwa-form { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.gnlwa-field { display: flex; flex-direction: column; gap: 4px; }
.gnlwa-box { position: relative; }
.gnlwa-dialog .gnlwa-box > input,
.gnlwa-dialog .gnlwa-box > textarea {
	display: block;
	width: 100%;
	max-width: none;
	font: inherit;
	font-size: 16px; /* 16px or more stops iPhones zooming in on focus */
	line-height: 20px;
	letter-spacing: normal;
	text-transform: none;
	color: var(--gnlwa-text);
	background: #fff;
	border: 1px solid var(--gnlwa-border);
	border-radius: 10px;
	box-shadow: none;
	margin: 0;
	-webkit-appearance: none;
	appearance: none;
}
.gnlwa-dialog .gnlwa-box > input { height: 54px; min-height: 0; padding: 23px 14px 7px; }
.gnlwa-dialog .gnlwa-box > label {
	position: absolute; left: 15px; top: 17px; z-index: 1;
	display: block; float: none; width: auto; height: auto; max-width: calc(100% - 30px);
	margin: 0; padding: 0; border: 0; background: none;
	font-family: inherit; font-size: 16px; font-weight: 400; line-height: 20px;
	letter-spacing: normal; text-transform: none; color: #6b7280;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
	pointer-events: none; /* taps go to the field underneath */
	transition: top .15s ease, font-size .15s ease, line-height .15s ease, color .15s ease;
}
/* Moved up: focused, or not empty (typed, pre-filled or autofilled) */
.gnlwa-dialog .gnlwa-box > :focus + label,
.gnlwa-dialog .gnlwa-box > :not(:placeholder-shown) + label { top: 7px; font-size: 12px; line-height: 16px; font-weight: 600; color: #374151; }
/* Autofill on its own lines: a browser that doesn't know one of these selectors drops the whole rule */
.gnlwa-dialog .gnlwa-box > input:-webkit-autofill + label { top: 7px; font-size: 12px; line-height: 16px; font-weight: 600; color: #374151; }
.gnlwa-dialog .gnlwa-box > input:autofill + label { top: 7px; font-size: 12px; line-height: 16px; font-weight: 600; color: #374151; }
.gnlwa-dialog .gnlwa-box > :focus + label { color: var(--gnlwa-action-dark); }
.gnlwa-optional { font-weight: 400; }
.gnlwa-dialog .gnlwa-box > input:focus { outline: 2px solid var(--gnlwa-action); outline-offset: 1px; border-color: var(--gnlwa-action); }
/* Message: the border is on the box, with a strip at the top for the label; the text area scrolls beneath it */
.gnlwa-dialog .gnlwa-box--area { border: 1px solid var(--gnlwa-border); border-radius: 10px; background: #fff; padding-top: 26px; }
.gnlwa-dialog .gnlwa-box--area > textarea { height: 62px; min-height: 0; padding: 0 14px 8px; border: 0; border-radius: 0 0 10px 10px; background: transparent; resize: none; }
.gnlwa-dialog .gnlwa-box--area > textarea:focus { outline: none; }
.gnlwa-dialog .gnlwa-box--area:focus-within { outline: 2px solid var(--gnlwa-action); outline-offset: 1px; border-color: var(--gnlwa-action); }
/* "How can we help?" only once the box is tapped. !important because some themes force their placeholder colour,
   which would show the hint on top of the resting "Message" label. */
.gnlwa-dialog .gnlwa-box--area > textarea:not(:focus)::placeholder { color: transparent !important; opacity: 1; }
.gnlwa-dialog .gnlwa-box--area > textarea:focus::placeholder { color: #6b7280; }
.gnlwa-dialog .gnlwa-box > input::placeholder { color: transparent; opacity: 1; } /* the blank placeholder never shows */
/* Errors */
.gnlwa-dialog .gnlwa-field.is-invalid .gnlwa-box > input,
.gnlwa-dialog .gnlwa-field.is-invalid .gnlwa-box--area { border: 2px solid var(--gnlwa-error); }
.gnlwa-dialog .gnlwa-field.is-invalid .gnlwa-box > label { color: var(--gnlwa-error); }
.gnlwa-error { margin: 0; padding: 6px 10px; border-radius: 8px; background: #fef3f2; color: var(--gnlwa-error); font-size: 13px; line-height: 1.4; }
@media (prefers-reduced-motion: reduce) {
	.gnlwa-dialog .gnlwa-box > label { transition: none; }
}

.gnlwa-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }

/* ---------- buttons ---------- */
.gnlwa-submit,
.gnlwa-btn {
	display: flex; align-items: center; justify-content: center; gap: 10px;
	width: 100%; min-height: 52px;
	border: 0; border-radius: var(--gnlwa-radius);
	background: var(--gnlwa-action); color: #fff;
	font: inherit; font-size: 17px; font-weight: 700;
	text-decoration: none; cursor: pointer;
}
.gnlwa-submit:hover, .gnlwa-btn:hover { background: var(--gnlwa-action-dark); color: #fff; }
.gnlwa-submit.is-busy { background: var(--gnlwa-action-dark); cursor: progress; }
.gnlwa-btn--outline { background: #fff; color: var(--gnlwa-action-dark); border: 2px solid var(--gnlwa-action); }
.gnlwa-btn--outline:hover { background: #f0faf5; color: var(--gnlwa-action-dark); }
.gnlwa-btn--plain { background: #fff; color: #1f2937; border: 1px solid var(--gnlwa-border); font-weight: 600; }
.gnlwa-btn--plain:hover { background: #f9fafb; color: #1f2937; }

.gnlwa-privacy { margin: 0; font-size: 13px; line-height: 1.45; color: var(--gnlwa-muted); text-align: center; }
.gnlwa-privacy a { color: #1f2937; }

/* ---------- done / error views ---------- */
.gnlwa-view--centre { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.gnlwa-view--centre p { margin: 0; font-size: 16px; line-height: 1.55; color: #374151; }
.gnlwa-view--centre .gnlwa-title { font-size: 22px; }
.gnlwa-tick { width: 72px; height: 72px; border-radius: 50%; background: #e3f5e9; color: #0b7a55; display: flex; align-items: center; justify-content: center; }
.gnlwa-small { font-size: 14px !important; color: var(--gnlwa-muted) !important; }
.gnlwa-or { display: flex; align-items: center; gap: 12px; width: 100%; font-size: 13px !important; }
.gnlwa-or::before, .gnlwa-or::after { content: ""; flex: 1; height: 1px; background: #e5e7eb; }
.gnlwa-qr-label { font-weight: 600; font-size: 14px !important; }
.gnlwa-qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
.gnlwa-qr-wrap[hidden] { display: none; }
.gnlwa-qr { width: 160px; height: 160px; }
.gnlwa-qr svg { width: 100%; height: 100%; }
.gnlwa-only-mobile, .gnlwa-only-desktop { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
.gnlwa-dialog[data-device="mobile"] .gnlwa-only-desktop,
.gnlwa-dialog[data-device="desktop"] .gnlwa-only-mobile { display: none; }
