/**
 * HTC Live Chat — visitor widget styles.
 * Everything is namespaced under #htc-chat-root so themes stay out of the way.
 */

#htc-chat-root {
	--htc-brand: #144d90;
	--htc-accent: #e96c24;
	--htc-surface: #ffffff;
	--htc-ink: #1d2733;
	--htc-muted: #63748a;
	--htc-line: #e3e8ee;
	--htc-radius: 14px;
	--htc-shadow: 0 18px 44px rgba(16, 33, 55, 0.22);

	position: fixed;
	bottom: 20px;
	right: 20px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
	color: var(--htc-ink);
}

#htc-chat-root[data-position="left"] {
	right: auto;
	left: 20px;
}

/* ---------------------------------------------------------------- Launcher */

#htc-chat-root .htc-launcher {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	padding: 13px 20px;
	border: 0;
	border-radius: 999px;
	background: var(--htc-brand);
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	box-shadow: var(--htc-shadow);
	transition: transform 0.15s ease, background 0.15s ease;
}

#htc-chat-root .htc-launcher:hover {
	transform: translateY(-2px);
	background: var(--htc-accent);
}

#htc-chat-root .htc-launcher:focus-visible {
	outline: 3px solid var(--htc-accent);
	outline-offset: 3px;
}

#htc-chat-root .htc-launcher-icon {
	display: inline-flex;
}

#htc-chat-root .htc-launcher.is-active .htc-launcher-label {
	display: none;
}

/* ------------------------------------------------------------------- Panel */

#htc-chat-root .htc-panel {
	position: absolute;
	bottom: 68px;
	right: 0;
	width: 360px;
	max-width: calc(100vw - 32px);
	max-height: min(560px, calc(100vh - 120px));
	display: none;
	flex-direction: column;
	overflow: hidden;
	background: var(--htc-surface);
	border-radius: var(--htc-radius);
	box-shadow: var(--htc-shadow);
}

#htc-chat-root[data-position="left"] .htc-panel {
	right: auto;
	left: 0;
}

#htc-chat-root .htc-panel.is-open {
	display: flex;
	animation: htc-pop 0.18s ease-out;
}

@keyframes htc-pop {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: translateY(0); }
}

#htc-chat-root .htc-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 18px;
	background: var(--htc-brand);
	color: #fff;
}

#htc-chat-root .htc-title {
	font-weight: 700;
	font-size: 16px;
}

#htc-chat-root .htc-presence {
	font-size: 12.5px;
	opacity: 0.85;
	display: flex;
	align-items: center;
	gap: 6px;
}

#htc-chat-root .htc-presence::before {
	content: "";
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #c9d3de;
}

#htc-chat-root .htc-presence.is-online::before {
	background: #2fd07a;
	box-shadow: 0 0 0 3px rgba(47, 208, 122, 0.25);
}

#htc-chat-root .htc-minimise {
	border: 0;
	background: rgba(255, 255, 255, 0.16);
	color: #fff;
	width: 30px;
	height: 30px;
	border-radius: 8px;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
}

#htc-chat-root .htc-body {
	display: flex;
	flex-direction: column;
	min-height: 220px;
	overflow: hidden;
}

/* ------------------------------------------------------- Intro / pre-chat */

#htc-chat-root .htc-intro {
	padding: 18px;
	overflow-y: auto;
}

#htc-chat-root .htc-intro-text {
	margin: 0 0 10px;
}

#htc-chat-root .htc-intro-note {
	margin: 0 0 12px;
	font-size: 13px;
	color: var(--htc-muted);
}

#htc-chat-root .htc-form {
	display: flex;
	flex-direction: column;
	gap: 9px;
}

#htc-chat-root .htc-input {
	width: 100%;
	box-sizing: border-box;
	padding: 11px 12px;
	border: 1px solid var(--htc-line);
	border-radius: 10px;
	font: inherit;
	color: var(--htc-ink);
	background: #fff;
}

#htc-chat-root .htc-input:focus {
	outline: none;
	border-color: var(--htc-brand);
	box-shadow: 0 0 0 3px rgba(20, 77, 144, 0.15);
}

#htc-chat-root .htc-textarea {
	resize: vertical;
	min-height: 78px;
}

#htc-chat-root .htc-honeypot {
	position: absolute !important;
	left: -9999px !important;
	opacity: 0;
	height: 0;
	width: 0;
}

#htc-chat-root .htc-submit {
	margin-top: 4px;
	padding: 12px 16px;
	border: 0;
	border-radius: 10px;
	background: var(--htc-accent);
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

#htc-chat-root .htc-submit:disabled {
	opacity: 0.6;
	cursor: progress;
}

#htc-chat-root .htc-error:empty {
	display: none;
}

#htc-chat-root .htc-error {
	margin: 2px 0 0;
	color: #c0392b;
	font-size: 13px;
}

/* ------------------------------------------------------------------ Thread */

#htc-chat-root .htc-thread {
	flex: 1;
	padding: 16px;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #f6f8fa;
	min-height: 260px;
	max-height: 380px;
}

#htc-chat-root .htc-msg {
	max-width: 82%;
	padding: 9px 12px;
	border-radius: 12px;
	background: #fff;
	border: 1px solid var(--htc-line);
	align-self: flex-start;
}

#htc-chat-root .htc-msg-visitor {
	align-self: flex-end;
	background: var(--htc-brand);
	border-color: var(--htc-brand);
	color: #fff;
}

#htc-chat-root .htc-msg-system {
	align-self: center;
	max-width: 100%;
	background: transparent;
	border: 0;
	color: var(--htc-muted);
	font-size: 13px;
	text-align: center;
}

#htc-chat-root .htc-msg-name {
	display: block;
	font-size: 12px;
	font-weight: 700;
	color: var(--htc-accent);
	margin-bottom: 2px;
}

#htc-chat-root .htc-msg-body {
	white-space: pre-wrap;
	word-break: break-word;
}

#htc-chat-root .htc-msg-time {
	display: block;
	margin-top: 3px;
	font-size: 11px;
	opacity: 0.6;
}

#htc-chat-root .htc-msg-system .htc-msg-time {
	display: none;
}

/* ---------------------------------------------------------------- Composer */

#htc-chat-root .htc-composer {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--htc-line);
	background: #fff;
}

#htc-chat-root .htc-composer-input {
	flex: 1;
	resize: none;
	/*
	 * min-height is not optional. Plenty of themes set a min-height on every
	 * textarea, and min-height always beats max-height, so without this the
	 * composer inherits the theme's size: PJM's pushed it to 150px and the Send
	 * button stretched to match, squashing the conversation above it.
	 */
	min-height: 0;
	height: 44px;
	max-height: 120px;
	padding: 10px 12px;
	border: 1px solid var(--htc-line);
	border-radius: 10px;
	font: inherit;
}

#htc-chat-root .htc-composer-input:focus {
	outline: none;
	border-color: var(--htc-brand);
}

#htc-chat-root .htc-send {
	align-self: stretch;
	min-height: 0;
	padding: 0 16px;
	border: 0;
	border-radius: 10px;
	background: var(--htc-brand);
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

#htc-chat-root .htc-send:hover {
	background: var(--htc-accent);
}

/* --------------------------------------------------------- Inline trigger */

.htc-chat-inline-trigger {
	display: inline-block;
	padding: 11px 18px;
	border: 0;
	border-radius: 999px;
	background: #e96c24;
	color: #fff;
	font-weight: 600;
	cursor: pointer;
}

/* ------------------------------------------------------------------ Mobile */

@media (max-width: 600px) {
	#htc-chat-root {
		bottom: 14px;
		right: 14px;
	}

	#htc-chat-root .htc-panel {
		width: calc(100vw - 28px);
		max-height: calc(100vh - 110px);
	}

	#htc-chat-root.htc-hide-mobile {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	#htc-chat-root .htc-launcher,
	#htc-chat-root .htc-panel.is-open {
		transition: none;
		animation: none;
	}
}

/* ------------------------------------------------- Banner and consent */

#htc-chat-root .htc-banner {
	padding: 8px 14px;
	background: var(--htc-accent);
	color: #fff;
	font-size: 12.5px;
	text-align: center;
}

#htc-chat-root .htc-consent {
	margin: 6px 0 0;
	font-size: 11.5px;
	line-height: 1.4;
	color: var(--htc-muted);
}

#htc-chat-root .htc-consent a {
	color: var(--htc-brand);
}

/* ------------------------------------------------------- Assistant         */

/*
 * The assistant's bubbles sit slightly apart from a colleague's: same side, but
 * a lighter face and a quieter name. Someone scrolling back should be able to
 * tell at a glance which answers came from a person.
 */
#htc-chat-root .htc-msg-bot {
	background: #f4f6f9;
	border-color: #e3e8ef;
}

#htc-chat-root .htc-msg-bot .htc-msg-name {
	color: var(--htc-muted);
	font-weight: 600;
}

#htc-chat-root .htc-msg-tag {
	display: inline-block;
	margin-left: 6px;
	padding: 1px 6px;
	border-radius: 9px;
	background: #e3e8ef;
	color: #4a5565;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	vertical-align: 1px;
}

/* ------------------------------------------------------- Typing indicator  */

#htc-chat-root .htc-typing {
	padding: 12px 14px;
}

#htc-chat-root .htc-typing-dots {
	display: flex;
	align-items: center;
	gap: 4px;
	height: 8px;
}

#htc-chat-root .htc-typing-dots span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #9aa4b2;
	animation: htc-typing-bounce 1.2s infinite ease-in-out;
}

#htc-chat-root .htc-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
#htc-chat-root .htc-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes htc-typing-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
	30%           { transform: translateY(-4px); opacity: 1; }
}

/* Honour the setting. A looping animation is a genuine problem for some people. */
@media (prefers-reduced-motion: reduce) {
	#htc-chat-root .htc-typing-dots span {
		animation: none;
		opacity: 0.6;
	}
}

/* ------------------------------------------------------- Handoff           */

/*
 * Sits between the thread and the composer, on screen the whole time the
 * assistant has the conversation. Understated, but never hidden: the single
 * worst thing a chat bot can do is make the way out hard to find.
 */
#htc-chat-root .htc-handoff {
	display: block;
	width: calc(100% - 24px);
	margin: 0 12px 10px;
	padding: 8px 12px;
	border: 1px solid var(--htc-line);
	border-radius: 999px;
	background: #fff;
	color: var(--htc-muted);
	font: inherit;
	font-size: 13px;
	line-height: 1.3;
	cursor: pointer;
	transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

#htc-chat-root .htc-handoff:hover,
#htc-chat-root .htc-handoff:focus-visible {
	border-color: var(--htc-accent);
	background: #fff;
	color: var(--htc-accent);
}

#htc-chat-root .htc-handoff[hidden] {
	display: none;
}
