.chat-container {
	position: fixed;
	bottom: 20px;
	right: 20px;
	width: min(360px, calc(100vw - 40px));
	height: min(600px, calc(100vh - 100px));
	background: #ffffff;
	border-radius: 12px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	z-index: 99999999;
	transition: all 0.3s ease;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;

	&.minimized {
		height: 60px;
		overflow: hidden;

		.chat-body {
			display: none;
		}

		.chat-header button {
			opacity: 1;
		}
	}

	&:hover {
		box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25);

		.chat-header button {
			opacity: 1;
		}
	}
}

.chat-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	background: var(--wp-admin-theme-color);
	padding: 8px 12px;
	border-radius: 12px 12px 0 0;
	min-height: 48px;

	h2 {
		color: #ffffff;
		margin: 0;
		font-size: 14px;
		font-weight: 600;
		display: flex;
		align-items: center;
		gap: 6px;

		svg {
			width: 18px !important;
			height: 18px !important;
			fill: currentColor !important;
		}
	}

	.chat-header-actions {
		display: flex;
		gap: 2px;
		align-items: center;
	}

	button {
		color: #ffffff !important;
		padding: 4px;
		height: 28px;
		width: 28px;
		min-width: 28px;
		display: flex !important;
		align-items: center;
		justify-content: center;
		opacity: 0.7;
		transition: all 0.2s ease;
		background: transparent !important;
		border: none;

		&:hover {
			opacity: 1;
			background: rgba(255, 255, 255, 0.1) !important;
		}

		svg {
			width: 18px !important;
			height: 18px !important;
			fill: currentColor !important;
		}
	}
}

.chat-body {
	flex: 1;
	display: flex;
	flex-direction: column;
	padding: 16px;
	overflow: hidden;
	background: #f6f7f7;
}

.chat-messages {
	flex: 1;
	overflow-y: auto;
	margin-bottom: 16px;
	padding-right: 8px;
	scroll-behavior: smooth;

	&::-webkit-scrollbar {
		width: 6px;
	}

	&::-webkit-scrollbar-track {
		background: rgba(0, 0, 0, 0.05);
		border-radius: 3px;
	}

	&::-webkit-scrollbar-thumb {
		background: rgba(0, 0, 0, 0.2);
		border-radius: 3px;

		&:hover {
			background: rgba(0, 0, 0, 0.3);
		}
	}
}

.demo-chat-message {
	margin-bottom: 12px;
	padding: 12px 16px;
	border-radius: 12px;
	max-width: 85%;
	word-wrap: break-word;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
	font-size: 14px;
	line-height: 1.5;

	> *:first-child {
		margin-top: 0;
	}

	> *:last-child {
		margin-bottom: 0;
	}

	pre {
		background: rgba(0, 0, 0, 0.05);
		padding: 8px;
		border-radius: 6px;
		overflow-x: auto;
	}

	code {
		font-family: monospace;
		font-size: 13px;
		padding: 2px 4px;
		background: rgba(0, 0, 0, 0.05);
		border-radius: 4px;
	}

	&-user {
		background: var(--wp-admin-theme-color);
		color: #ffffff;
		margin-left: auto;
	}

	&-assistant,
	&-tool {
		background: #ffffff;
		color: #1e1e1e;
		margin-right: auto;
	}

	&-tool {
		pre {
			white-space: pre-wrap;
			word-wrap: break-word;
			background: rgba(0, 0, 0, 0.03);
		}
	}
}

.chat-input {
	position: relative;
	border: 1px solid #dcdcde;
	border-radius: 12px;
	padding: 8px;
	background: #ffffff;
	transition: all 0.2s ease;
	display: flex;
	align-items: center;

	&:focus-within {
		border-color: var(--wp-admin-theme-color);
		box-shadow: 0 0 0 1px var(--wp-admin-theme-color);
	}

	&-textarea {
		flex: 1;
		border: none;
		padding: 8px 8px;
		font-size: 14px;
		resize: none;
		background: transparent;
		min-height: 24px;
		max-height: 150px;
		line-height: 1.5;
		color: #1e1e1e;
		margin: 0;

		&:focus {
			outline: none;
			box-shadow: none;
		}

		&::placeholder {
			color: #8c8f94;
		}
	}

	&-submit {
		position: relative;
		background: var(--wp-admin-theme-color);
		color: #ffffff;
		border: none;
		border-radius: 8px;
		padding: 0;
		margin: 0 0 0 4px;
		cursor: pointer;
		transition: all 0.2s ease;
		min-width: 36px;
		width: 36px;
		height: 36px;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-shrink: 0;

		svg {
			width: 20px;
			height: 20px;
			fill: currentColor;
		}

		&:hover:not(:disabled) {
			background: var(--wp-admin-theme-color-darker-10);
			transform: translateY(-1px);
		}

		&:disabled {
			background: #dcdcde;
			cursor: not-allowed;
			opacity: 0.7;
		}
	}
}

.demo-chat-message-pending {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 16px;

	.components-spinner {
		margin: 0;
	}
}
