/**
 * Custom LMS — AI Admissions Chatbot widget (Phase 11).
 * Deliberately self-contained (no dependency on student.css/admin.css —
 * this loads site-wide, including on pages/themes that never touch
 * either of those) and scoped to #custom-lms-chatbot-root so it can
 * never bleed into the host theme's own styles.
 */

#custom-lms-chatbot-root {
	position: fixed;
	right: 20px;
	/* Many institute sites already run a separate WhatsApp "click to
	 * chat" plugin, which near-universally docks at bottom-right with
	 * a ~20px margin and a ~50-60px button. Stacking this widget ABOVE
	 * that spot (rather than the more common bottom:20px) keeps both
	 * visible and tap-able instead of overlapping — the conventional
	 * pattern used by sites running more than one floating widget. If
	 * a site has no other floating widget, this still reads fine as a
	 * simple bottom-right position, just with a little extra breathing
	 * room above the page edge. */
	bottom: 96px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
}

#custom-lms-chatbot-root * {
	box-sizing: border-box;
}

.custom-lms-chatbot-bubble {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	background: linear-gradient(135deg, #4f46e5, #7c3aed);
	box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
	color: #fff;
	font-size: 26px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.15s ease;
}

.custom-lms-chatbot-bubble:hover {
	transform: scale(1.06);
}

.custom-lms-chatbot-teaser {
	position: absolute;
	right: 72px;
	bottom: 14px;
	background: #fff;
	color: #1f2937;
	padding: 10px 14px;
	border-radius: 12px;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
	white-space: nowrap;
	cursor: pointer;
	opacity: 0;
	transform: translateX(8px);
	pointer-events: none;
	transition: opacity 0.25s ease, transform 0.25s ease;
}

.custom-lms-chatbot-teaser.is-visible {
	opacity: 1;
	transform: translateX(0);
	pointer-events: auto;
}

.custom-lms-chatbot-panel {
	position: absolute;
	right: 0;
	bottom: 76px;
	width: 360px;
	max-width: calc(100vw - 32px);
	height: 520px;
	max-height: calc(100vh - 140px);
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.custom-lms-chatbot-header {
	background: linear-gradient(135deg, #4f46e5, #7c3aed);
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.custom-lms-chatbot-header-info {
	display: flex;
	align-items: center;
	gap: 10px;
}

.custom-lms-chatbot-avatar {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.2);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 18px;
	flex-shrink: 0;
}

.custom-lms-chatbot-name {
	font-weight: 700;
	font-size: 14px;
}

.custom-lms-chatbot-status {
	font-size: 12px;
	opacity: 0.85;
}

.custom-lms-chatbot-close {
	background: transparent;
	border: none;
	color: #fff;
	font-size: 16px;
	cursor: pointer;
	opacity: 0.85;
	padding: 4px 8px;
}

.custom-lms-chatbot-close:hover {
	opacity: 1;
}

.custom-lms-chatbot-messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	background: #f9fafb;
}

.custom-lms-chatbot-message {
	max-width: 82%;
	padding: 9px 13px;
	border-radius: 14px;
	white-space: pre-wrap;
	word-wrap: break-word;
}

.custom-lms-chatbot-message-bot {
	align-self: flex-start;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-bottom-left-radius: 4px;
	color: #1f2937;
}

.custom-lms-chatbot-message-visitor {
	align-self: flex-end;
	background: #4f46e5;
	color: #fff;
	border-bottom-right-radius: 4px;
}

.custom-lms-chatbot-typing {
	align-self: flex-start;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 14px;
	border-bottom-left-radius: 4px;
	padding: 10px 14px;
	display: flex;
	gap: 4px;
}

.custom-lms-chatbot-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #9ca3af;
	animation: custom-lms-chatbot-bounce 1.2s infinite ease-in-out;
}

.custom-lms-chatbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.custom-lms-chatbot-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes custom-lms-chatbot-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
	30% { transform: translateY(-4px); opacity: 1; }
}

.custom-lms-chatbot-quick-replies {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 0 14px 10px;
	flex-shrink: 0;
}

.custom-lms-chatbot-chip {
	display: inline-block;
	background: #eef2ff;
	color: #4338ca;
	border: 1px solid #c7d2fe;
	border-radius: 999px;
	padding: 6px 12px;
	font-size: 12.5px;
	cursor: pointer;
	text-decoration: none;
	transition: background 0.15s ease;
}

.custom-lms-chatbot-chip:hover {
	background: #e0e7ff;
}

.custom-lms-chatbot-callback-form {
	padding: 12px 14px;
	border-top: 1px solid #e5e7eb;
	background: #fffbeb;
	flex-shrink: 0;
}

.custom-lms-chatbot-callback-form label {
	display: block;
	font-size: 12px;
	font-weight: 600;
	color: #374151;
	margin: 6px 0 3px;
}

.custom-lms-chatbot-callback-form input {
	width: 100%;
	padding: 7px 10px;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	font-size: 13px;
}

.custom-lms-chatbot-cb-error {
	color: #b91c1c;
	font-size: 12px;
	margin: 6px 0 0;
}

.custom-lms-chatbot-cb-actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 10px;
}

.custom-lms-chatbot-cb-actions button {
	border: none;
	border-radius: 6px;
	padding: 7px 14px;
	font-size: 12.5px;
	cursor: pointer;
}

.custom-lms-chatbot-cb-cancel {
	background: #e5e7eb;
	color: #374151;
}

.custom-lms-chatbot-cb-submit {
	background: #4f46e5;
	color: #fff;
	font-weight: 600;
}

.custom-lms-chatbot-footer-actions {
	display: flex;
	gap: 8px;
	padding: 8px 14px;
	border-top: 1px solid #e5e7eb;
	flex-shrink: 0;
}

.custom-lms-chatbot-footer-btn {
	flex: 1;
	text-align: center;
	background: #f3f4f6;
	color: #374151;
	border: none;
	border-radius: 8px;
	padding: 7px 8px;
	font-size: 12px;
	cursor: pointer;
	text-decoration: none;
	display: block;
}

.custom-lms-chatbot-whatsapp-btn {
	background: #dcfce7;
	color: #166534;
}

.custom-lms-chatbot-input-row {
	display: flex;
	gap: 8px;
	padding: 10px 14px;
	border-top: 1px solid #e5e7eb;
	flex-shrink: 0;
}

.custom-lms-chatbot-input {
	flex: 1;
	border: 1px solid #d1d5db;
	border-radius: 999px;
	padding: 9px 14px;
	font-size: 13px;
}

.custom-lms-chatbot-input:focus {
	outline: none;
	border-color: #4f46e5;
}

.custom-lms-chatbot-send {
	background: #4f46e5;
	color: #fff;
	border: none;
	border-radius: 999px;
	padding: 9px 16px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
}

.custom-lms-chatbot-send:hover {
	background: #4338ca;
}

@media (max-width: 480px) {
	#custom-lms-chatbot-root {
		right: 12px;
		bottom: 80px;
	}

	.custom-lms-chatbot-panel {
		width: calc(100vw - 24px);
		height: calc(100vh - 160px);
		bottom: 72px;
	}

	.custom-lms-chatbot-bubble {
		width: 54px;
		height: 54px;
		font-size: 22px;
	}
}
