/**
 * AI Chatbot widget styles. Enqueued only when Settings → Prime Mortgage →
 * Chatbot → Enabled is checked (see Pmae_Chatbot::maybe_enqueue_assets()).
 *
 * @package Prime_Mortgage_Astra_Extensions
 */

.pmae-chatbot {
	position: fixed;
	z-index: 9500;
	right: 24px;
	bottom: 24px;
}

body.pmae-floating-buttons-right .pmae-chatbot {
	right: 92px;
}

/* -------------------------------------------------- */
/* Launcher                                            */
/* -------------------------------------------------- */
.pmae-chatbot__launcher {
	position: relative;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	border: none;
	background: var(--pmae-chatbot-color, var(--pmae-primary));
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
	transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.pmae-chatbot__launcher:hover {
	transform: translateY(-2px);
	box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.pmae-chatbot__launcher-icon-open,
.pmae-chatbot__launcher-icon-close {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%) scale(1) rotate(0deg);
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.pmae-chatbot__launcher-icon-close {
	opacity: 0;
	transform: translate(-50%, -50%) scale(0.4) rotate(-45deg);
}

.pmae-chatbot.pmae-is-open .pmae-chatbot__launcher-icon-open {
	opacity: 0;
	transform: translate(-50%, -50%) scale(0.4) rotate(45deg);
}

.pmae-chatbot.pmae-is-open .pmae-chatbot__launcher-icon-close {
	opacity: 1;
	transform: translate(-50%, -50%) scale(1) rotate(0deg);
}

/* -------------------------------------------------- */
/* Panel: open/close animation                         */
/* -------------------------------------------------- */
.pmae-chatbot__panel {
	position: absolute;
	right: 0;
	bottom: 72px;
	width: 340px;
	max-width: calc(100vw - 48px);
	max-height: min(70vh, 520px);
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 20px 50px rgba(0, 0, 0, 0.24);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translateY(12px) scale(0.96);
	transform-origin: bottom right;
	transition: opacity 0.2s ease, transform 0.22s cubic-bezier(0.2, 0.8, 0.3, 1), visibility 0.2s ease;
}

.pmae-chatbot.pmae-is-open .pmae-chatbot__panel {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: translateY(0) scale(1);
}

@media (prefers-reduced-motion: reduce) {
	.pmae-chatbot__panel,
	.pmae-chatbot__launcher-icon-open,
	.pmae-chatbot__launcher-icon-close {
		transition: none;
	}
}

/* -------------------------------------------------- */
/* Header                                              */
/* -------------------------------------------------- */
.pmae-chatbot__header {
	background: var(--pmae-chatbot-color, var(--pmae-primary));
	color: #fff;
	padding: 12px 14px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.pmae-chatbot__header-brand {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 0.92rem;
	min-width: 0;
}

.pmae-chatbot__header-brand span {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.pmae-chatbot__avatar {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
	background: rgba(255, 255, 255, 0.2);
}

.pmae-chatbot__avatar--placeholder {
	display: inline-block;
	position: relative;
}

.pmae-chatbot__avatar--placeholder::before {
	content: '';
	position: absolute;
	inset: 0;
	margin: auto;
	width: 14px;
	height: 14px;
	background: rgba(255, 255, 255, 0.85);
	border-radius: 50%;
}

.pmae-chatbot__minimize {
	background: rgba(255, 255, 255, 0.12);
	border: none;
	color: #fff;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	font-size: 1.1rem;
	line-height: 1;
	cursor: pointer;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease;
}

.pmae-chatbot__minimize:hover {
	background: rgba(255, 255, 255, 0.22);
}

/* -------------------------------------------------- */
/* Messages + bubbles                                  */
/* -------------------------------------------------- */
.pmae-chatbot__messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.pmae-chatbot__row {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	max-width: 100%;
}

.pmae-chatbot__row--user {
	justify-content: flex-end;
}

.pmae-chatbot__bubble-avatar {
	width: 22px;
	height: 22px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
}

.pmae-chatbot__bubble {
	max-width: 78%;
	padding: 9px 13px;
	border-radius: 14px;
	font-size: 0.88rem;
	line-height: 1.45;
	word-wrap: break-word;
}

.pmae-chatbot__bubble--bot {
	background: #f1f4f9;
	color: #1a202c;
	border-bottom-left-radius: 4px;
}

.pmae-chatbot__bubble--user {
	background: var(--pmae-chatbot-color, var(--pmae-primary));
	color: #fff;
	border-bottom-right-radius: 4px;
}

/* -------------------------------------------------- */
/* Typing indicator                                    */
/* -------------------------------------------------- */
.pmae-chatbot__typing {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 12px 14px;
}

.pmae-chatbot__typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: rgba(26, 32, 44, 0.4);
	animation: pmae-chatbot-typing 1.1s infinite ease-in-out;
}

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

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

@media (prefers-reduced-motion: reduce) {
	.pmae-chatbot__typing span {
		animation: none;
	}
}

/* -------------------------------------------------- */
/* Suggested questions                                 */
/* -------------------------------------------------- */
.pmae-chatbot__suggested {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 4px;
	margin-left: 30px;
}

.pmae-chatbot__suggested button {
	font-size: 0.78rem;
	border: 1px solid rgba(10, 37, 64, 0.18);
	background: #fff;
	border-radius: 999px;
	padding: 5px 10px;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.pmae-chatbot__suggested button:hover {
	background: rgba(11, 95, 255, 0.06);
	border-color: var(--pmae-chatbot-color, var(--pmae-primary));
}

/* -------------------------------------------------- */
/* Composer                                            */
/* -------------------------------------------------- */
.pmae-chatbot__composer {
	display: flex;
	border-top: 1px solid rgba(10, 37, 64, 0.08);
	padding: 10px;
	gap: 8px;
	flex-shrink: 0;
}

.pmae-chatbot__composer input {
	flex: 1;
	min-width: 0;
	border: 1px solid rgba(10, 37, 64, 0.18);
	border-radius: 8px;
	padding: 8px 10px;
	font-size: 0.9rem;
}

.pmae-chatbot__composer input:focus {
	outline: none;
	border-color: var(--pmae-chatbot-color, var(--pmae-primary));
	box-shadow: 0 0 0 3px rgba(11, 95, 255, 0.12);
}

.pmae-chatbot__composer button {
	background: var(--pmae-chatbot-color, var(--pmae-primary));
	color: #fff;
	border: none;
	border-radius: 8px;
	padding: 0 14px;
	cursor: pointer;
	font-weight: 600;
	flex-shrink: 0;
	transition: opacity 0.15s ease;
}

.pmae-chatbot__composer button:hover {
	opacity: 0.9;
}

/* -------------------------------------------------- */
/* Fallback contact form                               */
/* -------------------------------------------------- */
.pmae-chatbot__fallback {
	padding: 12px 16px;
	border-top: 1px solid rgba(10, 37, 64, 0.08);
	max-height: 260px;
	overflow-y: auto;
	flex-shrink: 0;
}

.pmae-chatbot__fallback .pmae-apply-now {
	border: none;
	padding: 0;
	box-shadow: none;
}

.pmae-apply-now--compact .pmae-apply-now__secondary-field {
	display: none;
}

/* -------------------------------------------------- */
/* Responsive                                          */
/* -------------------------------------------------- */
@media (max-width: 480px) {
	.pmae-chatbot {
		right: 16px;
		bottom: 16px;
	}

	body.pmae-floating-buttons-right .pmae-chatbot {
		right: 16px;
		bottom: 84px;
	}

	.pmae-chatbot__panel {
		width: calc(100vw - 32px);
		max-height: min(75vh, 480px);
		bottom: 68px;
	}

	.pmae-chatbot__launcher {
		width: 50px;
		height: 50px;
	}
}
