/**
 * AI Chatbot widget — House of Maple & Lily Lifestyle.
 * Uses theme CSS variables defined in style.css.
 */

.hml-chatbot {
	position: fixed;
	right: 22px;
	bottom: 22px;
	z-index: 9999;
	font-family: var(--hml-font-body, system-ui, sans-serif);
}

/* Floating toggle button */
.hml-chatbot__toggle {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	background: var(--hml-accent, #e8542a);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 12px 30px -8px rgba(28, 20, 16, 0.5);
	transition: transform 0.2s ease, background 0.2s ease;
}
.hml-chatbot__toggle:hover { transform: translateY(-2px) scale(1.04); }
.hml-chatbot__toggle:focus-visible { outline: 3px solid rgba(232, 84, 42, 0.4); outline-offset: 2px; }
.hml-chatbot__icon-close { display: none; }
.hml-chatbot.is-open .hml-chatbot__icon-chat { display: none; }
.hml-chatbot.is-open .hml-chatbot__icon-close { display: block; }

/* Panel */
.hml-chatbot__panel {
	position: absolute;
	right: 0;
	bottom: 74px;
	width: 370px;
	max-width: calc(100vw - 32px);
	height: 540px;
	max-height: calc(100vh - 120px);
	background: #fff;
	border: 1px solid var(--hml-border, #e7ddd1);
	border-radius: 18px;
	box-shadow: 0 24px 60px rgba(28, 20, 16, 0.22);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: hml-bot-in 0.22s ease;
}
/* Keep the close/hide working: the rule above sets display:flex, which would
   otherwise override the browser's default [hidden] styling. */
.hml-chatbot__panel[hidden] {
	display: none !important;
}
@keyframes hml-bot-in {
	from { opacity: 0; transform: translateY(12px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* Header */
.hml-chatbot__header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	background: var(--hml-accent, #e8542a);
	color: #fff;
}
.hml-chatbot__avatar {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.2);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
}
.hml-chatbot__title { font-weight: 700; font-size: 1rem; flex: 1; }
.hml-chatbot__close {
	background: none;
	border: none;
	color: #fff;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	opacity: 0.9;
	padding: 0 4px;
}
.hml-chatbot__close:hover { opacity: 1; }

/* Message log */
.hml-chatbot__log {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	background: var(--hml-cream, #faf6f1);
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.hml-chatbot__msg { display: flex; }
.hml-chatbot__msg--user { justify-content: flex-end; }
.hml-chatbot__bubble {
	max-width: 82%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 0.92rem;
	line-height: 1.5;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}
.hml-chatbot__msg--assistant .hml-chatbot__bubble {
	background: #fff;
	border: 1px solid var(--hml-border, #e7ddd1);
	color: var(--hml-ink, #1c1410);
	border-bottom-left-radius: 4px;
}
.hml-chatbot__msg--user .hml-chatbot__bubble {
	background: var(--hml-accent, #e8542a);
	color: #fff;
	border-bottom-right-radius: 4px;
}
.hml-chatbot__msg.is-error .hml-chatbot__bubble {
	background: #fdecea;
	border-color: #f5c2c0;
	color: #8a1f1a;
}
.hml-chatbot__bubble a { color: inherit; text-decoration: underline; }
.hml-chatbot__msg--assistant .hml-chatbot__bubble a { color: var(--hml-accent, #e8542a); }

/* Channels mode (Messenger / WhatsApp) */
.hml-chatbot__channels {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 6px 2px;
}
.hml-chatbot__ch-intro {
	margin: 0 0 4px;
	color: var(--hml-muted, #6c6258);
	font-size: 0.92rem;
	line-height: 1.5;
}
.hml-chatbot__ch {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 16px;
	border-radius: 12px;
	font-weight: 700;
	font-size: 0.95rem;
	color: #fff;
	text-decoration: none;
	transition: filter 0.15s ease, transform 0.15s ease;
}
.hml-chatbot__ch:hover { filter: brightness(1.06); transform: translateY(-1px); }
.hml-chatbot__ch svg { flex: 0 0 auto; }
.hml-chatbot__ch--whatsapp { background: #25d366; }
.hml-chatbot__ch--messenger {
	background: #0084ff;
	background: linear-gradient(135deg, #00b2ff, #006aff);
}

/* Quick-reply chips (Free FAQ bot) */
.hml-chatbot__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 2px;
}
.hml-chatbot__chip {
	background: #fff;
	border: 1px solid var(--hml-accent, #e8542a);
	color: var(--hml-accent, #e8542a);
	border-radius: 999px;
	padding: 7px 14px;
	font-size: 0.85rem;
	line-height: 1.3;
	cursor: pointer;
	text-align: left;
	transition: background 0.15s ease, color 0.15s ease;
}
.hml-chatbot__chip:hover {
	background: var(--hml-accent, #e8542a);
	color: #fff;
}

/* Typing indicator */
.hml-chatbot__typing { display: inline-flex; gap: 4px; align-items: center; }
.hml-chatbot__typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--hml-muted, #6c6258);
	opacity: 0.5;
	animation: hml-bot-blink 1.2s infinite ease-in-out;
}
.hml-chatbot__typing span:nth-child(2) { animation-delay: 0.2s; }
.hml-chatbot__typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes hml-bot-blink {
	0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
	40% { opacity: 1; transform: translateY(-3px); }
}

/* Input */
.hml-chatbot__form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid var(--hml-border, #e7ddd1);
	background: #fff;
}
.hml-chatbot__input {
	flex: 1;
	resize: none;
	border: 1px solid var(--hml-border, #e7ddd1);
	border-radius: 12px;
	padding: 10px 12px;
	font: inherit;
	font-size: 0.92rem;
	line-height: 1.4;
	max-height: 120px;
	color: var(--hml-ink, #1c1410);
}
.hml-chatbot__input:focus { outline: none; border-color: var(--hml-accent, #e8542a); }
.hml-chatbot__send {
	flex: 0 0 auto;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	background: var(--hml-accent, #e8542a);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s ease;
}
.hml-chatbot__send:hover { background: var(--hml-accent-dark, #c8431d); }
.hml-chatbot__send:focus-visible { outline: 3px solid rgba(232, 84, 42, 0.4); outline-offset: 2px; }

/* Phones */
@media (max-width: 480px) {
	.hml-chatbot { right: 14px; bottom: 14px; }
	.hml-chatbot__panel {
		width: calc(100vw - 24px);
		height: calc(100vh - 96px);
		bottom: 70px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.hml-chatbot__panel,
	.hml-chatbot__typing span { animation: none; }
	.hml-chatbot__toggle { transition: none; }
}
