/* SafeAnswer Chatbot widget */
.sa-root {
	--sa-primary: var(--sa-brand, #00558c);
	--sa-text: #1d2327;
	--sa-muted: #50575e;
	--sa-bg: #ffffff;
	--sa-soft: #f2f5f8;
	--sa-border: #c9d1d9;
	--sa-danger: #b3001b;
	--sa-danger-bg: #fff1f2;
	--sa-warn: #7a4b00;
	--sa-warn-bg: #fff8e5;
	--sa-ok: #1e6b35;
	--sa-radius: 14px;
	--sa-focus: #ffbf47;
	font-family: inherit;
	font-size: 16px;
	line-height: 1.5;
	color: var(--sa-text);
	box-sizing: border-box;
}
.sa-root *, .sa-root *::before, .sa-root *::after { box-sizing: inherit; }

.sa-root--floating {
	position: fixed;
	bottom: 20px;
	z-index: 99999;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 12px;
}
.sa-root--floating.sa-pos-right { right: 20px; }
.sa-root--floating.sa-pos-left { left: 20px; align-items: flex-start; }

.sa-root button { font: inherit; cursor: pointer; margin: 0; text-transform: none; letter-spacing: normal; }
.sa-root :focus-visible { outline: 3px solid var(--sa-focus); outline-offset: 2px; box-shadow: 0 0 0 5px #0b0c0c; }

.sa-sr {
	position: absolute !important;
	width: 1px; height: 1px; padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
	white-space: nowrap; border: 0;
}
.sa-svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Launcher */
.sa-launcher {
	display: inline-flex; align-items: center; gap: 10px;
	min-height: 52px; padding: 12px 20px;
	border: 2px solid transparent; border-radius: 999px;
	background: var(--sa-primary); color: #fff;
	font-weight: 600; font-size: 16px;
	box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
}
.sa-launcher:hover { filter: brightness(1.1); }
.sa-launcher .sa-svg { width: 24px; height: 24px; }
.sa-root.is-open .sa-launcher-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.sa-root.is-open .sa-launcher { padding: 12px 14px; }

/* Panel */
.sa-panel {
	display: flex; flex-direction: column;
	background: var(--sa-bg);
	border: 1px solid var(--sa-border);
	border-radius: var(--sa-radius);
	overflow: hidden;
}
.sa-panel[hidden] { display: none; }
.sa-root--floating .sa-panel {
	width: min(400px, calc(100vw - 40px));
	height: min(620px, calc(100vh - 120px));
	box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}
.sa-root--inline .sa-panel { width: 100%; max-width: 760px; height: 600px; margin: 0 auto; }

.sa-header {
	display: flex; align-items: center; justify-content: space-between; gap: 8px;
	padding: 10px 10px 10px 16px;
	background: var(--sa-primary); color: #fff;
}
.sa-root .sa-title { margin: 0; padding: 0; font-size: 17px; font-weight: 700; color: #fff; line-height: 1.3; font-family: inherit; }
.sa-header-actions { display: flex; gap: 4px; }
.sa-icon-btn {
	display: inline-flex; align-items: center; justify-content: center;
	width: 44px; height: 44px; padding: 0;
	background: transparent; color: #fff;
	border: 0; border-radius: 8px;
}
.sa-icon-btn:hover { background: rgba(255, 255, 255, .16); }

.sa-root .sa-disclaimer {
	margin: 0; padding: 8px 16px;
	font-size: 13.5px; line-height: 1.4;
	background: var(--sa-soft); color: var(--sa-muted);
	border-bottom: 1px solid var(--sa-border);
}

.sa-log {
	flex: 1 1 auto; overflow-y: auto;
	padding: 16px; display: flex; flex-direction: column; gap: 12px;
	scroll-behavior: smooth;
}
.sa-log:focus-visible { box-shadow: inset 0 0 0 3px var(--sa-focus); outline: none; }

.sa-msg { display: flex; }
.sa-msg--user { justify-content: flex-end; }
.sa-bubble {
	max-width: 88%;
	padding: 10px 14px;
	border-radius: 16px;
	word-wrap: break-word; overflow-wrap: anywhere;
}
.sa-msg--bot .sa-bubble { background: var(--sa-soft); border-bottom-left-radius: 4px; }
.sa-msg--user .sa-bubble { background: var(--sa-primary); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.sa-msg--answer .sa-bubble, .sa-msg--emergency .sa-bubble, .sa-msg--notice .sa-bubble, .sa-msg--signposts .sa-bubble { max-width: 100%; width: 100%; }
.sa-msg--answer .sa-bubble { background: #fff; border: 1px solid var(--sa-border); }

.sa-root .sa-text p { margin: 0 0 .6em; }
.sa-root .sa-text p:last-child { margin-bottom: 0; }
.sa-root .sa-text ul, .sa-root .sa-text ol { margin: .4em 0 .6em 1.2em; padding: 0; }
.sa-root .sa-text a, .sa-root .sa-links a { color: var(--sa-primary); text-decoration: underline; text-underline-offset: 2px; }

.sa-root .sa-answer-q { margin: 0 0 6px; font-weight: 700; }
.sa-root .sa-reviewed { display: flex; align-items: center; gap: 6px; margin: 10px 0 0; font-size: 13px; color: var(--sa-ok); }
.sa-root .sa-reviewed .sa-svg { width: 16px; height: 16px; }

.sa-root .sa-links { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sa-root .sa-links li { margin: 0; padding: 0; }
.sa-root .sa-links a { display: inline-flex; align-items: center; min-height: 24px; font-weight: 600; }
.sa-root .sa-links a::before { content: "→"; margin-right: 6px; text-decoration: none; display: inline-block; }

.sa-root .sa-links--buttons a {
	display: flex; width: 100%; min-height: 44px; padding: 10px 14px;
	background: #fff; border: 2px solid var(--sa-primary); border-radius: 10px;
	text-decoration: none; color: var(--sa-primary);
}
.sa-root .sa-links--buttons a:hover { background: var(--sa-primary); color: #fff; }
.sa-root .sa-signposts-title { margin: 0 0 4px; font-weight: 700; }

/* Chips */
.sa-chips { display: flex; flex-direction: column; gap: 6px; }
.sa-root .sa-chips-heading { margin: 0; font-size: 13.5px; font-weight: 700; color: var(--sa-muted); }
.sa-root .sa-chip-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.sa-root .sa-chip-list li { margin: 0; padding: 0; }
.sa-chip {
	min-height: 44px; padding: 8px 14px;
	background: #fff; color: var(--sa-primary);
	border: 2px solid var(--sa-primary); border-radius: 999px;
	text-align: left; font-size: 15px; font-weight: 600; line-height: 1.3;
}
.sa-chip:hover { background: var(--sa-primary); color: #fff; }

/* Emergency & notices */
.sa-msg--emergency .sa-bubble { background: var(--sa-danger-bg); border: 2px solid var(--sa-danger); }
.sa-root .sa-emergency-title { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-weight: 800; color: var(--sa-danger); text-transform: uppercase; letter-spacing: .03em; font-size: 14px; }
.sa-call-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.sa-root .sa-call {
	flex: 1 1 120px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	min-height: 48px; padding: 10px 14px;
	background: var(--sa-danger); color: #fff; border-radius: 10px;
	font-weight: 800; font-size: 17px; text-decoration: none;
}
.sa-root .sa-call:hover { filter: brightness(1.1); color: #fff; }
.sa-msg--notice .sa-bubble { background: var(--sa-warn-bg); border: 2px solid #d9a400; color: var(--sa-warn); }
.sa-msg--notice .sa-bubble { color: #4a2f00; }

/* Feedback */
.sa-feedback { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--sa-border); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sa-feedback-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sa-feedback-label { font-size: 14px; color: var(--sa-muted); margin-right: 4px; }
.sa-fb {
	display: inline-flex; align-items: center; gap: 6px;
	min-height: 40px; min-width: 44px; padding: 6px 12px;
	background: #fff; color: var(--sa-text);
	border: 1px solid var(--sa-border); border-radius: 8px; font-size: 14px;
}
.sa-fb:hover:not([aria-disabled="true"]) { border-color: var(--sa-primary); color: var(--sa-primary); }
.sa-fb[aria-pressed="true"] { background: var(--sa-primary); color: #fff; border-color: var(--sa-primary); }
.sa-fb[aria-disabled="true"] { cursor: default; }
.sa-fb[aria-disabled="true"]:not([aria-pressed="true"]) { opacity: .55; }
.sa-fb .sa-svg { width: 16px; height: 16px; }
.sa-feedback-status { font-size: 14px; color: var(--sa-ok); }

/* Typing */
.sa-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.sa-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--sa-muted); animation: sa-bounce 1.2s infinite ease-in-out; }
.sa-dots span:nth-child(2) { animation-delay: .15s; }
.sa-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes sa-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-5px); opacity: 1; } }

/* Footer */
.sa-footer { border-top: 1px solid var(--sa-border); padding: 10px 12px 8px; background: var(--sa-bg); }
.sa-form { display: flex; gap: 8px; margin: 0; }
.sa-root .sa-input {
	flex: 1 1 auto; min-width: 0; min-height: 48px; margin: 0;
	padding: 10px 14px; font: inherit; font-size: 16px;
	color: var(--sa-text); background: #fff;
	border: 2px solid #6c7781; border-radius: 10px;
}
.sa-root .sa-input:focus { border-color: var(--sa-primary); }
.sa-send {
	display: inline-flex; align-items: center; justify-content: center;
	width: 48px; height: 48px; padding: 0;
	background: var(--sa-primary); color: #fff; border: 0; border-radius: 10px;
}
.sa-send[disabled] { opacity: .6; cursor: progress; }
.sa-root .sa-hint { margin: 6px 2px 0; font-size: 12.5px; color: var(--sa-muted); }

/* Small screens: full-screen sheet */
@media (max-width: 480px) {
	.sa-root--floating { bottom: 12px; }
	.sa-root--floating.sa-pos-right { right: 12px; }
	.sa-root--floating.sa-pos-left { left: 12px; }
	.sa-root--floating.is-open .sa-panel {
		position: fixed; inset: 0; width: 100%; height: 100%;
		max-height: none; border-radius: 0; border: 0;
	}
	.sa-root--floating.is-open .sa-launcher { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.sa-log { scroll-behavior: auto; }
	.sa-dots span { animation: none; opacity: .8; }
}

@media (forced-colors: active) {
	.sa-launcher, .sa-send, .sa-chip, .sa-call, .sa-bubble, .sa-panel, .sa-fb { border: 2px solid CanvasText; }
	.sa-svg { stroke: CanvasText; }
}

@media print { .sa-root--floating { display: none !important; } }
