/* AI chat for refining the domain listing search.
 * Floating in-page widget (no iframe): a fixed-position toggle bubble in the corner
 * opens a fixed-position chat panel.
 */

:root {
	--chat-accent: #2c7be5;
	--chat-accent-hover: #1a68d1;
}

/* Floating toggle bubble */
.domain-chat-toggle {
	position: fixed;
	bottom: 20px;
	right: 20px;
	width: 58px;
	height: 58px;
	border-radius: 50%;
	border: none;
	background-color: var(--chat-accent, #2c7be5);
	color: #ffffff;
	font-size: 24px;
	line-height: 1;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
	cursor: pointer;
	z-index: 1040;
	transition: background-color 0.2s ease-in-out, transform 0.15s ease-in-out;
}

.domain-chat-toggle:hover {
	background-color: var(--chat-accent-hover, #1a68d1);
	transform: scale(1.05);
}

/* Speech-bubble label above the toggle; hidden while the chat panel is open */
.domain-chat-toggle-bubble {
	position: fixed;
	bottom: 90px;
	right: 20px;
	max-width: 220px;
	padding: 8px 14px;
	background-color: #ffffff;
	color: #333333;
	font-size: 13px;
	line-height: 1.3;
	border: 1px solid var(--chat-accent, #2c7be5);
	border-radius: 14px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
	cursor: pointer;
	z-index: 1040;
	white-space: nowrap;
	animation: domain-chat-bubble-float 2.6s ease-in-out infinite;
}

@keyframes domain-chat-bubble-float {
	0%, 100% { transform: translateY(0); }
	50% { transform: translateY(-5px); }
}

@media (prefers-reduced-motion: reduce) {
	.domain-chat-toggle-bubble {
		animation: none;
	}
}

/* Bubble tail pointing down to the toggle button */
.domain-chat-toggle-bubble::after {
	content: '';
	position: absolute;
	bottom: -7px;
	right: 21px;
	border-style: solid;
	border-width: 7px 7px 0 7px;
	border-color: #ffffff transparent transparent transparent;
	filter: drop-shadow(0 1px 0 var(--chat-accent, #2c7be5));
}

.domain-chat-toggle-bubble.hidden {
	display: none;
}

/* Floating chat panel */
.domain-chat {
	position: fixed;
	bottom: 90px;
	right: 20px;
	width: 360px;
	max-width: calc(100vw - 40px);
	max-height: calc(100vh - 120px);
	background: #ffffff;
	border: 1px solid #e1e1e1;
	border-radius: 4px;
	overflow: hidden;
	font-size: 13px;
	display: none;
	flex-direction: column;
	box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
	z-index: 1041;
}

.domain-chat.visible {
	display: flex;
}

.domain-chat-header {
	background-color: var(--chat-accent, #2c7be5);
	color: #ffffff;
	padding: 14px 15px;
	min-height: 48px;
	line-height: 1;
	font-size: 15px;
	font-weight: normal;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.domain-chat-header .domain-chat-title {
	display: flex;
	align-items: center;
	gap: 8px;
}

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

.domain-chat-header .domain-chat-reset,
.domain-chat-header .domain-chat-close {
	background: none;
	border: none;
	color: #ffffff;
	cursor: pointer;
	opacity: 0.85;
	padding: 0;
	width: 28px;
	height: 28px;
	font-size: 16px;
	line-height: 1;
	border-radius: 4px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background-color 0.15s ease-in-out, opacity 0.15s ease-in-out;
}

.domain-chat-header .domain-chat-reset i,
.domain-chat-header .domain-chat-close i {
	display: block;
	line-height: 1;
}

.domain-chat-header .domain-chat-reset:hover,
.domain-chat-header .domain-chat-close:hover {
	opacity: 1;
	background-color: rgba(255, 255, 255, 0.18);
}

.domain-chat-body {
	flex-grow: 1;
	min-height: 0;
	max-height: 60vh;
	overflow-y: auto;
	padding: 12px;
	background-color: #f7f7f8;
}

.domain-chat-body:empty {
	min-height: 0;
	height: 0;
	padding: 0;
	background-color: transparent;
}

.domain-chat-message {
	margin-bottom: 8px;
	padding: 7px 10px;
	border-radius: 6px;
	max-width: 95%;
	word-wrap: break-word;
	line-height: 1.4;
}

.domain-chat-message.user {
	background-color: #ececec;
	color: #222;
	text-align: right;
	margin-left: auto;
}

.domain-chat-message.bot {
	background-color: transparent;
	color: #222;
	margin-right: auto;
}

.domain-chat-message.bot p {
	margin: 0 0 6px 0;
}

.domain-chat-message.bot p:last-child {
	margin-bottom: 0;
}

.domain-chat-loader {
	display: flex;
	gap: 4px;
	padding: 4px 0;
}

.domain-chat-loader .dot {
	width: 6px;
	height: 6px;
	background-color: var(--chat-accent, #2c7be5);
	border-radius: 50%;
	animation: domain-chat-typing 1.2s infinite ease-in-out;
}

.domain-chat-loader .dot:nth-child(2) {
	animation-delay: 0.15s;
}

.domain-chat-loader .dot:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes domain-chat-typing {
	0%, 80%, 100% {
		transform: translateY(0);
		opacity: 0.5;
	}
	40% {
		transform: translateY(-4px);
		opacity: 1;
	}
}

.domain-chat-input-row {
	display: flex;
	flex-wrap: nowrap;
	align-items: stretch;
	padding: 8px;
	border-top: 1px solid #e1e1e1;
	background-color: #fff;
	gap: 6px;
	min-width: 0;
}

.domain-chat-input {
	flex: 1 1 auto;
	min-width: 0;
	width: 100%;
	border: 1px solid #ccc;
	border-radius: 4px;
	padding: 7px 10px;
	font-size: 13px;
	outline: none;
}

.domain-chat-input:focus {
	border-color: var(--chat-accent, #2c7be5);
}

.domain-chat-send,
.domain-chat-mic {
	flex: 0 0 auto;
	background-color: var(--chat-accent, #2c7be5);
	color: #ffffff;
	border: none;
	padding: 7px 10px;
	border-radius: 4px;
	cursor: pointer;
	font-size: 13px;
	line-height: 1;
}

.domain-chat-send:hover,
.domain-chat-mic:hover {
	background-color: var(--chat-accent-hover, #1a68d1);
}

.domain-chat-send[disabled],
.domain-chat-mic[disabled] {
	opacity: 0.6;
	cursor: not-allowed;
}

.domain-chat-mic.recording {
	background-color: #b00020;
}

.domain-chat-mic.recording:hover {
	background-color: #8a0019;
}

.domain-chat-mic.unsupported {
	display: none;
}

.domain-chat-error {
	color: #b00020;
	font-size: 12px;
	margin-top: 4px;
}

@media (max-width: 480px) {
	.domain-chat {
		right: 10px;
		left: 10px;
		width: auto;
		bottom: 80px;
	}

	.domain-chat-toggle {
		right: 14px;
		bottom: 14px;
		width: 52px;
		height: 52px;
		font-size: 22px;
	}

	.domain-chat-toggle-bubble {
		right: 14px;
		bottom: 76px;
	}
}
