/* Untersbergblick Gäste-Chatbot – Styles
   Farben kommen als CSS-Variablen vom JS (--ub-primary / --ub-accent). */

.ub-cb,
.ub-cb * { box-sizing: border-box; }

:root {
	--ub-primary: #1f4d3a;
	--ub-accent: #2f6fb0;
	--ub-creme: #f6f4ee;
	--ub-line: #e7e3d8;
	--ub-text: #26241f;
}

/* ── Schwebender Button (mit optionalem Text-Label) ── */
.ub-cb-fab {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99998;
	min-height: 56px;
	border: none;
	border-radius: 999px;
	background: var(--ub-primary);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 8px 24px rgba(0,0,0,.22);
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 0 20px 0 16px;
	font-size: 15px;
	font-weight: 600;
	line-height: 1;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	transition: transform .18s ease, box-shadow .18s ease;
}
.ub-cb-fab.ub-cb-iconly { /* ohne Label: runder Button */
	width: 58px;
	height: 58px;
	padding: 0;
	justify-content: center;
	border-radius: 50%;
	animation: ub-fab-beat 2.2s ease-in-out infinite;
}
.ub-cb-fab:hover { transform: scale(1.05); box-shadow: 0 10px 28px rgba(0,0,0,.3); }
.ub-cb-fab svg { width: 26px; height: 26px; flex: none; }
.ub-cb-fab .ub-cb-fab-txt { white-space: nowrap; }

@keyframes ub-fab-beat {
	0%, 100% { transform: scale(1); }
	50%      { transform: scale(1.08); }
}

/* Aufmerksamkeits-Puls */
.ub-cb-fab::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	animation: ub-pulse 2s ease-out infinite;
	pointer-events: none;
}
@keyframes ub-pulse {
	0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ub-primary) 70%, transparent); }
	70%  { box-shadow: 0 0 0 24px rgba(0,0,0,0); }
	100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); }
}

/* Auto-Sprechblase über dem Button */
.ub-cb-teaser {
	position: fixed;
	right: 20px;
	bottom: 92px;
	z-index: 99998;
	max-width: 260px;
	background: #fff;
	color: var(--ub-text);
	border: 1px solid var(--ub-line);
	border-radius: 14px;
	padding: 12px 34px 12px 14px;
	font-size: 14px;
	line-height: 1.45;
	box-shadow: 0 10px 30px rgba(0,0,0,.18);
	cursor: pointer;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	animation: ub-teaser-in .3s ease;
}
.ub-cb-teaser::after { /* Zipfel nach unten Richtung Button */
	content: "";
	position: absolute;
	right: 26px;
	bottom: -7px;
	width: 13px;
	height: 13px;
	background: #fff;
	border-right: 1px solid var(--ub-line);
	border-bottom: 1px solid var(--ub-line);
	transform: rotate(45deg);
}
.ub-cb-teaser-x {
	position: absolute;
	top: 5px;
	right: 7px;
	border: none;
	background: none;
	font-size: 17px;
	line-height: 1;
	color: #9a958a;
	cursor: pointer;
	padding: 2px 4px;
}
@keyframes ub-teaser-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Panel ── */
.ub-cb-backdrop { display: none; }

.ub-cb-panel {
	display: flex;
	flex-direction: column;
	background: #fff;
	border: 1px solid var(--ub-line);
	border-radius: 16px;
	overflow: hidden;
	box-shadow: 0 18px 50px rgba(0,0,0,.25);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--ub-text);
}

/* Floating-Variante: fixe Position */
.ub-cb-panel.ub-cb-floating {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99999;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 600px;
	max-height: calc(100vh - 100px);
}

/* Inline-Variante (Shortcode): im Seitenfluss */
.ub-cb-panel.ub-cb-inline {
	position: relative;
	width: 100%;
	max-width: 520px;
	height: 560px;
	margin: 1.5rem auto;
}

/* Kopfzeile */
.ub-cb-head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 14px;
	background: var(--ub-primary);
	color: var(--ub-creme);
}
.ub-cb-head .ub-cb-ic {
	background: rgba(255,255,255,.16);
	border-radius: 50%;
	padding: 6px;
	display: flex;
}
.ub-cb-head svg { width: 20px; height: 20px; }
.ub-cb-title { flex: 1; line-height: 1.25; }
.ub-cb-title strong { display: block; font-size: 14px; }
.ub-cb-title span { font-size: 12px; opacity: .82; }
.ub-cb-close {
	background: none; border: none; color: inherit; cursor: pointer;
	opacity: .85; padding: 4px; border-radius: 6px;
}
.ub-cb-close:hover { opacity: 1; }

/* Verlauf */
.ub-cb-log {
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 16px 12px;
	background: var(--ub-creme);
	display: flex;
	flex-direction: column;
	gap: 14px;
}
.ub-cb-row { display: flex; gap: 8px; align-items: flex-end; min-width: 0; }
.ub-cb-row.ub-user { justify-content: flex-end; }
.ub-cb-row.ub-bot { justify-content: flex-start; }
.ub-cb-avatar {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	flex: none;
	background: var(--ub-primary);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
}
.ub-cb-avatar svg { width: 17px; height: 17px; }
.ub-cb-msg {
	max-width: 80%;
	min-width: 0;
	padding: 10px 13px;
	font-size: 14px;
	line-height: 1.5;
	border-radius: 16px;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}
.ub-cb-msg.ub-user {
	background: var(--ub-accent);
	color: #fff;
	border-bottom-right-radius: 4px;
}
.ub-cb-msg.ub-bot {
	background: #fff;
	border: 1px solid var(--ub-line);
	border-bottom-left-radius: 4px;
}

/* Vorschläge */
.ub-cb-quick { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 0 38px; }
.ub-cb-quick button {
	font-size: 12px;
	padding: 7px 12px;
	border-radius: 999px;
	background: #fff;
	color: var(--ub-primary);
	border: 1px solid color-mix(in srgb, var(--ub-primary) 28%, transparent);
	cursor: pointer;
}
.ub-cb-quick button:hover { background: var(--ub-creme); }

/* Tipp-Punkte */
.ub-cb-typing { display: inline-flex; gap: 4px; }
.ub-cb-typing span {
	width: 7px; height: 7px; border-radius: 50%;
	background: #b9b4a6; animation: ub-bounce 1s infinite;
}
.ub-cb-typing span:nth-child(2) { animation-delay: .15s; }
.ub-cb-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes ub-bounce { 0%,80%,100% { transform: translateY(0); opacity:.5 } 40% { transform: translateY(-5px); opacity:1 } }

/* Eingabe */
.ub-cb-input {
	display: flex; align-items: flex-end; gap: 8px;
	padding: 10px; background: #fff; border-top: 1px solid var(--ub-line);
}
.ub-cb-input textarea {
	flex: 1; resize: none; border: 1px solid var(--ub-line);
	border-radius: 12px; padding: 9px 11px; font-size: 14px;
	background: var(--ub-creme); color: var(--ub-text);
	max-height: 96px; font-family: inherit; line-height: 1.4;
}
.ub-cb-input textarea:focus { outline: 2px solid var(--ub-accent); outline-offset: 1px; }
.ub-cb-send {
	border: none; border-radius: 12px; padding: 10px;
	background: var(--ub-primary); color: #fff; cursor: pointer; display: flex;
}
.ub-cb-send:disabled { opacity: .4; cursor: default; }
.ub-cb-send.ub-cb-send-idle { opacity: .6; }
.ub-cb-send svg { width: 18px; height: 18px; }

/* Mikrofon-Button (Frage einsprechen) */
.ub-cb-mic {
	border: 1px solid var(--ub-line);
	border-radius: 12px;
	padding: 10px;
	background: var(--ub-creme);
	color: var(--ub-primary);
	cursor: pointer;
	display: flex;
	flex: none;
}
.ub-cb-mic svg { width: 18px; height: 18px; }
.ub-cb-mic.ub-cb-mic-on {
	background: var(--ub-accent);
	color: #fff;
	border-color: var(--ub-accent);
	animation: ub-listen 1.2s ease-in-out infinite;
}
@keyframes ub-listen { 50% { opacity: .55; } }

/* Vorlese-Button an Bot-Antworten */
.ub-cb-speak {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	margin-left: 6px;
	vertical-align: middle;
	border: none;
	border-radius: 6px;
	cursor: pointer;
	flex: none;
	background: color-mix(in srgb, var(--ub-primary) 12%, transparent);
	color: var(--ub-primary);
}
.ub-cb-speak svg { width: 15px; height: 15px; }
.ub-cb-speak:hover { background: color-mix(in srgb, var(--ub-primary) 22%, transparent); }
.ub-cb-speak-loading { animation: ub-listen 1s ease-in-out infinite; }

/* Disclaimer-Fußzeile */
.ub-cb-foot {
	text-align: center; font-size: 10px; color: #a8a394;
	padding: 4px 0 7px; background: #fff;
}

/* Consent-Schicht */
.ub-cb-consent {
	position: absolute; inset: 0; background: rgba(255,255,255,.97);
	display: flex; flex-direction: column; justify-content: center;
	padding: 24px; text-align: center; z-index: 5;
}
.ub-cb-consent p { font-size: 13px; line-height: 1.5; color: var(--ub-text); margin: 0 0 14px; }
.ub-cb-consent a { color: var(--ub-accent); }
.ub-cb-consent button {
	align-self: center; border: none; border-radius: 10px;
	background: var(--ub-primary); color: #fff; padding: 10px 20px;
	font-size: 14px; cursor: pointer;
}
.ub-cb-consent:focus-within button:focus { outline: 2px solid var(--ub-accent); outline-offset: 2px; }

/* Mobile */
@media (max-width: 540px) {
	.ub-cb-panel.ub-cb-floating {
		top: 0; left: 0; right: 0; bottom: auto;
		width: 100vw; max-width: 100vw;
		height: 100dvh; max-height: 100dvh; border-radius: 0;
	}
	/* Deckender Hintergrund, damit nie die Webseite hinter der Tastatur durchscheint */
	.ub-cb-backdrop.ub-cb-open {
		display: block;
		position: fixed; inset: 0;
		background: #fff;
		z-index: 99998;
	}
	/* Auf dem Handy immer nur das runde Icon, nie Text */
	.ub-cb-fab {
		width: 58px; height: 58px;
		padding: 0;
		justify-content: center;
		border-radius: 50%;
	}
	.ub-cb-fab .ub-cb-fab-txt { display: none; }
	/* Verlauf unten andocken: neueste Antwort klebt am Eingabefeld, kein Leerraum */
	.ub-cb-log > :first-child { margin-top: auto; }
}

/* Reduzierte Bewegung respektieren */
@media (prefers-reduced-motion: reduce) {
	.ub-cb-fab, .ub-cb-fab::before, .ub-cb-teaser, .ub-cb-mic-on, .ub-cb-typing span { transition: none; animation: none; }
}
