/**
 * Avports AI Assistant — widget styles.
 * Everything is scoped under .avpaa-root and resets aggressively, so a theme's
 * global button/input rules can't bleed in.
 */

.avpaa-root {
	--avpaa-accent: #0b7fd4;
	--avpaa-ink: #14171a;
	--avpaa-ink-soft: #5b6570;
	--avpaa-line: #e3e7eb;
	--avpaa-bg: #ffffff;
	--avpaa-bubble: #f4f6f8;
	--avpaa-radius: 14px;
	--avpaa-shadow: 0 18px 50px rgba(12, 20, 28, 0.18), 0 2px 8px rgba(12, 20, 28, 0.08);
	--avpaa-serif: Georgia, "Times New Roman", serif;
	--avpaa-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

	position: fixed;
	bottom: 24px;
	z-index: 999999;
	font-family: var(--avpaa-sans);
	font-size: 15px;
	line-height: 1.55;
	color: var(--avpaa-ink);
}

.avpaa-root.avpaa-pos-right { right: 24px; }
.avpaa-root.avpaa-pos-left  { left: 24px; }

.avpaa-root *,
.avpaa-root *::before,
.avpaa-root *::after { box-sizing: border-box; }

.avpaa-sr {
	position: absolute !important;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0 0 0 0);
	white-space: nowrap; border: 0;
}


/* ---------- Theme defence ----------
   A host theme's global rules for p, span, li, a and headings beat plain
   inheritance inside the widget. Avports' theme, for example, colours every
   paragraph rgba(240,242,247,.65) — near-white — which made replies unreadable
   on the light bubble. Colour every element we actually render, explicitly,
   at a specificity a theme is unlikely to reach. */

.avpaa-root *,
.avpaa-root *::before,
.avpaa-root *::after {
	opacity: 1;
	visibility: visible;
	letter-spacing: normal;
	text-transform: none;
	text-shadow: none;
	float: none;
	max-width: none;
	text-indent: 0;
}

.avpaa-root .avpaa-bubble,
.avpaa-root .avpaa-bubble p,
.avpaa-root .avpaa-bubble li,
.avpaa-root .avpaa-bubble span,
.avpaa-root .avpaa-bubble em {
	color: var(--avpaa-ink);
	-webkit-text-fill-color: var(--avpaa-ink);
	font-family: var(--avpaa-sans);
	font-size: 14.5px;
	line-height: 1.55;
}

.avpaa-root .avpaa-bubble strong {
	color: var(--avpaa-ink);
	-webkit-text-fill-color: var(--avpaa-ink);
	font-weight: 600;
}

.avpaa-root .avpaa-msg--user .avpaa-bubble,
.avpaa-root .avpaa-msg--user .avpaa-bubble p,
.avpaa-root .avpaa-msg--user .avpaa-bubble li,
.avpaa-root .avpaa-msg--user .avpaa-bubble span,
.avpaa-root .avpaa-msg--user .avpaa-bubble strong {
	color: #fff;
	-webkit-text-fill-color: #fff;
}

.avpaa-root .avpaa-bubble a {
	color: var(--avpaa-accent);
	-webkit-text-fill-color: var(--avpaa-accent);
	text-decoration: underline;
}

.avpaa-root .avpaa-msg--user .avpaa-bubble a {
	color: #9ed0f7;
	-webkit-text-fill-color: #9ed0f7;
}

.avpaa-root .avpaa-head,
.avpaa-root .avpaa-head__title,
.avpaa-root .avpaa-head span {
	color: #fff;
	-webkit-text-fill-color: #fff;
}

.avpaa-root .avpaa-head__status {
	color: rgba( 255, 255, 255, 0.62 );
	-webkit-text-fill-color: rgba( 255, 255, 255, 0.62 );
}

.avpaa-root .avpaa-launcher,
.avpaa-root .avpaa-launcher span {
	color: #fff;
	-webkit-text-fill-color: #fff;
}

.avpaa-root .avpaa-prompt,
.avpaa-root .avpaa-prompt span {
	color: var(--avpaa-ink);
	-webkit-text-fill-color: var(--avpaa-ink);
	font-family: var(--avpaa-sans);
	font-size: 13.5px;
}

.avpaa-root .avpaa-lead,
.avpaa-root .avpaa-lead p,
.avpaa-root .avpaa-lead label,
.avpaa-root .avpaa-lead span {
	color: var(--avpaa-ink-soft);
	-webkit-text-fill-color: var(--avpaa-ink-soft);
	font-family: var(--avpaa-sans);
}

.avpaa-root .avpaa-lead__title {
	color: var(--avpaa-ink);
	-webkit-text-fill-color: var(--avpaa-ink);
}

.avpaa-root .avpaa-lead input,
.avpaa-root .avpaa-lead textarea,
.avpaa-root .avpaa-input {
	color: var(--avpaa-ink);
	-webkit-text-fill-color: var(--avpaa-ink);
	font-family: var(--avpaa-sans);
}

.avpaa-root .avpaa-lead__submit,
.avpaa-root .avpaa-lead__submit span {
	color: #fff;
	-webkit-text-fill-color: #fff;
}

.avpaa-root .avpaa-disclaimer {
	color: #8b949e;
	-webkit-text-fill-color: #8b949e;
	font-family: var(--avpaa-sans);
	font-size: 11.5px;
}

.avpaa-root .avpaa-send,
.avpaa-root .avpaa-close,
.avpaa-root .avpaa-reset {
	-webkit-text-fill-color: currentColor;
}

/* Icons. Every icon here is a stroked outline using currentColor, which only
   works if the SVG inherits its colour from the button. Themes that set a
   colour or fill on `svg` break that — on Avports it resolved to black on a
   near-black header, so the close button was drawn but invisible. */

.avpaa-root svg {
	color: inherit;
	fill: none;
	stroke: currentColor;
	overflow: visible;
	vertical-align: middle;
	max-width: none;
	max-height: none;
}

/* `stroke: currentColor` on the path is not enough: the Avports theme sets a
   colour on path elements themselves, so currentColor resolved to black there
   even once the parent svg was correct. Inherit the already-correct stroke
   from the svg instead of re-resolving it. */

.avpaa-root svg *,
.avpaa-root svg path,
.avpaa-root svg line,
.avpaa-root svg circle,
.avpaa-root svg polyline,
.avpaa-root svg rect,
.avpaa-root svg g {
	color: inherit;
	stroke: inherit;
	fill: none;
}

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

.avpaa-root .avpaa-launcher {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	margin: 0;
	padding: 13px 20px;
	border: 0;
	border-radius: 999px;
	background: #0d1115;
	color: #fff;
	font: inherit;
	font-size: 14.5px;
	font-weight: 500;
	letter-spacing: 0.01em;
	cursor: pointer;
	box-shadow: 0 10px 28px rgba(12, 20, 28, 0.26);
	transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.avpaa-root .avpaa-launcher:hover {
	background: #1b2229;
	transform: translateY(-1px);
	box-shadow: 0 14px 34px rgba(12, 20, 28, 0.3);
}

.avpaa-root .avpaa-launcher:focus-visible {
	outline: 3px solid var(--avpaa-accent);
	outline-offset: 3px;
}

.avpaa-launcher__icon { display: inline-flex; }

.avpaa-root.is-open .avpaa-launcher {
	opacity: 0;
	pointer-events: none;
	transform: scale(0.9);
}

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

.avpaa-root .avpaa-panel {
	position: absolute;
	bottom: 0;
	width: 392px;
	max-width: calc(100vw - 32px);
	height: 620px;
	max-height: calc(100vh - 48px);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: var(--avpaa-bg);
	border: 1px solid var(--avpaa-line);
	border-radius: var(--avpaa-radius);
	box-shadow: var(--avpaa-shadow);
	opacity: 0;
	transform: translateY(12px) scale(0.985);
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.avpaa-pos-right .avpaa-panel { right: 0; }
.avpaa-pos-left  .avpaa-panel { left: 0; }

.avpaa-root .avpaa-panel[hidden] { display: none; }

.avpaa-root.is-open .avpaa-panel {
	opacity: 1;
	transform: translateY(0) scale(1);
}

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

.avpaa-root .avpaa-head {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 15px 14px 15px 20px;
	background: #0d1115;
	color: #fff;
	flex: 0 0 auto;
}

.avpaa-head__text { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }

.avpaa-head__title {
	font-family: var(--avpaa-serif);
	font-size: 17px;
	line-height: 1.25;
	letter-spacing: 0.01em;
}

.avpaa-head__status {
	font-size: 12px;
	color: rgba(255, 255, 255, 0.62);
	margin-top: 2px;
}

.avpaa-root .avpaa-close,
.avpaa-root .avpaa-reset {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px; height: 34px;
	margin: 0; padding: 0;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: rgba(255, 255, 255, 0.72);
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.avpaa-root .avpaa-close:hover,
.avpaa-root .avpaa-reset:hover {
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
}

.avpaa-root .avpaa-close:focus-visible,
.avpaa-root .avpaa-reset:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

/* ---------- Message log ---------- */

.avpaa-root .avpaa-log {
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 20px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	scrollbar-width: thin;
}

.avpaa-msg { display: flex; }
.avpaa-msg--user { justify-content: flex-end; }

.avpaa-bubble {
	max-width: 86%;
	padding: 11px 14px;
	border-radius: 12px;
	background: var(--avpaa-bubble);
	color: var(--avpaa-ink);
	font-size: 14.5px;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.avpaa-msg--user .avpaa-bubble {
	background: #0d1115;
	color: #fff;
	border-bottom-right-radius: 4px;
}

.avpaa-msg--bot .avpaa-bubble { border-bottom-left-radius: 4px; }

.avpaa-bubble p { margin: 0 0 9px; }
.avpaa-bubble p:last-child { margin-bottom: 0; }

.avpaa-bubble ul,
.avpaa-bubble ol { margin: 0 0 9px; padding-left: 20px; }
.avpaa-bubble li { margin: 0 0 3px; }

.avpaa-bubble a {
	color: var(--avpaa-accent);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.avpaa-msg--user .avpaa-bubble a { color: #9ed0f7; }

.avpaa-bubble strong { font-weight: 600; }

/* Typing indicator */

.avpaa-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }

.avpaa-typing span {
	width: 6px; height: 6px;
	border-radius: 50%;
	background: #9aa5b1;
	animation: avpaa-bounce 1.1s infinite ease-in-out;
}

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

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

/* Suggested prompts */

.avpaa-prompts {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	margin-top: 2px;
}

.avpaa-root .avpaa-prompt {
	margin: 0;
	padding: 8px 13px;
	border: 1px solid var(--avpaa-line);
	border-radius: 999px;
	background: #fff;
	color: var(--avpaa-ink);
	font: inherit;
	font-size: 13.5px;
	text-align: left;
	cursor: pointer;
	transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.avpaa-root .avpaa-prompt:hover {
	border-color: var(--avpaa-accent);
	color: var(--avpaa-accent);
	background: #f7fbff;
}

.avpaa-root .avpaa-prompt:focus-visible {
	outline: 2px solid var(--avpaa-accent);
	outline-offset: 2px;
}

/* Error notice */

.avpaa-error {
	padding: 10px 13px;
	border: 1px solid #f0d3d3;
	border-radius: 10px;
	background: #fdf4f4;
	color: #96393b;
	font-size: 13.5px;
}

/* ---------- Lead form ---------- */

.avpaa-lead {
	border: 1px solid var(--avpaa-line);
	border-radius: 12px;
	padding: 16px;
	background: #fbfcfd;
}

.avpaa-lead__title {
	font-family: var(--avpaa-serif);
	font-size: 16px;
	margin: 0 0 5px;
}

.avpaa-lead__intro {
	margin: 0 0 13px;
	font-size: 13.5px;
	color: var(--avpaa-ink-soft);
}

.avpaa-field { margin-bottom: 10px; }

.avpaa-field label {
	display: block;
	font-size: 12.5px;
	font-weight: 500;
	color: var(--avpaa-ink-soft);
	margin-bottom: 4px;
}

.avpaa-root .avpaa-lead input[type="text"],
.avpaa-root .avpaa-lead input[type="email"],
.avpaa-root .avpaa-lead input[type="tel"],
.avpaa-root .avpaa-lead textarea {
	width: 100%;
	margin: 0;
	padding: 9px 11px;
	border: 1px solid var(--avpaa-line);
	border-radius: 8px;
	background: #fff;
	color: var(--avpaa-ink);
	font: inherit;
	font-size: 14px;
	line-height: 1.45;
}

.avpaa-root .avpaa-lead input:focus,
.avpaa-root .avpaa-lead textarea:focus {
	outline: 0;
	border-color: var(--avpaa-accent);
	box-shadow: 0 0 0 3px rgba(11, 127, 212, 0.16);
}

.avpaa-trap {
	position: absolute !important;
	left: -9999px;
	opacity: 0;
	height: 0;
	width: 0;
}

.avpaa-lead__actions { display: flex; gap: 8px; margin-top: 12px; }

.avpaa-root .avpaa-lead__submit {
	flex: 1 1 auto;
	margin: 0;
	padding: 11px 16px;
	border: 0;
	border-radius: 999px;
	background: #0d1115;
	color: #fff;
	font: inherit;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: background 0.15s ease;
}

.avpaa-root .avpaa-lead__submit:hover { background: #1b2229; }
.avpaa-root .avpaa-lead__submit[disabled] { opacity: 0.6; cursor: default; }

.avpaa-root .avpaa-lead__cancel {
	margin: 0;
	padding: 11px 14px;
	border: 1px solid var(--avpaa-line);
	border-radius: 999px;
	background: #fff;
	color: var(--avpaa-ink-soft);
	font: inherit;
	font-size: 14px;
	cursor: pointer;
}

.avpaa-root .avpaa-lead__cancel:hover { color: var(--avpaa-ink); border-color: #cfd6dd; }

.avpaa-root .avpaa-lead__submit:focus-visible,
.avpaa-root .avpaa-lead__cancel:focus-visible {
	outline: 2px solid var(--avpaa-accent);
	outline-offset: 2px;
}

.avpaa-lead__error {
	margin: 9px 0 0;
	font-size: 13px;
	color: #96393b;
}

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

.avpaa-root .avpaa-composer {
	flex: 0 0 auto;
	border-top: 1px solid var(--avpaa-line);
	padding: 12px 14px 10px;
	background: #fff;
}

.avpaa-root .avpaa-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	margin: 0;
	padding: 5px 5px 5px 14px;
	border: 1px solid var(--avpaa-line);
	border-radius: 22px;
	background: #fff;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.avpaa-root .avpaa-form:focus-within {
	border-color: var(--avpaa-accent);
	box-shadow: 0 0 0 3px rgba(11, 127, 212, 0.14);
}

.avpaa-root .avpaa-input {
	flex: 1 1 auto;
	max-height: 116px;
	margin: 0;
	padding: 8px 0;
	border: 0;
	background: transparent;
	color: var(--avpaa-ink);
	font: inherit;
	font-size: 14.5px;
	line-height: 1.45;
	resize: none;
	overflow-y: auto;
}

.avpaa-root .avpaa-input:focus { outline: 0; box-shadow: none; }

.avpaa-root .avpaa-send {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px; height: 36px;
	margin: 0; padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--avpaa-accent);
	color: #fff;
	cursor: pointer;
	transition: filter 0.15s ease, opacity 0.15s ease;
}

.avpaa-root .avpaa-send:hover { filter: brightness(1.08); }
.avpaa-root .avpaa-send[disabled] { opacity: 0.4; cursor: default; }

.avpaa-root .avpaa-send:focus-visible {
	outline: 2px solid var(--avpaa-accent);
	outline-offset: 2px;
}

.avpaa-disclaimer {
	margin: 8px 2px 0;
	font-size: 11.5px;
	line-height: 1.4;
	color: #8b949e;
	text-align: center;
}

/* ---------- Mobile ---------- */

@media (max-width: 560px) {
	.avpaa-root {
		bottom: 16px;
	}
	.avpaa-root.avpaa-pos-right { right: 16px; }
	.avpaa-root.avpaa-pos-left  { left: 16px; }

	.avpaa-root .avpaa-launcher__label { display: none; }

	.avpaa-root .avpaa-launcher {
		width: 54px; height: 54px;
		padding: 0;
		justify-content: center;
	}

	.avpaa-root.is-open {
		inset: 0;
		bottom: 0;
		right: 0;
		left: 0;
	}

	.avpaa-root .avpaa-panel {
		position: fixed;
		inset: 0;
		width: 100%;
		max-width: none;
		height: 100%;
		max-height: none;
		border: 0;
		border-radius: 0;
	}

	.avpaa-root .avpaa-head { padding-top: max(15px, env(safe-area-inset-top)); }
	.avpaa-root .avpaa-composer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
	.avpaa-root *,
	.avpaa-root *::before,
	.avpaa-root *::after {
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
	}
}

@media (prefers-contrast: more) {
	.avpaa-root { --avpaa-ink-soft: #3c454e; --avpaa-line: #b9c2cb; }
	.avpaa-disclaimer { color: #5b6570; }
}
