/* Hansi 0.5.0 – Layout im Stil von Version 0.2.0 */

#hansi-root {
	--hansi-green: #3d8b2f;
	--hansi-green-dark: #2c6b21;
	--hansi-green-light: #6dbb3c;
	--hansi-bg: #f3f8ee;
	--hansi-text: #24301f;
	--hansi-muted: #5d6b57;
	--hansi-border: #dbe7d1;
	font-family: inherit;
	font-size: 16px;
	line-height: 1.5;
	color: var(--hansi-text);
}

#hansi-root,
#hansi-root * {
	box-sizing: border-box;
}

#hansi-root [hidden] {
	display: none !important;
}

.hansi-sr {
	position: absolute !important;
	width: 1px; height: 1px;
	overflow: hidden; clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* ---------- Button „Frag Hansi“ ---------- */

#hansi-root .hansi-launcher {
	position: fixed !important;
	right: 20px;
	bottom: 20px;
	top: auto !important;
	left: auto !important;
	transform: none;
	z-index: 2147483000;
	display: flex;
	align-items: center;
	gap: 0;
	margin: 0;
	padding: 0;
	width: auto;
	height: auto;
	min-height: 0;
	background: transparent;
	border: 0;
	box-shadow: none;
	cursor: pointer;
	font: inherit;
	text-transform: none;
	letter-spacing: normal;
	-webkit-tap-highlight-color: transparent;
}

#hansi-root .hansi-launcher-label {
	order: 1;
	margin-right: -10px;
	padding: 8px 20px 8px 14px;
	background: #fff;
	color: var(--hansi-green-dark);
	font-size: 15px;
	font-weight: 700;
	line-height: 1.2;
	white-space: nowrap;
	border-radius: 999px 0 0 999px;
	box-shadow: 0 4px 14px rgba(0, 0, 0, .15);
}

#hansi-root .hansi-launcher-img {
	order: 2;
	position: relative;
	display: block;
	width: 64px;
	height: 64px;
	max-width: none;
	margin: 0;
	border: 3px solid #fff;
	border-radius: 50%;
	object-fit: cover;
	box-shadow: 0 4px 14px rgba(0, 0, 0, .22);
	transition: transform .2s ease;
}

#hansi-root .hansi-launcher:hover .hansi-launcher-img,
#hansi-root .hansi-launcher:focus-visible .hansi-launcher-img {
	transform: scale(1.06) rotate(-4deg);
}

#hansi-root .hansi-launcher:focus-visible {
	outline: 3px solid var(--hansi-green-light);
	outline-offset: 4px;
	border-radius: 999px;
}

#hansi-root.is-open .hansi-launcher-label {
	display: none;
}

/* ---------- Chatfenster ---------- */

#hansi-root .hansi-window {
	position: fixed !important;
	right: 20px;
	bottom: 100px;
	top: auto;
	left: auto;
	z-index: 2147483001;
	display: flex;
	flex-direction: column;
	width: 370px;
	max-width: calc(100vw - 40px);
	height: 560px;
	max-height: calc(100vh - 130px);
	margin: 0;
	padding: 0;
	background: #fff;
	border-radius: 18px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, .22);
	overflow: hidden;
	animation: hansi-in .2s ease-out;
}

@keyframes hansi-in {
	from { opacity: 0; transform: translateY(12px); }
	to   { opacity: 1; transform: none; }
}

#hansi-root .hansi-head {
	display: flex;
	align-items: center;
	gap: 12px;
	flex: 0 0 auto;
	padding: 14px 14px 14px 16px;
	background: linear-gradient(135deg, var(--hansi-green) 0%, var(--hansi-green-light) 100%);
	color: #fff;
}

#hansi-root .hansi-head-img {
	width: 56px;
	height: 56px;
	max-width: none;
	margin: 0;
	border: 3px solid #fff;
	border-radius: 50%;
	object-fit: cover;
	background: #fff;
	flex: 0 0 auto;
}

#hansi-root .hansi-head-text {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-width: 0;
}

#hansi-root .hansi-title {
	font-size: 19px;
	font-weight: 700;
	line-height: 1.2;
	color: #fff;
}

#hansi-root .hansi-subtitle {
	font-size: 13px;
	line-height: 1.3;
	color: rgba(255, 255, 255, .92);
}

#hansi-root .hansi-close {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 36px;
	height: 36px;
	min-height: 0;
	margin: 0;
	padding: 0;
	background: rgba(255, 255, 255, .18);
	color: #fff;
	border: 0;
	border-radius: 50%;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	box-shadow: none;
}

#hansi-root .hansi-close:hover,
#hansi-root .hansi-close:focus-visible {
	background: rgba(255, 255, 255, .32);
	outline: none;
}

/* ---------- Nachrichten ---------- */

#hansi-root .hansi-messages {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	padding: 16px 14px 8px;
	overflow-y: auto;
	overflow-anchor: none;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	background: var(--hansi-bg);
}

#hansi-root .hansi-msg {
	max-width: 88%;
	margin: 0 0 10px;
	padding: 10px 13px;
	font-size: 15px;
	line-height: 1.45;
	border-radius: 14px;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

#hansi-root .hansi-msg--bot {
	margin-right: auto;
	background: #fff;
	color: var(--hansi-text);
	border: 1px solid var(--hansi-border);
	border-bottom-left-radius: 4px;
}

#hansi-root .hansi-msg--user {
	margin-left: auto;
	background: var(--hansi-green);
	color: #fff;
	border-bottom-right-radius: 4px;
}

#hansi-root .hansi-msg--wait {
	color: var(--hansi-muted);
	font-style: italic;
}

#hansi-root .hansi-results {
	margin: 0 0 12px;
	padding: 0;
	list-style: none;
}

#hansi-root .hansi-result {
	margin: 0 0 8px;
	padding: 11px 13px;
	background: #fff;
	border: 1px solid var(--hansi-border);
	border-left: 4px solid var(--hansi-green-light);
	border-radius: 10px;
}

#hansi-root .hansi-result-type {
	display: inline-block;
	margin: 0 0 4px;
	padding: 1px 8px;
	font-size: 11px;
	font-weight: 600;
	line-height: 1.6;
	letter-spacing: .02em;
	text-transform: uppercase;
	color: var(--hansi-green-dark);
	background: #e6f2dc;
	border-radius: 999px;
}

#hansi-root .hansi-result-title {
	display: block;
	margin: 0 0 4px;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.3;
	color: var(--hansi-green-dark);
	text-decoration: none;
}

#hansi-root .hansi-result-title:hover,
#hansi-root .hansi-result-title:focus-visible {
	text-decoration: underline;
}

#hansi-root .hansi-result-excerpt {
	margin: 0 0 6px;
	font-size: 14px;
	line-height: 1.45;
	color: #3b4636;
}

#hansi-root .hansi-result-more {
	font-size: 13px;
	font-weight: 600;
	color: var(--hansi-green);
	text-decoration: none;
}

#hansi-root .hansi-result-more:hover {
	text-decoration: underline;
}

#hansi-root .hansi-spacer {
	display: block;
	width: 100%;
	pointer-events: none;
}

/* ---------- Hinweis & Eingabe ---------- */

#hansi-root .hansi-note {
	flex: 0 0 auto;
	margin: 0;
	padding: 7px 14px;
	font-size: 11.5px;
	line-height: 1.35;
	color: var(--hansi-muted);
	background: var(--hansi-bg);
	border-top: 1px solid var(--hansi-border);
}

#hansi-root .hansi-form {
	display: flex;
	gap: 8px;
	flex: 0 0 auto;
	margin: 0;
	padding: 10px 12px 12px;
	background: #fff;
	border-top: 1px solid var(--hansi-border);
}

#hansi-root .hansi-input {
	flex: 1 1 auto;
	min-width: 0;
	height: 44px;
	margin: 0;
	padding: 0 16px;
	font: inherit;
	font-size: 16px; /* verhindert Zoom auf iOS */
	color: var(--hansi-text);
	background: #fff;
	border: 1.5px solid var(--hansi-border);
	border-radius: 999px;
	box-shadow: none;
	outline: none;
}

#hansi-root .hansi-input:focus {
	border-color: var(--hansi-green-light);
	box-shadow: 0 0 0 3px rgba(109, 187, 60, .2);
}

#hansi-root .hansi-send {
	flex: 0 0 auto;
	height: 44px;
	min-height: 0;
	margin: 0;
	padding: 0 18px;
	font: inherit;
	font-size: 15px;
	font-weight: 700;
	line-height: 1;
	text-transform: none;
	letter-spacing: normal;
	color: #fff;
	background: var(--hansi-green);
	border: 0;
	border-radius: 999px;
	box-shadow: none;
	cursor: pointer;
}

#hansi-root .hansi-send:hover,
#hansi-root .hansi-send:focus-visible {
	background: var(--hansi-green-dark);
	outline: none;
}

#hansi-root .hansi-send[disabled] {
	opacity: .6;
	cursor: default;
}

/* ---------- Mobil ---------- */

@media (max-width: 600px) {
	#hansi-root .hansi-launcher {
		right: 14px;
		bottom: 14px;
	}

	#hansi-root .hansi-launcher-img {
		width: 58px;
		height: 58px;
	}

	#hansi-root .hansi-launcher-label {
		font-size: 14px;
	}

	#hansi-root.is-open .hansi-launcher {
		display: none;
	}

	#hansi-root .hansi-window {
		right: 0;
		left: 0;
		bottom: 0;
		top: auto;
		width: 100%;
		max-width: 100%;
		height: 100%;
		max-height: 100%;
		border-radius: 0;
	}

	#hansi-root .hansi-window.is-viewport {
		/* Höhe/Position setzt das Skript passend zur Bildschirmtastatur */
		bottom: auto;
	}

	#hansi-root .hansi-head {
		padding: 10px 12px;
		padding-top: max(10px, env(safe-area-inset-top));
	}

	#hansi-root .hansi-head-img {
		width: 46px;
		height: 46px;
	}

	#hansi-root .hansi-form {
		padding-bottom: max(12px, env(safe-area-inset-bottom));
	}
}

@media (prefers-reduced-motion: reduce) {
	#hansi-root .hansi-window { animation: none; }
	#hansi-root .hansi-launcher-img { transition: none; }
}

@media print {
	#hansi-root { display: none !important; }
}
