:root {
	--n8n-primary-color: #0073aa; /* Default, overridden by inline style */
	--n8n-chat-width: 350px;
	--n8n-chat-height: 500px;
	--n8n-launcher-size: 60px;
}

/* Container */
#n8n-chat-widget-container {
	position: fixed;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Position classes */
.n8n-chat-position-bottom-right {
	bottom: 20px;
	right: 20px;
}

.n8n-chat-position-bottom-left {
	bottom: 20px;
	left: 20px;
}

/* Launcher Button */
.n8n-chat-launcher {
	width: var(--n8n-launcher-size);
	height: var(--n8n-launcher-size);
	background-color: var(--n8n-primary-color);
	border-radius: 50%;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.3s ease, box-shadow 0.3s ease;
	position: absolute;
	bottom: 0;
	right: 0; /* Relative to container */
}

.n8n-chat-position-bottom-left .n8n-chat-launcher {
	right: auto;
	left: 0;
}

.n8n-chat-launcher:hover {
	transform: scale(1.05);
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.n8n-chat-launcher svg {
	width: 30px;
	height: 30px;
	fill: white;
}

.n8n-chat-launcher-close-icon {
	display: none;
}

.n8n-chat-open .n8n-chat-launcher-open-icon {
	display: none;
}

.n8n-chat-open .n8n-chat-launcher-close-icon {
	display: block;
}

/* Chat Window */
.n8n-chat-window {
	width: var(--n8n-chat-width);
	height: var(--n8n-chat-height);
	background: white;
	border-radius: 12px;
	box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
	position: absolute;
	bottom: calc(var(--n8n-launcher-size) + 15px);
	right: 0;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(20px) scale(0.95);
	pointer-events: none;
	transition: opacity 0.3s ease, transform 0.3s ease;
}

.n8n-chat-position-bottom-left .n8n-chat-window {
	right: auto;
	left: 0;
}

.n8n-chat-open .n8n-chat-window {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: all;
}

/* Header */
.n8n-chat-header {
	background-color: var(--n8n-primary-color);
	color: white;
	padding: 15px 20px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	border-top-left-radius: 12px;
	border-top-right-radius: 12px;
}

.n8n-chat-title {
	font-weight: 600;
	font-size: 16px;
	margin: 0;
}

.n8n-chat-close {
	background: none;
	border: none;
	color: white;
	cursor: pointer;
	font-size: 20px;
	padding: 0;
	line-height: 1;
	opacity: 0.8;
}

.n8n-chat-close:hover {
	opacity: 1;
}

/* Messages Area */
.n8n-chat-messages {
	flex: 1;
	padding: 15px;
	overflow-y: auto;
	background-color: #f9f9f9;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.n8n-chat-message {
	max-width: 80%;
	padding: 10px 14px;
	border-radius: 12px;
	font-size: 14px;
	line-height: 1.4;
	word-wrap: break-word;
	position: relative;
}

.n8n-chat-message-user {
	align-self: flex-end;
	background-color: var(--n8n-primary-color);
	color: white;
	border-bottom-right-radius: 2px;
}

.n8n-chat-message-ai {
	align-self: flex-start;
	background-color: #e5e5ea;
	color: #333;
	border-bottom-left-radius: 2px;
}

.n8n-chat-timestamp {
	font-size: 10px;
	margin-top: 4px;
	opacity: 0.7;
	text-align: right;
}

/* Input Area */
.n8n-chat-input-area {
	padding: 15px;
	border-top: 1px solid #eee;
	background: white;
	display: flex;
	gap: 10px;
	align-items: center;
}

.n8n-chat-input {
	flex: 1;
	border: 1px solid #ddd;
	border-radius: 20px;
	padding: 10px 15px;
	font-size: 14px;
	outline: none;
	transition: border-color 0.2s;
}

.n8n-chat-input:focus {
	border-color: var(--n8n-primary-color);
}

.n8n-chat-send {
	background: none;
	border: none;
	cursor: pointer;
	color: var(--n8n-primary-color);
	padding: 5px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.2s;
}

.n8n-chat-send:hover {
	transform: scale(1.1);
}

.n8n-chat-send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.n8n-chat-send svg {
	width: 20px;
	height: 20px;
	fill: currentColor;
}

/* Typing Indicator */
.n8n-chat-typing {
	display: flex;
	gap: 4px;
	padding: 12px 16px;
	background: #e5e5ea;
	border-radius: 12px;
	border-bottom-left-radius: 2px;
	align-self: flex-start;
	width: fit-content;
}

.n8n-chat-typing-dot {
	width: 6px;
	height: 6px;
	background: #999;
	border-radius: 50%;
	animation: n8n-typing 1.4s infinite ease-in-out both;
}

.n8n-chat-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.n8n-chat-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes n8n-typing {
	0%, 80%, 100% { transform: scale(0); }
	40% { transform: scale(1); }
}

/* Responsive */
@media (max-width: 480px) {
	.n8n-chat-window {
		width: calc(100vw - 40px);
		height: calc(100vh - 100px);
		bottom: calc(var(--n8n-launcher-size) + 15px);
		right: 0;
	}
	
	.n8n-chat-position-bottom-right {
		right: 20px;
		bottom: 20px;
	}
	
	.n8n-chat-position-bottom-left {
		left: 20px;
		bottom: 20px;
	}
}
