/* ==========================================================================
   Immersion AI — chat panel + floating button (live agent and scripted demo).
   Loaded while either provider is on. Sized like a HubSpot/Intercom widget:
   ~380px wide, up to 640px tall, one comfortable reading size.
   Uses the --imm-* tokens from immersion.css, so it follows the colour scheme.
   ========================================================================== */

.imm-chat-fab {
	position: fixed;
	right: 1.25rem;
	bottom: 1.25rem;
	z-index: 40;
	background: var(--imm-paper);
	color: var(--imm-ink);
	border: 1px solid var(--imm-line);
	border-radius: var(--imm-r);
	padding: 0;
	width: 48px;
	height: 48px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font: 500 .875rem/1.2 var(--imm-body);
	text-transform: none;
	letter-spacing: 0;
	box-shadow: 0 2px 8px color-mix(in srgb, var(--imm-navy) 10%, transparent);
	cursor: pointer;
}

.imm-chat-fab[hidden] {
	display: none;
}

/* Always visible (ADR-033). immersion.js sets --imm-fab-lift when the launcher has to step up
   out of the way of a control; reduced motion drops the glide (below). */
.imm-chat-fab {
	transform: translateY(calc(-1 * var(--imm-fab-lift, 0px)));
	transition: transform .18s ease-out;
}

.imm-chat-fab svg {
	width: 20px;
	height: 20px;
	color: var(--imm-steel);
}

.imm-chat {
	position: fixed;
	right: 1.25rem;
	bottom: 1.25rem;
	z-index: 45;
	width: min(400px, calc(100vw - 2.5rem));
	height: min(720px, calc(100vh - 5rem));
	background: var(--imm-paper);
	color: var(--imm-ink);
	border: 1px solid var(--imm-line);
	border-radius: 12px;
	box-shadow: var(--imm-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	font-family: var(--imm-body);
	box-sizing: border-box;
}

.imm-chat *,
.imm-chat *::before,
.imm-chat *::after {
	box-sizing: border-box;
}

.imm-chat[hidden] {
	display: none;
}

.imm-chat p {
	margin: 0;
}

.imm-chat svg {
	display: block;
}

/* Brand-coloured header like a standard support widget; white text on navy. */
.imm-chat__head {
	display: flex;
	align-items: center;
	gap: .75rem;
	padding: 1rem 1.1rem;
	background: var(--imm-navy);
	color: #fff;
}

/* Phones: the panel takes the whole screen, as support widgets do. */
@media (max-width: 37.5em) {
	.imm-chat {
		inset: 0;
		width: 100%;
		height: 100%;
		border-radius: 0;
		border: 0;
	}
}

.imm-chat__flag {
	width: 26px;
	height: 24px;
	flex: none;
}

.imm-chat__head b {
	font-family: var(--imm-body);
	font-weight: 600;
	text-transform: none;
	font-size: 1.05rem;
	display: block;
	line-height: 1;
	color: #fff;
}

.imm-chat__head span {
	font-size: .78rem;
	color: rgba(255, 255, 255, .78);
}

.imm-chat__head button {
	margin-left: auto;
	background: none;
	border: 0;
	cursor: pointer;
	padding: .3rem;
	border-radius: 3px;
	color: inherit;
}

.imm-chat__head button svg {
	width: 20px;
	height: 20px;
	color: #fff;
}

.imm-chat__head button:hover,
.imm-chat__head button:focus-visible {
	background: rgba(255, 255, 255, .14);
}

.imm-chat__log {
	flex: 1;
	overflow-y: auto;
	padding: 1rem;
	display: flex;
	flex-direction: column;
	gap: .75rem;
	background: var(--imm-paper);
}

.imm-msg {
	max-width: 88%;
	padding: .8rem 1rem;
	border-radius: 12px;
	font-size: .95rem;
	line-height: 1.5;
	position: relative;
}

/* White body, soft grey assistant bubbles, navy visitor bubbles (support-widget convention). */
.imm-msg--bot {
	background: var(--imm-ground);
	align-self: flex-start;
	color: var(--imm-ink);
}

.imm-msg--user {
	background: var(--imm-navy-2);
	color: #fff;
	align-self: flex-end;
}

/* Reply structure: paragraphs, bullet / numbered lists, bold item names. */
.imm-msg p {
	margin: 0 0 .55rem;
}

.imm-msg p:last-of-type {
	margin-bottom: 0;
}

.imm-msg ul,
.imm-msg ol {
	margin: .3rem 0 .55rem;
	padding-left: 1.15rem;
}

.imm-msg ul:last-of-type,
.imm-msg ol:last-of-type {
	margin-bottom: 0;
}

.imm-msg li {
	margin: .25rem 0;
	padding-left: .1rem;
}

.imm-msg li::marker {
	color: var(--imm-muted);
}

.imm-msg time {
	display: block;
	font-size: .7rem;
	opacity: .6;
	margin-top: .35rem;
	text-align: right;
}

.imm-msg strong {
	font-weight: 600;
}

.imm-msg a {
	color: var(--imm-steel);
}

.imm-chips {
	display: flex;
	flex-wrap: wrap;
	gap: .4rem;
}

.imm-chips button {
	background: var(--imm-paper);
	border: 1px solid var(--imm-line);
	border-radius: 6px;
	padding: .55rem .8rem;
	font: inherit;
	font-size: .875rem;
	cursor: pointer;
	text-align: left;
	color: var(--imm-ink);
}

.imm-chips button:hover {
	border-color: var(--imm-steel);
}

/* Call-back request (ADR-056): the answer taken from the conversation, the review card, and the
   actions under a message (open in the email app, copy, edit). */
.imm-msg__quote {
	margin: .5rem 0 0;
	padding: .15rem 0 .15rem .75rem;
	border-left: 2px solid var(--imm-line);
	white-space: pre-line;
}

.imm-handoff {
	display: grid;
	grid-template-columns: max-content minmax(0, 1fr);
	gap: .3rem .75rem;
	margin: .6rem 0 0;
	font-size: .875rem;
}

.imm-handoff dt {
	color: var(--imm-muted);
}

.imm-handoff dd {
	margin: 0;
	overflow-wrap: anywhere;
	white-space: pre-line;
}

.imm-msg__acts {
	display: flex;
	flex-wrap: wrap;
	gap: .4rem;
	margin-top: .75rem;
}

.imm-msg .imm-msg__act {
	display: inline-flex;
	align-items: center;
	padding: .5rem .8rem;
	border: 1px solid var(--imm-line);
	border-radius: 6px;
	background: var(--imm-paper);
	color: var(--imm-ink);
	font: inherit;
	font-size: .875rem;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
}

.imm-msg .imm-msg__act:hover {
	border-color: var(--imm-steel);
}

.imm-msg .imm-msg__act--primary {
	background: var(--imm-navy-2);
	border-color: var(--imm-navy-2);
	color: #fff;
}

.imm-msg__pre {
	margin: .5rem 0 0;
	white-space: pre-wrap;
	font: inherit;
	font-size: .85rem;
}

.imm-chat__form {
	display: flex;
	gap: .5rem;
	padding: .75rem;
	border-top: 1px solid var(--imm-line-soft);
	background: var(--imm-paper);
	margin: 0;
}

.imm-chat__form input {
	flex: 1;
	border: 1px solid var(--imm-line);
	border-radius: 6px;
	padding: .7rem .85rem;
	font: inherit;
	font-size: .9rem;
	background: var(--imm-ground);
	color: var(--imm-ink);
	min-width: 0;
}

/* iOS Safari zooms the page into a focused field whose text is under 16px, so on phones and touch
   screens the field's text is 16px (.9rem elsewhere is unchanged). Pinch zoom stays available: the
   viewport sets no maximum-scale (Section 508). */
@media (max-width: 61.99em), (pointer: coarse) {
	.imm-chat__form input {
		font-size: max(16px, 1rem);
	}
}

.imm-chat__form button {
	background: var(--imm-navy-2);
	border: 0;
	border-radius: 6px;
	width: 42px;
	display: grid;
	place-items: center;
	cursor: pointer;
}

.imm-chat__form button svg {
	width: 18px;
	height: 18px;
	color: #fff;
}

.imm-chat__foot {
	font-size: .68rem;
	color: var(--imm-muted);
	padding: 0 .9rem .7rem;
	line-height: 1.35;
	background: var(--imm-paper);
}

.imm-chat__foot a {
	color: inherit;
	text-decoration: underline;
}

/* Live agent: typing indicator while the model answers. */
.imm-msg--typing {
	display: inline-flex;
	gap: 4px;
	align-items: center;
	min-height: 1.5em;
}

.imm-msg--typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--imm-muted);
	animation: imm-typing 1s infinite ease-in-out;
}

.imm-msg--typing span:nth-child(2) {
	animation-delay: .15s;
}

.imm-msg--typing span:nth-child(3) {
	animation-delay: .3s;
}

@keyframes imm-typing {
	0%, 80%, 100% { opacity: .3; transform: translateY(0); }
	40% { opacity: 1; transform: translateY(-2px); }
}

/* After a few seconds without an answer: a line that says it is still coming. */
.imm-msg--typing .imm-msg__wait {
	width: auto;
	height: auto;
	margin-left: 6px;
	border-radius: 0;
	background: none;
	color: var(--imm-muted);
	font-size: .875em;
	opacity: 1;
	animation: none;
}

.imm-chat__form button:disabled {
	opacity: .5;
	cursor: wait;
}

@media (prefers-reduced-motion: reduce) {
	.imm-chat *,
	.imm-chat-fab {
		transition: none !important;
		animation: none !important;
	}

	.imm-msg--typing span {
		opacity: .6;
	}
}
