/*
 * Public-site chat widget (logged-out marketing pages).
 * Deliberately mirrors the shape of public/css/aiChat.css so the two feel like
 * siblings, but it is standalone: this file only ships on public pages.
 * Palette comes from the custom properties in public/css/main.css.
 */

/* Floating launcher */
#site-chat-btn {
	position: fixed;
	bottom: 24px;
	right: 24px;
	width: 52px;
	height: 52px;
	border-radius: 50%;
	background: var(--brand);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	/* Deliberately low, matching aiChat.css: gModal's click cover is 2500 and
	   its dialog 1040 inside a stacking context, so anything higher here would
	   paint the widget over an open modal. */
	z-index: 11;
	box-shadow: 0 2px 10px rgba(0,0,0,0.25);
	font-size: 22px;
	transition: transform 0.15s, background 0.15s;
}
#site-chat-btn:hover {
	transform: scale(1.08);
	background: var(--brand-dark);
}
#site-chat-btn.active {
	display: none;
}

/* Panel */
#site-chat-panel {
	position: fixed;
	bottom: 24px;
	right: 24px;
	width: 380px;
	max-height: 560px;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 4px 24px rgba(0,0,0,0.18);
	z-index: 12;
	display: none;
	flex-direction: column;
	overflow: hidden;
	font-size: 14px;
	font-family: var(--font-family), sans-serif;
	color: var(--text-dark);
}
#site-chat-panel.open {
	display: flex;
}

/* The cookie banner also parks itself bottom-right, and (like gModal) sits well
   above the widget. Lift the widget clear of it while it is on screen;
   siteChat.js drops the class when the banner is dismissed. */
html.site-chat-cc #site-chat-btn { bottom: 190px; }
html.site-chat-cc #site-chat-panel { bottom: 190px; max-height: calc(100dvh - 214px); }

/* Header */
.site-chat-header {
	background: var(--brand);
	color: #fff;
	padding: 12px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}
.site-chat-title {
	font-weight: 600;
	font-size: 14px;
}
.site-chat-title i {
	margin-right: 6px;
}
.site-chat-close {
	cursor: pointer;
	opacity: 0.8;
	font-size: 14px;
	background: none;
	border: 0;
	color: inherit;
	padding: 0 2px;
	line-height: 1;
}
.site-chat-close:hover {
	opacity: 1;
}

/* Messages */
.site-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.site-chat-msg {
	padding: 10px 14px;
	border-radius: 10px;
	max-width: 85%;
	word-wrap: break-word;
	overflow-wrap: anywhere;
	line-height: 1.5;
	white-space: pre-wrap;
}
.site-chat-msg-them {
	background: var(--grey7);
	color: var(--text-dark);
	align-self: flex-start;
	border-bottom-left-radius: 3px;
}
.site-chat-msg-you {
	background: var(--brand);
	color: #fff;
	align-self: flex-end;
	border-bottom-right-radius: 3px;
}
.site-chat-msg-error {
	background: var(--danger-light);
	color: var(--danger-dark);
	align-self: center;
	max-width: 100%;
	font-size: 13px;
	text-align: center;
}

/* Input area */
.site-chat-input {
	border-top: 1px solid var(--grey5);
	padding: 12px;
	flex-shrink: 0;
	background: #fff;
}
.site-chat-input.hidden {
	display: none;
}
.site-chat-row {
	display: flex;
	gap: 8px;
	align-items: flex-end;
}
.site-chat-input textarea,
.site-chat-input input[type=text],
.site-chat-input input[type=email] {
	flex: 1;
	width: 100%;
	border: 1px solid var(--grey4);
	border-radius: 8px;
	padding: 8px 12px;
	font-size: 14px;
	font-family: var(--font-family), sans-serif;
	outline: none;
	line-height: 1.4;
	box-sizing: border-box;
}
.site-chat-input textarea {
	resize: none;
	max-height: 120px;
	min-height: 38px;
}
.site-chat-input textarea:focus,
.site-chat-input input:focus {
	border-color: var(--brand);
}
.site-chat-fields {
	display: flex;
	flex-direction: column;
	gap: 8px;
}
/* Column children must size to their own content: the shared `flex: 1` above
   is meant for the single-row question step, and would zero the basis here. */
.site-chat-fields > input,
.site-chat-fields > textarea {
	flex: 0 0 auto;
}
.site-chat-send {
	background: var(--brand);
	color: #fff;
	border: none;
	border-radius: 8px;
	min-width: 38px;
	height: 38px;
	padding: 0 12px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	font-size: 14px;
	font-family: var(--font-family), sans-serif;
	transition: background 0.15s;
}
.site-chat-send:hover {
	background: var(--brand-dark);
}
.site-chat-send:disabled {
	opacity: 0.5;
	cursor: default;
}

/* Honeypot: off-screen rather than display:none, which some bots skip. */
.site-chat-hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	opacity: 0;
}

/* Mobile */
@media (max-width: 480px) {
	#site-chat-panel {
		left: 8px;
		right: 8px;
		width: auto;
		max-height: calc(100dvh - 16px);
		bottom: 8px;
		border-radius: 10px;
	}
	#site-chat-btn {
		bottom: 16px;
		right: 16px;
	}
	html.site-chat-cc #site-chat-btn { bottom: 200px; }
	html.site-chat-cc #site-chat-panel { bottom: 200px; max-height: calc(100dvh - 216px); }
	.site-chat-header {
		padding: 10px 12px;
	}
	.site-chat-messages {
		padding: 12px;
	}
	.site-chat-input {
		padding: 10px;
	}
	.site-chat-input textarea,
	.site-chat-input input {
		font-size: 16px; /* stops iOS zooming on focus */
	}
	.site-chat-input textarea {
		max-height: 84px;
	}
}
