/* ==========================================================================
   FWS Chatbot – Frontend
   Farben, Rundung und Schrift kommen als CSS-Variablen aus den Einstellungen.
   ========================================================================== */

#fws-cb-root {
	--fwscb-accent: #6ba83d;
	--fwscb-deep: #2f5e1c;
	--fwscb-radius: 20px;
	--fwscb-font: inherit;

	--fwscb-bg: #ffffff;
	--fwscb-fg: #14171a;
	--fwscb-muted: #5f676e;
	--fwscb-surface: #f2f4f0;
	--fwscb-line: rgba(0, 0, 0, .08);
	--fwscb-shadow: 0 28px 70px -28px rgba(12, 20, 8, .55);

	position: fixed;
	inset: auto 0 0 0;
	z-index: 99990;
	pointer-events: none;
	font-family: var(--fwscb-font);
}

#fws-cb-root[data-theme="dark"] { color-scheme: dark; }

#fws-cb-root[data-theme="dark"],
#fws-cb-root[data-theme="auto"].fwscb-dark {
	--fwscb-bg: #15181a;
	--fwscb-fg: #eef0f1;
	--fwscb-muted: #a0a7ad;
	--fwscb-surface: #22262a;
	--fwscb-line: rgba(255, 255, 255, .1);
	--fwscb-shadow: 0 28px 70px -28px rgba(0, 0, 0, .8);
}

#fws-cb-root *,
#fws-cb-root *::before,
#fws-cb-root *::after { box-sizing: border-box; }

#fws-cb-root button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }

/* ---------- Launcher ---------- */

.fwscb-launcher {
	pointer-events: auto;
	position: fixed;
	bottom: 22px;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 9px 20px 9px 9px;
	border-radius: 999px;
	color: #fff;
	background: linear-gradient(135deg, var(--fwscb-accent), var(--fwscb-deep));
	box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .5);
	font-size: 15px;
	font-weight: 600;
	line-height: 1;
	transition: transform .25s cubic-bezier(.2, .8, .3, 1), box-shadow .25s;
}
#fws-cb-root[data-pos="right"] .fwscb-launcher { right: 22px; }
#fws-cb-root[data-pos="left"]  .fwscb-launcher { left: 22px; flex-direction: row-reverse; padding: 9px 9px 9px 20px; }

.fwscb-launcher:hover { transform: translateY(-2px); box-shadow: 0 20px 38px -14px rgba(0, 0, 0, .55); }
.fwscb-launcher:focus-visible { outline: 3px solid var(--fwscb-accent); outline-offset: 3px; }
.fwscb-launcher.is-hidden { opacity: 0; transform: scale(.85); pointer-events: none; }

.fwscb-launcher-av {
	width: 36px; height: 36px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .22);
	display: flex; align-items: center; justify-content: center;
	font-size: 13px; font-weight: 700;
	overflow: hidden; flex: none;
}
.fwscb-launcher-av img { width: 100%; height: 100%; object-fit: cover; }

/* Signatur: ein einzelner, ruhiger Puls am Launcher, solange nie geöffnet wurde */
.fwscb-launcher.is-new::after {
	content: "";
	position: absolute; inset: -4px;
	border-radius: 999px;
	border: 2px solid var(--fwscb-accent);
	animation: fwscb-pulse 2.6s ease-out infinite;
}
@keyframes fwscb-pulse {
	0%   { opacity: .55; transform: scale(1); }
	70%  { opacity: 0;   transform: scale(1.22); }
	100% { opacity: 0;   transform: scale(1.22); }
}

/* ---------- Panel ---------- */

.fwscb-panel {
	pointer-events: auto;
	position: fixed;
	bottom: 22px;
	width: 384px;
	max-width: calc(100vw - 32px);
	height: min(640px, calc(100vh - 44px));
	display: flex;
	flex-direction: column;
	background: var(--fwscb-bg);
	color: var(--fwscb-fg);
	border-radius: calc(var(--fwscb-radius) + 6px);
	box-shadow: var(--fwscb-shadow);
	overflow: hidden;
	opacity: 0;
	transform: translateY(14px) scale(.96);
	transition: opacity .22s ease, transform .28s cubic-bezier(.2, .8, .3, 1);
}
#fws-cb-root[data-pos="right"] .fwscb-panel { right: 22px; transform-origin: 100% 100%; }
#fws-cb-root[data-pos="left"]  .fwscb-panel { left: 22px;  transform-origin: 0 100%; }
.fwscb-panel.is-open { opacity: 1; transform: translateY(0) scale(1); }
.fwscb-panel[hidden] { display: none; }

/* Kopf */
.fwscb-head {
	position: relative;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 14px 16px 18px;
	color: #fff;
	background: linear-gradient(135deg, var(--fwscb-accent), var(--fwscb-deep));
}
.fwscb-head::after {
	content: "";
	position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
	background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .55), transparent);
}
.fwscb-head-av {
	width: 40px; height: 40px; border-radius: 50%;
	background: rgba(255, 255, 255, .22);
	display: flex; align-items: center; justify-content: center;
	font-size: 14px; font-weight: 700; overflow: hidden; flex: none;
}
.fwscb-head-av img { width: 100%; height: 100%; object-fit: cover; }
.fwscb-head-txt { flex: 1; min-width: 0; }
.fwscb-head-name { display: block; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.fwscb-head-tag { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: .9; }
.fwscb-dot { width: 7px; height: 7px; border-radius: 50%; background: #8ef07b; box-shadow: 0 0 0 3px rgba(142, 240, 123, .25); flex: none; }

.fwscb-icon {
	width: 32px; height: 32px; border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	color: #fff; opacity: .85; flex: none;
	transition: background .18s, opacity .18s;
}
.fwscb-icon:hover { background: rgba(255, 255, 255, .18); opacity: 1; }
.fwscb-icon:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.fwscb-icon svg { width: 17px; height: 17px; }

/* Hinweiszeile */
.fwscb-info {
	padding: 11px 18px;
	font-size: 12px;
	line-height: 1.5;
	color: var(--fwscb-muted);
	background: var(--fwscb-surface);
	border-bottom: 1px solid var(--fwscb-line);
}
.fwscb-info[hidden] { display: none; }

/* Verlauf */
.fwscb-log {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 18px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scrollbar-width: thin;
}
.fwscb-log::-webkit-scrollbar { width: 8px; }
.fwscb-log::-webkit-scrollbar-thumb { background: var(--fwscb-line); border-radius: 999px; }

.fwscb-msg {
	max-width: 86%;
	padding: 11px 14px;
	font-size: 14.5px;
	line-height: 1.55;
	word-wrap: break-word;
	animation: fwscb-in .26s cubic-bezier(.2, .8, .3, 1) both;
}
.fwscb-msg a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.fwscb-msg.bot {
	align-self: flex-start;
	background: var(--fwscb-surface);
	border-radius: var(--fwscb-radius) var(--fwscb-radius) var(--fwscb-radius) 6px;
}
.fwscb-msg.user {
	align-self: flex-end;
	background: var(--fwscb-accent);
	color: #fff;
	border-radius: var(--fwscb-radius) var(--fwscb-radius) 6px var(--fwscb-radius);
}
.fwscb-msg.bot a { color: var(--fwscb-deep); font-weight: 600; }
#fws-cb-root[data-theme="dark"] .fwscb-msg.bot a,
#fws-cb-root.fwscb-dark .fwscb-msg.bot a { color: var(--fwscb-accent); }

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

.fwscb-tag {
	align-self: flex-start;
	margin-top: -4px;
	font-size: 10.5px;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--fwscb-muted);
}

/* Vorschläge */
.fwscb-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.fwscb-chip {
	padding: 7px 14px;
	font-size: 13px;
	border-radius: 999px;
	border: 1px solid var(--fwscb-accent);
	color: var(--fwscb-accent);
	background: transparent;
	transition: background .16s, color .16s;
}
.fwscb-chip:hover { background: var(--fwscb-accent); color: #fff; }
.fwscb-chip:focus-visible { outline: 2px solid var(--fwscb-accent); outline-offset: 2px; }

/* Tippen */
.fwscb-typing { display: flex; gap: 4px; align-self: flex-start; padding: 13px 15px; background: var(--fwscb-surface); border-radius: var(--fwscb-radius) var(--fwscb-radius) var(--fwscb-radius) 6px; }
.fwscb-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--fwscb-muted); animation: fwscb-bounce 1.2s infinite; }
.fwscb-typing i:nth-child(2) { animation-delay: .15s; }
.fwscb-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes fwscb-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: .45; }
	30%           { transform: translateY(-4px); opacity: 1; }
}

/* Eingabe */
.fwscb-form { display: flex; align-items: center; gap: 8px; padding: 12px 14px 14px; border-top: 1px solid var(--fwscb-line); }
.fwscb-input {
	flex: 1;
	min-width: 0;
	padding: 12px 16px;
	font: inherit;
	font-size: 14.5px;
	color: var(--fwscb-fg);
	background: var(--fwscb-surface);
	border: 1px solid transparent;
	border-radius: 999px;
	outline: none;
	transition: border-color .16s;
}
.fwscb-input::placeholder { color: var(--fwscb-muted); }
.fwscb-input:focus { border-color: var(--fwscb-accent); }
.fwscb-send {
	width: 44px; height: 44px; flex: none;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--fwscb-accent), var(--fwscb-deep));
	color: #fff;
	display: flex; align-items: center; justify-content: center;
	transition: transform .16s, opacity .16s;
}
.fwscb-send:hover { transform: scale(1.06); }
.fwscb-send:disabled { opacity: .4; transform: none; cursor: default; }
.fwscb-send:focus-visible { outline: 2px solid var(--fwscb-accent); outline-offset: 2px; }
.fwscb-send svg { width: 18px; height: 18px; }

.fwscb-foot { padding: 0 18px 12px; font-size: 11px; color: var(--fwscb-muted); text-align: center; }

/* Mobil: Vollbild-Sheet */
@media (max-width: 520px) {
	.fwscb-panel {
		inset: 0;
		width: 100%;
		max-width: none;
		height: 100%;
		border-radius: 0;
	}
	#fws-cb-root[data-pos="right"] .fwscb-panel,
	#fws-cb-root[data-pos="left"] .fwscb-panel { right: 0; left: 0; }
	.fwscb-launcher { bottom: 16px; }
	#fws-cb-root[data-pos="right"] .fwscb-launcher { right: 16px; }
	#fws-cb-root[data-pos="left"]  .fwscb-launcher { left: 16px; }
}

@media (prefers-reduced-motion: reduce) {
	#fws-cb-root *,
	#fws-cb-root *::after { animation: none !important; transition: none !important; }
}
