/* Sardar Patel AI Counselling Chatbot Stylesheet - CSS Isolation & Responsive Layout */

#spai-chatbot-container,
#spai-chatbot-container *,
#spai-chatbot-container *::before,
#spai-chatbot-container *::after {
	box-sizing: border-box;
}

#spai-chatbot-container {
	position: fixed;
	z-index: 999999;
	font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 14px;
	line-height: 1.45;
	color: #333333;
}

/* Floating Launcher Button */
#spai-chatbot-launcher {
	position: fixed;
	bottom: 20px;
	right: 20px;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background-color: var(--spai-primary-color);
	color: #ffffff;
	border: none;
	cursor: pointer;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
	outline: none;
	padding: 0;
	z-index: 999999;
}

#spai-chatbot-launcher:hover {
	transform: scale(1.08);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

#spai-chatbot-launcher:focus {
	box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.8), 0 0 0 6px var(--spai-primary-color);
}

.spai-launcher-close {
	display: none;
}

/* Launcher Active State */
#spai-chatbot-launcher.active .spai-launcher-icon {
	display: none;
}

#spai-chatbot-launcher.active .spai-launcher-close {
	display: flex;
}

/* Chat Panel Drawer */
#spai-chatbot-panel {
	position: fixed;
	bottom: 95px;
	right: 20px;
	width: min(390px, calc(100vw - 24px));
	max-width: 390px;
	height: calc(100vh - 120px);
	max-height: 600px;
	background-color: #ffffff;
	border-radius: 16px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
	opacity: 0;
	transform: translateY(20px);
	border: 1px solid rgba(0, 0, 0, 0.08);
	z-index: 999998;
}

#spai-chatbot-panel.open {
	opacity: 1;
	transform: translateY(0);
	display: flex !important;
}

/* Header */
.spai-chat-header {
	background-color: var(--spai-primary-color);
	color: #ffffff;
	padding: 14px 18px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	border-top-left-radius: 16px;
	border-top-right-radius: 16px;
	width: 100%;
}

.spai-header-info {
	display: flex;
	align-items: center;
	gap: 12px;
	min-width: 0;
	flex: 1;
}

.spai-bot-avatar {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	object-fit: cover;
	border: 2px solid rgba(255, 255, 255, 0.8);
	background-color: #ffffff;
	flex-shrink: 0;
}

#spai-header-title {
	margin: 0;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.25;
	white-space: normal;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.spai-header-subtext {
	font-size: 11px;
	opacity: 0.85;
	display: block;
	line-height: 1.3;
}

#spai-chatbot-close {
	background: transparent;
	border: none;
	color: #ffffff;
	cursor: pointer;
	padding: 4px;
	opacity: 0.85;
	transition: opacity 0.2s;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	outline: none;
}

#spai-chatbot-close:hover {
	opacity: 1;
}

/* Chat Body (Messages List) */
.spai-chat-body {
	flex: 1;
	padding: 16px;
	overflow-y: auto;
	overflow-x: hidden;
	background-color: #f7f9fc;
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.spai-messages-list {
	display: flex;
	flex-direction: column;
	gap: 14px;
	width: 100%;
}

/* Message Styles */
.spai-message {
	max-width: 85%;
	display: flex;
	flex-direction: column;
}

.spai-message-bot {
	align-self: flex-start;
}

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

.spai-message-bubble {
	padding: 12px 16px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.45;
	overflow-wrap: anywhere;
	word-break: normal;
	white-space: normal;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
	width: 100%;
}

.spai-message-bot .spai-message-bubble {
	background-color: #ffffff;
	color: #333333;
	border-top-left-radius: 2px;
	border: 1px solid rgba(0, 0, 0, 0.04);
}

.spai-message-user .spai-message-bubble {
	background-color: var(--spai-primary-color);
	color: #ffffff;
	border-top-right-radius: 2px;
}

/* HTML formatting inside chat bubbles */
.spai-message-bubble a {
	color: inherit;
	text-decoration: underline;
	font-weight: 600;
}

.spai-message-bubble p {
	margin: 0 0 8px 0;
}
.spai-message-bubble p:last-child {
	margin-bottom: 0;
}

.spai-message-bubble ul, .spai-message-bubble ol {
	margin: 5px 0;
	padding-left: 20px;
}

.spai-message-time {
	font-size: 11px;
	color: #8e9cae;
	margin-top: 4px;
	align-self: flex-start;
	line-height: 1.3;
}

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

/* Choice Buttons generated dynamically inside bubbles */
.spai-choice-buttons {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-top: 10px;
	width: 100%;
}

.spai-choice-btn {
	background-color: #ffffff;
	border: 1px solid var(--spai-primary-color);
	color: var(--spai-primary-color);
	padding: 8px 12px;
	border-radius: 8px;
	cursor: pointer;
	font-size: 13px;
	line-height: 1.4;
	font-weight: 600;
	transition: all 0.2s;
	text-align: left;
	outline: none;
	width: 100%;
	max-width: 100%;
	white-space: normal;
	overflow-wrap: anywhere;
}

.spai-choice-btn:hover {
	background-color: var(--spai-primary-color);
	color: #ffffff;
}

/* Typing Indicator Animation */
.spai-typing-indicator {
	align-self: flex-start;
	background-color: #ffffff;
	padding: 10px 16px;
	border-radius: 14px;
	border-top-left-radius: 2px;
	border: 1px solid rgba(0, 0, 0, 0.04);
	display: flex;
	align-items: center;
	gap: 4px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.spai-typing-indicator span {
	width: 8px;
	height: 8px;
	background-color: #8e9cae;
	border-radius: 50%;
	display: inline-block;
	animation: spai-bounce 1.3s infinite ease-in-out;
}

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

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

@keyframes spai-bounce {
	0%, 80%, 100% { transform: scale(0); }
	40% { transform: scale(1.0); }
}

/* Quick Replies Wrapping Layout (NO horizontal overflow) */
.spai-quick-replies {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 10px 16px;
	background-color: #ffffff;
	border-top: 1px solid rgba(0, 0, 0, 0.05);
	width: 100%;
}

.spai-quick-reply-btn {
	background-color: #f1f3f5;
	border: 1px solid #e9ecef;
	color: #495057;
	padding: 6px 12px;
	border-radius: 20px;
	cursor: pointer;
	font-size: 12.5px;
	line-height: 1.4;
	font-weight: 500;
	transition: all 0.2s ease;
	outline: none;
	max-width: 100%;
	white-space: normal;
	word-wrap: break-word;
	text-align: left;
	overflow-wrap: anywhere;
}

.spai-quick-reply-btn:hover {
	background-color: var(--spai-primary-color);
	color: #ffffff;
	border-color: var(--spai-primary-color);
}

/* Footer & Input bar */
.spai-chat-footer {
	background-color: #ffffff;
	border-top: 1px solid rgba(0, 0, 0, 0.08);
	padding: 12px 16px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: 100%;
	max-width: 100%;
}

.spai-privacy-consent-box {
	font-size: 11px;
	color: #6c757d;
	line-height: 1.35;
	width: 100%;
}

.spai-consent-label {
	display: flex;
	align-items: flex-start;
	gap: 6px;
	cursor: pointer;
	width: 100%;
}

.spai-consent-label input {
	margin-top: 2px;
	flex-shrink: 0;
}

.spai-consent-text {
	flex: 1;
	white-space: normal;
	overflow-wrap: anywhere;
}

.spai-consent-text a {
	color: var(--spai-primary-color);
	text-decoration: underline;
}

.spai-chat-input-bar {
	display: flex;
	align-items: flex-end;
	background-color: #f8f9fa;
	border: 1px solid #ced4da;
	border-radius: 24px;
	padding: 6px 14px;
	gap: 8px;
	transition: border-color 0.2s;
	width: 100%;
	max-width: 100%;
}

.spai-chat-input-bar:focus-within {
	border-color: var(--spai-primary-color);
	background-color: #ffffff;
}

#spai-chat-input {
	flex: 1;
	border: none;
	background: transparent;
	outline: none;
	resize: none;
	font-family: inherit;
	font-size: 14px;
	padding: 4px 0;
	max-height: 80px;
	line-height: 1.4;
	color: #212529;
	min-width: 0;
}

#spai-chat-send {
	background: transparent;
	border: none;
	color: #6c757d;
	cursor: pointer;
	padding: 4px;
	transition: color 0.2s;
	display: flex;
	align-items: center;
	justify-content: center;
	outline: none;
	flex-shrink: 0;
}

#spai-chat-input:valid + #spai-chat-send,
#spai-chat-send.active {
	color: var(--spai-primary-color);
}

#spai-chat-send:hover {
	transform: scale(1.05);
}

/* RESPONSIVE DESIGN (Mobile optimization) */
@media (max-width: 576px) {
	#spai-chatbot-panel {
		bottom: 10px !important;
		right: 10px !important;
		width: calc(100vw - 20px) !important;
		max-width: none !important;
		height: calc(100vh - 30px) !important;
		max-height: none !important;
		border-radius: 12px !important;
	}

	.spai-chat-header {
		border-top-left-radius: 12px !important;
		border-top-right-radius: 12px !important;
	}

	#spai-chatbot-launcher {
		bottom: 15px;
		right: 15px;
	}
}

/* Embedded inline layout (useful for shortcode pages) */
.spai-position-embedded {
	position: relative !important;
	z-index: 100 !important;
	width: 100%;
	max-width: 500px;
	margin: 20px auto;
}

.spai-position-embedded #spai-chatbot-panel {
	position: relative !important;
	bottom: auto !important;
	right: auto !important;
	width: 100% !important;
	height: 500px !important;
	max-height: 500px !important;
	opacity: 1 !important;
	transform: none !important;
	display: flex !important;
	border-radius: 16px !important;
}
