/* CGI Chatbot Widget Styles */

.cgi-chatbot-container {
	position: fixed;
	bottom: 20px;
	right: 20px;
	z-index: 9999;
	font-family: 'Barlow Semi Condensed', Arial, sans-serif;
}

.widget-container {
	position: fixed;
	bottom: 20px;
	right: 20px;
	z-index: 9999;
	font-family: 'Barlow Semi Condensed', Arial, sans-serif;
}

/* Left-aligned variant — toggled by admin setting via the JS root class. */
.widget-container.position-left {
	right: auto;
	left: 20px;
}

.widget-bubble {
	width: 64px;
	height: 64px;
	border-radius: 50%;
	background: #d0493d;
	border: none;
	color: white;
	font-size: 28px;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(208, 73, 61, 0.4);
	transition: transform 0.2s, box-shadow 0.2s;
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
}

.widget-bubble:hover {
	transform: scale(1.08);
	box-shadow: 0 8px 28px rgba(208, 73, 61, 0.5);
}

.widget-bubble::after {
	content: '';
	position: absolute;
	top: 8px;
	right: 8px;
	width: 12px;
	height: 12px;
	background: #74aa50;
	border-radius: 50%;
	border: 2px solid white;
	box-shadow: 0 0 0 0 rgba(116, 170, 80, 0.6);
	animation: pulse 2s infinite;
}

@keyframes pulse {
	0% {
		box-shadow: 0 0 0 0 rgba(116, 170, 80, 0.6);
	}
	70% {
		box-shadow: 0 0 0 10px rgba(116, 170, 80, 0);
	}
	100% {
		box-shadow: 0 0 0 0 rgba(116, 170, 80, 0);
	}
}

.chat-window {
	width: 420px;
	height: 620px;
	background: white;
	border-radius: 16px;
	box-shadow: 0 10px 50px rgba(0, 0, 0, 0.18);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
	from {
		transform: translateY(20px);
		opacity: 0;
	}
	to {
		transform: translateY(0);
		opacity: 1;
	}
}

.chat-header {
	background: linear-gradient(135deg, #d0493d 0%, #b73a30 100%);
	color: white;
	padding: 16px 18px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-shrink: 0;
}

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

.chat-header-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.2);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 20px;
}

.chat-header h3 {
	font-family: 'Barlow Condensed', Arial, sans-serif;
	font-size: 18px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.3px;
	margin: 0;
}

.chat-header-status {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 11px;
	opacity: 0.95;
	margin: 0;
}

.status-dot {
	width: 8px;
	height: 8px;
	background: #74aa50;
	border-radius: 50%;
	animation: pulse 2s infinite;
}

.chat-actions {
	display: flex;
	gap: 4px;
}

.icon-button {
	background: rgba(255, 255, 255, 0.15);
	border: none;
	color: white;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	cursor: pointer;
	font-size: 14px;
	transition: background 0.2s;
	display: flex;
	align-items: center;
	justify-content: center;
}

.icon-button:hover {
	background: rgba(255, 255, 255, 0.3);
}

.messages-container {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #f7f9fa;
	scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
	width: 6px;
}

.messages-container::-webkit-scrollbar-thumb {
	background: #d0d0d0;
	border-radius: 3px;
}

.message-wrapper {
	display: flex;
	flex-direction: column;
	max-width: 85%;
	animation: fadeIn 0.3s;
}

@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.message-wrapper.user {
	align-self: flex-end;
	align-items: flex-end;
}

.message-wrapper.assistant {
	align-self: flex-start;
	align-items: flex-start;
}

.message-bubble {
	padding: 11px 15px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.5;
	white-space: pre-wrap;
	word-wrap: break-word;
}

.message-bubble.user {
	background: #00617f;
	color: white;
	border-bottom-right-radius: 4px;
}

.message-bubble.assistant {
	background: white;
	color: #231f20;
	border: 1px solid #e8e8e8;
	border-bottom-left-radius: 4px;
}

/* Autolinked URLs, emails, and phone numbers inside chat bubbles. */
.message-bubble .cgi-chatbot-link {
	text-decoration: underline;
	font-weight: 600;
	overflow-wrap: anywhere;
	word-break: break-word;
}

.message-bubble.assistant .cgi-chatbot-link {
	color: #00617f;
}

.message-bubble.assistant .cgi-chatbot-link:hover,
.message-bubble.assistant .cgi-chatbot-link:focus {
	color: #004a63;
	text-decoration: underline;
}

.message-bubble.user .cgi-chatbot-link {
	color: #ffffff;
	text-decoration: underline;
}

.message-bubble.user .cgi-chatbot-link:hover,
.message-bubble.user .cgi-chatbot-link:focus {
	color: #cdeaf6;
}

.message-meta {
	font-size: 10px;
	color: #999;
	margin-top: 3px;
	padding: 0 4px;
	display: flex;
	gap: 6px;
	align-items: center;
}

.model-badge {
	display: inline-block;
	padding: 2px 6px;
	border-radius: 8px;
	font-size: 9px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.3px;
}

.model-badge.haiku {
	background: #e3f2fd;
	color: #1565c0;
}

.model-badge.opus {
	background: #f3e5f5;
	color: #6a1b9a;
}

.typing-indicator {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 12px 15px;
	background: white;
	border: 1px solid #e8e8e8;
	border-radius: 14px;
	border-bottom-left-radius: 4px;
	width: fit-content;
}

.typing-dot {
	width: 7px;
	height: 7px;
	background: #b0b0b0;
	border-radius: 50%;
	animation: typingBounce 1.4s infinite;
}

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

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

@keyframes typingBounce {
	0%,
	60%,
	100% {
		transform: translateY(0);
		opacity: 0.4;
	}
	30% {
		transform: translateY(-6px);
		opacity: 1;
	}
}

.quick-replies {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 6px 0 4px;
}

.quick-reply-chip {
	background: white;
	border: 1.5px solid #00617f;
	color: #00617f;
	padding: 7px 12px;
	border-radius: 18px;
	font-size: 12px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s;
	font-family: inherit;
}

.quick-reply-chip:hover {
	background: #00617f;
	color: white;
	transform: translateY(-1px);
}

.lead-form {
	background: linear-gradient(135deg, #e8f4f8 0%, #f0f8fb 100%);
	padding: 14px;
	border-radius: 12px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	border: 1px solid #b0e0f0;
}

.lead-form h4 {
	font-family: 'Barlow Condensed', Arial, sans-serif;
	font-size: 16px;
	text-transform: uppercase;
	color: #00617f;
	margin: 0 0 4px 0;
}

.lead-input {
	padding: 10px 12px;
	border: 1px solid #d0d8dc;
	border-radius: 8px;
	font-size: 13px;
	font-family: inherit;
	outline: none;
	transition: border-color 0.2s;
}

.lead-input:focus {
	border-color: #00617f;
}

.lead-input.has-error {
	border-color: #d0493d;
	background-color: #fef5f4;
}

.form-error {
	background: #fef5f4;
	border: 1px solid #d0493d;
	border-radius: 8px;
	padding: 10px 12px;
	font-size: 12px;
	color: #b73a30;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.suggestion-button {
	background: #d0493d;
	color: white;
	border: none;
	padding: 6px 10px;
	border-radius: 6px;
	font-size: 11px;
	cursor: pointer;
	font-family: inherit;
	font-weight: 600;
	align-self: flex-start;
	transition: background 0.2s;
}

.suggestion-button:hover {
	background: #b73a30;
}

.lead-submit {
	padding: 10px;
	background: #74aa50;
	color: white;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	font-size: 13px;
	font-weight: 600;
	font-family: inherit;
	transition: background 0.2s;
}

.lead-submit:hover {
	background: #5e8c41;
}

.lead-submit:disabled {
	background: #b0b0b0;
	cursor: not-allowed;
}

.lead-confirmation {
	background: #f0f8f0;
	padding: 12px;
	border-radius: 12px;
	border: 2px solid #74aa50;
}

.lead-confirmation h4 {
	font-family: 'Barlow Condensed', Arial, sans-serif;
	text-transform: uppercase;
	font-size: 14px;
	color: #4a6a32;
	margin: 0 0 6px 0;
}

.lead-json {
	font-size: 10px;
	font-family: 'Courier New', monospace;
	overflow: auto;
	max-height: 140px;
	background: white;
	padding: 8px;
	border-radius: 6px;
	border: 1px solid #d0e0c0;
	margin: 0;
}

.input-area {
	display: flex;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid #eaeaea;
	background: white;
}

.text-input {
	flex: 1;
	padding: 11px 14px;
	border: 1.5px solid #e0e0e0;
	border-radius: 22px;
	font-size: 14px;
	outline: none;
	font-family: inherit;
	transition: border-color 0.2s;
}

.text-input:focus {
	border-color: #d0493d;
}

.send-button {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: #d0493d;
	color: white;
	border: none;
	cursor: pointer;
	font-size: 18px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s, transform 0.2s;
	flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
	background: #b73a30;
	transform: rotate(15deg);
}

.send-button:disabled {
	background: #d0d0d0;
	cursor: not-allowed;
}

.chat-footer {
	padding: 6px 12px;
	font-size: 10px;
	color: #999;
	border-top: 1px solid #eaeaea;
	text-align: center;
	background: #fafafa;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

@media (max-width: 480px) {
	.chat-window {
		width: calc(100vw - 24px);
		height: calc(100vh - 100px);
		max-height: 620px;
	}
}
