/*
 * HorizonWP Editorial Automation: site chatbot widget (public).
 * Tokens mirror admin/admin.css (navy + coral, Montserrat when the theme has it,
 * squared corners). Everything is scoped under .hz-chat so theme styles and the
 * widget never bleed into each other. Font falls back to the theme's sans.
 */
.hz-chat {
	--hz-ink: #1a1f3a;
	--hz-muted: #5b6276;
	--hz-faint: #9aa1b4;
	--hz-paper: #ffffff;
	--hz-panel: #f5f7fa;
	--hz-line: #e6e9f0;
	--hz-line-2: #d6dbe6;
	--hz-coral: #d15040;
	--hz-on-coral: #ffffff;
	--hz-navy: #16223f;
	--hz-on-navy: #ffffff;
	--hz-hover: #1a1f3a;
	--hz-peri: #8ea6d0;
	--hz-rose: #d23b2f;
	--hz-sans: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	position: fixed;
	/* Distance from the corner's two edges: set per site from Settings >
	   Chatbot (v2.36.0), so the launcher can clear another floating button. */
	--hz-offset-x: 20px;
	--hz-offset-y: 20px;
	right: var( --hz-offset-x );
	bottom: var( --hz-offset-y );
	z-index: 99990;
	font-family: var(--hz-sans);
	font-size: 13px;
	line-height: 1.5;
	color: var(--hz-ink);
	-webkit-font-smoothing: antialiased;
}
.hz-chat *, .hz-chat *::before, .hz-chat *::after { box-sizing: border-box; }
.hz-chat button, .hz-chat input, .hz-chat textarea {
	font-family: inherit;
	font-size: inherit;
	line-height: inherit;
	margin: 0;
}

/* ---- Launcher ---- */
.hz-chat__launcher {
	display: flex;
	align-items: center;
	gap: 10px;
	height: 48px;
	padding: 0 18px 0 14px;
	font-size: 13px;
	font-weight: 600;
	color: var(--hz-on-coral);
	background: var(--hz-coral);
	border: 1px solid var(--hz-coral);
	border-radius: 0;
	box-shadow: 0 10px 24px rgba(22, 34, 63, 0.22);
	cursor: pointer;
	transition: background 120ms ease, border-color 120ms ease;
}
.hz-chat__launcher:hover, .hz-chat__launcher:focus-visible {
	background: var(--hz-hover);
	border-color: var(--hz-hover);
	outline: none;
}
.hz-chat__launcher svg { flex: 0 0 auto; }
.hz-chat--open .hz-chat__launcher { display: none; }

/* ---- Panel ---- */
.hz-chat__panel {
	display: none;
	flex-direction: column;
	width: 360px;
	height: 520px;
	max-height: calc(100vh - 40px);
	background: var(--hz-paper);
	border: 1px solid var(--hz-line-2);
	border-radius: 0;
	box-shadow: 0 18px 40px rgba(22, 34, 63, 0.16);
}
.hz-chat--open .hz-chat__panel { display: flex; }

.hz-chat__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	background: var(--hz-navy);
	color: var(--hz-on-navy);
}
.hz-chat__title { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.hz-chat__site { font-size: 11px; opacity: 0.72; }
.hz-chat__actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.hz-chat__iconbtn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	background: transparent;
	border: 1px solid currentColor;
	border-radius: 0;
	color: var(--hz-on-navy);
	opacity: 0.75;
	cursor: pointer;
}
.hz-chat__iconbtn:hover, .hz-chat__iconbtn:focus-visible { opacity: 1; outline: none; }

/* ---- Messages ---- */
.hz-chat__messages {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 16px;
	overflow-y: auto;
	background: var(--hz-paper);
}
.hz-chat__msg {
	max-width: 86%;
	padding: 10px 12px;
	font-size: 13px;
	line-height: 1.5;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}
.hz-chat__msg--bot { align-self: flex-start; background: var(--hz-panel); color: var(--hz-ink); }
.hz-chat__msg--user { align-self: flex-end; background: var(--hz-navy); color: var(--hz-on-navy); }
.hz-chat__msg--error { align-self: flex-start; background: #fbeae8; color: var(--hz-rose); }
.hz-chat__msg--typing { color: var(--hz-faint); }

.hz-chat__sources {
	align-self: flex-start;
	display: flex;
	flex-direction: column;
	gap: 4px;
	max-width: 86%;
	margin-top: -4px;
	padding: 0 2px;
}
.hz-chat__sources-label {
	font-size: 10px;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--hz-faint);
}
.hz-chat__sources a {
	align-self: flex-start;
	font-size: 12px;
	font-weight: 600;
	color: var(--hz-coral);
	text-decoration: none;
	border-bottom: 1px solid var(--hz-coral);
}
.hz-chat__sources a:hover { color: var(--hz-hover); border-color: var(--hz-hover); }

/* ---- Fallback contact form ---- */
.hz-chat__form {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 14px;
	border: 1px solid var(--hz-line);
	background: var(--hz-panel);
}
.hz-chat__form-title { font-size: 12px; font-weight: 600; color: var(--hz-ink); }
.hz-chat__form input, .hz-chat__form textarea {
	width: 100%;
	height: 38px;
	padding: 0 12px;
	color: var(--hz-ink);
	background: var(--hz-paper);
	border: 1px solid var(--hz-line-2);
	border-radius: 0;
}
.hz-chat__form textarea { height: 64px; padding: 10px 12px; resize: none; }
.hz-chat__form input:focus, .hz-chat__form textarea:focus, .hz-chat__input:focus {
	border-color: var(--hz-coral);
	box-shadow: 0 0 0 1px var(--hz-coral);
	outline: none;
}
.hz-chat__consent {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	font-size: 11px;
	line-height: 1.45;
	color: var(--hz-muted);
	cursor: pointer;
}
.hz-chat__consent input {
	width: 14px;
	height: 14px;
	margin-top: 2px;
	padding: 0;
	flex: 0 0 auto;
	accent-color: var(--hz-coral);
}
.hz-chat__hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ---- Buttons ---- */
.hz-chat__btn {
	height: 38px;
	padding: 0 16px;
	font-size: 12px;
	font-weight: 600;
	color: var(--hz-on-coral);
	background: var(--hz-coral);
	border: 1px solid var(--hz-coral);
	border-radius: 0;
	cursor: pointer;
	transition: background 120ms ease, border-color 120ms ease;
}
.hz-chat__btn:hover, .hz-chat__btn:focus-visible { background: var(--hz-hover); border-color: var(--hz-hover); outline: none; }
.hz-chat__btn[disabled] { opacity: 0.55; cursor: default; }
.hz-chat__form .hz-chat__btn { align-self: flex-start; }

/* ---- Composer ---- */
.hz-chat__composer {
	display: flex;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--hz-line);
	background: var(--hz-paper);
}
.hz-chat__input {
	flex: 1 1 auto;
	min-width: 0;
	height: 40px;
	padding: 0 12px;
	color: var(--hz-ink);
	background: var(--hz-paper);
	border: 1px solid var(--hz-line-2);
	border-radius: 0;
}
.hz-chat__composer .hz-chat__btn { height: 40px; }

/* ---- Ended (a lead was left): the composer gives way to a restart bar ---- */
.hz-chat__ended {
	display: none;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 12px;
	border-top: 1px solid var(--hz-line);
	background: var(--hz-paper);
	font-size: 12px;
	color: var(--hz-muted);
}
.hz-chat--ended .hz-chat__composer { display: none; }
.hz-chat--ended .hz-chat__ended { display: flex; }

/* ---- Corner (client setting): the wrap is the anchor, the panel is in flow
   inside it, so a top anchor opens the panel downward by itself ---- */
.hz-chat--left { right: auto; left: var( --hz-offset-x ); }
.hz-chat--top { bottom: auto; top: var( --hz-offset-y ); }

/* ---- Small screens: the panel takes the viewport width ---- */
@media (max-width: 480px) {
	/* Phones: the panel spans the width, so the side offset does not apply;
	   the vertical one still does (capped, to keep the launcher on screen). */
	.hz-chat, .hz-chat--left { right: 12px; left: 12px; bottom: min( var( --hz-offset-y ), 120px ); }
	.hz-chat--top { top: min( var( --hz-offset-y ), 120px ); bottom: auto; }
	.hz-chat__launcher { margin-left: auto; }
	.hz-chat--left .hz-chat__launcher { margin-left: 0; margin-right: auto; }
	.hz-chat__panel { width: 100%; height: min(560px, calc(100vh - 24px)); }
}
