.elaia-chat-widget {
	position: fixed;
	bottom: 20px;
	right: 20px;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Corner position variants */
.elaia-pos-bottom-right {
	bottom: 20px;
	right: 20px;
	top: auto;
	left: auto;
}

.elaia-pos-bottom-left {
	bottom: 20px;
	left: 20px;
	top: auto;
	right: auto;
}

.elaia-pos-top-right {
	top: 20px;
	right: 20px;
	bottom: auto;
	left: auto;
}

.elaia-pos-top-left {
	top: 20px;
	left: 20px;
	bottom: auto;
	right: auto;
}

/* Toggle Button */
.elaia-chat-toggle {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background-color: var(--elaia-primary-color, #0073aa);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	transition: transform 0.2s, box-shadow 0.2s;
}

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

.elaia-chat-toggle svg {
	width: 28px;
	height: 28px;
	color: white;
}

/* Chat Window — base */
.elaia-chat-window {
	position: absolute;
	bottom: 70px;
	right: 0;
	width: 350px;
	height: 450px;
	background: white;
	border-radius: 12px;
	box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

/* Chat window placement per corner */
.elaia-pos-bottom-right .elaia-chat-window {
	bottom: 70px;
	right: 0;
	top: auto;
	left: auto;
}

.elaia-pos-bottom-left .elaia-chat-window {
	bottom: 70px;
	left: 0;
	top: auto;
	right: auto;
}

.elaia-pos-top-right .elaia-chat-window {
	top: 70px;
	right: 0;
	bottom: auto;
	left: auto;
}

.elaia-pos-top-left .elaia-chat-window {
	top: 70px;
	left: 0;
	bottom: auto;
	right: auto;
}

/* Header */
.elaia-chat-header {
	background-color: var(--elaia-primary-color, #0073aa);
	color: white;
	padding: 15px 20px;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.elaia-chat-title {
	font-weight: 600;
	font-size: 16px;
}

.elaia-chat-close {
	background: none;
	border: none;
	color: white;
	font-size: 24px;
	cursor: pointer;
	padding: 0;
	line-height: 1;
	opacity: 0.8;
	transition: opacity 0.2s;
}

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

/* Messages Area */
.elaia-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 15px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.elaia-message {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 12px;
	line-height: 1.4;
	font-size: 14px;
	word-wrap: break-word;
}

.elaia-message-user {
	align-self: flex-end;
	background-color: var(--elaia-primary-color, #0073aa);
	color: white;
	border-bottom-right-radius: 4px;
}

.elaia-message-assistant {
	align-self: flex-start;
	background-color: #f0f0f0;
	color: #333;
	border-bottom-left-radius: 4px;
}

/* Links in messages */
.elaia-message-assistant a,
.elaia-message-assistant .elaia-link {
	color: var(--elaia-primary-color, #0073aa);
	text-decoration: underline;
	word-break: break-all;
	transition: color 0.2s;
}

.elaia-message-assistant a:hover,
.elaia-message-assistant .elaia-link:hover {
	color: #005177;
	text-decoration: underline;
}

.elaia-message-assistant a:visited {
	color: #6b3fa0;
}

/* Text formatting in assistant messages */
.elaia-message-assistant strong {
	font-weight: 600;
}

.elaia-message-assistant em {
	font-style: italic;
}

/* Long URLs handling */
.elaia-message-assistant a {
	max-width: 100%;
	display: inline;
	overflow-wrap: break-word;
}

.elaia-message-error {
	align-self: center;
	background-color: #ffebee;
	color: #c62828;
	font-size: 13px;
}

/* Thinking Indicator */
.elaia-thinking {
	padding: 12px 16px;
	background-color: #f0f0f0;
	border-radius: 12px;
	align-self: flex-start;
	border-bottom-left-radius: 4px;
}

.elaia-thinking-content {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.elaia-thinking-dots {
	display: flex;
	gap: 4px;
}

.elaia-thinking-dot {
	width: 8px;
	height: 8px;
	background-color: #999;
	border-radius: 50%;
	animation: elaia-thinking-bounce 1.4s infinite ease-in-out both;
}

.elaia-thinking-dot:nth-child(1) {
	animation-delay: -0.32s;
}

.elaia-thinking-dot:nth-child(2) {
	animation-delay: -0.16s;
}

.elaia-thinking-text {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	color: #666;
}

.elaia-thinking-label {
	font-style: italic;
}

.elaia-thinking-timer {
	font-family: monospace;
	background-color: #e0e0e0;
	padding: 2px 6px;
	border-radius: 4px;
	font-size: 12px;
	color: #555;
}

@keyframes elaia-thinking-bounce {
	0%, 80%, 100% {
		transform: scale(0);
	}
	40% {
		transform: scale(1);
	}
}

/* Input Area */
.elaia-chat-input-area {
	display: flex;
	padding: 12px;
	border-top: 1px solid #e0e0e0;
	gap: 8px;
	align-items: flex-end;
}

.elaia-chat-input {
	flex: 1;
	border: 1px solid #ddd;
	border-radius: 20px;
	padding: 10px 15px;
	font-size: 14px;
	outline: none;
	transition: border-color 0.2s;
	resize: none;
	min-height: 40px;
	max-height: 120px;
	overflow-y: hidden;
	line-height: 1.4;
	font-family: inherit;
	box-sizing: border-box;
}

/* Show scrollbar only when content exceeds max-height (toggled by JS). */
.elaia-chat-input.elaia-overflowing {
	overflow-y: auto;
	scrollbar-width: thin;
}

.elaia-chat-input.elaia-overflowing::-webkit-scrollbar {
	width: 4px;
}

.elaia-chat-input.elaia-overflowing::-webkit-scrollbar-thumb {
	background: #ccc;
	border-radius: 2px;
}

.elaia-chat-input:focus {
	border-color: var(--elaia-primary-color, #0073aa);
}

.elaia-chat-send {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background-color: var(--elaia-primary-color, #0073aa);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 0.2s;
}

.elaia-chat-send:hover {
	opacity: 0.9;
}

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

.elaia-chat-widget .elaia-chat-send svg {
	width: 18px;
	height: 18px;
	display: block;
	flex-shrink: 0;
	stroke: white;
	fill: none;
}

.elaia-chat-widget .elaia-chat-toggle svg {
	display: block;
	stroke: white;
	fill: none;
}

/* Mobile Responsive */
@media (max-width: 480px) {
	.elaia-chat-widget {
		bottom: 10px;
		right: 10px;
	}

	.elaia-pos-bottom-right {
		bottom: 10px;
		right: 10px;
	}

	.elaia-pos-bottom-left {
		bottom: 10px;
		left: 10px;
	}

	.elaia-pos-top-right {
		top: 10px;
		right: 10px;
	}

	.elaia-pos-top-left {
		top: 10px;
		left: 10px;
	}

	.elaia-chat-window {
		width: calc(100vw - 40px);
		height: calc(100vh - 100px);
	}

	.elaia-pos-bottom-right .elaia-chat-window,
	.elaia-pos-bottom-left .elaia-chat-window {
		bottom: 70px;
		top: auto;
	}

	.elaia-pos-top-right .elaia-chat-window,
	.elaia-pos-top-left .elaia-chat-window {
		top: 70px;
		bottom: auto;
	}

	.elaia-pos-bottom-right .elaia-chat-window,
	.elaia-pos-top-right .elaia-chat-window {
		right: 0;
		left: auto;
	}

	.elaia-pos-bottom-left .elaia-chat-window,
	.elaia-pos-top-left .elaia-chat-window {
		left: 0;
		right: auto;
	}
}
