/*
 * C&S Chatbot.
 *
 * Inherits the theme's brand tokens where they exist and falls back to the
 * brand navy otherwise, so the widget matches the site without being coupled
 * to the theme being active.
 */

.cs-chat {
	--chat-accent: var(--cs-accent, #0D193E);
	--chat-accent-ink: var(--cs-accent-ink, #FFFFFF);
	--chat-seal: var(--cs-seal, #A67C34);
	--chat-ink: var(--cs-ink, #0F1A2E);
	--chat-ground: var(--cs-ground, #FFFFFF);
	--chat-line: color-mix(in srgb, var(--chat-accent) 16%, transparent);
	--chat-surface: color-mix(in srgb, var(--chat-accent) 5%, var(--chat-ground));
	--chat-radius: var(--cs-radius, 2px);
	--chat-font: var(--cs-font-body, system-ui, sans-serif);
	--chat-font-head: var(--cs-font-head, system-ui, sans-serif);
	--chat-font-data: var(--cs-font-data, ui-monospace, monospace);

	font-family: var(--chat-font);
	color: var(--chat-ink);
}

/* Launcher ----------------------------------------------------------- */

.cs-chat__launcher {
	position: fixed;
	right: 1.25rem;
	bottom: 1.25rem;
	z-index: 9998;
	display: inline-flex;
	align-items: center;
	gap: .55rem;
	padding: .8rem 1.15rem;
	background: var(--chat-accent);
	color: var(--chat-accent-ink);
	border: 0;
	border-radius: 999px;
	font: inherit;
	font-weight: 600;
	font-size: .9375rem;
	cursor: pointer;
	box-shadow: 0 6px 24px rgba(13, 25, 62, .28);
}

.cs-chat__launcher:hover { background: color-mix(in srgb, var(--chat-accent) 85%, #000); }
.cs-chat__launcher svg { flex: none; }

/* Panel -------------------------------------------------------------- */

.cs-chat__panel {
	display: flex;
	flex-direction: column;
	background: var(--chat-ground);
	border: 1px solid var(--chat-line);
	border-radius: var(--chat-radius);
	overflow: hidden;
}

.cs-chat[data-variant="floating"] .cs-chat__panel {
	position: fixed;
	right: 1.25rem;
	bottom: 1.25rem;
	z-index: 9999;
	width: min(23rem, calc(100vw - 2.5rem));
	height: min(34rem, calc(100vh - 4rem));
	box-shadow: 0 18px 50px rgba(13, 25, 62, .3);
}

/* Inline, the panel starts compact and grows with the conversation rather
   than reserving a screenful of empty log. */
.cs-chat--inline .cs-chat__panel { min-height: 20rem; max-height: min(34rem, 80vh); }
.cs-chat--inline .cs-chat__log { min-height: 8rem; }
.cs-chat__page-heading { margin-bottom: 1rem; }

.cs-chat__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .75rem;
	padding: .85rem 1rem;
	background: var(--chat-accent);
	color: var(--chat-accent-ink);
}

.cs-chat__title { margin: 0; font-family: var(--chat-font-head); font-size: 1rem; font-weight: 600; color: inherit; }

.cs-chat__close {
	background: none;
	border: 0;
	color: inherit;
	cursor: pointer;
	padding: .25rem;
	line-height: 1;
	font-size: 1.25rem;
	opacity: .8;
}

.cs-chat__close:hover { opacity: 1; }

/* Log ---------------------------------------------------------------- */

.cs-chat__log {
	flex: 1;
	overflow-y: auto;
	padding: 1rem;
	display: flex;
	flex-direction: column;
	gap: .7rem;
	background: var(--chat-surface);
}

.cs-chat__msg {
	max-width: 85%;
	padding: .6rem .8rem;
	border-radius: var(--chat-radius);
	font-size: .9375rem;
	line-height: 1.5;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.cs-chat__msg--bot {
	align-self: flex-start;
	background: var(--chat-ground);
	border: 1px solid var(--chat-line);
}

.cs-chat__msg--user {
	align-self: flex-end;
	background: var(--chat-accent);
	color: var(--chat-accent-ink);
}

/* A saved answer arrives as markup, so the newlines between its tags must not
   survive as blank lines the way they do in a plain-text reply. */
.cs-chat__msg--rich { white-space: normal; }
.cs-chat__msg--rich > :first-child { margin-top: 0; }
.cs-chat__msg--rich > :last-child { margin-bottom: 0; }
.cs-chat__msg--rich ul,
.cs-chat__msg--rich ol { margin: .4rem 0; padding-left: 1.15rem; }
.cs-chat__msg--rich li { margin: .15rem 0; }
.cs-chat__msg--rich a { color: var(--chat-accent); text-underline-offset: .15em; }

.cs-chat__msg--note {
	align-self: stretch;
	max-width: none;
	background: transparent;
	border-left: 2px solid var(--chat-seal);
	border-radius: 0;
	font-size: .875rem;
	color: color-mix(in srgb, var(--chat-ink) 70%, transparent);
}

.cs-chat__typing {
	align-self: flex-start;
	font-family: var(--chat-font-data);
	font-size: .75rem;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: color-mix(in srgb, var(--chat-ink) 55%, transparent);
}

/* Quick replies ------------------------------------------------------ */

.cs-chat__quick {
	display: flex;
	flex-wrap: wrap;
	gap: .4rem;
	padding: 0 1rem .75rem;
	background: var(--chat-surface);
}

.cs-chat__chip {
	background: var(--chat-ground);
	border: 1px solid var(--chat-line);
	border-radius: 999px;
	padding: .4rem .75rem;
	font: inherit;
	font-size: .8125rem;
	color: var(--chat-accent);
	cursor: pointer;
}

.cs-chat__chip:hover { border-color: var(--chat-seal); }

/* Composer ----------------------------------------------------------- */

.cs-chat__form {
	display: flex;
	gap: .5rem;
	padding: .75rem;
	border-top: 1px solid var(--chat-line);
	background: var(--chat-ground);
}

.cs-chat__input {
	flex: 1;
	resize: none;
	font: inherit;
	font-size: .9375rem;
	padding: .55rem .7rem;
	border: 1px solid var(--chat-line);
	border-radius: var(--chat-radius);
	color: inherit;
	background: var(--chat-ground);
	max-height: 7rem;
}

.cs-chat__input:focus-visible,
.cs-chat__chip:focus-visible,
.cs-chat__send:focus-visible,
.cs-chat__launcher:focus-visible {
	outline: 2px solid var(--chat-seal);
	outline-offset: 2px;
}

.cs-chat__send {
	background: var(--chat-accent);
	color: var(--chat-accent-ink);
	border: 0;
	border-radius: var(--chat-radius);
	padding: 0 .9rem;
	font: inherit;
	font-weight: 600;
	font-size: .875rem;
	cursor: pointer;
}

.cs-chat__send[disabled] { opacity: .55; cursor: default; }

/* Handoff form ------------------------------------------------------- */

.cs-chat__handoff {
	padding: 1rem;
	border-top: 1px solid var(--chat-line);
	background: var(--chat-ground);
	display: grid;
	gap: .5rem;
}

.cs-chat__handoff h3 { margin: 0 0 .25rem; font-family: var(--chat-font-head); font-size: .9375rem; }

.cs-chat__handoff input {
	font: inherit;
	font-size: .9375rem;
	padding: .5rem .65rem;
	border: 1px solid var(--chat-line);
	border-radius: var(--chat-radius);
	width: 100%;
	color: inherit;
	background: var(--chat-ground);
}

.cs-chat__handoff-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.cs-chat__footer-actions {
	display: flex;
	gap: .5rem;
	flex-wrap: wrap;
	padding: 0 .75rem .75rem;
	background: var(--chat-ground);
}

.cs-chat__link {
	background: none;
	border: 0;
	padding: 0;
	font: inherit;
	font-size: .8125rem;
	color: var(--chat-seal);
	text-decoration: underline;
	cursor: pointer;
}

.cs-chat[hidden],
.cs-chat [hidden] { display: none !important; }

.cs-chat__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
	.cs-chat * { transition: none !important; animation: none !important; }
}
