/* AI Chat Widget */

.spay-chat__chip {
	margin: 0;
	font-family: inherit;
	text-transform: none;
	appearance: none;
	-webkit-appearance: none;
}

.spay-chat {
	--spay-chat-accent: #6366f1;
	--spay-chat-accent-hover: #4f46e5;
	--spay-chat-accent-rgb: 99, 102, 241;
	--spay-chat-header-text: #ffffff;
	--spay-chat-bg: #ffffff;
	--spay-chat-surface: #f8fafc;
	--spay-chat-border: #e2e8f0;
	--spay-chat-text: #0f172a;
	--spay-chat-muted: #64748b;
	--spay-chat-user-bg: var(--spay-chat-accent);
	--spay-chat-bot-bg: #f1f5f9;
	--spay-chat-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
	--spay-chat-radius: 16px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
	font-size: 14px;
	line-height: 1.5;
	z-index: 999999;
	position: relative;
}

.spay-chat *,
.spay-chat *::before,
.spay-chat *::after {
	box-sizing: border-box;
}

/* Bubble */
.spay-chat__bubble {
	position: fixed;
	bottom: 24px;
	right: 24px;
	width: 60px;
	height: 60px;
	border: none;
	border-radius: 50%;
	background: var(--spay-chat-accent);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 8px 24px rgba(var(--spay-chat-accent-rgb), 0.45);
	transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
	z-index: 999999;
	pointer-events: auto;
}

.spay-chat__bubble:hover {
	background: var(--spay-chat-accent-hover);
	transform: scale(1.05);
	box-shadow: 0 12px 28px rgba(var(--spay-chat-accent-rgb), 0.5);
}

.spay-chat__bubble:focus-visible {
	outline: 3px solid var(--spay-chat-accent);
	outline-offset: 3px;
}

.spay-chat__bubble-icon,
.spay-chat__bubble-close {
	width: 26px;
	height: 26px;
	transition: opacity 0.2s, transform 0.2s;
}

.spay-chat__bubble-close {
	position: absolute;
	opacity: 0;
	transform: rotate(-90deg) scale(0.8);
}

.spay-chat--open .spay-chat__bubble-icon {
	opacity: 0;
	transform: rotate(90deg) scale(0.8);
}

.spay-chat--open .spay-chat__bubble-close {
	opacity: 1;
	transform: rotate(0) scale(1);
}

.spay-chat__badge {
	position: absolute;
	top: -2px;
	right: -2px;
	min-width: 20px;
	height: 20px;
	padding: 0 6px;
	border-radius: 10px;
	background: #ef4444;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2px solid #fff;
}

/* Panel */
.spay-chat__panel {
	position: fixed;
	bottom: 96px;
	right: 24px;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 520px;
	max-height: calc(100vh - 120px);
	background: var(--spay-chat-bg);
	border-radius: var(--spay-chat-radius);
	box-shadow: var(--spay-chat-shadow);
	display: none;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--spay-chat-border);
	z-index: 999998;
	opacity: 0;
	transform: translateY(16px) scale(0.96);
	transition: opacity 0.25s ease, transform 0.25s ease;
	pointer-events: none;
	visibility: hidden;
}

.spay-chat--open .spay-chat__panel {
	display: flex;
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
	visibility: visible;
}

/* Header */
.spay-chat__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 16px 12px;
	background: linear-gradient(135deg, var(--spay-chat-accent) 0%, var(--spay-chat-accent-hover) 100%);
	color: var(--spay-chat-header-text);
	flex-shrink: 0;
}

.spay-chat__header-info {
	display: flex;
	align-items: center;
	gap: 12px;
}

.spay-chat__avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.2);
	display: flex;
	align-items: center;
	justify-content: center;
}

.spay-chat__avatar svg {
	width: 24px;
	height: 24px;
}

.spay-chat__title {
	display: block;
	font-size: 15px;
	font-weight: 600;
}

.spay-chat__status {
	display: block;
	font-size: 12px;
	opacity: 0.85;
}

.spay-chat__status::before {
	content: "";
	display: inline-block;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #4ade80;
	margin-right: 5px;
	vertical-align: middle;
}

.spay-chat__close {
	width: 32px;
	height: 32px;
	border: none;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.15);
	color: var(--spay-chat-header-text);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s;
}

.spay-chat__close:hover {
	background: rgba(255, 255, 255, 0.25);
}

.spay-chat__close svg {
	width: 18px;
	height: 18px;
}

/* Disclaimer */
.spay-chat__disclaimer {
	margin: 0;
	padding: 8px 16px;
	font-size: 11px;
	color: var(--spay-chat-muted);
	background: var(--spay-chat-surface);
	border-bottom: 1px solid var(--spay-chat-border);
	flex-shrink: 0;
	line-height: 1.4;
}

.spay-chat__disclaimer:empty {
	display: none;
}

/* Messages */
.spay-chat__messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	scroll-behavior: smooth;
}

.spay-chat__message {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 14px;
	word-wrap: break-word;
	white-space: normal;
	animation: spayChatFadeIn 0.25s ease;
}

.spay-chat__message a {
	color: inherit;
	text-decoration: underline;
	font-weight: 500;
}
.spay-chat__message--assistant a {
	color: var(--spay-chat-accent);
}
.spay-chat__message--user a {
	color: #fff;
}

.spay-chat__message ul,
.spay-chat__message ol {
	margin: 8px 0;
	padding-left: 20px;
}
.spay-chat__message li {
	margin: 4px 0;
}

.spay-chat__message code {
	font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
	font-size: 0.9em;
	background: rgba(0, 0, 0, 0.06);
	padding: 2px 4px;
	border-radius: 4px;
}
.spay-chat__message--user code {
	background: rgba(255, 255, 255, 0.2);
}
.spay-chat__message pre {
	margin: 8px 0;
	background: rgba(0, 0, 0, 0.05);
	padding: 8px;
	border-radius: 6px;
	overflow-x: auto;
}
.spay-chat__message--user pre {
	background: rgba(255, 255, 255, 0.15);
}
.spay-chat__message pre code {
	background: none;
	padding: 0;
}

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

.spay-chat__message--user {
	align-self: flex-end;
	background: var(--spay-chat-user-bg);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.spay-chat__message--assistant {
	align-self: flex-start;
	background: var(--spay-chat-bot-bg);
	color: var(--spay-chat-text);
	border-bottom-left-radius: 4px;
}

.spay-chat__message--staff {
	align-self: flex-start;
	background: #ecfdf5;
	color: var(--spay-chat-text);
	border-bottom-left-radius: 4px;
	border: 1px solid #a7f3d0;
}

.spay-chat__staff-label {
	font-size: 11px;
	font-weight: 600;
	color: #047857;
	margin-bottom: 4px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

.spay-chat__message--staff a {
	color: #047857;
}

.spay-chat__message--system {
	align-self: center;
	background: #f3f4f6;
	color: #6b7280;
	font-size: 12px;
	text-align: center;
	border-radius: 8px;
	max-width: 92%;
	border: 1px dashed #d1d5db;
}

.spay-chat__message--welcome {
	align-self: flex-start;
	background: var(--spay-chat-bot-bg);
	color: var(--spay-chat-text);
	border-bottom-left-radius: 4px;
}

/* Typing indicator */
.spay-chat__typing {
	align-self: flex-start;
	display: flex;
	gap: 4px;
	padding: 12px 16px;
	background: var(--spay-chat-bot-bg);
	border-radius: 14px;
	border-bottom-left-radius: 4px;
}

.spay-chat__typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--spay-chat-muted);
	animation: spayChatBounce 1.2s infinite ease-in-out;
}

.spay-chat__typing span:nth-child(2) {
	animation-delay: 0.15s;
}

.spay-chat__typing span:nth-child(3) {
	animation-delay: 0.3s;
}

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

/* Quick replies */
.spay-chat__quick-replies {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 0 16px 12px;
	flex-shrink: 0;
}

.spay-chat__quick-replies:empty {
	display: none;
	padding: 0;
}

.spay-chat__chip {
	border: 1px solid var(--spay-chat-border);
	background: var(--spay-chat-bg);
	color: var(--spay-chat-text);
	padding: 6px 12px;
	border-radius: 20px;
	font-size: 12px;
	cursor: pointer;
	transition: border-color 0.15s, background 0.15s, color 0.15s;
	font-family: inherit;
	line-height: 1.3;
}

.spay-chat__chip:hover {
	border-color: var(--spay-chat-accent);
	background: rgba(var(--spay-chat-accent-rgb), 0.08);
	color: var(--spay-chat-accent);
}

/* Form */
.spay-chat__form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px 16px 16px;
	border-top: 1px solid var(--spay-chat-border);
	background: var(--spay-chat-bg);
	flex-shrink: 0;
}

.spay-chat__input {
	flex: 1;
	resize: none;
	border: 1px solid var(--spay-chat-border);
	border-radius: 12px;
	padding: 10px 14px;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.4;
	max-height: 100px;
	outline: none;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.spay-chat__input:focus {
	border-color: var(--spay-chat-accent);
	box-shadow: 0 0 0 3px rgba(var(--spay-chat-accent-rgb), 0.15);
}

.spay-chat__send {
	width: 42px;
	height: 42px;
	flex-shrink: 0;
	border: none;
	border-radius: 12px;
	background: var(--spay-chat-accent);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s, transform 0.15s;
}

.spay-chat__send:hover:not(:disabled) {
	background: var(--spay-chat-accent-hover);
}

.spay-chat__send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.spay-chat__send svg {
	width: 20px;
	height: 20px;
}

/* Bubble position */
.spay-chat--pos-left .spay-chat__bubble {
	left: 24px;
	right: auto;
}

.spay-chat--pos-left .spay-chat__panel {
	left: 24px;
	right: auto;
}

/* Mobile */
@media (max-width: 480px) {
	.spay-chat__bubble {
		bottom: 16px;
		right: 16px;
		width: 56px;
		height: 56px;
	}

	.spay-chat__panel {
		bottom: 0;
		right: 0;
		left: 0;
		width: 100%;
		max-width: 100%;
		height: 100%;
		max-height: 100%;
		border-radius: 0;
		border: none;
	}

	.spay-chat--open .spay-chat__bubble {
		display: none;
	}
}

/* Email collection banner */
.spay-chat__email-collect {
	padding: 12px 16px;
	background: #f8fafc;
	border-top: 1px solid var(--spay-chat-border);
	display: flex;
	flex-direction: column;
	gap: 8px;
	flex-shrink: 0;
}

.spay-chat__email-collect-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 8px;
}

.spay-chat__email-collect-text {
	font-size: 12px;
	color: #64748b;
	line-height: 1.4;
	font-weight: 500;
}

.spay-chat__email-collect-close {
	background: none;
	border: none;
	color: #94a3b8;
	cursor: pointer;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: color 0.15s;
}

.spay-chat__email-collect-close:hover {
	color: #64748b;
}

.spay-chat__email-collect-close svg {
	width: 14px;
	height: 14px;
}

.spay-chat__email-collect-fields {
	display: flex;
	gap: 8px;
}

.spay-chat__email-input {
	flex: 1;
	border: 1px solid var(--spay-chat-border);
	border-radius: 8px;
	padding: 8px 12px;
	font-family: inherit;
	font-size: 13px;
	outline: none;
	background: #fff;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.spay-chat__email-input:focus {
	border-color: var(--spay-chat-accent);
	box-shadow: 0 0 0 2px rgba(var(--spay-chat-accent-rgb), 0.1);
}

.spay-chat__email-submit {
	border: none;
	border-radius: 8px;
	background: var(--spay-chat-accent);
	color: #fff;
	font-size: 13px;
	font-weight: 600;
	padding: 8px 16px;
	cursor: pointer;
	transition: background 0.15s;
}

.spay-chat__email-submit:hover {
	background: var(--spay-chat-accent-hover);
}

