/**
 * Frontend Chatbot Styles
 * Mobile-first responsive design
 */

:root {
	--chatbot-primary: #2563eb;
	--chatbot-primary-dark: #1e40af;
	--chatbot-bg: #ffffff;
	--chatbot-text: #1f2937;
	--chatbot-text-light: #6b7280;
	--chatbot-border: #e5e7eb;
	--chatbot-user-bg: #eff6ff;
	--chatbot-ai-bg: #f9fafb;
	--chatbot-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
	--chatbot-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Chat button (floating) */
#equinest-chat-button {
	position: fixed;
	bottom: 20px;
	z-index: 999;
	background: var(--chatbot-primary);
	color: white;
	width: 60px;
	height: 60px;
	border-radius: 30px;
	border: none;
	cursor: pointer;
	box-shadow: var(--chatbot-shadow-lg);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 24px;
	transition: all 0.3s ease;
}

#equinest-chat-button:hover {
	background: var(--chatbot-primary-dark);
	transform: scale(1.05);
}

#equinest-chat-button.bottom-right {
	right: 20px;
}

#equinest-chat-button.bottom-left {
	left: 20px;
}

/* Chat window */
#equinest-chat-window {
	position: fixed;
	bottom: 90px;
	z-index: 1000;
	width: 100%;
	max-width: 400px;
	height: 600px;
	max-height: calc(100vh - 110px);
	background: var(--chatbot-bg);
	border-radius: 12px;
	box-shadow: var(--chatbot-shadow-lg);
	display: none;
	flex-direction: column;
	overflow: hidden;
	transition: all 0.3s ease;
}

#equinest-chat-window.open {
	display: flex;
}

#equinest-chat-window.bottom-right {
	right: 20px;
}

#equinest-chat-window.bottom-left {
	left: 20px;
}

/* Chat header */
#equinest-chat-header {
	background: var(--chatbot-primary);
	color: white;
	padding: 16px 20px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

#equinest-chat-header h3 {
	margin: 0;
	font-size: 16px;
	font-weight: 600;
}

#equinest-chat-close {
	background: transparent;
	border: none;
	color: white;
	font-size: 24px;
	cursor: pointer;
	padding: 0;
	width: 30px;
	height: 30px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 4px;
	transition: background 0.2s;
}

#equinest-chat-close:hover {
	background: rgba(255, 255, 255, 0.1);
}

/* Chat messages */
#equinest-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 20px;
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.equinest-message {
	display: flex;
	flex-direction: column;
	max-width: 85%;
	animation: slideIn 0.3s ease;
}

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

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

.equinest-message.ai {
	align-self: flex-start;
}

.equinest-message-content {
	padding: 12px 16px;
	border-radius: 12px;
	line-height: 1.5;
	font-size: 14px;
	word-wrap: break-word;
}

.equinest-message.user .equinest-message-content {
	background: var(--chatbot-primary);
	color: white;
	border-bottom-right-radius: 4px;
}

.equinest-message.ai .equinest-message-content {
	background: var(--chatbot-ai-bg);
	color: var(--chatbot-text);
	border-bottom-left-radius: 4px;
	border: 1px solid var(--chatbot-border);
}

.equinest-message-content a {
	color: var(--chatbot-primary);
	text-decoration: underline;
}

.equinest-message.user .equinest-message-content a {
	color: white;
	font-weight: 500;
}

.equinest-message-time {
	font-size: 11px;
	color: var(--chatbot-text-light);
	margin-top: 4px;
	padding: 0 4px;
}

/* Typing indicator */
.equinest-typing {
	display: flex;
	gap: 4px;
	padding: 12px 16px;
	background: var(--chatbot-ai-bg);
	border-radius: 12px;
	border-bottom-left-radius: 4px;
	max-width: 60px;
	border: 1px solid var(--chatbot-border);
}

.equinest-typing span {
	width: 8px;
	height: 8px;
	background: var(--chatbot-text-light);
	border-radius: 50%;
	animation: typing 1.4s infinite;
}

.equinest-typing span:nth-child(2) {
	animation-delay: 0.2s;
}

.equinest-typing span:nth-child(3) {
	animation-delay: 0.4s;
}

@keyframes typing {
	0%, 60%, 100% {
		transform: translateY(0);
		opacity: 0.7;
	}
	30% {
		transform: translateY(-10px);
		opacity: 1;
	}
}

/* Chat input */
#equinest-chat-input-container {
	padding: 16px 20px;
	border-top: 1px solid var(--chatbot-border);
	display: flex;
	gap: 8px;
	flex-shrink: 0;
	background: var(--chatbot-bg);
}

#equinest-chat-input {
	flex: 1;
	border: 1px solid var(--chatbot-border);
	border-radius: 8px;
	padding: 10px 12px;
	font-size: 14px;
	font-family: inherit;
	resize: none;
	min-height: 40px;
	max-height: 120px;
	line-height: 1.5;
}

#equinest-chat-input:focus {
	outline: none;
	border-color: var(--chatbot-primary);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#equinest-chat-send {
	background: var(--chatbot-primary);
	color: white;
	border: none;
	border-radius: 8px;
	padding: 10px 16px;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: background 0.2s;
	min-width: 60px;
}

#equinest-chat-send:hover:not(:disabled) {
	background: var(--chatbot-primary-dark);
}

#equinest-chat-send:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* Mobile styles */
@media (max-width: 768px) {
	#equinest-chat-button {
		width: 56px;
		height: 56px;
		bottom: 16px;
	}

	#equinest-chat-button.bottom-right {
		right: 16px;
	}

	#equinest-chat-button.bottom-left {
		left: 16px;
	}

	#equinest-chat-window {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		max-width: 100%;
		height: 100%;
		max-height: 100%;
		border-radius: 0;
	}

	#equinest-chat-window.bottom-right,
	#equinest-chat-window.bottom-left {
		left: 0;
		right: 0;
	}

	#equinest-chat-header {
		padding: 14px 16px;
	}

	#equinest-chat-messages {
		padding: 16px;
	}

	.equinest-message {
		max-width: 90%;
	}

	#equinest-chat-input-container {
		padding: 12px 16px;
		padding-bottom: max(12px, env(safe-area-inset-bottom));
	}
}

/* Scrollbar styling */
#equinest-chat-messages::-webkit-scrollbar {
	width: 6px;
}

#equinest-chat-messages::-webkit-scrollbar-track {
	background: transparent;
}

#equinest-chat-messages::-webkit-scrollbar-thumb {
	background: var(--chatbot-border);
	border-radius: 3px;
}

#equinest-chat-messages::-webkit-scrollbar-thumb:hover {
	background: var(--chatbot-text-light);
}

/* Markdown support */
.equinest-message-content p {
	margin: 0 0 8px 0;
}

.equinest-message-content p:last-child {
	margin-bottom: 0;
}

.equinest-message-content ul,
.equinest-message-content ol {
	margin: 8px 0;
	padding-left: 20px;
}

.equinest-message-content li {
	margin: 4px 0;
}

.equinest-message-content strong {
	font-weight: 600;
}

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

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
	* {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

/* Focus visible */
*:focus-visible {
	outline: 2px solid var(--chatbot-primary);
	outline-offset: 2px;
}
