/* Roark – AI Assistant (flying chat widget) */

.roark-assistant {
	/* Same shared theme-aware chain as every other Roark primary CTA (see
	   roark-tokens.css, registered as this stylesheet's dependency). When
	   the admin has configured a custom "Accent Color" in Settings ▸ AI
	   Studio, ai-assistant.js sets --roark-assistant-accent inline on this
	   element instead (higher specificity than this class rule, so it
	   wins) — an unset/empty admin setting leaves this chain in charge. */
	--roark-assistant-accent: var(--roark-btn-bg);
	/* A full-viewport, non-fixed-sized anchor layer: it does not itself need
	   a box (the bubble and panel below are each position:fixed, so they
	   position against the viewport regardless of this element's own box —
	   only transformed/filtered ancestors would change that, and this one is
	   neither). Kept `position: fixed; inset: 0;` so its own ::before
	   backdrop (expanded+open state, below) can cover the viewport. */
	position: fixed;
	inset: 0;
	z-index: 99999;
	font-family: inherit;
	pointer-events: none;
}

.roark-assistant__bubble {
	position: fixed;
	pointer-events: auto;
	display: flex;
	align-items: center;
	justify-content: center;
	border: none;
	background: transparent;
	padding: 0;
	line-height: 1;
	cursor: pointer;
}

.roark-assistant__bubble:focus-visible {
	outline: none;
}

.roark-assistant__bubble-inner {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	background: var(--roark-assistant-accent);
	color: #fff;
}

.roark-assistant__bubble:focus-visible .roark-assistant__bubble-inner {
	box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9), 0 0 0 6px var(--roark-assistant-accent);
}

.roark-assistant__bubble-icon {
	width: 30px;
	height: 30px;
	max-width: none;
	flex: 0 0 auto;
	display: block;
}

.roark-assistant.is-open .roark-assistant__bubble {
	display: none;
}

/* Hidden (not just faded) while the inquiry modal or the mobile filter panel
   is open — visibility + no pointer events, not display:none, so no layout
   shift; see isBlockedByOtherUi()/refreshBlockedState() in ai-assistant.js. */
.roark-assistant__bubble.is-blocked {
	visibility: hidden;
	pointer-events: none;
}

/* ── Bottom-right (classic) launcher ───────────────────────────────────── */

.roark-assistant--bottom-right .roark-assistant__bubble {
	right: 24px;
	bottom: 24px;
	width: 60px;
	height: 60px;
}

.roark-assistant--bottom-right .roark-assistant__bubble-inner {
	border-radius: 50%;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
	transition: transform 0.15s ease;
}

.roark-assistant--bottom-right .roark-assistant__bubble:hover .roark-assistant__bubble-inner {
	transform: scale(1.06);
}

/* Move the toggle above the mobile sticky action bar so the two never
   overlap. Detected purely in CSS via :has() (same pattern already used
   in listing.css / expose-mobile.css to pad the page for these bars) —
   no JS/PHP body-class plumbing needed, and it stays correct regardless
   of which widget/page rendered the bar. Only relevant to this variant:
   the side-docked tab (below) sits at ~55% viewport height, well clear of
   any bottom sticky bar. */
@media (max-width: 767px) {
	body:has(.roark-mobile-listing-bar) .roark-assistant--bottom-right .roark-assistant__bubble,
	body:has(.roark-expose-mobile-bar:not([hidden])) .roark-assistant--bottom-right .roark-assistant__bubble {
		bottom: 88px;
	}
}

@media (max-width: 480px) {
	.roark-assistant--bottom-right .roark-assistant__bubble {
		right: 12px;
		bottom: 12px;
	}
}

/* ── Side-docked edge tab (default) ────────────────────────────────────── */

.roark-assistant--side .roark-assistant__bubble {
	top: 55%;
	right: env(safe-area-inset-right, 0px);
	bottom: auto;
	transform: translateY(-50%);
	width: 44px;
	height: 56px;
	justify-content: flex-end;
}

.roark-assistant--side .roark-assistant__bubble-inner {
	width: 44px;
	height: 56px;
	border-radius: 12px 0 0 12px;
	box-shadow: -2px 4px 14px rgba(0, 0, 0, 0.2);
	opacity: 0.6;
	transition: opacity 0.15s ease, transform 0.15s ease;
}

.roark-assistant--side .roark-assistant__bubble:hover .roark-assistant__bubble-inner,
.roark-assistant--side .roark-assistant__bubble:focus-visible .roark-assistant__bubble-inner,
.roark-assistant--side .roark-assistant__bubble.is-pressed .roark-assistant__bubble-inner {
	opacity: 1;
	transform: translateX(-6px);
}

@media (max-width: 767px) {
	.roark-assistant--side .roark-assistant__bubble {
		/* Visible box is smaller (~36x48) but the button itself (the actual
		   hit area) stays >=44px wide/tall — the inner span is what's
		   visually sized down, flush right within the wider button. */
		width: 48px;
		height: 56px;
	}

	.roark-assistant--side .roark-assistant__bubble-inner {
		width: 36px;
		height: 48px;
		margin-left: auto;
	}
}

@media (prefers-reduced-motion: reduce) {
	.roark-assistant__bubble-inner {
		transition: none;
	}
}

.roark-assistant__panel {
	position: absolute;
	pointer-events: auto;
	right: 0;
	bottom: 0;
	width: 320px;
	max-width: calc(100vw - 32px);
	height: 440px;
	max-height: calc(100vh - 96px);
	display: flex;
	flex-direction: column;
	background: #fff;
	border-radius: 16px;
	overflow: hidden;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
}

/*
 * Author `display: flex` above overrides the user-agent `[hidden] { display: none }`
 * rule, so the panel cannot be hidden via the `hidden` attribute alone. Restore it
 * explicitly — this is what makes the close (×) button actually close the panel.
 */
.roark-assistant__panel[hidden] {
	display: none;
}

/* Expanded ("full") modal: centered large panel with a dimmed backdrop. The
   backdrop is shown only while the panel is also open — otherwise it would linger
   after closing (and after a reload, since the expanded state is remembered),
   covering the page and swallowing clicks. */
.roark-assistant.is-expanded.is-open::before {
	content: "";
	position: fixed;
	pointer-events: auto;
	inset: 0;
	background: rgba(15, 23, 42, 0.45);
}

.roark-assistant.is-expanded .roark-assistant__panel {
	position: fixed;
	top: 50%;
	left: 50%;
	right: auto;
	bottom: auto;
	transform: translate(-50%, -50%);
	width: min(820px, calc(100vw - 32px));
	height: min(90vh, 900px);
	max-width: none;
	max-height: none;
}

.roark-assistant__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 14px;
	background: var(--roark-assistant-accent);
	color: #fff;
}

.roark-assistant__title {
	font-weight: 600;
	font-size: 14px;
}

.roark-assistant__actions {
	display: flex;
	align-items: center;
	gap: 2px;
}

.roark-assistant__close,
.roark-assistant__expand {
	background: none;
	border: none;
	color: #fff;
	line-height: 1;
	cursor: pointer;
	padding: 0 4px;
	opacity: 0.9;
}

.roark-assistant__close {
	font-size: 24px;
}

.roark-assistant__expand {
	font-size: 18px;
}

.roark-assistant__close:hover,
.roark-assistant__expand:hover {
	opacity: 1;
}

/* EU AI Act Art. 50(1) transparency notice — small, muted, always visible
   (never hidden/collapsed), directly under the header and above the message
   list so it is seen before the first message is sent. */
.roark-assistant__disclosure {
	margin: 0;
	padding: 6px 14px;
	font-size: 11px;
	line-height: 1.4;
	color: #6b7280;
	background: #f1f2f4;
	border-bottom: 1px solid #e5e7eb;
}

.roark-assistant__messages {
	flex: 1;
	overflow-y: auto;
	padding: 12px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	background: #f7f8fa;
}

.roark-assistant__msg {
	max-width: 88%;
	padding: 8px 11px;
	border-radius: 13px;
	font-size: 13px;
	line-height: 1.45;
	word-wrap: break-word;
}

.roark-assistant__msg--user {
	align-self: flex-end;
	background: var(--roark-assistant-accent);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.roark-assistant__msg--assistant {
	align-self: flex-start;
	background: #fff;
	color: #1a2332;
	border: 1px solid #e5e7eb;
	border-bottom-left-radius: 4px;
}

.roark-assistant__msg a {
	color: var(--roark-assistant-accent);
	text-decoration: underline;
}

.roark-assistant__msg--user a {
	color: #fff;
}

.roark-assistant__msg p {
	margin: 0 0 6px;
}

.roark-assistant__msg p:last-child {
	margin-bottom: 0;
}

.roark-assistant__msg ul,
.roark-assistant__msg ol {
	margin: 4px 0;
	padding-left: 18px;
}

.roark-assistant__msg li {
	margin: 2px 0;
}

.roark-assistant__note {
	align-self: center;
	font-size: 12px;
	color: #15803d;
	background: #f0fdf4;
	border: 1px solid #bbf7d0;
	padding: 6px 12px;
	border-radius: 10px;
}

.roark-assistant__typing span {
	display: inline-block;
	width: 7px;
	height: 7px;
	margin: 0 2px;
	border-radius: 50%;
	background: #9ca3af;
	animation: roark-assistant-blink 1.2s infinite both;
}

.roark-assistant__typing span:nth-child(2) {
	animation-delay: 0.2s;
}

.roark-assistant__typing span:nth-child(3) {
	animation-delay: 0.4s;
}

@keyframes roark-assistant-blink {
	0%, 80%, 100% {
		opacity: 0.3;
	}
	40% {
		opacity: 1;
	}
}

.roark-assistant__form {
	display: flex;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid #e5e7eb;
	background: #fff;
}

.roark-assistant__input {
	flex: 1;
	min-width: 0;
	border: 1px solid #d1d5db;
	border-radius: 10px;
	padding: 8px 10px;
	font-size: 13px;
	font-family: inherit;
	line-height: 1.35;
	outline: none;
	resize: none;
	max-height: 110px;
	overflow-y: auto;
}

.roark-assistant__input:focus {
	border-color: var(--roark-assistant-accent);
}

.roark-assistant__send {
	border: none;
	background: var(--roark-assistant-accent);
	color: #fff;
	border-radius: 10px;
	padding: 0 16px;
	font-size: 14px;
	cursor: pointer;
}

.roark-assistant__send:disabled,
.roark-assistant__input:disabled {
	opacity: 0.6;
}

.roark-assistant__confirm {
	align-self: flex-start;
	max-width: 90%;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 14px;
	padding: 12px;
	font-size: 13px;
}

.roark-assistant__confirm-body {
	margin-bottom: 10px;
	line-height: 1.5;
}

.roark-assistant__confirm-consent {
	display: flex;
	align-items: flex-start;
	gap: 6px;
	margin-bottom: 10px;
	font-size: 12px;
	line-height: 1.4;
	color: #374151;
	cursor: pointer;
}

.roark-assistant__confirm-consent input {
	margin-top: 2px;
	flex: 0 0 auto;
}

.roark-assistant__confirm-captcha {
	margin-bottom: 10px;
}

.roark-assistant__confirm-actions {
	display: flex;
	gap: 8px;
}

.roark-assistant__confirm-send {
	border: none;
	background: var(--roark-assistant-accent);
	color: #fff;
	border-radius: 8px;
	padding: 7px 12px;
	cursor: pointer;
	font-size: 13px;
}

.roark-assistant__confirm-cancel {
	border: 1px solid #d1d5db;
	background: #fff;
	color: #374151;
	border-radius: 8px;
	padding: 7px 12px;
	cursor: pointer;
	font-size: 13px;
}

.roark-assistant__confirm-send:disabled,
.roark-assistant__confirm-cancel:disabled {
	opacity: 0.6;
}

@media (max-width: 480px) {
	.roark-assistant__panel {
		width: calc(100vw - 24px);
	}
}
