/*
 * KI-Produktberater – Chat-Widget
 * Alle Regeln hängen an #wcpb-root, damit Theme- und WooCommerce-Styles
 * (z. B. „.woocommerce form textarea“) das Widget nicht verändern.
 */
#wcpb-root {
	--wcpb-color: #2271b1;
	position: fixed;
	bottom: var(--wcpb-bottom, 20px);
	z-index: 2147483647; /* höchste Ebene: offener Chat liegt auch über Siegeln wie dem Trustbadge */
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
	color: #1d2327;
	text-align: left;
}
#wcpb-root.wcpb--right { right: 20px; }
#wcpb-root.wcpb--left { left: 20px; }
#wcpb-root *, #wcpb-root *::before, #wcpb-root *::after { box-sizing: border-box; }

/* Grund-Reset gegen Theme-Styles */
#wcpb-root button,
#wcpb-root textarea {
	margin: 0; min-width: 0; min-height: 0; width: auto;
	text-transform: none; letter-spacing: normal; text-shadow: none; box-shadow: none;
	font-family: inherit; line-height: inherit;
}
#wcpb-root button:focus { outline: none; }
#wcpb-root button:focus-visible { outline: 2px solid var(--wcpb-color); outline-offset: 2px; }
#wcpb-root .wcpb-head button:focus-visible { outline-color: #fff; outline-offset: -2px; }
#wcpb-root p, #wcpb-root ul, #wcpb-root li { font-size: inherit; line-height: inherit; color: inherit; }

#wcpb-root .wcpb-launcher {
	width: 58px; height: 58px; border-radius: 50%;
	border: 0; cursor: pointer; padding: 0;
	background: var(--wcpb-color); color: #fff;
	box-shadow: 0 6px 20px rgba(0,0,0,.2);
	display: flex; align-items: center; justify-content: center;
	transition: transform .15s ease;
}
#wcpb-root .wcpb-launcher:hover { transform: scale(1.06); }
#wcpb-root.wcpb--left .wcpb-launcher { margin-right: auto; }
#wcpb-root.wcpb--right .wcpb-launcher { margin-left: auto; }

#wcpb-root .wcpb-panel {
	display: none;
	flex-direction: column;
	width: 370px; height: 560px; max-height: calc(100vh - 90px - var(--wcpb-bottom, 20px));
	margin-bottom: 14px;
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 12px 40px rgba(0,0,0,.22);
	overflow: hidden;
}
#wcpb-root.wcpb--open .wcpb-panel { display: flex; }

#wcpb-root .wcpb-head {
	display: flex; align-items: center; gap: 6px;
	padding: 14px 14px 14px 18px;
	background: var(--wcpb-color); color: #fff;
}
#wcpb-root .wcpb-title { flex: 1; font-weight: 600; font-size: 16px; }
#wcpb-root .wcpb-ai {
	font-size: 11px; font-weight: 700; letter-spacing: .03em;
	background: rgba(255,255,255,.22); border-radius: 6px; padding: 2px 7px; margin-right: 4px;
}
#wcpb-root .wcpb-icon {
	background: transparent; border: 0; color: #fff; cursor: pointer;
	font-size: 17px; width: 32px; height: 32px; border-radius: 8px; padding: 0; line-height: 1;
}
#wcpb-root .wcpb-icon:hover { background: rgba(255,255,255,.18); }

#wcpb-root .wcpb-log {
	flex: 1; overflow-y: auto; padding: 16px;
	display: flex; flex-direction: column; gap: 10px;
	background: #f6f7f9;
}
#wcpb-root .wcpb-log > * { flex-shrink: 0; } /* sonst werden Karten zusammengedrückt statt gescrollt */
#wcpb-root .wcpb-msg {
	max-width: 86%; padding: 9px 13px; border-radius: 14px;
	word-wrap: break-word; overflow-wrap: anywhere;
}
#wcpb-root .wcpb-msg p { margin: 0 0 6px; }
#wcpb-root .wcpb-msg p:last-child { margin-bottom: 0; }
#wcpb-root .wcpb-msg ul { margin: 4px 0 6px; padding-left: 18px; list-style: disc; }
#wcpb-root .wcpb-msg li { margin: 2px 0; }
#wcpb-root .wcpb-msg a { color: var(--wcpb-color); text-decoration: underline; }
#wcpb-root .wcpb-msg--assistant { align-self: flex-start; background: #fff; border: 1px solid #e3e5e8; border-bottom-left-radius: 4px; }
#wcpb-root .wcpb-msg--user { align-self: flex-end; background: var(--wcpb-color); color: #fff; border-bottom-right-radius: 4px; }
#wcpb-root .wcpb-msg--error { border-color: #d63638; color: #8a1f11; }

#wcpb-root .wcpb-typing { display: flex; gap: 4px; padding: 12px 14px; }
#wcpb-root .wcpb-typing span {
	width: 7px; height: 7px; border-radius: 50%; background: #9aa0a6;
	animation: wcpb-blink 1.2s infinite ease-in-out;
}
#wcpb-root .wcpb-typing span:nth-child(2) { animation-delay: .2s; }
#wcpb-root .wcpb-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes wcpb-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

#wcpb-root .wcpb-cards { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
#wcpb-root .wcpb-card {
	flex: 0 0 140px; display: flex; flex-direction: column; gap: 3px;
	background: #fff; border: 1px solid #e3e5e8; border-radius: 12px;
	padding: 8px; text-decoration: none; color: inherit;
	font-size: 13px; position: relative;
}
#wcpb-root .wcpb-card:hover { border-color: var(--wcpb-color); }
#wcpb-root .wcpb-card img { width: 100%; height: 110px; max-width: none; object-fit: contain; border-radius: 8px; background: #fafafa; margin: 0; }
#wcpb-root .wcpb-card-name { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#wcpb-root .wcpb-card-price { color: var(--wcpb-color); font-weight: 600; }
#wcpb-root .wcpb-card-unit { color: #646970; font-size: 11px; }
#wcpb-root .wcpb-price-note { font-size: 11px; color: #646970; margin-top: -4px; }
#wcpb-root .wcpb-price-note a { color: inherit; text-decoration: underline; }
#wcpb-root .wcpb-badge {
	position: absolute; top: 12px; left: 12px;
	background: #d63638; color: #fff; font-size: 11px; font-weight: 600;
	padding: 1px 7px; border-radius: 10px;
}
#wcpb-root .wcpb-badge--muted { position: static; align-self: flex-start; background: #646970; }

#wcpb-root .wcpb-form {
	display: flex; align-items: flex-end; gap: 8px;
	padding: 10px; border-top: 1px solid #e3e5e8; background: #fff; margin: 0;
}
#wcpb-root .wcpb-input {
	flex: 1; display: block; resize: none; border: 1px solid #c3c4c7; border-radius: 12px;
	padding: 9px 12px; font-size: 15px; height: auto; min-height: 40px; max-height: 120px;
	background: #fff; color: inherit; outline: none;
}
#wcpb-root .wcpb-input:focus { border-color: var(--wcpb-color); }
#wcpb-root .wcpb-send {
	width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%; border: 0; padding: 0;
	background: var(--wcpb-color); color: #fff; cursor: pointer;
	display: flex; align-items: center; justify-content: center;
}
#wcpb-root .wcpb-send:disabled { opacity: .5; cursor: default; }

#wcpb-root .wcpb-note { font-size: 11px; line-height: 1.4; color: #646970; padding: 0 12px 10px; background: #fff; }
#wcpb-root .wcpb-note a { color: inherit; text-decoration: underline; }

@media (max-width: 480px) {
	#wcpb-root { bottom: calc(var(--wcpb-bottom, 20px) * .6); }
	#wcpb-root.wcpb--right { right: 12px; }
	#wcpb-root.wcpb--left { left: 12px; }
	#wcpb-root.wcpb--open { left: 0; right: 0; bottom: 0; top: 0; }
	#wcpb-root.wcpb--open .wcpb-panel { width: 100%; height: 100%; max-height: none; margin: 0; border-radius: 0; }
	#wcpb-root.wcpb--open .wcpb-launcher { display: none; }
	#wcpb-root .wcpb-input { font-size: 16px; } /* verhindert Zoom auf iOS */
}
