/*
 * WMT AI Salesman — Chat Widget Styles
 * BEM prefix: .wmt-ai-
 * Brand colour injected as --wmt-ai-color via wp_add_inline_style()
 */

/* ── Reset ───────────────────────────────────────────────────────────── */
.wmt-ai-chat *,
.wmt-ai-chat *::before,
.wmt-ai-chat *::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

/* ── Root container ──────────────────────────────────────────────────── */
.wmt-ai-chat {
	--wmt-ai-color: #4175fc;      /* overridden by inline style */
	--wmt-ai-color-dark: #2a5de8; /* overridden by inline style */
	--wmt-ai-radius: 16px;
	--wmt-ai-shadow: 0 8px 32px rgba(0,0,0,.18);
	--wmt-ai-panel-w: 380px;
	--wmt-ai-panel-h: 540px;
	--wmt-ai-z: 99999;

	position: fixed;
	z-index: var(--wmt-ai-z);
	bottom: 24px;
	right: 24px;
}

.wmt-ai-chat--bottom-left {
	right: auto;
	left: 24px;
}

/* ── Bubble ──────────────────────────────────────────────────────────── */
.wmt-ai-bubble {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	border: none;
	background: var(--wmt-ai-color);
	color: #fff;
	cursor: pointer;
	box-shadow: var(--wmt-ai-shadow);
	transition: background 0.2s, transform 0.2s;
	position: relative;
	outline: none;
}

.wmt-ai-bubble:hover,
.wmt-ai-bubble:focus-visible {
	background: var(--wmt-ai-color-dark);
	transform: scale(1.07);
}

.wmt-ai-bubble:active {
	transform: scale(0.96);
}

/* Icons */
.wmt-ai-bubble__icon {
	width: 26px;
	height: 26px;
	position: absolute;
	transition: opacity 0.2s, transform 0.2s;
}

.wmt-ai-bubble__icon--chat {
	opacity: 1;
	transform: scale(1);
}

.wmt-ai-bubble__icon--close {
	opacity: 0;
	transform: scale(0.6) rotate(-45deg);
}

/* Open state icon swap */
.wmt-ai-chat--open .wmt-ai-bubble__icon--chat {
	opacity: 0;
	transform: scale(0.6) rotate(45deg);
}

.wmt-ai-chat--open .wmt-ai-bubble__icon--close {
	opacity: 1;
	transform: scale(1) rotate(0deg);
}

/* Unread dot */
.wmt-ai-bubble__dot {
	display: none;
	position: absolute;
	top: 4px;
	right: 4px;
	width: 12px;
	height: 12px;
	background: #ef4444;
	border-radius: 50%;
	border: 2px solid #fff;
	animation: wmt-ai-dot-pulse 2s infinite;
}

.wmt-ai-bubble__dot--visible {
	display: block;
}

@keyframes wmt-ai-dot-pulse {
	0%, 100% { transform: scale(1); }
	50%       { transform: scale(1.3); }
}

/* ── Panel ───────────────────────────────────────────────────────────── */
.wmt-ai-panel {
	position: absolute;
	bottom: 76px;
	right: 0;
	width: var(--wmt-ai-panel-w);
	height: var(--wmt-ai-panel-h);
	background: #fff;
	border-radius: var(--wmt-ai-radius);
	box-shadow: var(--wmt-ai-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;

	/* Hidden state */
	opacity: 0;
	pointer-events: none;
	transform: translateY(16px) scale(0.97);
	transform-origin: bottom right;
	transition: opacity 0.22s ease, transform 0.22s ease;
}

.wmt-ai-chat--bottom-left .wmt-ai-panel {
	right: auto;
	left: 0;
	transform-origin: bottom left;
}

/* Visible state */
.wmt-ai-chat--open .wmt-ai-panel {
	opacity: 1;
	pointer-events: auto;
	transform: translateY(0) scale(1);
}

/* ── Panel header ────────────────────────────────────────────────────── */
.wmt-ai-panel__header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 16px;
	background: var(--wmt-ai-color);
	color: #fff;
	flex-shrink: 0;
}

.wmt-ai-panel__avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(255,255,255,.15);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	overflow: hidden;
}

.wmt-ai-panel__avatar svg {
	width: 40px;
	height: 40px;
}

.wmt-ai-panel__header-info {
	flex: 1;
	min-width: 0;
}

.wmt-ai-panel__header-info strong {
	display: block;
	font-size: 0.95rem;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.wmt-ai-panel__status {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 0.75rem;
	opacity: 0.85;
}

.wmt-ai-panel__status-dot {
	display: inline-block;
	width: 7px;
	height: 7px;
	background: #4ade80;
	border-radius: 50%;
}

.wmt-ai-panel__close {
	background: none;
	border: none;
	color: #fff;
	cursor: pointer;
	padding: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 4px;
	transition: background 0.15s;
	flex-shrink: 0;
}

.wmt-ai-panel__close:hover,
.wmt-ai-panel__close:focus-visible {
	background: rgba(255,255,255,.2);
}

.wmt-ai-panel__close svg {
	width: 18px;
	height: 18px;
}

/* ── Messages area ───────────────────────────────────────────────────── */
.wmt-ai-panel__messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}

/* Thin scrollbar */
.wmt-ai-panel__messages::-webkit-scrollbar { width: 4px; }
.wmt-ai-panel__messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
.wmt-ai-panel__messages::-webkit-scrollbar-track { background: transparent; }

/* ── Message bubbles ─────────────────────────────────────────────────── */
.wmt-ai-msg {
	max-width: 85%;
	line-height: 1.5;
	font-size: 0.875rem;
	word-break: break-word;
	white-space: pre-wrap;
	animation: wmt-ai-fade-in 0.18s ease;
}

@keyframes wmt-ai-fade-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

.wmt-ai-msg--user {
	align-self: flex-end;
	background: var(--wmt-ai-color);
	color: #fff;
	padding: 9px 13px;
	border-radius: 16px 16px 4px 16px;
}

.wmt-ai-msg--assistant {
	align-self: flex-start;
	background: #f3f4f6;
	color: #111827;
	padding: 9px 13px;
	border-radius: 16px 16px 16px 4px;
}

/* Error state */
.wmt-ai-msg--error {
	align-self: flex-start;
	background: #fef2f2;
	color: #dc2626;
	padding: 9px 13px;
	border-radius: 8px;
	font-size: 0.8rem;
}

/* ── Typing indicator ────────────────────────────────────────────────── */
.wmt-ai-typing {
	padding: 0 14px 4px;
	flex-shrink: 0;
	display: none;
}

.wmt-ai-typing--visible {
	display: block;
}

.wmt-ai-typing__bubble {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: #f3f4f6;
	padding: 9px 13px;
	border-radius: 16px 16px 16px 4px;
}

.wmt-ai-typing__bubble span {
	display: block;
	width: 7px;
	height: 7px;
	background: #9ca3af;
	border-radius: 50%;
	animation: wmt-ai-bounce 1.2s infinite ease-in-out;
}

.wmt-ai-typing__bubble span:nth-child(2) { animation-delay: .2s; }
.wmt-ai-typing__bubble span:nth-child(3) { animation-delay: .4s; }

@keyframes wmt-ai-bounce {
	0%, 60%, 100% { transform: translateY(0); }
	30%            { transform: translateY(-5px); }
}

/* ── Input area ──────────────────────────────────────────────────────── */
.wmt-ai-panel__input-area {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid #e5e7eb;
	flex-shrink: 0;
	background: #fff;
}

.wmt-ai-panel__input {
	flex: 1;
	resize: none;
	border: 1px solid #d1d5db;
	border-radius: 10px;
	padding: 8px 12px;
	font-family: inherit;
	font-size: 0.875rem;
	line-height: 1.4;
	color: #111827;
	background: #f9fafb;
	outline: none;
	min-height: 38px;
	max-height: 120px;
	overflow-y: auto;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.wmt-ai-panel__input:focus {
	border-color: var(--wmt-ai-color);
	box-shadow: 0 0 0 3px rgba(65,117,252,.15);
	background: #fff;
}

.wmt-ai-panel__input::placeholder {
	color: #9ca3af;
}

.wmt-ai-panel__send {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: none;
	background: var(--wmt-ai-color);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
	transition: background 0.15s, transform 0.15s;
}

.wmt-ai-panel__send:hover,
.wmt-ai-panel__send:focus-visible {
	background: var(--wmt-ai-color-dark);
}

.wmt-ai-panel__send:active {
	transform: scale(0.93);
}

.wmt-ai-panel__send:disabled {
	opacity: 0.4;
	cursor: default;
	pointer-events: none;
}

.wmt-ai-panel__send svg {
	width: 17px;
	height: 17px;
}

/* ── Footer ──────────────────────────────────────────────────────────── */
.wmt-ai-panel__footer {
	padding: 5px 12px 8px;
	text-align: center;
	font-size: 0.68rem;
	color: #9ca3af;
	flex-shrink: 0;
	background: #fff;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
	.wmt-ai-chat {
		bottom: 12px;
		right: 12px;
	}

	.wmt-ai-chat--bottom-left {
		left: 12px;
	}

	.wmt-ai-panel {
		width: calc(100vw - 24px);
		height: 70vh;
		bottom: 72px;
		right: 0;
		left: 0;
		margin: 0 auto;
		position: fixed;
		transform-origin: bottom center;
	}

	.wmt-ai-chat--bottom-left .wmt-ai-panel {
		transform-origin: bottom center;
	}
}
