/* Sonidekor AI Chat Widget */

:root {
	--snai-accent: #1e293b;
	--snai-accent-light: #334155;
	--snai-white: #ffffff;
	--snai-bg: #F8F7F0;
	--snai-border: #e2e8f0;
	--snai-text: #1e293b;
	--snai-text-muted: #64748b;
	--snai-user-bg: #e8edf2;
	--snai-user-text: #1e293b;
	--snai-bot-bg: #ffffff;
	--snai-bot-text: var(--snai-text);
	--snai-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
	--snai-radius: 16px;
	--snai-z: 99999;
}

/* ── ROOT ─────────────────────────────────────────────────────────── */

#snai-root {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: var(--snai-z);
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	box-sizing: border-box;
}

#snai-root *,
#snai-root *::before,
#snai-root *::after {
	box-sizing: border-box;
}

/* ── OVERLAY ──────────────────────────────────────────────────────── */

#snai-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: #fff;
	z-index: 1;
}

/* ── LAUNCHER BUTTON ──────────────────────────────────────────────── */

#snai-launcher {
	position: relative;
	height: 52px;
	padding: 0 18px 0 14px;
	border-radius: 26px;
	background: var(--snai-accent);
	color: #fff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 9px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	margin-left: auto;
	white-space: nowrap;
}

#snai-launcher:hover {
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
	filter: brightness(1.1);
}

#snai-launcher svg {
	width: 24px;
	height: 24px;
	display: block;
}

.snai-icon-close {
	font-size: 20px;
	display: none;
	line-height: 1;
}

.snai-icon-open {
	display: flex;
}

.snai-launcher-label {
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.2px;
}

#snai-launcher.snai-active .snai-icon-open {
	display: none;
}

#snai-launcher.snai-active .snai-icon-close {
	display: block;
}

#snai-launcher.snai-active .snai-launcher-label {
	display: none;
}

/* ── CHAT WINDOW ──────────────────────────────────────────────────── */

#snai-window {
	position: absolute;
	bottom: 68px;
	right: 0;
	width: 432px;
	z-index: 2;
	max-height: 624px;
	background: var(--snai-white);
	border-radius: var(--snai-radius);
	box-shadow: var(--snai-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(12px) scale(0.97);
	pointer-events: none;
	transition: opacity 0.22s ease, transform 0.22s ease, width 0.2s ease, max-height 0.2s ease;
}

#snai-window.snai-open {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

#snai-window.snai-expanded {
	width: 540px;
	max-height: 760px;
}

/* ── HEADER ───────────────────────────────────────────────────────── */

#snai-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	background: var(--snai-accent);
	color: #fff;
	flex-shrink: 0;
}

.snai-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.2);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.5px;
	flex-shrink: 0;
}

.snai-header-info {
	flex: 1;
	min-width: 0;
}

.snai-bot-name {
	font-size: 14px;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.snai-status {
	font-size: 11px;
	opacity: 0.8;
	display: flex;
	align-items: center;
	gap: 4px;
}

.snai-status::before {
	content: '';
	display: inline-block;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #4ade80;
	flex-shrink: 0;
}

#snai-expand,
#snai-close {
	background: none;
	border: none;
	color: rgba(255, 255, 255, 0.7);
	cursor: pointer;
	line-height: 1;
	padding: 4px;
	border-radius: 4px;
	transition: color 0.15s;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

#snai-expand {
	font-size: 0;
}

#snai-expand svg {
	width: 16px;
	height: 16px;
	display: block;
}

#snai-close {
	font-size: 18px;
}

#snai-expand:hover,
#snai-close:hover {
	color: #fff;
}

/* ── MESSAGES ─────────────────────────────────────────────────────── */

#snai-messages {
	flex: 1;
	overflow-y: scroll;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--snai-bg);
	scroll-behavior: smooth;
}

#snai-messages::-webkit-scrollbar {
	width: 4px;
}

#snai-messages::-webkit-scrollbar-track {
	background: transparent;
}

#snai-messages::-webkit-scrollbar-thumb {
	background: var(--snai-border);
	border-radius: 2px;
}

.snai-message {
	max-width: 78%;
	min-width: 0;
}


.snai-message.snai-user {
	align-self: flex-end;
}

.snai-message.snai-bot {
	align-self: flex-start;
}

/* Greeting sits at the bottom above quick replies, disappears on first user message */
.snai-message.snai-greeting {
	margin-top: auto;
}

.snai-bubble {
	display: block;
	padding: 10px 14px;
	border-radius: 12px;
	font-size: 14px;
	line-height: 1.55;
	word-break: break-word;
	overflow-wrap: break-word;
	white-space: normal;
}

.snai-user .snai-bubble {
	background: var(--snai-user-bg);
	color: var(--snai-user-text);
	border-bottom-right-radius: 0;
}

.snai-bot .snai-bubble {
	background: var(--snai-bot-bg);
	color: var(--snai-bot-text);
	border-bottom-left-radius: 0;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.snai-error .snai-bubble {
	background: #fef2f2;
	color: #991b1b;
}

/* ── QUICK REPLIES ────────────────────────────────────────────────── */

.snai-quick-replies {
	display: flex;
	flex-direction: column;
	gap: 8px;
	align-self: flex-end;
	align-items: flex-end;
	max-width: 100%;
	padding-bottom: 4px;
}

.snai-quick-btn,
.snai-quick-btn:hover,
.snai-quick-btn:focus,
.snai-quick-btn:active {
	border: none;
}

.snai-quick-btn {
	background: var(--snai-user-bg);
	border-radius: 24px;
	padding: 13px 18px;
	font-size: 14px;
	font-family: inherit;
	color: var(--snai-accent);
	cursor: pointer;
	outline: none;
	line-height: 1.3;
	text-align: left;
}

.snai-quick-btn:hover,
.snai-quick-btn:focus {
	background: var(--snai-bg);
	border-color: var(--snai-accent-light);
}

/* ── TYPING INDICATOR ─────────────────────────────────────────────── */

.snai-typing {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 12px 16px;
	min-width: 48px;
}

.snai-typing span {
	display: block;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--snai-text-muted);
	animation: snai-bounce 1.2s ease-in-out infinite;
}

.snai-typing span:nth-child(2) { animation-delay: 0.2s; }
.snai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes snai-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
	30%            { transform: translateY(-5px); opacity: 1; }
}

/* ── INPUT AREA ───────────────────────────────────────────────────── */

#snai-input-area {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 14px;
	border-top: 1px solid var(--snai-border);
	background: var(--snai-white);
	flex-shrink: 0;
}

#snai-chat-field {
	flex: 1;
	border: 1px solid var(--snai-border);
	border-radius: 24px;
	padding: 9px 16px;
	margin: 0;
	font-size: 14px;
	font-family: inherit;
	color: var(--snai-text);
	background: var(--snai-bg);
	outline: none;
	transition: border-color 0.15s;
	min-width: 0;
	-webkit-appearance: none;
	appearance: none;
}

#snai-chat-field:focus {
	border-color: var(--snai-accent);
}

#snai-chat-field:disabled {
	opacity: 0.6;
}

#snai-send {
	width: 38px;
	height: 38px;
	min-width: 38px;
	min-height: 38px;
	border-radius: 50%;
	background: var(--snai-accent);
	color: #fff;
	border: none;
	padding: 0;
	margin: 0;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: opacity 0.15s, transform 0.15s;
}

#snai-send:hover:not(:disabled) {
	opacity: 0.82;
}

#snai-send:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

#snai-send svg {
	width: 16px;
	height: 16px;
	display: block;
}

/* ── FOOTER ───────────────────────────────────────────────────────── */

#snai-footer {
	padding: 6px 14px 8px;
	text-align: center;
	font-size: 11px;
	color: var(--snai-text-muted);
	border-top: 1px solid var(--snai-border);
	background: var(--snai-white);
	flex-shrink: 0;
}

#snai-footer a {
	color: var(--snai-text-muted);
	text-decoration: underline;
}

#snai-footer a:hover {
	color: var(--snai-accent);
}

/* ── MOBILE ───────────────────────────────────────────────────────── */

@media (max-width: 560px) {
	#snai-root {
		bottom: 16px;
		right: 16px;
	}

	/* Hide launcher button when chat is open — prevents overlap with input area */
	#snai-root.snai-chat-open #snai-launcher {
		display: none;
	}

	/* Hide maximize button — full-width is automatic on mobile */
	#snai-expand {
		display: none;
	}

	#snai-window,
	#snai-window.snai-expanded {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		width: 100%;
		height: 100svh;
		max-height: 100svh;
		border-radius: 0;
	}

	/* 16px prevents iOS auto-zoom on input focus */
	#snai-chat-field {
		font-size: 16px;
		line-height: 1.2;
		padding: 6px 14px;
	}

	#snai-close {
		font-size: 26px;
		padding: 8px;
	}

	#snai-input-area {
		padding: 7px 10px;
	}

	/* Overlay covers the page behind the chat window — mobile only */
	#snai-root.snai-chat-open #snai-overlay {
		display: block;
	}
}
