/* KPC Assistant — chat widget. Everything is scoped under .kpca-. */
.kpca-root {
	--kpca-brand: #ee3342;
	--kpca-brand-dark: #c81e2c;
	--kpca-text: #1d2327;
	--kpca-muted: #6b7280;
	--kpca-bubble: #eef0f3;
	--kpca-border: #e5e7eb;
	--kpca-radius: 18px;
	--kpca-btn: 48px;
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 99990;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.45;
	color: var(--kpca-text);
}
.kpca-root.is-left { right: auto; left: 24px; }
/* The KPC theme has an accessibility button in the bottom-right corner —
   sit just above it instead of covering it. */
body:has(#kpcA11yToggle) .kpca-root:not(.is-left):not(.is-open) { bottom: 80px; right: 16px; }
.kpca-root *, .kpca-root *::before, .kpca-root *::after { box-sizing: border-box; }
.kpca-root button { font: inherit; cursor: pointer; }

/* Launcher — size comes from the "Chat button size" setting (--kpca-btn). */
.kpca-launcher {
	display: flex; align-items: center; justify-content: center;
	width: var(--kpca-btn); height: var(--kpca-btn); padding: 0;
	border: 0; border-radius: 50%;
	background: var(--kpca-brand); color: #fff;
	box-shadow: 0 6px 18px rgba(0,0,0,.2);
	transition: transform .2s ease, background .2s ease;
}
.kpca-launcher:hover { transform: translateY(-2px); background: var(--kpca-brand-dark); }
.kpca-launcher svg { width: calc(var(--kpca-btn) * .46); height: calc(var(--kpca-btn) * .46); }
.kpca-launcher-label {
	position: absolute; right: calc(var(--kpca-btn) + 10px); bottom: calc(var(--kpca-btn) / 2);
	transform: translateY(50%);
	padding: 6px 10px; border-radius: 8px;
	background: #fff; color: var(--kpca-text);
	box-shadow: 0 4px 14px rgba(0,0,0,.15);
	font-size: 12.5px; font-weight: 600; white-space: nowrap;
	pointer-events: none;
	transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.kpca-root.is-left .kpca-launcher-label { right: auto; left: calc(var(--kpca-btn) + 10px); }
/* Hover-only label: hidden until the button is hovered or focused with the keyboard. */
.kpca-root.label-hover .kpca-launcher-label { opacity: 0; visibility: hidden; transform: translate(6px, 50%); }
.kpca-root.label-hover.is-left .kpca-launcher-label { transform: translate(-6px, 50%); }
.kpca-root.label-hover .kpca-launcher:hover ~ .kpca-launcher-label,
.kpca-root.label-hover .kpca-launcher:focus-visible ~ .kpca-launcher-label,
.kpca-root.label-hover:has(.kpca-launcher:hover) .kpca-launcher-label,
.kpca-root.label-hover:has(.kpca-launcher:focus-visible) .kpca-launcher-label { opacity: 1; visibility: visible; transform: translateY(50%); }
.kpca-root.label-never .kpca-launcher-label { display: none; }
.kpca-root.is-open .kpca-launcher, .kpca-root.is-open .kpca-launcher-label { display: none; }

/* Panel */
.kpca-panel {
	display: none; flex-direction: column;
	width: 400px; height: min(640px, calc(100vh - 48px));
	background: #fff;
	border-radius: 22px;
	box-shadow: 0 18px 50px rgba(0,0,0,.25);
	overflow: hidden;
}
.kpca-root.is-open .kpca-panel { display: flex; animation: kpca-in .22s ease-out; }
@keyframes kpca-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.kpca-head {
	display: flex; align-items: center; gap: 14px;
	padding: 18px 16px 18px 20px;
	background: var(--kpca-brand); color: #fff;
}
.kpca-head-avatar { position: relative; flex: 0 0 48px; width: 48px; height: 48px; }
.kpca-head-avatar img { width: 48px; height: 48px; border-radius: 50%; background: #fff; object-fit: cover; }
.kpca-dot { position: absolute; right: 0; bottom: 1px; width: 12px; height: 12px; border: 2px solid var(--kpca-brand); border-radius: 50%; background: #22c55e; }
.kpca-head-text { flex: 1 1 auto; min-width: 0; }
.kpca-head-name { font-weight: 800; letter-spacing: .02em; text-transform: uppercase; font-size: 15px; }
.kpca-head-sub { font-size: 14px; opacity: .92; }
.kpca-icon-btn {
	display: inline-flex; align-items: center; justify-content: center;
	width: 38px; height: 38px; padding: 0;
	border: 0; border-radius: 50%;
	background: transparent; color: inherit;
}
.kpca-icon-btn:hover { background: rgba(255,255,255,.16); }
.kpca-icon-btn svg { width: 22px; height: 22px; }

.kpca-test { padding: 6px 14px; background: #fff7d6; color: #6b5200; font-size: 12px; text-align: center; }

/* Messages */
.kpca-body { flex: 1 1 auto; overflow-y: auto; padding: 18px 16px 8px; scroll-behavior: smooth; }
.kpca-day { display: flex; justify-content: center; margin: 6px 0 14px; }
.kpca-day span { padding: 4px 14px; border: 1px solid var(--kpca-border); border-radius: 999px; background: #f7f8fa; color: var(--kpca-muted); font-size: 13px; }

.kpca-row { display: flex; align-items: flex-end; gap: 10px; margin: 0 0 8px; }
.kpca-row.is-user { justify-content: flex-end; }
.kpca-row-avatar { flex: 0 0 34px; width: 34px; height: 34px; }
.kpca-row-avatar img { width: 34px; height: 34px; border-radius: 50%; }
.kpca-row:not(.is-last) .kpca-row-avatar img { visibility: hidden; }
.kpca-bubbles { display: flex; flex-direction: column; gap: 6px; max-width: 82%; }
.kpca-row.is-user .kpca-bubbles { align-items: flex-end; }
.kpca-bubble { padding: 11px 16px; border-radius: var(--kpca-radius); background: var(--kpca-bubble); word-wrap: break-word; overflow-wrap: anywhere; }
.kpca-row.is-user .kpca-bubble { background: var(--kpca-brand); color: #fff; }
.kpca-bubble p { margin: 0 0 8px; }
.kpca-bubble p:last-child, .kpca-bubble ul:last-child { margin-bottom: 0; }
.kpca-bubble ul { margin: 4px 0 8px; padding-left: 20px; }
.kpca-bubble a { color: var(--kpca-brand-dark); font-weight: 600; text-decoration: underline; }
.kpca-row.is-user .kpca-bubble a { color: #fff; }
.kpca-meta { margin: 2px 0 12px 44px; color: var(--kpca-muted); font-size: 12.5px; }
.kpca-row.is-user + .kpca-meta { margin-left: 0; text-align: right; }

.kpca-sources { font-size: 12.5px; color: var(--kpca-muted); padding: 0 4px; }
.kpca-sources a { color: var(--kpca-brand-dark); text-decoration: none; font-weight: 600; }
.kpca-sources a:hover { text-decoration: underline; }
.kpca-feedback { display: flex; gap: 4px; padding: 0 2px; }
.kpca-feedback button { display: inline-flex; padding: 4px; border: 0; border-radius: 6px; background: transparent; color: #9ca3af; }
.kpca-feedback button:hover, .kpca-feedback button.is-on { color: var(--kpca-brand); background: #fdecee; }
.kpca-feedback svg { width: 16px; height: 16px; }

.kpca-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 12px 44px; }
.kpca-chip { padding: 8px 14px; border: 1.5px solid var(--kpca-brand); border-radius: 999px; background: #fff; color: var(--kpca-brand-dark); font-size: 13.5px; font-weight: 600; }
.kpca-chip:hover { background: var(--kpca-brand); color: #fff; }

.kpca-typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.kpca-typing i { width: 7px; height: 7px; border-radius: 50%; background: #9ca3af; animation: kpca-bounce 1.2s infinite ease-in-out; }
.kpca-typing i:nth-child(2) { animation-delay: .15s; }
.kpca-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes kpca-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-5px); opacity: 1; } }

/* Composer */
.kpca-foot { border-top: 1px solid var(--kpca-border); padding: 12px 14px 10px; }
.kpca-compose { display: flex; align-items: center; gap: 10px; }
.kpca-home { color: #6b7280; }
.kpca-home:hover { color: var(--kpca-brand); background: #fdecee; }
.kpca-input-wrap {
	flex: 1 1 auto; display: flex; align-items: center; gap: 4px;
	min-height: 52px; padding: 6px 6px 6px 18px;
	border: 1.5px solid var(--kpca-border); border-radius: 999px;
	background: #fff;
}
.kpca-input-wrap:focus-within { border-color: var(--kpca-brand); }
.kpca-input { flex: 1 1 auto; min-width: 0; max-height: 110px; padding: 6px 0; border: 0; outline: 0; resize: none; background: transparent; color: var(--kpca-text); font: inherit; line-height: 1.4; }
.kpca-mic, .kpca-send { color: #6b7280; }
.kpca-mic:hover, .kpca-send:hover { color: var(--kpca-brand); background: #fdecee; }
.kpca-mic.is-listening { color: #fff; background: var(--kpca-brand); animation: kpca-pulse 1.2s infinite; }
@keyframes kpca-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(238,51,66,.45); } 50% { box-shadow: 0 0 0 8px rgba(238,51,66,0); } }
.kpca-send[disabled] { opacity: .4; cursor: default; }
.kpca-privacy { margin: 8px 6px 0; color: var(--kpca-muted); font-size: 11.5px; text-align: center; }

@media (max-width: 520px) {
	.kpca-root { right: 14px; bottom: 14px; }
	.kpca-root.is-left { left: 14px; }
	.kpca-root.is-open { inset: 0; }
	.kpca-panel { width: 100vw; height: 100dvh; border-radius: 0; }
	.kpca-launcher-label { display: none; }
}
@media (prefers-reduced-motion: reduce) {
	.kpca-launcher, .kpca-launcher-label { transition: none !important; }
	.kpca-panel, .kpca-typing i, .kpca-mic.is-listening { animation: none !important; }
}
