/* ------------------------------------------------------------------
 * Supporty AI — Frontend chat UI
 * ------------------------------------------------------------------ */

/* Widget root */
.supporty-widget {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* -------------------- Floating launcher bubble -------------------- */

.supporty-launcher {
	position: relative;
	width: 62px;
	height: 62px;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #ffffff;
	background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
	box-shadow: 0 8px 24px rgba(79, 70, 229, 0.4);
	transition: transform 0.25s ease, box-shadow 0.25s ease;
	padding: 0;
	outline: none;
}

.supporty-launcher:hover {
	transform: scale(1.08);
	box-shadow: 0 10px 32px rgba(79, 70, 229, 0.55);
}

.supporty-launcher:active {
	transform: scale(0.96);
}

.supporty-launcher-icon {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 0.2s ease, transform 0.25s ease;
}

.supporty-icon-open {
	opacity: 1;
	transform: rotate(0deg);
}

.supporty-icon-close {
	opacity: 0;
	transform: rotate(-90deg);
}

/* Launcher state when the chat window is open */
.supporty-widget.is-open .supporty-launcher {
	background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
	box-shadow: 0 8px 24px rgba(239, 68, 68, 0.4);
}

.supporty-widget.is-open .supporty-icon-open {
	opacity: 0;
	transform: rotate(90deg);
}

.supporty-widget.is-open .supporty-icon-close {
	opacity: 1;
	transform: rotate(0deg);
}

/* --------------------------- Chat window -------------------------- */

.supporty-chat-window {
	position: fixed;
	bottom: 98px;
	right: 24px;
	width: 380px;
	max-width: calc(100vw - 48px);
	height: 560px;
	max-height: calc(100vh - 130px);
	background: #ffffff;
	border-radius: 18px;
	box-shadow: 0 24px 64px rgba(15, 23, 42, 0.28);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transform: translateY(16px) scale(0.96);
	transform-origin: bottom right;
	transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

.supporty-widget.is-open .supporty-chat-window {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
}

/* ----------------------------- Header ----------------------------- */

.supporty-chat-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 18px;
	background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
	color: #ffffff;
	flex-shrink: 0;
}

.supporty-agent-avatar {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 22px;
	flex-shrink: 0;
	border: 2px solid rgba(255, 255, 255, 0.35);
	overflow: hidden;
}

.supporty-agent-avatar .supporty-agent-logo {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.supporty-agent-info {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.supporty-agent-name {
	font-size: 15px;
	font-weight: 700;
	line-height: 1.2;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.supporty-agent-status {
	font-size: 12px;
	opacity: 0.9;
	display: flex;
	align-items: center;
	gap: 6px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.supporty-status-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #34d399;
	box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
	animation: supporty-pulse 1.8s infinite;
	flex-shrink: 0;
}

@keyframes supporty-pulse {
	0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6); }
	70%  { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
	100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.supporty-close-btn {
	margin-left: auto;
	width: 32px;
	height: 32px;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.15);
	color: #ffffff;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: background 0.2s ease;
	flex-shrink: 0;
}

.supporty-close-btn:hover {
	background: rgba(255, 255, 255, 0.3);
}

/* --------------------------- Message body ------------------------- */

.supporty-chat-body {
	flex: 1;
	overflow-y: auto;
	padding: 18px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: #f8fafc;
	scrollbar-width: thin;
	scrollbar-color: #cbd5e1 transparent;
}

.supporty-chat-body::-webkit-scrollbar {
	width: 6px;
}

.supporty-chat-body::-webkit-scrollbar-thumb {
	background: #cbd5e1;
	border-radius: 3px;
}

.supporty-message {
	max-width: 82%;
	padding: 11px 15px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.55;
	word-wrap: break-word;
	overflow-wrap: break-word;
	white-space: pre-wrap;
}

.supporty-message-agent {
	align-self: flex-start;
	background: #ffffff;
	color: #1e293b;
	border: 1px solid #e2e8f0;
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.supporty-message-user {
	align-self: flex-end;
	background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
	color: #ffffff;
	border-bottom-right-radius: 4px;
}

/* --------------------- Typing indicator --------------------------- */

.supporty-typing {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 13px 16px;
}

.supporty-error-debug {
	margin-top: 6px;
	font-size: 11px;
	opacity: 0.7;
	word-break: break-all;
}

.supporty-typing-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #94a3b8;
	animation: supporty-bounce 1.2s infinite;
}

.supporty-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.supporty-typing-dot:nth-child(3) { animation-delay: 0.3s; }

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

/* ------------------------------ Form ------------------------------ */

.supporty-chat-form {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 14px;
	border-top: 1px solid #e2e8f0;
	background: #ffffff;
	flex-shrink: 0;
}

.supporty-chat-input {
	flex: 1;
	border: 1px solid #e2e8f0;
	border-radius: 24px;
	padding: 11px 16px;
	font-size: 14px;
	font-family: inherit;
	color: #1e293b;
	background: #f8fafc;
	outline: none;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.supporty-chat-input:focus {
	border-color: #7c3aed;
	box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
	background: #ffffff;
}

.supporty-chat-input::placeholder {
	color: #94a3b8;
}

.supporty-send-btn {
	width: 42px;
	height: 42px;
	border: none;
	border-radius: 50%;
	background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
	color: #ffffff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	flex-shrink: 0;
	transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
	box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.supporty-send-btn:hover {
	transform: scale(1.06);
	box-shadow: 0 6px 16px rgba(79, 70, 229, 0.45);
}

.supporty-send-btn:active {
	transform: scale(0.94);
}

.supporty-send-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
}

/* --------------------------- Responsive --------------------------- */

@media (max-width: 480px) {
	.supporty-widget {
		bottom: 14px;
		right: 14px;
	}

	.supporty-chat-window {
		position: fixed;
		top: 10px;
		left: 10px;
		right: 10px;
		bottom: 84px;
		width: auto;
		height: auto;
		max-width: none;
		max-height: none;
		border-radius: 16px;
	}

	.supporty-launcher {
		width: 56px;
		height: 56px;
	}
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
	.supporty-launcher,
	.supporty-chat-window,
	.supporty-typing-dot,
	.supporty-status-dot {
		animation: none !important;
		transition: none !important;
	}
}
