/* Phuket Plus AI Assistant — widget styles. Scoped to .pai; colours from the 2026 homepage tokens (AA contrast). */
.pai {
	--pai-navy: #061827;
	--pai-ink: #10202c;
	--pai-slate: #5f6f7b;
	--pai-lime: #c8e85f;
	--pai-surface: #f5f7f6;
	--pai-field: #fafcfb;
	--pai-border: #dde2ea;
	--pai-field-border: #7f8b98;
	--pai-error: #b42318;
	font: 400 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Thai", "Noto Sans", sans-serif;
	color: var(--pai-ink);
	letter-spacing: normal;
	text-transform: none;
}

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

.pai p {
	margin: 0;
	font: inherit;
	color: inherit;
}

.pai button,
.pai input,
.pai select,
.pai textarea {
	font: inherit;
	letter-spacing: normal;
	text-transform: none;
}

/* Pages with their own chat UI (PhuketPlusAIChat) add class "pai-ui" to get the widget's tooltips, delivery status and
   hover lift — only the colour tokens, none of the .pai resets (font, margins, box-sizing). */
.pai-ui {
	--pai-navy: #061827;
	--pai-ink: #10202c;
	--pai-slate: #5f6f7b;
	--pai-lime: #c8e85f;
	--pai-border: #dde2ea;
}

/* Bottom-left: Chaty's WhatsApp button owns bottom-right. Buttons use `.pai .pai-x` (+ explicit :hover/:focus/:active)
   so the theme's and Elementor kit's global button styles (e.g. `.elementor-kit-6 button:hover`, 0,2,1) never win. */
.pai .pai-launcher,
.pai .pai-launcher:hover,
.pai .pai-launcher:focus,
.pai .pai-launcher:active {
	position: fixed;
	left: 24px;
	bottom: 24px;
	z-index: 99990;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 48px;
	margin: 0;
	padding: 0 18px 0 14px;
	border: 2px solid var(--pai-lime);
	border-radius: 999px;
	background: var(--pai-navy);
	color: #fff;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(4, 19, 31, 0.28);
}

.pai .pai-launcher:hover {
	background: #0b2438;
}

.pai-launcher svg {
	color: var(--pai-lime);
	flex: none;
}

.pai-panel {
	position: fixed;
	left: 24px;
	bottom: 88px;
	z-index: 100001;
	display: flex;
	flex-direction: column;
	width: min(390px, calc(100vw - 32px));
	height: min(620px, calc(100vh - 112px));
	background: #fff;
	border: 1px solid var(--pai-border);
	border-radius: 16px;
	box-shadow: 0 18px 50px rgba(4, 19, 31, 0.3);
	overflow: hidden;
	/* Closed pose; chat.js adds .pai-panel--in after unhiding, and hides the panel when the closing transition ends. */
	opacity: 0;
	transform: translateY(16px) scale(0.96);
	transform-origin: bottom left;
	pointer-events: none;
	transition: opacity 160ms ease-in, transform 160ms ease-in;
}

.pai-panel.pai-panel--in {
	opacity: 1;
	transform: none;
	pointer-events: auto;
	transition: opacity 220ms cubic-bezier(0.2, 0.8, 0.2, 1), transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.pai-panel[hidden],
.pai [hidden] {
	display: none !important;
}

.pai-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 8px;
	padding: 14px 8px 12px 16px;
	background: var(--pai-navy);
	color: #fff;
}

.pai .pai-title {
	font-weight: 700;
	font-size: 16px;
	line-height: 1.3;
	color: #fff;
}

.pai .pai-sub {
	margin-top: 2px;
	font-size: 12.5px;
	line-height: 1.4;
	color: #d4dce4;
}

.pai .pai-badge {
	display: inline-block;
	margin-top: 6px;
	padding: 2px 8px;
	border-radius: 999px;
	background: var(--pai-lime);
	color: var(--pai-navy);
	font-size: 12px;
	font-weight: 700;
}

.pai .pai-close,
.pai .pai-close:focus,
.pai .pai-close:active {
	flex: none;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: transparent;
	color: #fff;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
}

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

.pai-titles {
	flex: 1;
	min-width: 0;
}

/* Back arrow (lead form → chat), top-left of the header; same 44 px target as the close button. */
.pai .pai-back,
.pai .pai-back:hover,
.pai .pai-back:focus,
.pai .pai-back:active {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: -4px 0 0 -10px;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: transparent;
	color: #fff;
	line-height: 1;
	cursor: pointer;
}

.pai .pai-back:hover {
	background: rgba(255, 255, 255, 0.12);
}

.pai .pai-back svg {
	display: block;
}

/* Open the full-page A.I Sales Agent (link), left of the close button. */
.pai .pai-expand,
.pai .pai-expand:hover,
.pai .pai-expand:focus,
.pai .pai-expand:active,
.pai .pai-expand:visited {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: transparent;
	color: #fff;
	text-decoration: none;
	transition: background-color 160ms ease, color 160ms ease;
}

.pai .pai-expand:hover {
	background: rgba(255, 255, 255, 0.12);
	color: var(--pai-lime);
}

.pai .pai-expand svg {
	display: block;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	.pai .pai-expand svg {
		transition: transform 160ms ease;
	}

	.pai .pai-expand:hover svg {
		transform: scale(1.12);
	}
}

.pai-log {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 10px;
	overflow-y: auto;
	padding: 16px;
	background: var(--pai-surface);
}

.pai-msg {
	max-width: 88%;
	padding: 10px 12px;
	border-radius: 14px;
	overflow-wrap: anywhere;
}

.pai-msg p + p,
.pai-msg ul + p,
.pai-msg p + ul {
	margin-top: 0.5em;
}

.pai-msg ul {
	margin: 0.25em 0 0 1.1em;
	padding: 0;
	list-style: disc;
}

.pai-msg li {
	margin: 0.15em 0;
}

.pai-msg--user {
	align-self: flex-end;
	background: var(--pai-navy);
	color: #fff;
	border-bottom-right-radius: 4px;
}

/* Delivery status of a visitor message (chat.js setStatus()). On navy #061827: text rgba(255,255,255,.82) 12.2:1,
   lime "read" ticks 13:1, failed #ffb4a8 10.6:1. */
.pai-delivery {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
	gap: 4px;
	margin: 4px 0 0;
	color: rgba(255, 255, 255, 0.82);
	font-size: 12px;
	line-height: 1.3;
}

.pai-delivery-icon {
	display: inline-flex;
}

.pai-delivery[data-status="read"] .pai-delivery-icon {
	color: var(--pai-lime);
}

.pai-delivery[data-status="failed"] {
	color: #ffb4a8;
}

:is(.pai, .pai-ui) .pai-retry:is(*, :hover, :focus, :active) {
	min-height: 24px;
	margin: 0 0 0 4px;
	padding: 0 2px;
	border: 0;
	background: none;
	color: #fff;
	font: inherit;
	font-weight: 700;
	text-decoration: underline;
	cursor: pointer;
}

:is(.pai, .pai-ui) .pai-retry:focus-visible {
	outline: 2px solid var(--pai-lime);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: no-preference) {
	.pai-delivery[data-status="sending"] .pai-delivery-icon {
		animation: pai-delivery-pulse 1.2s ease-in-out infinite;
	}
}

@keyframes pai-delivery-pulse {
	50% {
		opacity: 0.4;
	}
}

.pai-msg--bot {
	align-self: flex-start;
	background: #fff;
	border: 1px solid var(--pai-border);
	border-bottom-left-radius: 4px;
}

.pai .pai-msg--bot a,
.pai .pai-notice a,
.pai .pai-sources a {
	color: var(--pai-ink);
	font-size: inherit;
	font-weight: 600;
	text-decoration: underline;
}

.pai .pai-sources {
	margin-top: 8px;
	font-size: 12.5px;
	color: var(--pai-slate);
}

/* Project pictures under an answer (chat.js renderImages()): widget bubble and the A.I Sales Agent page alike. */
.pai-gallery {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 6px;
	margin-top: 10px;
}

.pai-gallery a {
	display: block;
	border-radius: 10px;
	overflow: hidden;
	line-height: 0;
}

.pai-gallery img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 16 / 10;
	object-fit: cover;
	margin: 0;
	border-radius: 0;
	transition: transform 0.2s ease;
}

.pai-gallery a:hover img {
	transform: scale(1.04);
}

.pai-gallery a:focus-visible {
	outline: 2px solid var(--pai-navy, #061827) !important;
	outline-offset: 2px !important;
}

.pai .pai-gallery-note,
.pai-gallery-note {
	margin: 6px 0 0;
	font-size: 12px;
	line-height: 1.4;
	color: var(--pai-slate, #4b5b66);
}

@media (prefers-reduced-motion: reduce) {
	.pai-gallery img {
		transition: none;
	}
}

.pai-dots {
	display: inline-block;
	width: 28px;
	height: 8px;
	background: radial-gradient(circle, var(--pai-slate) 3px, transparent 3.5px) 0 50% / 10px 8px repeat-x;
	animation: pai-pulse 1.2s ease-in-out infinite;
}

@keyframes pai-pulse {
	50% {
		opacity: 0.35;
	}
}

.pai .pai-notice {
	padding: 8px 16px;
	font-size: 12px;
	line-height: 1.45;
	color: var(--pai-slate);
	background: #fff;
	border-top: 1px solid var(--pai-border);
}

.pai-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 8px 16px 0;
	background: #fff;
}

.pai .pai-chip,
.pai .pai-chip:focus,
.pai .pai-chip:active,
.pai .pai-chip:visited {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	margin: 0;
	padding: 0 16px;
	border: 1px solid var(--pai-field-border);
	border-radius: 999px;
	background: #fff;
	color: var(--pai-ink);
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
}

.pai .pai-chip:hover {
	border-color: var(--pai-field-border);
	background: var(--pai-surface);
	color: var(--pai-ink);
}

/* Sales call-to-action under answers about prices, availability, promotions, brochures or viewings. */
.pai .pai-cta,
.pai .pai-cta:focus,
.pai .pai-cta:active {
	margin-top: 10px;
	min-height: 40px;
	height: auto;
	padding: 8px 14px;
	border-color: var(--pai-navy);
	background: var(--pai-navy);
	color: #fff;
	line-height: 1.3;
	text-align: left;
	white-space: normal;
}

.pai .pai-cta:hover {
	border-color: var(--pai-navy);
	background: #0b2438;
	color: #fff;
}

.pai-form {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding: 10px 12px 12px 16px;
	background: #fff;
}

.pai-field {
	flex: 1;
	min-width: 0;
}

.pai .pai-input {
	display: block;
	width: 100%;
	min-height: 44px;
	max-height: 120px;
	margin: 0;
	padding: 10px 12px;
	border: 1px solid var(--pai-field-border);
	border-radius: 12px;
	background: var(--pai-field);
	color: var(--pai-ink);
	line-height: 1.4;
	resize: vertical;
}

.pai-count {
	display: block;
	margin-top: 2px;
	font-size: 11px;
	color: var(--pai-slate);
	text-align: right;
}

.pai .pai-send,
.pai .pai-send:hover,
.pai .pai-send:focus,
.pai .pai-send:active {
	flex: none;
	min-width: 64px;
	height: 44px;
	margin: 0;
	padding: 0 16px;
	border: 0;
	border-radius: 12px;
	background: var(--pai-navy);
	color: #fff;
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
}

.pai .pai-send[disabled] {
	opacity: 0.55;
	cursor: wait;
}

/* Lead form buttons share one shape with the chips (Leave your details, Cancel): 44 px pill, 1 px border. */
.pai .pai-lead-buttons .pai-send,
.pai .pai-lead-buttons .pai-send:hover,
.pai .pai-lead-buttons .pai-send:focus,
.pai .pai-lead-buttons .pai-send:active {
	border: 1px solid var(--pai-navy);
	border-radius: 999px;
	font-size: 14px;
}

.pai .pai-lead-buttons .pai-send:hover {
	border-color: #0b2438;
	background: #0b2438;
}

/* Lead form */
.pai-lead {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	background: #fff;
}

.pai .pai-lead-title {
	font-size: 16px;
	font-weight: 700;
}

.pai .pai-hint {
	margin-top: 2px;
	font-size: 12.5px;
	color: var(--pai-slate);
}

.pai-row {
	margin-top: 12px;
}

.pai-row label {
	display: block;
	margin-bottom: 4px;
	font-size: 14px;
	font-weight: 600;
	color: var(--pai-ink);
}

.pai-row input[type="text"],
.pai-row input[type="email"],
.pai-row input[type="tel"],
.pai-row select,
.pai-row textarea {
	display: block;
	width: 100%;
	min-height: 44px;
	margin: 0;
	padding: 8px 12px;
	border: 1px solid var(--pai-field-border);
	border-radius: 10px;
	background: var(--pai-field);
	color: var(--pai-ink);
}

.pai-row [aria-invalid="true"] {
	border-color: var(--pai-error);
	box-shadow: 0 0 0 1px var(--pai-error);
}

.pai .pai-error,
.pai .pai-status {
	margin-top: 4px;
	font-size: 13px;
	font-weight: 600;
	color: var(--pai-error);
}

.pai-consent {
	display: grid;
	grid-template-columns: 24px 1fr;
	gap: 4px 10px;
	align-items: start;
}

.pai-consent input {
	width: 22px;
	height: 22px;
	margin: 2px 0 0;
	accent-color: var(--pai-navy);
}

.pai-consent label {
	margin: 0;
	font-size: 13px;
	font-weight: 400;
	line-height: 1.45;
}

.pai-consent .pai-error {
	grid-column: 2;
}

.pai-lead-buttons {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 16px;
}

.pai-trap {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

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

/* Focus: visible on every control. !important beats the site-wide `a:focus{outline:0 !important}` (KI-062). */
.pai a:focus-visible,
.pai button:focus-visible,
.pai input:focus-visible,
.pai select:focus-visible,
.pai textarea:focus-visible,
.pai-log:focus-visible {
	outline: 2px solid var(--pai-navy) !important;
	outline-offset: 2px !important;
}

.pai .pai-launcher:focus-visible,
.pai .pai-head :focus-visible {
	outline: 3px solid var(--pai-lime) !important;
	outline-offset: 2px !important;
}

@media (max-width: 600px) {
	.pai-launcher {
		left: 16px;
		bottom: 16px;
	}

	.pai-panel {
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		height: min(88vh, calc(100% - 16px));
		height: min(88dvh, calc(100% - 16px));
		border-radius: 16px 16px 0 0;
		/* Bottom sheet: slide up from the screen edge. */
		opacity: 1;
		transform: translateY(100%);
		transition: transform 200ms ease-in;
	}

	.pai-panel.pai-panel--in {
		transform: none;
		transition: transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
	}

	.pai--open .pai-launcher {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.pai *,
	.pai *::before,
	.pai *::after {
		animation: none !important;
		transition: none !important;
	}
}

/* Privacy policy pop-up (chat.js openPrivacy()): the site's privacy page in the page's language, above the chat. */
html.pai-modal-open {
	overflow: hidden;
}

.pai-modal-wrap {
	position: fixed;
	inset: 0;
	z-index: 100010;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
}

.pai-modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(6, 24, 39, 0.55);
	opacity: 0;
	transition: opacity 160ms ease-in;
}

.pai-modal {
	position: relative;
	display: flex;
	flex-direction: column;
	width: min(640px, 100%);
	max-height: min(760px, calc(100vh - 32px));
	max-height: min(760px, calc(100dvh - 32px));
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 24px 60px rgba(4, 19, 31, 0.35);
	overflow: hidden;
	opacity: 0;
	transform: translateY(12px) scale(0.97);
	transition: opacity 160ms ease-in, transform 160ms ease-in;
}

.pai-modal-wrap--in .pai-modal-backdrop {
	opacity: 1;
	transition: opacity 220ms ease-out;
}

.pai-modal-wrap--in .pai-modal {
	opacity: 1;
	transform: none;
	transition: opacity 220ms cubic-bezier(0.2, 0.8, 0.2, 1), transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.pai .pai-modal h2.pai-title {
	margin: 0;
	padding-top: 10px;
	font-family: inherit;
	font-size: 17px;
	letter-spacing: normal;
	text-transform: none;
}

.pai-modal-body {
	flex: 1;
	overflow-y: auto;
	padding: 8px 20px 20px;
	overscroll-behavior: contain;
	font-size: 14.5px;
	line-height: 1.6;
}

.pai .pai-modal-body p,
.pai .pai-modal-body ul,
.pai .pai-modal-body ol {
	margin: 10px 0 0;
}

.pai .pai-modal-body ul,
.pai .pai-modal-body ol {
	padding-left: 22px;
}

.pai .pai-modal-body li + li {
	margin-top: 4px;
}

.pai .pai-modal-body h3,
.pai .pai-modal-body h4,
.pai .pai-modal-body h5,
.pai .pai-modal-body h6 {
	margin: 20px 0 0;
	padding: 0;
	font-family: inherit;
	font-size: 15.5px;
	font-weight: 700;
	line-height: 1.35;
	letter-spacing: normal;
	text-transform: none;
	color: var(--pai-navy);
}

.pai .pai-modal-body h4,
.pai .pai-modal-body h5,
.pai .pai-modal-body h6 {
	font-size: 14.5px;
}

.pai .pai-modal-body a,
.pai .pai-modal-foot a {
	color: var(--pai-ink);
	font-size: inherit;
	font-weight: 600;
	line-height: inherit;
	text-decoration: underline;
}

.pai .pai-modal-status {
	margin-top: 12px;
	color: var(--pai-slate);
}

.pai-modal-body:focus-visible {
	outline: 2px solid var(--pai-navy) !important;
	outline-offset: -2px !important;
}

.pai-modal-foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 16px;
	padding: 12px 20px;
	border-top: 1px solid var(--pai-border);
	font-size: 13.5px;
}

.pai .pai-modal-done,
.pai .pai-modal-done:hover,
.pai .pai-modal-done:focus,
.pai .pai-modal-done:active {
	min-height: 44px;
	margin: 0 0 0 auto;
	padding: 0 18px;
	border: 0;
	border-radius: 999px;
	background: var(--pai-navy);
	color: #fff;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
}

.pai .pai-modal-done:hover {
	background: #0b2438;
}

.pai .pai-modal-done:focus-visible,
.pai .pai-modal-foot a:focus-visible,
.pai .pai-modal .pai-head :focus-visible {
	outline: 3px solid var(--pai-lime) !important;
	outline-offset: 2px !important;
}

.pai .pai-modal-foot a:focus-visible {
	outline-color: var(--pai-navy) !important;
}

@media (max-width: 600px) {
	.pai-modal-wrap {
		align-items: flex-end;
		padding: 0;
	}

	.pai-modal {
		width: 100%;
		max-height: 92vh;
		max-height: 92dvh;
		border-radius: 16px 16px 0 0;
		opacity: 1;
		transform: translateY(100%);
		transition: transform 200ms ease-in;
	}

	.pai-modal-wrap--in .pai-modal {
		transform: none;
		transition: transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
	}
}

/* Chat ↔ "Leave your details" view switch (chat.js slideView()). */
@media (prefers-reduced-motion: no-preference) {
	.pai-view-in-fwd {
		animation: pai-view-in-fwd 240ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
	}

	.pai-view-in-back {
		animation: pai-view-in-back 240ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
	}
}

@keyframes pai-view-in-fwd {
	from {
		opacity: 0;
		transform: translateX(28px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes pai-view-in-back {
	from {
		opacity: 0;
		transform: translateX(-28px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

/* Tooltips on icon buttons (chat.js: .pai-tip + data-tip = the button's accessible name, so screen readers hear it
   once). Shown on mouse hover (after a short delay) and on keyboard focus; Esc hides a hovered one (dismissTip()).
   White with a border so it reads on the navy header and on the light chat alike. */
.pai-head {
	position: relative;
	z-index: 2;
}

:is(.pai, .pai-ui) .pai-tip {
	position: relative;
	--pai-tip-x: -50%;
	--pai-tip-y: -4px;
}

:is(.pai, .pai-ui) .pai-tip[data-tip-align="start"] {
	--pai-tip-x: 0%;
}

:is(.pai, .pai-ui) .pai-tip::after,
:is(.pai, .pai-ui) .pai-tip::before {
	position: absolute;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 120ms ease-in, transform 120ms ease-in, visibility 0s linear 120ms;
}

:is(.pai, .pai-ui) .pai-tip::after {
	content: attr(data-tip);
	top: calc(100% + 8px);
	left: 50%;
	z-index: 3;
	padding: 6px 10px;
	border: 1px solid var(--pai-border);
	border-radius: 8px;
	background: #fff;
	color: var(--pai-ink);
	box-shadow: 0 6px 18px rgba(4, 19, 31, 0.18);
	font: 600 12.5px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Thai", "Noto Sans", sans-serif;
	letter-spacing: normal;
	text-transform: none;
	white-space: nowrap;
	transform: translate(var(--pai-tip-x), var(--pai-tip-y));
}

:is(.pai, .pai-ui) .pai-tip[data-tip-align="start"]::after {
	left: 0;
}

:is(.pai, .pai-ui) .pai-tip[data-tip-align="end"]::after {
	left: auto;
	right: 0;
	--pai-tip-x: 0%;
}

/* Arrow, centred under the button. */
:is(.pai, .pai-ui) .pai-tip::before {
	content: "";
	top: calc(100% + 4px);
	left: 50%;
	z-index: 4;
	width: 9px;
	height: 9px;
	border-top: 1px solid var(--pai-border);
	border-left: 1px solid var(--pai-border);
	background: #fff;
	transform: translate(-50%, var(--pai-tip-y)) rotate(45deg);
}

@media (hover: hover) {
	:is(.pai, .pai-ui) .pai-tip:hover::after,
	:is(.pai, .pai-ui) .pai-tip:hover::before {
		opacity: 1;
		visibility: visible;
		--pai-tip-y: 0px;
		transition: opacity 160ms ease-out 250ms, transform 160ms ease-out 250ms, visibility 0s linear 250ms;
	}

	:is(.pai, .pai-ui) .pai-tip:hover::after {
		pointer-events: auto; /* WCAG 1.4.13: the pointer can move onto the tooltip without it disappearing. */
	}
}

:is(.pai, .pai-ui) .pai-tip:focus-visible::after,
:is(.pai, .pai-ui) .pai-tip:focus-visible::before {
	opacity: 1;
	visibility: visible;
	--pai-tip-y: 0px;
	transition: opacity 160ms ease-out, transform 160ms ease-out, visibility 0s;
}

/* Text buttons (Leave your details, Send details, Cancel): tooltip above, wrapping, so it is never cut off at the
   bottom of the scrolling lead form or the panel. */
:is(.pai, .pai-ui) .pai-tip[data-tip-pos="top"] {
	--pai-tip-y: 4px;
}

:is(.pai, .pai-ui) .pai-tip[data-tip-pos="top"]::after {
	top: auto;
	bottom: calc(100% + 8px);
	width: max-content;
	max-width: 240px;
	white-space: normal;
	text-align: left;
}

:is(.pai, .pai-ui) .pai-tip[data-tip-pos="top"]::before {
	top: auto;
	bottom: calc(100% + 4px);
	border-top: 0;
	border-left: 0;
	border-right: 1px solid var(--pai-border);
	border-bottom: 1px solid var(--pai-border);
}

/* Below the element but wrapping, for narrow scroll areas (e.g. the A.I Sales Agent page sidebar). */
:is(.pai, .pai-ui) .pai-tip[data-tip-pos="bottom"]::after {
	width: max-content;
	max-width: 240px;
	white-space: normal;
	text-align: left;
}

/* "Ask AI" launcher: tooltip to the right, where the open chat panel (above the launcher) never covers it. The
   launcher keeps position: fixed (.pai-tip would make it relative). Here --pai-tip-y is the horizontal slide. */
.pai .pai-launcher.pai-tip {
	position: fixed;
}

:is(.pai, .pai-ui) .pai-tip[data-tip-pos="right"]::after {
	top: 50%;
	left: calc(100% + 10px);
	transform: translate(var(--pai-tip-y), -50%);
}

:is(.pai, .pai-ui) .pai-tip[data-tip-pos="right"]::before {
	top: 50%;
	left: calc(100% + 6px);
	border-top: 0;
	border-right: 0;
	border-left: 1px solid var(--pai-border);
	border-bottom: 1px solid var(--pai-border);
	transform: translate(var(--pai-tip-y), -50%) rotate(45deg);
}

:is(.pai, .pai-ui) .pai-tip.pai-tip--off::after,
:is(.pai, .pai-ui) .pai-tip.pai-tip--off::before {
	opacity: 0 !important;
	visibility: hidden !important;
	transition: none !important;
}

/* Hover animation: buttons lift slightly and gain a soft shadow; the back arrow nudges left; the close × turns lime.
   Pointer devices only, and only without prefers-reduced-motion. */
.pai .pai-close,
.pai .pai-back {
	transition: background-color 160ms ease, color 160ms ease;
}

.pai .pai-close:hover {
	color: var(--pai-lime);
}

.pai .pai-modal .pai-close:hover {
	color: var(--pai-lime);
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	.pai .pai-chip,
	.pai .pai-send,
	.pai .pai-modal-done,
	.pai .pai-launcher {
		transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease, border-color 160ms ease;
	}

	.pai .pai-chip:hover,
	.pai .pai-send:not([disabled]):hover,
	.pai .pai-modal-done:hover {
		transform: translateY(-1px);
		box-shadow: 0 4px 12px rgba(4, 19, 31, 0.14);
	}

	.pai .pai-launcher:hover {
		transform: translateY(-2px);
		box-shadow: 0 10px 26px rgba(4, 19, 31, 0.32);
	}

	.pai .pai-chip:active,
	.pai .pai-send:not([disabled]):active,
	.pai .pai-modal-done:active,
	.pai .pai-launcher:active {
		transform: translateY(0) scale(0.98);
		box-shadow: none;
	}

	.pai .pai-back svg {
		transition: transform 160ms ease;
	}

	.pai .pai-back:hover svg {
		transform: translateX(-3px);
	}
}

/* Hover lift for page buttons that opt in (class pai-lift, set by the page through PhuketPlusAIChat). */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	.pai-ui .pai-lift {
		transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
	}

	.pai-ui .pai-lift:not(:disabled):hover {
		transform: translateY(-1px);
		box-shadow: 0 4px 12px rgba(4, 19, 31, 0.14);
	}

	.pai-ui .pai-lift:not(:disabled):active {
		transform: translateY(0) scale(0.98);
		box-shadow: none;
	}
}
