/*
 * Abihealth Care Chat -- widget styles.
 * Styled to match care.abihealth.co.uk: Poppins, brand blue (#2177C2), soft
 * sky-blue accents (#6ec1e4), pill-shaped controls, on white. All selectors are
 * scoped under .abihealth-chat so they never collide with the host theme;
 * colours derive from --abihealth-accent so re-theming is a single value.
 */
.abihealth-chat {
	--abihealth-accent: #2177c2;
	--abihealth-accent-dark: #1a5f9c;
	--abihealth-accent-soft: #6ec1e4;
	--abihealth-tint: #eef6fb;
	--abihealth-bg: #ffffff;
	--abihealth-fg: #3a4450;
	--abihealth-muted: #7a7a7a;
	--abihealth-user-bg: var(--abihealth-accent);
	--abihealth-bot-bg: var(--abihealth-tint);
	--abihealth-radius: 12px;
	--abihealth-font: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	position: fixed;
	right: 22px;
	bottom: 22px;
	z-index: 2147483000;
	font-family: var(--abihealth-font);
	font-size: 15px;
	line-height: 1.5;
	color: var(--abihealth-fg);
}

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

/* Launcher --------------------------------------------------------------- */
.abihealth-launcher {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 13px 20px;
	border-radius: 14px;
	border: 0;
	background: var(--abihealth-accent);
	color: #fff;
	cursor: pointer;
	font-family: var(--abihealth-font);
	font-size: 15px;
	font-weight: 600;
	box-shadow: 0 8px 22px rgba(33, 119, 194, 0.38);
	transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.abihealth-launcher:hover {
	transform: translateY(-2px);
	background: var(--abihealth-accent-dark);
	box-shadow: 0 12px 26px rgba(33, 119, 194, 0.45);
}
.abihealth-launcher:focus-visible { outline: 3px solid var(--abihealth-accent-soft); outline-offset: 3px; }
.abihealth-launcher-label { white-space: nowrap; line-height: 1; }
.abihealth-launcher svg { flex: 0 0 auto; }

/* Panel ------------------------------------------------------------------ */
.abihealth-panel {
	position: absolute;
	right: 0;
	bottom: 78px;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 120px);
	background: var(--abihealth-bg);
	border-radius: 20px;
	box-shadow: 0 18px 50px rgba(26, 51, 84, 0.28);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: abihealth-pop 0.18s ease-out;
}
.abihealth-panel[hidden] { display: none; }
@keyframes abihealth-pop {
	from { opacity: 0; transform: translateY(12px) scale(0.98); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

.abihealth-header {
	background: linear-gradient(135deg, var(--abihealth-accent) 0%, var(--abihealth-accent-dark) 100%);
	color: #fff;
	padding: 16px 18px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.abihealth-title { font-weight: 600; font-size: 16px; letter-spacing: 0.2px; }
.abihealth-close {
	background: rgba(255, 255, 255, 0.15);
	border: 0;
	color: #fff;
	width: 30px; height: 30px;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	border-radius: 8px;
	display: flex; align-items: center; justify-content: center;
	transition: background 0.14s ease;
}
.abihealth-close:hover { background: rgba(255, 255, 255, 0.28); }
.abihealth-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Messages --------------------------------------------------------------- */
.abihealth-messages {
	flex: 1;
	overflow-y: auto;
	padding: 18px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: #ffffff;
}
.abihealth-msg { display: flex; flex-direction: column; max-width: 86%; }
.abihealth-msg--user { align-self: flex-end; align-items: flex-end; }
.abihealth-msg--bot { align-self: flex-start; align-items: flex-start; }

.abihealth-bubble {
	padding: 11px 15px;
	border-radius: var(--abihealth-radius);
	word-wrap: break-word;
	overflow-wrap: anywhere;
}
.abihealth-msg--user .abihealth-bubble {
	background: var(--abihealth-user-bg);
	color: #fff;
	border-bottom-right-radius: 5px;
}
.abihealth-msg--bot .abihealth-bubble {
	background: var(--abihealth-bot-bg);
	color: var(--abihealth-fg);
	border-bottom-left-radius: 5px;
}
.abihealth-bubble a { color: inherit; text-decoration: underline; }
.abihealth-msg--bot .abihealth-bubble a { color: var(--abihealth-accent); }

/* Source chips ----------------------------------------------------------- */
.abihealth-sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.abihealth-source {
	font-size: 12.5px;
	font-weight: 500;
	text-decoration: none;
	color: var(--abihealth-accent);
	border: 1px solid var(--abihealth-accent-soft);
	border-radius: 8px;
	padding: 4px 11px;
	background: var(--abihealth-tint);
	transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.abihealth-source:hover { background: var(--abihealth-accent); border-color: var(--abihealth-accent); color: #fff; }

/* Typing indicator ------------------------------------------------------- */
.abihealth-typing .abihealth-bubble { display: inline-flex; gap: 4px; align-items: center; }
.abihealth-dot {
	width: 7px; height: 7px; border-radius: 50%;
	background: var(--abihealth-accent);
	opacity: 0.5;
	animation: abihealth-blink 1.2s infinite ease-in-out both;
}
.abihealth-dot:nth-child(2) { animation-delay: 0.2s; }
.abihealth-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes abihealth-blink { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Input bar -------------------------------------------------------------- */
.abihealth-inputbar {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid #e9eef3;
	background: var(--abihealth-bg);
}
.abihealth-input {
	flex: 1;
	resize: none;
	border: 1px solid #d4dde5;
	border-radius: 10px;
	padding: 10px 14px;
	font: inherit;
	font-size: 14.5px;
	color: var(--abihealth-fg);
	max-height: 120px;
	transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
.abihealth-input::placeholder { color: #9aa5b1; }
.abihealth-input:focus-visible {
	outline: none;
	border-color: var(--abihealth-accent);
	box-shadow: 0 0 0 3px rgba(33, 119, 194, 0.15);
}
.abihealth-send {
	flex: 0 0 auto;
	height: 44px;
	padding: 0 18px;
	border: 0; border-radius: 12px;
	background: var(--abihealth-accent);
	color: #fff;
	font-family: var(--abihealth-font);
	font-size: 14.5px;
	font-weight: 600;
	cursor: pointer;
	display: flex; align-items: center; justify-content: center;
	transition: background 0.14s ease, transform 0.14s ease;
}
.abihealth-send:hover:not(:disabled) { background: var(--abihealth-accent-dark); transform: scale(1.05); }
.abihealth-send:disabled { opacity: 0.45; cursor: default; }
.abihealth-send:focus-visible { outline: 2px solid var(--abihealth-accent-soft); outline-offset: 2px; }

.abihealth-note {
	padding: 8px 14px 12px;
	font-size: 11.5px;
	color: var(--abihealth-muted);
	background: var(--abihealth-bg);
	text-align: center;
}

/* Mobile ----------------------------------------------------------------- */
@media (max-width: 480px) {
	.abihealth-chat { right: 16px; bottom: 16px; }
	.abihealth-panel {
		width: 100vw;
		height: 100dvh;
		max-width: 100vw;
		max-height: 100dvh;
		right: -16px;
		bottom: -16px;
		border-radius: 0;
	}
}

/* Respect reduced-motion ------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	.abihealth-launcher,
	.abihealth-source,
	.abihealth-send { transition: none; }
	.abihealth-panel { animation: none; }
	.abihealth-dot { animation: none; opacity: 0.6; }
}
