.ha-chat-widget {
	--ha-chat-primary: #2271b1;
	--ha-chat-accent: #72aee6;
	--ha-chat-bg: #ffffff;
	--ha-chat-fg: #1e1e1e;
	--ha-chat-border: #e2e2e2;
	--ha-chat-bubble-bg: var(--ha-chat-bg);

	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.ha-chat-widget.ha-chat-theme-dark {
	--ha-chat-bg: #1e1e1e;
	--ha-chat-fg: #f1f1f1;
	--ha-chat-border: #3a3a3a;
}

.ha-chat-bubble {
	width: 60px;
	height: 60px;
	padding: 0;
	box-sizing: border-box;
	border-radius: 50%;
	border: none;
	background: var(--ha-chat-primary);
	color: #fff;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.15s ease;
}

.ha-chat-bubble:hover {
	transform: scale(1.05);
}

.ha-chat-icon {
	display: block;
	width: 28px;
	height: 28px;
}

.ha-chat-icon[hidden] {
	display: none;
}

.ha-chat-window {
	position: absolute;
	right: 0;
	bottom: 76px;
	width: 340px;
	max-width: calc(100vw - 48px);
	height: 460px;
	max-height: calc(100vh - 140px);
	background: var(--ha-chat-bg);
	color: var(--ha-chat-fg);
	border: 1px solid var(--ha-chat-border);
	border-radius: 12px;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.ha-chat-window[hidden] {
	display: none;
}

.ha-chat-header {
	background: var(--ha-chat-primary);
	color: #fff;
	padding: 12px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-weight: 600;
}

.ha-chat-close {
	background: transparent;
	border: none;
	color: #fff;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	padding: 0;
}

.ha-chat-messages {
	flex: 1;
	padding: 12px 16px;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

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

.ha-chat-message.ha-chat-message-user {
	align-self: flex-end;
	background: var(--ha-chat-accent);
	color: #fff;
}

.ha-chat-message.ha-chat-message-bot {
	align-self: flex-start;
	background: rgba(127, 127, 127, 0.15);
}

.ha-chat-message.ha-chat-message-error {
	align-self: flex-start;
	background: rgba(220, 50, 50, 0.15);
	color: #dc3232;
}

.ha-chat-message.ha-chat-typing {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 12px 14px;
}

.ha-chat-typing-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background-color: currentColor;
	opacity: 0.3;
	animation: ha-chat-typing-fade 1.2s infinite ease-in-out;
}

.ha-chat-typing-dot:nth-child(2) {
	animation-delay: 0.2s;
}

.ha-chat-typing-dot:nth-child(3) {
	animation-delay: 0.4s;
}

@keyframes ha-chat-typing-fade {
	0%, 80%, 100% {
		opacity: 0.3;
		transform: translateY(0);
	}
	40% {
		opacity: 1;
		transform: translateY(-2px);
	}
}

.ha-chat-end-chat-wrapper {
	align-self: center;
	margin: 4px 0;
}

.ha-chat-end-chat-btn {
	padding: 8px 18px;
	border: 1px solid var(--ha-chat-accent);
	border-radius: 20px;
	background: transparent;
	color: var(--ha-chat-primary);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.ha-chat-end-chat-btn:hover {
	background: var(--ha-chat-accent);
	color: #fff;
}

.ha-chat-input-form {
	display: flex;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--ha-chat-border);
}

.ha-chat-input {
	flex: 1;
	padding: 8px 12px;
	border: 1px solid var(--ha-chat-border);
	border-radius: 20px;
	background: var(--ha-chat-bg);
	color: var(--ha-chat-fg);
	font-size: 14px;
}

.ha-chat-input:focus {
	outline: none;
	border-color: var(--ha-chat-accent);
}

.ha-chat-send {
	width: 36px;
	height: 36px;
	padding: 0;
	box-sizing: border-box;
	border-radius: 50%;
	border: none;
	background: var(--ha-chat-primary);
	color: #fff;
	cursor: pointer;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ha-chat-send svg {
	display: block;
}

.ha-chat-send:disabled {
	opacity: 0.6;
	cursor: default;
}
