/**
 * Centricity Research Chatbot — Midnight design system.
 * Tokens taken verbatim from design-system.json. All values scoped under
 * #crx-chatbot to avoid clashing with theme styles.
 */

#crx-chatbot {
	/* Navy (primary) */
	--crx-navy-700: #0D2850;
	--crx-navy-600: #14375F;
	--crx-navy-500: #1D4A7A;
	--crx-navy-50:  #E8EEF6;
	/* Steel (secondary) */
	--crx-steel:    #3E6FA8;
	/* Pine (tertiary / accents) */
	--crx-pine:     #2C6145;
	/* Neutrals */
	--crx-ink:      #0D2850;
	--crx-body:     #2A3A52;
	--crx-muted:    #6B7A90;
	--crx-paper:    #FFFFFF;
	--crx-pearl:    #F4F6FA;
	--crx-border:   #DCE3EE;
	--crx-neutral-100: #EAEFF6;
	/* Type */
	--crx-font-display: 'Poppins', system-ui, -apple-system, sans-serif;
	--crx-font-body: 'Inter', system-ui, -apple-system, sans-serif;
	/* Radius */
	--crx-radius-md: 10px;
	--crx-radius-lg: 16px;
	--crx-radius-xl: 24px;
	--crx-radius-pill: 999px;
	/* Shadow (navy-tinted) */
	--crx-shadow-xs: 0 1px 2px rgba(8,27,51,0.05);
	--crx-shadow-lg: 0 10px 15px -3px rgba(8,27,51,0.12), 0 4px 6px -2px rgba(8,27,51,0.06);
	--crx-shadow-xl: 0 20px 25px -5px rgba(8,27,51,0.16), 0 10px 10px -5px rgba(8,27,51,0.05);
	--crx-gradient: linear-gradient(120deg, #0D2850 0%, #1D4A7A 100%);

	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 2147483000;
	font-family: var(--crx-font-body);
	/* Inter Regular is the body weight in the design system — keep text from
	   inheriting a heavier weight from the host theme. */
	font-weight: 400;
	font-size: 15px;
	line-height: 1.6;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

section#crx-panel button {
    display: flex;
    font-size: 12px;
    padding: 10px 20px;
}

section#crx-panel button svg {
    width: 12px;
    height: 12px;
}

button#crx-launcher {
    display: flex;
}

section#crx-panel button:hover {
    background: #0d2850;
	border:#0d2850;
}

.crx-panel {
    border: 1px solid #0d2850;
}

button#crx-contact {
    margin: 0px 18px;
}

#crx-chatbot *,
#crx-chatbot *::before,
#crx-chatbot *::after {
	box-sizing: border-box;
}

/* Normalize inherited weight from the host theme on all text surfaces. */
#crx-chatbot .crx-msg__bubble,
#crx-chatbot .crx-composer__input,
#crx-chatbot .crx-panel__status,
#crx-chatbot .crx-panel__footer,
#crx-chatbot .crx-field input,
#crx-chatbot .crx-field select,
#crx-chatbot .crx-field textarea {
	font-weight: 400;
}

/* ----------------------------------------------------------------------
 * Launcher pill
 * -------------------------------------------------------------------- */
.crx-launcher {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 10px 20px;
	/* gradient/steel — horizon (from the design system) */
	background: linear-gradient(107deg, #14375F 0.26%, #3E6FA8 100.05%);
	color: #fff;
	border: none;
	border-radius: 30px;
	font-family: var(--crx-font-body);
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 0.01em;
	cursor: pointer;
	/* shadow/lg */
	box-shadow: 0 10px 15px -3px rgba(8,27,51,0.12);
	transition: transform 0.2s ease, box-shadow 0.2s ease, padding 0.3s ease,
		border-radius 0.3s ease, gap 0.3s ease;
}

.crx-launcher:hover {
	transform: translateY(-2px);
	box-shadow: 0 12px 18px -3px rgba(8,27,51,0.18);
}

.crx-launcher:focus-visible {
	outline: none;
	box-shadow: 0 10px 15px -3px rgba(8,27,51,0.12), 0 0 0 3px rgba(62,111,168,0.45);
}

.crx-launcher__mark {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	flex: 0 0 auto;
}

.crx-launcher__icon { display: block; width: 24px; height: 24px; }

.crx-launcher__label {
	white-space: nowrap;
	overflow: hidden;
	max-width: 200px;
	transition: max-width 0.3s ease, opacity 0.25s ease;
}

/* When the panel is open, collapse the launcher to an icon-only circle that
   stays anchored bottom-right while the chat window pops up above it. */
#crx-chatbot.is-open .crx-launcher {
	padding: 0;
	width: 56px;
	height: 56px;
	border-radius: var(--crx-radius-pill);
}

#crx-chatbot.is-open .crx-launcher__label {
	display: none;
}

/* Collapsed state — triggered after 3 s; icon-only pill that expands on hover. */
#crx-chatbot.is-collapsed:not(.is-open) .crx-launcher {
	padding: 16px;
	border-radius: var(--crx-radius-pill);
	gap: 0;
}

#crx-chatbot.is-collapsed:not(.is-open) .crx-launcher .crx-launcher__label {
	max-width: 0;
	opacity: 0;
}

#crx-chatbot.is-collapsed:not(.is-open) .crx-launcher:hover {
	padding: 10px 20px;
	border-radius: 30px;
	gap: 10px;
}

#crx-chatbot.is-collapsed:not(.is-open) .crx-launcher:hover .crx-launcher__label {
	max-width: 200px;
	opacity: 1;
}

/* ----------------------------------------------------------------------
 * Panel
 * -------------------------------------------------------------------- */
/* Native [hidden] must win over the display:flex below. */
.crx-panel[hidden] {
	display: none !important;
}

.crx-panel {
	position: absolute;
	right: 0;
	/* Sit above the collapsed launcher icon (56px) with a small gap. */
	bottom: 72px;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 600px;
	max-height: calc(100vh - 120px);
	display: flex;
	flex-direction: column;
	background: var(--crx-paper);
	border: 1px solid var(--crx-border);
	/* Rounded-rectangle corners. !important + the #crx-chatbot scope guard below
	   keep host-theme resets (e.g. `* { border-radius: 0 }`) from flattening it. */
	border-radius: 16px !important;
	box-shadow: var(--crx-shadow-xl);
	overflow: hidden;
	transform-origin: bottom right;
	animation: crx-pop 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

#crx-chatbot .crx-panel {
	border-radius: 16px;
}

@keyframes crx-pop {
	from { opacity: 0; transform: translateY(12px) scale(0.96); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header — hero "Midnight" gradient with soft radial glows + overline */
.crx-panel__header {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 12px 14px;
	background: linear-gradient(135deg, #0B2648 0%, #0B2648 48%, #14375F 100%);
	color: #fff;
	overflow: hidden;
}

.crx-panel__glow {
	position: absolute;
	border-radius: 50%;
	pointer-events: none;
}
.crx-panel__glow--a {
	top: -55%;
	right: -15%;
	width: 240px;
	height: 240px;
	background: radial-gradient(circle, rgba(30,103,178,0.30) 0%, transparent 70%);
}
.crx-panel__glow--b {
	bottom: -60%;
	left: 10%;
	width: 200px;
	height: 200px;
	background: radial-gradient(circle, rgba(30,103,178,0.16) 0%, transparent 70%);
}

.crx-panel__brand {
	display: flex;
	align-items: center;
	gap: 13px;
	position: relative;
	z-index: 1;
}

.crx-panel__avatar {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	flex: 0 0 auto;
	border-radius: var(--crx-radius-pill);
	background: rgba(255,255,255,0.12);
	box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16);
	color: #fff;
}

.crx-panel__avatar img { display: block; width: 22px; height: 22px; }

.crx-panel__titles {
	display: flex;
	flex-direction: column;
	line-height: 1.25;
}

.crx-panel__eyebrow {
	align-self: flex-start;
	font-size: 9.5px;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: #A6BFDA;
	background: rgba(30,103,178,0.22);
	padding: 2px 8px;
	border-radius: 6px;
	margin-bottom: 3px;
}

.crx-panel__title {
	font-family: var(--crx-font-display);
	font-weight: 600;
	font-size: 16px;
	letter-spacing: -0.01em;
}

.crx-panel__status {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 11.5px;
	color: rgba(255,255,255,0.78);
	margin-top: 2px;
}

.crx-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #4ade80;
	box-shadow: 0 0 0 3px rgba(74,222,128,0.25);
}

.crx-panel__actions {
	position: relative;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	flex: 0 0 auto;
}

.crx-panel__action,
.crx-panel__close {
	position: relative;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border: none;
	border-radius: var(--crx-radius-pill);
	background: rgba(255,255,255,0.12);
	color: #fff;
	cursor: pointer;
	transition: background 0.2s ease;
}

.crx-panel__action:hover,
.crx-panel__close:hover {
	background: rgba(255,255,255,0.24);
}

/* Messages */
.crx-messages {
	flex: 1;
	overflow-y: auto;
	padding: 18px 16px 8px;
	background: var(--crx-pearl);
	display: flex;
	flex-direction: column;
	gap: 12px;
	scroll-behavior: smooth;
}

.crx-messages::-webkit-scrollbar { width: 8px; }
.crx-messages::-webkit-scrollbar-thumb { background: #C2CCDA; border-radius: 99px; }

.crx-msg {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	max-width: 88%;
	animation: crx-fade 0.2s ease;
}

@keyframes crx-fade {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* Small brand avatar beside bot messages (layered Midnight feel) */
.crx-msg__avatar {
	flex: 0 0 auto;
	width: 28px;
	height: 28px;
	border-radius: var(--crx-radius-pill);
	background: var(--crx-paper) center/18px no-repeat;
	background-image: url(../img/logomark-gradient.svg);
	border: 1px solid var(--crx-border);
	box-shadow: var(--crx-shadow-xs);
	align-self: flex-end;
}

.crx-msg__bubble {
	padding: 11px 14px;
	font-size: 14px;
	line-height: 1.55;
	border-radius: var(--crx-radius-lg);
	white-space: pre-wrap;
	word-wrap: break-word;
}

/* Bot */
.crx-msg.is-bot {
	align-self: flex-start;
}
.crx-msg.is-bot .crx-msg__bubble {
	background: var(--crx-paper);
	color: var(--crx-body);
	border: 1px solid var(--crx-border);
	border-bottom-left-radius: 6px;
}

/* User */
.crx-msg.is-user {
	align-self: flex-end;
}
.crx-msg.is-user .crx-msg__bubble {
	background: var(--crx-navy-500);
	color: #fff;
	border-bottom-right-radius: 6px;
}

.crx-msg__bubble a {
	color: inherit;
	text-decoration: underline;
}
.crx-msg.is-bot .crx-msg__bubble a {
	color: var(--crx-navy-500);
}

/* Typing indicator */
.crx-typing {
	display: inline-flex;
	gap: 4px;
	align-items: center;
}
.crx-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #9AA8BC;
	animation: crx-bounce 1.2s infinite ease-in-out;
}
.crx-typing span:nth-child(2) { animation-delay: 0.15s; }
.crx-typing span:nth-child(3) { animation-delay: 0.3s; }

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

/* Quick replies */
.crx-quickreplies {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 4px 16px 12px;
	background: var(--crx-pearl);
}

.crx-chip {
	padding: 8px 14px;
	background: var(--crx-paper);
	border: 1px solid var(--crx-steel);
	color: var(--crx-navy-500);
	border-radius: var(--crx-radius-pill);
	font-family: var(--crx-font-body);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.18s ease, color 0.18s ease;
}

.crx-chip:hover {
	background: var(--crx-navy-50);
}

/* Always-available "Connect with a team member" bar */
.crx-contactbar {
	display: flex;
	align-items: center;
	gap: 9px;
	width: 100%;
	padding: 11px 16px;
	border: none;
	border-top: 1px solid var(--crx-border);
	background: var(--crx-navy-50);
	color: var(--crx-navy-500);
	font-family: var(--crx-font-body);
	font-size: 13.5px;
	font-weight: 600;
	letter-spacing: 0.01em;
	cursor: pointer;
	transition: background 0.18s ease;
}

.crx-contactbar:hover {
	background: #DCE7F4;
}

.crx-contactbar__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	flex: 0 0 auto;
	border-radius: var(--crx-radius-pill);
	background: var(--crx-paper);
	color: var(--crx-navy-500);
	box-shadow: var(--crx-shadow-xs);
}

.crx-contactbar__label { flex: 1; text-align: left; }

.crx-contactbar__chev { color: var(--crx-steel); flex: 0 0 auto; }

/* Composer */
.crx-composer {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 14px;
	border-top: 1px solid var(--crx-border);
	background: var(--crx-paper);
}

.crx-composer__input {
	flex: 1;
	padding: 11px 14px;
	border: 1px solid #C2CCDA;
	border-radius: var(--crx-radius-pill);
	font-family: var(--crx-font-body);
	font-size: 14px;
	color: var(--crx-body);
	background: var(--crx-paper);
	outline: none;
	transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.crx-composer__input::placeholder { color: #9AA8BC; }

.crx-composer__input:focus {
	border-color: var(--crx-navy-500);
	box-shadow: 0 0 0 3px rgba(62,111,168,0.22);
}

.crx-composer__send {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	flex: 0 0 auto;
	border: none;
	border-radius: var(--crx-radius-pill);
	background: var(--crx-navy-500);
	color: #fff;
	cursor: pointer;
	transition: background 0.18s ease;
}

.crx-composer__send:hover { background: var(--crx-navy-600); }

.crx-panel__footer {
	text-align: center;
	font-size: 11px;
	color: var(--crx-muted);
	padding: 8px;
	background: var(--crx-paper);
	border-top: 1px solid var(--crx-border);
}

/* ----------------------------------------------------------------------
 * Lead form (inside a bot bubble)
 * -------------------------------------------------------------------- */
.crx-leadform {
	display: flex;
	flex-direction: column;
	gap: 10px;
	width: 100%;
}

.crx-leadform__title {
	font-family: var(--crx-font-display);
	font-weight: 600;
	font-size: 15px;
	color: var(--crx-ink);
}

.crx-field {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.crx-field label {
	font-size: 12px;
	font-weight: 600;
	color: var(--crx-body);
}

.crx-field input,
.crx-field select,
.crx-field textarea {
	width: 100%;
	padding: 9px 12px;
	border: 1px solid #C2CCDA;
	border-radius: var(--crx-radius-md);
	font-family: var(--crx-font-body);
	font-size: 13px;
	color: var(--crx-body);
	background: var(--crx-paper);
	outline: none;
}

.crx-field input:focus,
.crx-field select:focus,
.crx-field textarea:focus {
	border-color: var(--crx-navy-500);
	box-shadow: 0 0 0 3px rgba(62,111,168,0.2);
}

.crx-field textarea { resize: vertical; min-height: 56px; }

.crx-leadform__actions {
	display: flex;
	gap: 8px;
	margin-top: 2px;
}

.crx-btn {
	padding: 10px 18px;
	border-radius: var(--crx-radius-pill);
	font-family: var(--crx-font-body);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.02em;
	border: 2px solid transparent;
	cursor: pointer;
	transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.crx-btn--primary {
	background: var(--crx-navy-500);
	border-color: var(--crx-navy-500);
	color: #fff;
}
.crx-btn--primary:hover { background: var(--crx-navy-600); border-color: var(--crx-navy-600); }
.crx-btn--primary:disabled { opacity: 0.5; cursor: default; }

.crx-btn--ghost {
	background: transparent;
	color: var(--crx-muted);
}
.crx-btn--ghost:hover { background: var(--crx-neutral-100); color: var(--crx-body); }

.crx-field__error {
	font-size: 12px;
	color: #C0504D;
}

/* ----------------------------------------------------------------------
 * Responsive
 * -------------------------------------------------------------------- */
/* Tablet / short viewports — let the panel breathe without overflowing. */
@media (max-width: 600px) {
	.crx-panel {
		width: min(380px, calc(100vw - 24px));
		height: min(600px, calc(100vh - 120px));
	}
}

/* Phones — go (nearly) full-screen and pin to the viewport edges. */
@media (max-width: 479px) {
	#crx-chatbot { right: 12px; bottom: 12px; }
	.crx-panel {
		position: fixed;
		right: 0;
		bottom: 0;
		width: 100vw;
		height: 100vh;
		height: 100dvh;
		max-width: none;
		max-height: none;
		border-radius: 0 !important;
		border: none;
	}
	#crx-chatbot .crx-panel { border-radius: 0; }
	.crx-launcher__label { display: none; }
	.crx-launcher { padding: 16px; }
	/* A touch more room for the header on the larger phone canvas. */
	.crx-panel__header { padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); }
	.crx-messages { padding: 16px 14px 8px; }
}

@media (prefers-reduced-motion: reduce) {
	#crx-chatbot * { animation: none !important; transition: none !important; }
}
