/**
 * AI Chatbot widget.
 * Every colour comes from a CSS variable set per site, so the same stylesheet
 * carries a law firm's navy and a bakery's pink without a code change.
 */

.wpaic-root {
	--wpaic-brand: #2563eb;
	--wpaic-ink: #ffffff;
	--wpaic-bubble: #ffffff;
	--wpaic-surface: #f6f7f9;
	--wpaic-text: #1f2430;
	--wpaic-muted: #6b7280;
	--wpaic-line: #e5e7eb;
	--wpaic-radius: 16px;
	--wpaic-height: 520px;
	font-family: inherit;
	line-height: 1.45;
	box-sizing: border-box;
}

.wpaic-root *,
.wpaic-root *::before,
.wpaic-root *::after {
	box-sizing: inherit;
}

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

.wpaic-launcher {
	position: fixed;
	bottom: 22px;
	z-index: 99998;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 56px;
	padding: 0 18px;
	border: 0;
	border-radius: 999px;
	background: var(--wpaic-brand);
	color: var(--wpaic-ink);
	cursor: pointer;
	box-shadow: 0 8px 26px rgba( 15, 23, 42, 0.22 );
	transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.wpaic-pos-right .wpaic-launcher { right: 22px; }
.wpaic-pos-left .wpaic-launcher { left: 22px; }

.wpaic-launcher:hover { transform: translateY( -2px ); }
.wpaic-launcher:focus-visible { outline: 3px solid var(--wpaic-brand); outline-offset: 3px; }
.wpaic-launcher-label { font-size: 15px; font-weight: 600; }
.wpaic-launcher-open { transform: scale( 0.92 ); opacity: 0.85; }

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

.wpaic-panel {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: var(--wpaic-surface);
	border: 1px solid var(--wpaic-line);
	border-radius: var(--wpaic-radius);
	box-shadow: 0 18px 48px rgba( 15, 23, 42, 0.18 );
	color: var(--wpaic-text);
}

.wpaic-pos-right .wpaic-panel,
.wpaic-pos-left .wpaic-panel {
	position: fixed;
	bottom: 92px;
	z-index: 99999;
	width: 380px;
	max-width: calc( 100vw - 32px );
	height: 560px;
	max-height: calc( 100vh - 130px );
}

.wpaic-pos-right .wpaic-panel { right: 22px; }
.wpaic-pos-left .wpaic-panel { left: 22px; }

.wpaic-inline .wpaic-panel {
	position: relative;
	width: 100%;
	height: var(--wpaic-height);
}

.wpaic-hidden { display: none !important; }

/* ----------------------------------------------------------------- Header */

.wpaic-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 16px;
	background: var(--wpaic-brand);
	color: var(--wpaic-ink);
}

.wpaic-identity { display: flex; align-items: center; gap: 10px; min-width: 0; }

.wpaic-avatar {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	flex: 0 0 38px;
	overflow: hidden;
	border-radius: 50%;
	background: rgba( 255, 255, 255, 0.22 );
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 0.02em;
}

.wpaic-avatar img { width: 100%; height: 100%; object-fit: cover; }

.wpaic-name {
	font-size: 15px;
	font-weight: 700;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.wpaic-status { font-size: 12px; opacity: 0.85; }

.wpaic-dot {
	display: inline-block;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #34d399;
	vertical-align: middle;
}

.wpaic-close {
	border: 0;
	background: none;
	color: inherit;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	opacity: 0.85;
	padding: 0 4px;
}

.wpaic-close:hover { opacity: 1; }
.wpaic-close:focus-visible { outline: 2px solid var(--wpaic-ink); outline-offset: 2px; }

/* ------------------------------------------------------------------- Body */

.wpaic-body {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 16px;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.wpaic-msg {
	max-width: 82%;
	padding: 10px 14px;
	border-radius: var(--wpaic-radius);
	font-size: 14px;
	word-wrap: break-word;
	animation: wpaic-in 0.22s ease;
}

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

@media ( prefers-reduced-motion: reduce ) {
	.wpaic-msg,
	.wpaic-launcher { animation: none; transition: none; }
}

.wpaic-bot {
	align-self: flex-start;
	background: var(--wpaic-bubble);
	border: 1px solid var(--wpaic-line);
	border-bottom-left-radius: 4px;
}

.wpaic-user {
	align-self: flex-end;
	background: var(--wpaic-brand);
	color: var(--wpaic-ink);
	border-bottom-right-radius: 4px;
}

.wpaic-bot a { color: var(--wpaic-brand); text-decoration: underline; word-break: break-word; }
.wpaic-user a { color: inherit; text-decoration: underline; }
.wpaic-msg strong { font-weight: 700; }

.wpaic-typing {
	align-self: flex-start;
	display: flex;
	gap: 4px;
	padding: 12px 14px;
	background: var(--wpaic-bubble);
	border: 1px solid var(--wpaic-line);
	border-radius: var(--wpaic-radius);
}

.wpaic-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--wpaic-muted);
	animation: wpaic-bounce 1.2s infinite;
}

.wpaic-typing span:nth-child( 2 ) { animation-delay: 0.15s; }
.wpaic-typing span:nth-child( 3 ) { animation-delay: 0.3s; }

@keyframes wpaic-bounce {
	0%, 60%, 100% { transform: none; opacity: 0.45; }
	30% { transform: translateY( -4px ); opacity: 1; }
}

/* ------------------------------------------------------------------ Chips */

.wpaic-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.wpaic-chips-quiet { margin-top: -2px; }

.wpaic-chip {
	padding: 8px 14px;
	border: 1px solid var(--wpaic-brand);
	border-radius: 999px;
	background: var(--wpaic-bubble);
	color: var(--wpaic-brand);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
}

.wpaic-chip:hover { background: var(--wpaic-brand); color: var(--wpaic-ink); }
.wpaic-chip:focus-visible { outline: 2px solid var(--wpaic-brand); outline-offset: 2px; }
.wpaic-chip:disabled { opacity: 0.5; cursor: not-allowed; }

.wpaic-chip-ghost {
	border-color: var(--wpaic-line);
	color: var(--wpaic-muted);
	font-weight: 500;
}

.wpaic-chip-ghost:hover { background: var(--wpaic-line); color: var(--wpaic-text); }

/* --------------------------------------------------------------- Composer */

.wpaic-composer {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	background: var(--wpaic-bubble);
	border-top: 1px solid var(--wpaic-line);
}

.wpaic-input {
	flex: 1;
	min-width: 0;
	padding: 11px 14px;
	border: 1px solid var(--wpaic-line);
	border-radius: 999px;
	background: var(--wpaic-surface);
	color: var(--wpaic-text);
	font-size: 14px;
	font-family: inherit;
}

.wpaic-input:focus { outline: 2px solid var(--wpaic-brand); outline-offset: -1px; }
.wpaic-input:disabled { opacity: 0.6; }

.wpaic-send {
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	flex: 0 0 42px;
	border: 0;
	border-radius: 50%;
	background: var(--wpaic-brand);
	color: var(--wpaic-ink);
	cursor: pointer;
}

.wpaic-send:disabled { opacity: 0.5; cursor: not-allowed; }
.wpaic-send:focus-visible { outline: 2px solid var(--wpaic-brand); outline-offset: 2px; }

/* ---------------------------------------------------------------- Consent */

.wpaic-consent {
	display: flex;
	flex-direction: column;
	gap: 8px;
	align-items: flex-start;
	padding: 12px 14px;
	background: var(--wpaic-bubble);
	border: 1px solid var(--wpaic-line);
	border-radius: var(--wpaic-radius);
	font-size: 13px;
}

.wpaic-consent-label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.wpaic-consent-link { color: var(--wpaic-brand); font-size: 12px; }

/* ------------------------------------------------------------------- Form */

.wpaic-form {
	display: flex;
	flex-direction: column;
	gap: 12px;
	max-width: 520px;
	padding: 22px;
	background: var(--wpaic-bubble);
	border: 1px solid var(--wpaic-line);
	border-radius: var(--wpaic-radius);
	color: var(--wpaic-text);
}

.wpaic-form-title { font-size: 18px; font-weight: 700; }
.wpaic-form-row { display: flex; flex-direction: column; gap: 5px; }
.wpaic-form-label { font-size: 13px; font-weight: 600; color: var(--wpaic-muted); }

.wpaic-form-control {
	width: 100%;
	padding: 11px 13px;
	border: 1px solid var(--wpaic-line);
	border-radius: 10px;
	background: var(--wpaic-surface);
	color: var(--wpaic-text);
	font-size: 15px;
	font-family: inherit;
}

.wpaic-form-control:focus { outline: 2px solid var(--wpaic-brand); outline-offset: -1px; }
.wpaic-form-consent { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
.wpaic-form-error { min-height: 18px; color: #b42318; font-size: 13px; }

.wpaic-form-submit {
	padding: 12px 18px;
	border: 0;
	border-radius: 10px;
	background: var(--wpaic-brand);
	color: var(--wpaic-ink);
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
}

.wpaic-form-submit:disabled { opacity: 0.6; cursor: wait; }
.wpaic-form-done { padding: 18px 0; font-size: 15px; font-weight: 600; }

.wpaic-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	opacity: 0;
}

/* ------------------------------------------------------------------ Small */

@media ( max-width: 480px ) {
	.wpaic-pos-right .wpaic-panel,
	.wpaic-pos-left .wpaic-panel {
		right: 8px;
		left: 8px;
		bottom: 84px;
		width: auto;
		height: calc( 100vh - 110px );
	}

	.wpaic-msg { max-width: 88%; font-size: 15px; }
}
