/*
 * Real Estate AI Chat — widget styles
 *
 * Palette rationale: the host site's existing brand color is a deep
 * UAE-luxury maroon (#b71f37). That is kept as the primary accent so the
 * widget matches the site it's embedded on. A warm brass/gold is layered
 * in as the secondary accent -- a natural pairing for luxury UAE real
 * estate branding -- and used sparingly for the agent "spark" mark, the
 * AI badge, and focus states, so it reads as a considered choice rather
 * than decoration.
 */

.reaic-chat {
	/* Neutrals */
	--reaic-ink: #1b1512;
	--reaic-muted: #8a7d76;
	--reaic-border: #e9e2dd;
	--reaic-surface: #ffffff;
	--reaic-paper: #fbf8f6;

	/* Brand */
	--reaic-brand: #b71f37;
	--reaic-brand-ink: #7a1120;
	--reaic-brand-soft: rgba(183, 31, 55, .08);
	--reaic-gold: #b9975b;
	--reaic-gold-soft: rgba(185, 151, 91, .16);

	/* Legacy aliases kept for backward compatibility with any custom CSS
	   a site owner may have layered on top of this widget. */
	--border: var(--reaic-border);
	--muted: var(--reaic-muted);
	--primary: var(--reaic-ink);
	--soft: var(--reaic-paper);

	display: flex;
	flex-direction: column;
	height: var(--reaic-height, 620px);
	max-width: 920px;
	margin: auto;
	border: 1px solid var(--reaic-border);
	border-radius: 20px;
	background: var(--reaic-surface);
	box-shadow: 0 24px 60px rgba(27, 21, 18, .10);
	overflow: hidden;
	font-family: inherit;
	color: var(--reaic-ink);
}

.reaic-chat,
.reaic-chat * {
	box-sizing: border-box;
}

/* Dark theme — activated via [theme="dark"] on the shortcode. */
.reaic-chat.reaic-theme-dark {
	--reaic-ink: #f4efec;
	--reaic-muted: #b4a8a1;
	--reaic-border: #3a2f2c;
	--reaic-surface: #201a18;
	--reaic-paper: #17130f;
	--reaic-brand: #e3546a;
	--reaic-brand-ink: #ff8296;
	--reaic-brand-soft: rgba(227, 84, 106, .14);
	--reaic-gold: #d4b47c;
	--reaic-gold-soft: rgba(212, 180, 124, .18);

	box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}

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

.reaic-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 20px;
	border-bottom: 1px solid var(--reaic-border);
	background: var(--reaic-surface);
	flex-shrink: 0;
}

.reaic-header-avatar {
	position: relative;
	width: 38px;
	height: 38px;
	flex-shrink: 0;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, var(--reaic-brand), var(--reaic-brand-ink));
	box-shadow: 0 0 0 3px var(--reaic-gold-soft);
}

.reaic-header-avatar svg {
	width: 18px;
	height: 18px;
	color: #fff;
}

.reaic-status-dot {
	position: absolute;
	right: -1px;
	bottom: -1px;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: #22c55e;
	border: 2px solid var(--reaic-surface);
}

.reaic-status-dot.is-busy {
	background: var(--reaic-gold);
	animation: reaicStatusPulse 1.1s ease-in-out infinite;
}

@keyframes reaicStatusPulse {
	0%, 100% { opacity: 1; transform: scale(1); }
	50% { opacity: .55; transform: scale(.85); }
}

.reaic-header-info {
	display: flex;
	flex-direction: column;
	min-width: 0;
	gap: 2px;
}

.reaic-header-title-row {
	display: flex;
	align-items: center;
	gap: 8px;
}

.reaic-header-title-row strong {
	font-size: 15px;
	font-weight: 700;
	letter-spacing: -0.01em;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.reaic-agent-badge {
	flex-shrink: 0;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	padding: 3px 7px;
	border-radius: 999px;
	color: var(--reaic-brand-ink);
	background: var(--reaic-gold-soft);
	border: 1px solid rgba(185, 151, 91, .35);
}

.reaic-theme-dark .reaic-agent-badge {
	color: var(--reaic-gold);
}

.reaic-header small {
	color: var(--reaic-muted);
	font-size: 12.5px;
	display: flex;
	align-items: center;
	gap: 5px;
}

.reaic-header-status-text {
	transition: opacity .15s ease;
}

/* ---------- Message list ---------- */

.reaic-messages {
	flex: 1;
	overflow: auto;
	padding: 20px;
	background: var(--reaic-paper);
	min-width: 0;
	scroll-behavior: smooth;
}

.reaic-message {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	width: 100%;
	margin: 0 0 16px;
	animation: reaicMessageIn .28s cubic-bezier(.2, .7, .3, 1) both;
}

@keyframes reaicMessageIn {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: translateY(0); }
}

.reaic-user {
	justify-content: flex-end;
}

.reaic-assistant {
	justify-content: flex-start;
}

.reaic-msg-avatar {
	flex-shrink: 0;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, var(--reaic-brand), var(--reaic-brand-ink));
	margin-bottom: 2px;
}

.reaic-msg-avatar svg {
	width: 13px;
	height: 13px;
	color: #fff;
}

.reaic-bubble {
	max-width: min(720px, 82%);
	padding: 13px 16px;
	border-radius: 16px;
	line-height: 1.6;
	font-size: 14.5px;
	overflow-wrap: anywhere;
	word-break: normal;
	min-width: 0;
}

/* User message */
.reaic-user .reaic-bubble {
	background: var(--reaic-ink);
	color: var(--reaic-surface);
	border-bottom-right-radius: 4px;
}

.reaic-theme-dark .reaic-user .reaic-bubble {
	background: #3a2f2c;
	color: var(--reaic-ink);
}

/* AI reply */
.reaic-assistant .reaic-bubble {
	background: linear-gradient(165deg, var(--reaic-brand) 0%, var(--reaic-brand-ink) 130%);
	color: #ffffff;
	border-bottom-left-radius: 4px;
	box-shadow: 0 6px 18px var(--reaic-brand-soft);
}

/* ---------- Thinking / typing indicator ---------- */

.reaic-thinking {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	color: #ffffff;
}

.reaic-thinking-dots {
	display: inline-flex;
	gap: 4px;
}

.reaic-thinking-dots span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .9);
	animation: reaicDotBounce 1.1s ease-in-out infinite;
}

.reaic-thinking-dots span:nth-child(2) { animation-delay: .15s; }
.reaic-thinking-dots span:nth-child(3) { animation-delay: .3s; }

@keyframes reaicDotBounce {
	0%, 60%, 100% { transform: translateY(0); opacity: .55; }
	30% { transform: translateY(-4px); opacity: 1; }
}

.reaic-thinking-label {
	font-size: 13.5px;
	opacity: .95;
}

/* ---------- Suggestions ---------- */

.reaic-suggestions {
	/* display: flex;
	gap: 8px; */
	overflow: auto;
	padding: 12px 18px;
	flex-shrink: 0;
	background: var(--reaic-surface);
	border-top: 1px solid var(--reaic-border);
	scrollbar-width: none;
}

.reaic-suggestions::-webkit-scrollbar {
	display: none;
}

.reaic-suggestions button {
	white-space: nowrap;
	border: 1px solid var(--reaic-border);
	background: var(--reaic-surface);
	color: var(--reaic-ink);
	border-radius: 999px;
	padding: 9px 14px;
	font-size: 13px;
	margin-bottom: 10px;
	font: inherit;
	cursor: pointer;
	transition: border-color .15s ease, transform .15s ease, background .15s ease;
}

.reaic-suggestions button:hover,
.reaic-suggestions button:focus-visible {
	border-color: var(--reaic-brand);
	background: var(--reaic-brand-soft);
	transform: translateY(-1px);
}

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

.reaic-form {
	display: flex;
	align-items: flex-end;
	gap: 10px;
	padding: 14px 18px;
	border-top: 1px solid var(--reaic-border);
	background: var(--reaic-surface);
	flex-shrink: 0;
}

.reaic-form textarea {
	flex: 1;
	min-width: 0;
	resize: none;
	min-height: 46px;
	max-height: 140px;
	border: 1px solid var(--reaic-border);
	border-radius: 14px;
	padding: 12px 14px;
	font: inherit;
	font-size: 14.5px;
	color: var(--reaic-ink);
	background: var(--reaic-paper);
	outline: none;
	transition: border-color .15s ease, box-shadow .15s ease;
}

.reaic-form textarea::placeholder {
	color: var(--reaic-muted);
}

.reaic-form textarea:focus {
	border-color: var(--reaic-gold);
	box-shadow: 0 0 0 3px var(--reaic-gold-soft);
	background: var(--reaic-surface);
}

section.reaic-chat{
    height: 90vh;
}

.reaic-form button {
	width: 46px;
	height: 46px;
	flex-shrink: 0;
	border: 0;
	border-radius: 14px;
	background: linear-gradient(135deg, var(--reaic-brand), var(--reaic-brand-ink));
	color: #fff;
	font-size: 17px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .12s ease, opacity .12s ease;
}

.reaic-form button svg {
	width: 18px;
	height: 18px;
}

.reaic-form button:hover:not(:disabled) {
	transform: translateY(-1px);
}

.reaic-form button:active:not(:disabled) {
	transform: translateY(0);
}

.reaic-form button:disabled {
	opacity: .5;
	cursor: default;
}

.reaic-disclaimer {
	text-align: center;
	color: var(--reaic-muted);
	font-size: 11px;
	padding: 0 12px 12px;
	flex-shrink: 0;
	background: var(--reaic-surface);
}

/* ---------- Answer text + inline links ---------- */

.reaic-answer-text {
	color: #ffffff;
	overflow-wrap: anywhere;
}

.reaic-assistant .reaic-inline-link {
	color: #ffffff !important;
	font-weight: 700;
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}

.reaic-assistant .reaic-inline-link:hover,
.reaic-assistant .reaic-inline-link:focus {
	color: #ffffff !important;
	opacity: .82;
}

/* ---------- Did-you-mean ---------- */

.reaic-did-you-mean {
	display: block;
	width: 100%;
	margin-top: 12px;
	padding: 11px 14px;
	border: 1px solid rgba(255, 255, 255, .55);
	border-radius: 12px;
	background: rgba(255, 255, 255, .14);
	color: #ffffff;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.45;
	text-align: left;
	cursor: pointer;
	transition: background .15s ease;
}

.reaic-did-you-mean:hover,
.reaic-did-you-mean:focus {
	background: rgba(255, 255, 255, .24);
}

.reaic-did-you-mean strong {
	color: #ffffff;
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* ---------- Result cards ---------- */

.reaic-results {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
	gap: 10px;
	margin-top: 14px;
	min-width: 0;
}

.reaic-card {
	display: block;
	min-width: 0;
	overflow: hidden;
	text-decoration: none !important;
	color: inherit !important;
	padding: 12px;
	background: rgba(255, 255, 255, .14);
	border: 1px solid rgba(255, 255, 255, .3);
	border-radius: 14px;
	transition: transform .15s ease, background .15s ease;
}

.reaic-card:hover,
.reaic-card:focus-visible {
	background: rgba(255, 255, 255, .22);
	transform: translateY(-2px);
}

.reaic-card.no-image {
	padding-top: 14px;
}

.reaic-card img {
	display: block;
	width: 100%;
	/* height: 108px; */
	margin-bottom: 9px;
	border-radius: 9px;
	object-fit: cover;
}

.reaic-card.no-image img {
	display: none !important;
}

.reaic-card-type {
	display: inline-block;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: .05em;
	text-transform: uppercase;
	color: #ffffff;
	background: rgba(255, 255, 255, .22);
	border-radius: 999px;
	padding: 3px 8px;
	margin-bottom: 7px;
}

.reaic-result-title {
	display: block;
	color: #ffffff !important;
	font-weight: 700;
	font-size: 13.5px;
	line-height: 1.4;
	text-decoration: underline !important;
	text-underline-offset: 3px;
	overflow-wrap: anywhere;
}

.reaic-card.no-image .reaic-result-title {
	margin-top: 0;
}

.reaic-result-title:hover,
.reaic-result-title:focus {
	color: #ffffff !important;
	opacity: .82;
}

.reaic-result-price {
	display: block;
	margin-top: 6px;
	color: #ffffff;
	font-weight: 700;
	font-size: 13px;
}

.reaic-card small {
	display: -webkit-box;
	margin-top: 5px;
	color: rgba(255, 255, 255, .85);
	overflow-wrap: anywhere;
	font-size: 12.5px;
	line-height: 1.45;
	/*
	 * Clamp to 3 lines regardless of how long the underlying excerpt
	 * is, so one long-excerpt card doesn't tower over its neighbors in
	 * the results grid. The full excerpt is still sent to the AI for
	 * grounding -- this only affects what's rendered on the card.
	 */
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
	.reaic-message,
	.reaic-status-dot.is-busy,
	.reaic-thinking-dots span,
	.reaic-card,
	.reaic-form button {
		animation: none !important;
		transition: none !important;
	}
}

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

@media (max-width: 600px) {
	.reaic-chat {
		height: 560px!important;
		border-radius: 14px;
	}

	.reaic-messages {
		padding: 15px;
	}

	.reaic-bubble {
		max-width: 88%;
	}

	.reaic-results {
		grid-template-columns: 1fr;
	}
}
