/**
 * Site assistant widget.
 *
 * Uses the theme's own tokens so the panel reads as part of the site rather
 * than a bolted-on third-party box.
 */

.iso-chat {
	/* Held in a variable because the panel's height is measured from it. */
	--iso-chat-bottom: var(--gutter);

	position: fixed;
	right: var(--gutter);
	bottom: var(--iso-chat-bottom);
	z-index: 900;
	font-family: inherit;
}

/* The theme already floats a "Request a quote" button in this corner, and it
   sits lower in the stacking order, so the launcher would simply cover it.
   Stack above it instead — and only when it is actually on the page, since it
   is switched on and off in the Customizer. */
body:has(.floating-cta) .iso-chat {
	--iso-chat-bottom: calc(var(--gutter) + 3.875rem);
}

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

/* Matches .floating-cta exactly — same colour, padding, gap and glow — so the
   two buttons stacked in this corner read as one designed pair rather than two
   widgets that happened to land together. Deliberately the launcher only: the
   open panel keeps its own brand-blue treatment. */
.iso-chat__launch {
	display: flex;
	align-items: center;
	gap: 0.625rem;
	padding: 0.875rem 1.375rem;
	border: 0;
	border-radius: var(--radius-pill);
	background: var(--accent);
	color: #fff;
	font: inherit;
	font-weight: 600;
	font-size: 0.9375rem;
	cursor: pointer;
	box-shadow: 0 6px 24px rgb(241 123 34 / 40%);
	transition: background var(--transition), transform var(--transition);
}

.iso-chat__launch:hover {
	background: var(--accent-hover);
	transform: translateY(-2px);
}

/* No override here: the theme's global :focus-visible is teal, which is the one
   ring that stays visible against orange. The old rule used --accent and would
   now be an orange outline on an orange button. */

.iso-chat__launch svg {
	width: 20px;
	height: 20px;
	flex: none;
}

.iso-chat.is-open .iso-chat__launch {
	transform: scale(0.9);
	opacity: 0;
	pointer-events: none;
}

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

.iso-chat__panel {
	display: none;
	flex-direction: column;
	width: min(24rem, calc(100vw - 2 * var(--gutter)));
	height: min(34rem, calc(100vh - var(--iso-chat-bottom) - var(--gutter)));
	border: 1px solid var(--line);
	border-radius: var(--radius-lg);
	background: var(--base);
	box-shadow: var(--shadow-lift);
	overflow: hidden;
}

.iso-chat.is-open .iso-chat__panel {
	display: flex;
}

.iso-chat__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.875rem 1rem;
	background: var(--brand);
	color: #fff;
}

.iso-chat__title {
	margin: 0;
	font-size: 0.9375rem;
	font-weight: 700;
}

.iso-chat__close {
	display: flex;
	padding: 0.25rem;
	border: 0;
	border-radius: var(--radius);
	background: transparent;
	color: inherit;
	cursor: pointer;
	line-height: 0;
}

.iso-chat__close:hover {
	background: rgb(255 255 255 / 15%);
}

.iso-chat__close svg {
	width: 20px;
	height: 20px;
}

/* Messages ---------------------------------------------------------------- */

.iso-chat__log {
	flex: 1;
	overflow-y: auto;
	padding: 1rem;
	background: var(--surface);
}

.iso-chat__intro {
	margin: 0 0 1rem;
	color: var(--fg-muted);
	font-size: 0.875rem;
	line-height: 1.6;
}

.iso-chat__msg {
	max-width: 85%;
	margin: 0 0 0.75rem;
	padding: 0.625rem 0.875rem;
	border-radius: var(--radius);
	font-size: 0.9375rem;
	line-height: 1.6;
	overflow-wrap: anywhere;
}

.iso-chat__msg--user {
	margin-left: auto;
	background: var(--brand);
	color: #fff;
	border-bottom-right-radius: 0.25rem;
}

.iso-chat__msg--bot {
	background: var(--base);
	border: 1px solid var(--line);
	border-bottom-left-radius: 0.25rem;
}

.iso-chat__msg--error {
	background: #fdf1e8;
	border-color: #f3c9a6;
	color: #8a4b12;
}

.iso-chat__msg a {
	color: inherit;
}

.iso-chat__msg--bot a {
	color: var(--brand);
}

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

.iso-chat__typing {
	display: flex;
	gap: 0.25rem;
	align-items: center;
}

.iso-chat__typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--fg-muted);
	animation: iso-chat-bounce 1.2s infinite ease-in-out;
}

.iso-chat__typing span:nth-child(2) {
	animation-delay: 0.15s;
}

.iso-chat__typing span:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes iso-chat-bounce {
	0%, 60%, 100% {
		opacity: 0.3;
		transform: translateY(0);
	}

	30% {
		opacity: 1;
		transform: translateY(-3px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.iso-chat__typing span {
		animation: none;
	}
}

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

/* Suggested questions --------------------------------------------------- */

.iso-chat__suggest {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	padding: 0.75rem 0.75rem 0;
	border-top: 1px solid var(--line);
	background: var(--base);
}

.iso-chat__chip {
	padding: 0.375rem 0.75rem;
	border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent);
	border-radius: 999px;
	background: color-mix(in srgb, var(--brand) 7%, var(--base));
	color: var(--brand);
	font: inherit;
	font-size: 0.8125rem;
	line-height: 1.4;
	text-align: left;
	cursor: pointer;
	transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.iso-chat__chip:hover,
.iso-chat__chip:focus-visible {
	border-color: var(--brand);
	background: var(--brand);
	color: #fff;
}

.iso-chat__chip:focus-visible {
	outline: 2px solid var(--brand);
	outline-offset: 2px;
}

/* While an answer is coming in, as the send button is. */
.iso-chat__chip:disabled {
	opacity: 0.5;
	cursor: default;
	pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
	.iso-chat__chip {
		transition: none;
	}
}

.iso-chat__form {
	display: flex;
	gap: 0.5rem;
	align-items: flex-end;
	padding: 0.75rem;
	border-top: 1px solid var(--line);
	background: var(--base);
}

/* With the suggestions showing, they and the message box are one composer. */
.iso-chat__suggest:not([hidden]) + .iso-chat__form {
	border-top: 0;
}

.iso-chat__input {
	flex: 1;
	max-height: 6rem;
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	font: inherit;
	font-size: 0.9375rem;
	line-height: 1.5;
	resize: none;
}

.iso-chat__input:focus {
	outline: 2px solid var(--brand);
	outline-offset: -1px;
}

.iso-chat__send {
	display: flex;
	padding: 0.5rem;
	border: 0;
	border-radius: var(--radius);
	background: var(--brand);
	color: #fff;
	cursor: pointer;
	line-height: 0;
}

.iso-chat__send:hover:not(:disabled) {
	background: var(--brand-dark);
}

.iso-chat__send:disabled {
	opacity: 0.45;
	cursor: default;
}

.iso-chat__send svg {
	width: 20px;
	height: 20px;
}

.iso-chat__notice {
	margin: 0;
	padding: 0 0.75rem 0.625rem;
	background: var(--base);
	color: var(--fg-muted);
	font-size: 0.6875rem;
	line-height: 1.5;
}

@media (max-width: 480px) {
	.iso-chat {
		--iso-chat-bottom: 0.75rem;

		right: 0.75rem;
	}

	body:has(.floating-cta) .iso-chat {
		--iso-chat-bottom: calc(0.75rem + 3.625rem);
	}

	.iso-chat__panel {
		width: calc(100vw - 1.5rem);
		height: min(30rem, calc(100vh - var(--iso-chat-bottom) - 0.75rem));
	}
}

/* Translatable strings JavaScript reads at runtime. Hidden with CSS rather
   than the `hidden` attribute, which the translation layer skips. */

.iso-chat__strings {
	display: none;
}
