/* ==========================================================
   Toni-Chatfenster: Optik nach Prototyp A1
   Nur Darstellung – Funktion (Senden, Antworten, Sitzung) steckt in js/plchat-core.js.
   ========================================================== */
/* ---------- Fenster ---------- */
.plchat-modal {
	width: min(600px, calc(100vw - 48px));
	border-radius: 20px;
	background: #fff;
	box-shadow: 0 24px 60px rgba(15, 35, 70, .2), 0 0 0 1px rgba(15, 35, 70, .04);
	font-family: Barlow, sans-serif;
	color: #323232;
}
.plchat-modal.is-maximized {
	width: min(880px, calc(100vw - 48px));
}

/* ---------- Kopfzeile ---------- */
.plchat-modal-header {
	gap: 12px;
	height: auto;
	padding: 14px 10px 14px 16px;
	background: linear-gradient(180deg, #fff, #f8fafd);
	border-bottom: 1px solid #e4e9f0;
}
.px-chat-orb {
	position: relative;
	flex: none;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(15, 35, 70, .12);
}
.px-chat-orb span {
	position: absolute;
	inset: 2px;
	overflow: hidden;
	border-radius: 50%;
	background: var(--color-blue);
}
.px-chat-orb img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: 50% 30%;
	transform: scale(1.85);
	transform-origin: 50% 28%;
}
.plchat-modal-title {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
	font-family: Montserrat, sans-serif;
	font-size: 17px;
	font-weight: 600;
	line-height: 1.2;
}
.px-chat-status {
	display: flex;
	align-items: center;
	gap: 6px;
	font-family: Barlow, sans-serif;
	font-size: 13px;
	font-weight: 400;
	color: #5b6573;
}
.px-chat-status i {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--color-green);
	box-shadow: 0 0 0 3px rgba(0, 229, 82, .16);
}
/* Icon-Buttons rechts: Neuer Chat, Vergrößern, Schließen */
.plchat-modal-actions {
	gap: 2px;
}
.px-chat-icon-btn,
.plchat-modal-maximize,
.plchat-modal-close {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background-color: transparent;
	color: #7a8594;
	cursor: pointer;
	transition: background-color .2s, color .2s;
}
.px-chat-icon-btn:hover,
.plchat-modal-maximize:hover {
	background-color: #e9eef5;
	color: #323232;
}
.px-chat-icon-btn svg {
	width: 19px;
	height: 19px;
}
.plchat-modal-maximize svg.plchat-icon {
	width: 19px;
	height: 19px;
	min-width: 19px;
}
.plchat-modal-maximize svg.plchat-icon path {
	fill: currentColor;
}
/* Schließen: Kreuz über Maske, Farbe wie die anderen Icons */
.plchat-modal-close {
	background-color: #7a8594;
	-webkit-mask-size: 14px;
	mask-size: 14px;
}
.plchat-modal-close:hover {
	background-color: #323232;
}

/* ---------- Verlauf ---------- */
.plchat-modal-body {
	padding: 0;
}
.plchat-out {
	gap: 16px;
	padding: 22px 18px 16px;
	border: 0;
	border-radius: 0;
	white-space: normal;
	scroll-behavior: smooth;
	overscroll-behavior: contain;
}
/* Leerer Verlauf nimmt keinen Platz ein (Begrüßung steht darunter) */
.plchat-out:empty {
	display: none;
}

/* Begrüßung */
.plchat-suggestions {
	display: grid;
	grid-template-columns: 34px 1fr;
	column-gap: 12px;
	align-content: start;
	margin: 0;
	padding: 22px 18px 16px;
	overflow-y: auto;
	flex: 1 1 auto;
}
.px-chat-welcome-orb {
	grid-row: 1 / span 2;
	width: 34px;
	height: 34px;
	margin-top: 2px;
}
.plchat-intro-headline,
.plchat-intro-text {
	grid-column: 2;
}
.plchat-intro-headline strong {
	display: block;
	margin: 0 0 6px;
	font: 600 19px/1.3 Montserrat, sans-serif;
	color: #323232;
}
.plchat-intro-text p {
	margin: 0 0 14px;
	font-size: 17px;
	line-height: 1.5;
	color: #4b5563;
}
.plchat-intro-text ul {
	margin: 0;
	padding: 0;
	list-style: none;
}
.plchat-intro-text li {
	position: relative;
	margin: 0;
	padding: 6px 0 6px 22px;
	font-size: 16px;
	line-height: 1.45;
	color: #323232;
}
/* Pfeil vor den Fragen in Blau wie im Prototyp A1 (Form kommt aus der globalen Listen-Optik in style.css,
   deren Selektor sehr spezifisch ist – daher hier drei Klassen) */
.plchat .plchat-suggestions .plchat-intro-text li::before {
	/* Mittig zur ersten Textzeile: Innenabstand oben + (Zeilenhöhe − Pfeilhöhe) / 2 */
	top: calc(6px + (1.45em - 0.875rem) / 2);
	background-color: var(--color-blue);
}

/* Nachrichten */
.plchat-msg {
	max-width: 88%;
	font-family: Barlow, sans-serif;
	font-size: 16px;
	line-height: 1.55;
	white-space: pre-wrap;
}
.plchat-msg--user {
	align-self: flex-end;
	padding: 10px 15px;
	border-radius: 18px 18px 4px 18px;
	background: var(--color-blue);
	color: #fff;
	font-size: 16px;
	font-weight: 500;
	line-height: 1.55;
}
.plchat-msg--ai {
	align-self: flex-start;
	max-width: 88%;
	padding: 12px 15px;
	border-radius: 4px 18px 18px 18px;
	background: #f3f6fa;
	color: #323232;
	font-size: 16px;
	line-height: 1.55;
}
.plchat-msg--ai a {
	color: var(--color-blue);
	text-decoration: underline;
	text-underline-offset: 2px;
}
.plchat-msg--sys {
	align-self: center;
	padding: 0;
	background: transparent;
	font-size: 13px;
	font-style: normal;
	color: #8a94a3;
}

/* Tipp-Anzeige, solange Toni antwortet (Klasse setzt toni.js) */
.plchat-msg.px-typing {
	display: inline-flex;
	gap: 5px;
	padding: 15px 16px;
	font-size: 0;
}
.plchat-msg.px-typing::before,
.plchat-msg.px-typing::after,
.plchat-msg.px-typing span {
	content: "";
	display: block;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--color-blue), var(--color-green));
	animation: px-chat-dot 1s ease-in-out infinite;
}
.plchat-msg.px-typing span {
	animation-delay: .15s;
}
.plchat-msg.px-typing::after {
	animation-delay: .3s;
}
@keyframes px-chat-dot {
	0%,
	100% {
		transform: translateY(0);
		opacity: .5;
	}
	50% {
		transform: translateY(-4px);
		opacity: 1;
	}
}

/* Quellen unter der Antwort */
.plchat-sources {
	margin-top: 10px;
	padding-top: 10px;
	border-top: 1px solid #e4e9f0;
	font-size: 14px;
}

/* ---------- Eingabe ---------- */
.plchat-composer {
	display: flex;
	align-items: flex-end;
	gap: 10px;
	margin: 0 14px;
	padding: 8px 8px 8px 16px;
	border: 1px solid transparent;
	border-radius: 16px;
	background: #f3f6fa;
	transition: border-color .2s, background-color .2s, box-shadow .2s;
}
.plchat-composer:focus-within {
	background: #fff;
	border-color: #bcd3ef;
	box-shadow: 0 0 0 4px rgba(5, 117, 229, .08);
}
.plchat-input,
.plchat-input:focus {
	flex: 1;
	width: auto;
	height: 40px;
	min-height: 24px;
	max-height: 140px;
	padding: 8px 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	outline: none;
	overflow-y: hidden;
	resize: none;
	font: 17px/1.45 Barlow, sans-serif;
	color: #323232;
}
.plchat-send {
	position: static;
	flex: none;
	width: 42px;
	height: 42px;
	background: linear-gradient(135deg, var(--color-blue), #03a7b0);
	transition: transform .2s, filter .2s, opacity .25s;
}
.plchat-send:hover {
	transform: translateY(-1px);
	filter: brightness(1.08);
	background: linear-gradient(135deg, var(--color-blue), #03a7b0);
}
.plchat-send svg {
	left: 0;
	width: 20px;
	height: 20px;
}
.plchat-spinner {
	right: 8px;
	bottom: 8px;
	width: 42px;
	height: 42px;
	background: linear-gradient(135deg, var(--color-blue), #03a7b0);
}

/* „Neuen Chat erstellen“ sitzt als Icon in der Kopfzeile, der Original-Button bleibt unsichtbar für die Funktion */
.plchat-new {
	display: none;
}

/* Pfeil „nach unten“ über der Eingabe */
.plchat-scrollDown {
	bottom: 130px;
	border-color: #e4e9f0;
	box-shadow: 0 6px 18px rgba(15, 35, 70, .14);
}

/* ---------- Hinweis unten ---------- */
.hinweis-ki-bot {
	padding: 10px 18px 14px;
	font-size: 12px;
	line-height: 1.45;
	color: #8a94a3;
}
.hinweis-ki-bot strong {
	font-weight: 600;
	color: #5b6573;
}
.hinweis-ki-bot a {
	color: inherit;
}

/* ---------- Mobil: Bottom-Sheet ---------- */
@media (max-width: 1023px) {
	.plchat-modal,
	.plchat-modal.is-maximized {
		top: auto;
		left: 0;
		right: 0;
		bottom: 0;
		width: auto;
		height: min(88dvh, 780px);
		padding-bottom: env(safe-area-inset-bottom, 0px);
		border-radius: 24px 24px 0 0;
		box-shadow: 0 -10px 40px rgba(15, 35, 70, .18);
	}
	/* Griff oben */
	.plchat-modal::before {
		content: "";
		display: block;
		flex: none;
		width: 40px;
		height: 5px;
		margin: 8px auto 2px;
		border-radius: 3px;
		background: #d3dae3;
	}
	.plchat-modal-header {
		padding-top: 6px;
		background: #fff;
	}
	.plchat-modal-maximize {
		display: none;
	}
	/* Abgedunkelter Hintergrund, Tippen schließt den Chat */
	.plchat-modal-backdrop.is-open {
		display: block;
		background: rgba(18, 30, 48, .3);
		-webkit-backdrop-filter: blur(4px);
		backdrop-filter: blur(4px);
	}
	.plchat-composer {
		margin: 0 12px;
	}
	.plchat-intro-headline strong {
		font-size: 18px;
	}
	.plchat-intro-text p {
		font-size: 16px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.plchat-msg.px-typing::before,
	.plchat-msg.px-typing::after,
	.plchat-msg.px-typing span {
		animation: none !important;
	}
}

/* ---------- Feinschliff: Listen-Abstände, Follow-up-Button ---------- */

/* Listen in Antworten: gleichmäßige Abstände (überflüssige Zeilenumbrüche entfernt toni.js) */
.plchat-msg--ai .plchat-md-ul {
	margin: 8px 0;
}
.plchat-msg--ai .plchat-md-ul li {
	margin: 4px 0;
}

/* Follow-up-Frage mit Button „Ja“ */
.plchat-followup-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 10px;
}
.plchat-followup-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 11px 18px;
	border: 0;
	border-radius: 0;
	background: var(--color-blue);
	color: #fff;
	font: 600 14px/1 Barlow, sans-serif;
	letter-spacing: 1.2px;
	text-transform: uppercase;
	cursor: pointer;
	transition: background-color .2s, opacity .2s;
}
.plchat-followup-btn:hover,
.plchat-followup-btn:focus-visible {
	background: var(--color-navy-blue);
	color: #fff;
}
.plchat-followup-btn:disabled {
	opacity: .5;
	cursor: default;
}
.plchat-followup-btn:disabled:hover {
	background: var(--color-blue);
}
