/**
 * AI Customer Assistant — Chat Widget Styles
 */

/* ---- Reset & Container ---- */

.aca-chatbot-wrapper,
.aca-chatbot-wrapper * {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.aca-chatbot-wrapper {
	position: fixed;
	bottom: 20px;
	right: 20px;
	z-index: 999999;
	font-size: 14px;
	line-height: 1.5;
}

/* ---- Chat Bubble Toggle ---- */

.aca-chat-toggle {
	position: relative;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	border: none;
	background: var(--aca-primary, #0073e6);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	outline: none;
}

.aca-chat-toggle:hover {
	transform: scale(1.05);
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

.aca-chat-toggle:focus-visible {
	outline: 3px solid rgba(0, 115, 230, 0.5);
	outline-offset: 2px;
}

.aca-chat-toggle.aca-open .aca-icon-chat {
	display: none;
}

.aca-chat-toggle.aca-open .aca-icon-close {
	display: block !important;
}

/* Unread badge */
.aca-unread-badge {
	position: absolute;
	top: -2px;
	right: -2px;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: #d63638;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}

/* ---- Chat Window ---- */

.aca-chat-window {
	position: absolute;
	bottom: 72px;
	right: 0;
	width: 380px;
	max-height: 640px;
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: acaSlideUp 0.25s ease-out;
}

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

/* ---- Header ---- */

.aca-chat-header {
	background: var(--aca-primary, #0073e6);
	color: #fff;
	padding: 16px 16px 14px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.aca-chat-header-info {
	display: flex;
	align-items: center;
	gap: 10px;
}

.aca-chat-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.2);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.aca-chat-avatar svg {
	color: #fff;
}

.aca-chat-title {
	font-size: 15px;
	font-weight: 600;
	line-height: 1.3;
}

.aca-chat-subtitle {
	font-size: 12px;
	opacity: 0.85;
	line-height: 1.3;
}

.aca-chat-minimise {
	background: none;
	border: none;
	color: #fff;
	cursor: pointer;
	padding: 4px;
	border-radius: 4px;
	opacity: 0.8;
	transition: opacity 0.15s;
}

.aca-chat-minimise:hover {
	opacity: 1;
}

/* ---- Messages Area ---- */

.aca-chat-messages {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-height: 120px;
	max-height: 420px;
	scroll-behavior: smooth;
}

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

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

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

/* Message bubbles */
.aca-message {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 16px;
	word-wrap: break-word;
	overflow-wrap: break-word;
	animation: acaFadeIn 0.2s ease;
}

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

.aca-message-bot {
	background: #f0f2f5;
	color: #1d2327;
	align-self: flex-start;
	border-bottom-left-radius: 4px;
}

.aca-message-user {
	background: var(--aca-primary, #0073e6);
	color: #fff;
	align-self: flex-end;
	border-bottom-right-radius: 4px;
}

/* Markdown-like formatting in bot messages */
.aca-message-bot strong {
	font-weight: 600;
}

.aca-message-bot a {
	color: var(--aca-primary, #0073e6);
	text-decoration: underline;
}

.aca-message-bot a:hover {
	text-decoration: none;
}

/* Typing indicator */
.aca-typing-indicator {
	display: flex;
	gap: 4px;
	padding: 12px 16px;
	align-self: flex-start;
	background: #f0f2f5;
	border-radius: 16px;
	border-bottom-left-radius: 4px;
}

.aca-typing-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #999;
	animation: acaTypingBounce 1.2s ease-in-out infinite;
}

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

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

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

/* ---- Quick Replies ---- */

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

.aca-quick-reply-btn {
	background: #fff;
	border: 1.5px solid var(--aca-primary, #0073e6);
	color: var(--aca-primary, #0073e6);
	padding: 6px 14px;
	border-radius: 20px;
	font-size: 13px;
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
	white-space: nowrap;
	line-height: 1.3;
}

.aca-quick-reply-btn:hover {
	background: var(--aca-primary, #0073e6);
	color: #fff;
}

/* ---- Contact Form ---- */

.aca-contact-form {
	padding: 12px 16px;
	border-top: 1px solid #eee;
	flex-shrink: 0;
}

.aca-form-field {
	margin-bottom: 8px;
}

.aca-form-field input,
.aca-form-field textarea {
	width: 100%;
	padding: 8px 12px;
	border: 1.5px solid #d0d5dd;
	border-radius: 8px;
	font-size: 13px;
	font-family: inherit;
	resize: vertical;
	transition: border-color 0.15s;
}

.aca-form-field input:focus,
.aca-form-field textarea:focus {
	border-color: var(--aca-primary, #0073e6);
	outline: none;
}

.aca-contact-submit {
	width: 100%;
	padding: 10px;
	background: var(--aca-primary, #0073e6);
	color: #fff;
	border: none;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: opacity 0.15s;
}

.aca-contact-submit:hover {
	opacity: 0.9;
}

.aca-contact-submit:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* ---- Input Area ---- */

.aca-chat-input-area {
	padding: 12px 16px;
	border-top: 1px solid #eee;
	flex-shrink: 0;
}

.aca-chat-form {
	display: flex;
	gap: 8px;
	align-items: center;
}

.aca-chat-input {
	flex: 1;
	padding: 10px 14px;
	border: 1.5px solid #d0d5dd;
	border-radius: 24px;
	font-size: 14px;
	font-family: inherit;
	outline: none;
	transition: border-color 0.15s;
}

.aca-chat-input:focus {
	border-color: var(--aca-primary, #0073e6);
}

.aca-chat-send {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: none;
	background: var(--aca-primary, #0073e6);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: opacity 0.15s;
}

.aca-chat-send:hover {
	opacity: 0.9;
}

.aca-chat-send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

/* ---- Mobile Responsive ---- */

@media (max-width: 480px) {
	.aca-chatbot-wrapper {
		bottom: 12px;
		right: 12px;
	}

	.aca-chat-window {
		width: calc(100vw - 24px);
		max-height: calc(100vh - 100px);
		bottom: 68px;
		right: 0;
		border-radius: 12px;
	}

	.aca-chat-messages {
		max-height: calc(100vh - 300px);
	}

	.aca-chat-toggle {
		width: 52px;
		height: 52px;
	}
}

/* ---- Accessibility: Reduced Motion ---- */

@media (prefers-reduced-motion: reduce) {
	.aca-chat-window {
		animation: none;
	}

	.aca-message {
		animation: none;
	}

	.aca-typing-dot {
		animation: none;
		opacity: 0.6;
	}

	.aca-chat-toggle {
		transition: none;
	}
}
