/**
 * JKI Chatbot Styling
 * Integrates with modern.css design system
 */

/* CSS Variables */
:root {
	--chatbot-primary: #006666;
	--chatbot-primary-dark: #004d4d;
	--chatbot-primary-light: #e6f5f5;
	--chatbot-bg: #ffffff;
	--chatbot-text: #2d2d2d;
	--chatbot-text-light: #666666;
	--chatbot-user-bg: #f5f5f5;
	--chatbot-border: #e0e0e0;
	--chatbot-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	--chatbot-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
	--chatbot-width: 380px;
	--chatbot-max-height: 600px;
	--chatbot-radius: 16px;
	--chatbot-radius-sm: 8px;
}

/* Screen Reader Only */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border-width: 0;
}

/* Chatbot Container */
.chatbot {
	position: fixed;
	bottom: 20px;
	right: 20px;
	z-index: 1000;
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Toggle Button */
.chatbot-toggle {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: var(--chatbot-primary);
	color: white;
	border: none;
	cursor: pointer;
	box-shadow: var(--chatbot-shadow);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.3s ease;
	position: relative;
}

.chatbot-toggle:hover {
	background: var(--chatbot-primary-dark);
	transform: scale(1.05);
}

.chatbot-toggle:focus {
	outline: 3px solid var(--chatbot-primary);
	outline-offset: 2px;
}

.chatbot-toggle svg {
	width: 28px;
	height: 28px;
	fill: white;
	transition: all 0.3s ease;
}

.chatbot-toggle .chatbot-close {
	display: none;
	position: absolute;
}

.chatbot-toggle[aria-expanded="true"] .chatbot-icon {
	display: none;
}

.chatbot-toggle[aria-expanded="true"] .chatbot-close {
	display: block;
}

/* Chat Window */
.chatbot-window {
	position: fixed;
	bottom: 90px;
	right: 20px;
	width: var(--chatbot-width);
	max-height: var(--chatbot-max-height);
	background: var(--chatbot-bg);
	border-radius: var(--chatbot-radius);
	box-shadow: var(--chatbot-shadow);
	display: flex;
	flex-direction: column;
	opacity: 0;
	transform: translateY(20px) scale(0.95);
	transition: all 0.3s ease;
	pointer-events: none;
}

.chatbot-window:not([hidden]) {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: all;
}

/* Chat Header */
.chatbot-header {
	padding: 20px;
	background: var(--chatbot-primary);
	color: white;
	border-radius: var(--chatbot-radius) var(--chatbot-radius) 0 0;
}

.chatbot-header h3 {
	margin: 0 0 4px 0;
	font-size: 18px;
	font-weight: 600;
}

.chatbot-header p {
	margin: 0;
	font-size: 13px;
	opacity: 0.9;
}

/* Messages Area */
.chatbot-messages {
	flex: 1;
	overflow-y: auto;
	padding: 20px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-height: 300px;
	max-height: 400px;
}

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

.chatbot-messages::-webkit-scrollbar-track {
	background: transparent;
}

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

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

/* Message Bubbles */
.chatbot-message {
	display: flex;
	gap: 8px;
	align-items: flex-start;
	animation: messageSlideIn 0.3s ease;
}

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

.chatbot-message.user {
	flex-direction: row-reverse;
}

.chatbot-message-avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	font-weight: 600;
	font-size: 14px;
}

.chatbot-message.bot .chatbot-message-avatar {
	background: var(--chatbot-primary);
	color: white;
}

.chatbot-message.user .chatbot-message-avatar {
	background: var(--chatbot-user-bg);
	color: var(--chatbot-text);
}

.chatbot-message-bubble {
	max-width: 75%;
	padding: 12px 16px;
	border-radius: var(--chatbot-radius-sm);
	line-height: 1.5;
	font-size: 14px;
	white-space: pre-wrap;
	word-wrap: break-word;
}

.chatbot-message.bot .chatbot-message-bubble {
	background: var(--chatbot-primary-light);
	color: var(--chatbot-primary-dark);
	border-bottom-left-radius: 4px;
}

.chatbot-message.user .chatbot-message-bubble {
	background: var(--chatbot-user-bg);
	color: var(--chatbot-text);
	border-bottom-right-radius: 4px;
}

/* Typing Indicator */
.chatbot-typing {
	display: flex;
	gap: 4px;
	padding: 8px 12px;
}

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

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

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

@keyframes typingDot {
	0%, 60%, 100% {
		opacity: 0.3;
		transform: translateY(0);
	}
	30% {
		opacity: 1;
		transform: translateY(-4px);
	}
}

/* Quick Replies */
.chatbot-quick-replies {
	padding: 0 20px 12px;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	animation: quickRepliesSlideIn 0.3s ease;
}

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

.chatbot-quick-reply {
	padding: 8px 16px;
	border: 2px solid var(--chatbot-primary);
	background: white;
	color: var(--chatbot-primary);
	border-radius: 20px;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s ease;
	white-space: nowrap;
}

.chatbot-quick-reply:hover {
	background: var(--chatbot-primary-light);
	transform: translateY(-1px);
}

.chatbot-quick-reply:focus {
	outline: 2px solid var(--chatbot-primary);
	outline-offset: 2px;
}

.chatbot-quick-reply:active {
	transform: translateY(0);
}

/* Input Area */
.chatbot-input {
	padding: 16px 20px;
	border-top: 1px solid var(--chatbot-border);
	background: var(--chatbot-bg);
	border-radius: 0 0 var(--chatbot-radius) var(--chatbot-radius);
}

.chatbot-input form {
	display: flex;
	gap: 8px;
	align-items: center;
}

.chatbot-input input {
	flex: 1;
	padding: 12px 16px;
	border: 1px solid var(--chatbot-border);
	border-radius: 24px;
	font-size: 14px;
	font-family: inherit;
	transition: all 0.2s ease;
}

.chatbot-input input:focus {
	outline: none;
	border-color: var(--chatbot-primary);
	box-shadow: 0 0 0 3px var(--chatbot-primary-light);
}

.chatbot-input input::placeholder {
	color: var(--chatbot-text-light);
}

.chatbot-input button[type="submit"] {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--chatbot-primary);
	color: white;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
	flex-shrink: 0;
}

.chatbot-input button[type="submit"]:hover:not(:disabled) {
	background: var(--chatbot-primary-dark);
	transform: scale(1.05);
}

.chatbot-input button[type="submit"]:focus {
	outline: 2px solid var(--chatbot-primary);
	outline-offset: 2px;
}

.chatbot-input button[type="submit"]:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.chatbot-input button[type="submit"] svg {
	width: 20px;
	height: 20px;
	fill: white;
}

/* Mobile Responsive */
@media (max-width: 767px) {
	.chatbot {
		bottom: 0;
		right: 0;
		left: 0;
	}

	.chatbot-toggle {
		position: fixed;
		bottom: 16px;
		right: 16px;
		left: auto;
	}

	.chatbot-window {
		bottom: 0;
		left: 0;
		right: 0;
		width: 100%;
		max-height: 90vh;
		border-radius: var(--chatbot-radius) var(--chatbot-radius) 0 0;
	}

	.chatbot-window:not([hidden]) {
		transform: translateY(0);
	}

	.chatbot-header {
		border-radius: var(--chatbot-radius) var(--chatbot-radius) 0 0;
	}

	.chatbot-input {
		border-radius: 0;
	}

	.chatbot-quick-replies {
		overflow-x: auto;
		flex-wrap: nowrap;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
		-ms-overflow-style: none;
	}

	.chatbot-quick-replies::-webkit-scrollbar {
		display: none;
	}

	.chatbot-message-bubble {
		max-width: 80%;
	}

	/* Ensure touch targets are 44x44px minimum */
	.chatbot-quick-reply {
		min-height: 44px;
		display: flex;
		align-items: center;
	}

	.chatbot-input input {
		min-height: 48px;
	}

	.chatbot-input button[type="submit"] {
		width: 44px;
		height: 44px;
	}
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1023px) {
	.chatbot-window {
		right: 20px;
		width: 360px;
	}
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
	.chatbot-toggle,
	.chatbot-header {
		border: 2px solid currentColor;
	}

	.chatbot-message-bubble {
		border: 1px solid currentColor;
	}
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
	.chatbot-window,
	.chatbot-toggle,
	.chatbot-message,
	.chatbot-quick-replies,
	.chatbot-quick-reply {
		animation: none;
		transition: none;
	}

	.chatbot-typing span {
		animation: none;
		opacity: 0.6;
	}
}
