/*
 * HPS Site Assistant widget.
 * Every rule starts with #hpssa-root so theme and builder styles cannot override the layout.
 */

/* ---------- Reset: strip theme styles from everything inside the widget ---------- */
#hpssa-root,
#hpssa-root :where(div, span, p, ul, ol, li, a, strong, em, label, button, textarea) {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	border: 0;
	width: auto;
	height: auto;
	min-width: 0;
	min-height: 0;
	max-width: none;
	max-height: none;
	float: none;
	position: static;
	background: none;
	box-shadow: none;
	text-shadow: none;
	text-transform: none;
	text-align: left;
	letter-spacing: normal;
	text-decoration: none;
	font-family: inherit;
	font-size: inherit;
	font-weight: inherit;
	font-style: normal;
	line-height: inherit;
	color: inherit;
	transform: none;
	transition: none;
	animation: none;
	outline: 0;
}
#hpssa-root .hpssa-icon { display: block; flex: none; width: 20px; height: 20px; }

/* ---------- Root ---------- */
#hpssa-root {
	--hpssa-brand: #0b2a4a;
	--hpssa-bg: #ffffff;
	--hpssa-text: #1d2430;
	--hpssa-muted: #5f6b7a;
	--hpssa-line: #e3e7ed;
	--hpssa-soft: #f3f5f8;
	position: fixed;
	bottom: 20px;
	z-index: 99990;
	font-size: 15px;
	line-height: 1.5;
	color: var(--hpssa-text);
	-webkit-font-smoothing: antialiased;
}
#hpssa-root.hpssa--left { left: 20px; right: auto; }
#hpssa-root.hpssa--right { right: 20px; left: auto; }

#hpssa-root .hpssa-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* ---------- Launcher ---------- */
#hpssa-root .hpssa-launcher {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 18px;
	border-radius: 999px;
	background: var(--hpssa-brand);
	color: #fff;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
	transition: transform .15s ease, box-shadow .15s ease;
}
#hpssa-root .hpssa-launcher:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(0, 0, 0, .22); }
#hpssa-root.is-open .hpssa-launcher { display: none; }

#hpssa-root .hpssa-launcher:focus-visible,
#hpssa-root .hpssa-close:focus-visible,
#hpssa-root .hpssa-send:focus-visible,
#hpssa-root .hpssa-starters button:focus-visible,
#hpssa-root .hpssa-msg a:focus-visible {
	outline: 3px solid var(--hpssa-brand);
	outline-offset: 2px;
}

/* ---------- Panel ---------- */
#hpssa-root .hpssa-panel {
	display: flex;
	flex-direction: column;
	width: 380px;
	height: 600px;
	max-height: calc(100vh - 40px);
	background: var(--hpssa-bg);
	border: 1px solid var(--hpssa-line);
	border-radius: 16px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, .2);
	overflow: hidden;
}
#hpssa-root .hpssa-panel[hidden] { display: none; }

/* Header */
#hpssa-root .hpssa-head {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 14px 12px 16px;
	background: var(--hpssa-brand);
	color: #fff;
}
#hpssa-root .hpssa-title { display: flex; flex-direction: column; min-width: 0; }
#hpssa-root .hpssa-name { font-size: 16px; font-weight: 700; line-height: 1.3; }
#hpssa-root .hpssa-sub { font-size: 12px; line-height: 1.3; opacity: .85; }
#hpssa-root .hpssa-close {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .15);
	color: #fff;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}
#hpssa-root .hpssa-close:hover { background: rgba(255, 255, 255, .28); }

/* Messages: this area takes all spare height */
#hpssa-root .hpssa-log {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 14px;
	background: var(--hpssa-soft);
	overscroll-behavior: contain;
}
#hpssa-root .hpssa-msg {
	flex: none;
	max-width: 85%;
	padding: 9px 13px;
	border-radius: 14px;
	overflow-wrap: anywhere;
}
#hpssa-root .hpssa-msg p { display: block; margin: 0 0 8px; }
#hpssa-root .hpssa-msg p:last-child { margin-bottom: 0; }
#hpssa-root .hpssa-msg ul { display: block; margin: 4px 0 8px; padding-left: 18px; list-style: disc outside; }
#hpssa-root .hpssa-msg li { display: list-item; margin: 2px 0; list-style: inherit; }
#hpssa-root .hpssa-msg strong { font-weight: 700; }
#hpssa-root .hpssa-msg a { color: var(--hpssa-brand); text-decoration: underline; font-weight: 600; }
#hpssa-root .hpssa-msg--assistant {
	align-self: flex-start;
	background: var(--hpssa-bg);
	border: 1px solid var(--hpssa-line);
	border-bottom-left-radius: 4px;
}
#hpssa-root .hpssa-msg--user {
	align-self: flex-end;
	background: var(--hpssa-brand);
	color: #fff;
	border-bottom-right-radius: 4px;
	white-space: pre-wrap;
}
#hpssa-root .hpssa-msg--error { background: #fff6f6; border-color: #e7b4b4; }

#hpssa-root .hpssa-typing { display: inline-flex; gap: 4px; padding: 13px 14px; }
#hpssa-root .hpssa-typing span {
	display: block;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--hpssa-muted);
	animation: hpssa-bounce 1.2s infinite ease-in-out;
}
#hpssa-root .hpssa-typing span:nth-child(2) { animation-delay: .15s; }
#hpssa-root .hpssa-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes hpssa-bounce {
	0%, 80%, 100% { opacity: .3; transform: translateY(0); }
	40% { opacity: 1; transform: translateY(-3px); }
}

/* Starter questions */
#hpssa-root .hpssa-starters {
	flex: none;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 0 14px 10px;
	background: var(--hpssa-soft);
}
#hpssa-root .hpssa-starters[hidden] { display: none; }
#hpssa-root .hpssa-starters button {
	display: inline-block;
	padding: 6px 12px;
	border: 1px solid var(--hpssa-brand);
	border-radius: 999px;
	background: var(--hpssa-bg);
	color: var(--hpssa-brand);
	font-size: 13px;
	line-height: 1.35;
	cursor: pointer;
}
#hpssa-root .hpssa-starters button:hover { background: var(--hpssa-brand); color: #fff; }

/* Input row */
#hpssa-root .hpssa-form {
	flex: none;
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid var(--hpssa-line);
	background: var(--hpssa-bg);
}
#hpssa-root .hpssa-input {
	display: block;
	flex: 1 1 auto;
	width: 100%;
	height: 42px;
	min-height: 42px;
	max-height: 120px;
	padding: 10px 12px;
	border: 1px solid var(--hpssa-line);
	border-radius: 10px;
	background: var(--hpssa-bg);
	color: var(--hpssa-text);
	font-size: 15px;
	line-height: 1.4;
	resize: none;
	overflow-y: auto;
}
#hpssa-root .hpssa-input:focus { border-color: var(--hpssa-brand); }
#hpssa-root .hpssa-input::placeholder { color: var(--hpssa-muted); opacity: 1; }
#hpssa-root .hpssa-send {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	border-radius: 10px;
	background: var(--hpssa-brand);
	color: #fff;
	cursor: pointer;
}
#hpssa-root .hpssa-send:disabled { opacity: .5; cursor: wait; }

#hpssa-root .hpssa-privacy {
	flex: none;
	padding: 0 12px 8px;
	background: var(--hpssa-bg);
	color: var(--hpssa-muted);
	font-size: 11px;
	line-height: 1.4;
}

/* ---------- Phones: full-width sheet ---------- */
@media (max-width: 480px) {
	#hpssa-root { bottom: 12px; }
	#hpssa-root.hpssa--left { left: 12px; }
	#hpssa-root.hpssa--right { right: 12px; }
	#hpssa-root.is-open { left: 0; right: 0; bottom: 0; }
	#hpssa-root .hpssa-panel {
		width: 100%;
		height: 85vh;
		height: 85dvh;
		max-height: none;
		border-radius: 16px 16px 0 0;
		border-bottom: 0;
	}
	#hpssa-root .hpssa-input { font-size: 16px; } /* Stops iOS zooming in. */
}

@media (prefers-reduced-motion: reduce) {
	#hpssa-root .hpssa-launcher,
	#hpssa-root .hpssa-typing span { transition: none; animation: none; }
}
