/**
 * MasarPlus - AI Educational Sales & Support Assistant Stylesheet
 * @version 2.0.0
 */

:root {
	--mp-ai-primary: #0092a6;
	--mp-ai-primary-dark: #016070;
	--mp-ai-primary-glow: rgba(0, 146, 166, 0.35);
	--mp-ai-bg: #ffffff;
	--mp-ai-dark: #0f172a;
	--mp-ai-bubble-user: #0092a6;
	--mp-ai-bubble-bot: #f8fafc;
	--mp-ai-border: #e2e8f0;
	--mp-ai-radius: 22px;
	--mp-ai-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
}

/* ==========================================================================
   1. FLOATING TOGGLE BUTTON (ALWAYS ON THE LEFT)
   ========================================================================== */
.mp-ai-chat-root {
	position: fixed;
	bottom: 28px;
	left: 28px !important;
	right: auto !important;
	z-index: 999999;
	font-family: inherit;
}

[dir="rtl"] .mp-ai-chat-root {
	left: 28px !important;
	right: auto !important;
}

.mp-ai-chat-toggle {
	width: 64px;
	height: 64px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--mp-ai-primary) 0%, var(--mp-ai-primary-dark) 100%);
	color: #ffffff;
	border: none;
	cursor: pointer;
	box-shadow: 0 10px 25px var(--mp-ai-primary-glow);
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	outline: none;
	-webkit-tap-highlight-color: transparent;
}

.mp-ai-chat-toggle:hover {
	transform: scale(1.08) translateY(-2px);
	box-shadow: 0 14px 30px rgba(0, 146, 166, 0.5);
}

.mp-ai-chat-toggle__glow {
	position: absolute;
	inset: -4px;
	border-radius: 50%;
	background: linear-gradient(135deg, #38bdf8, #00e5ff);
	opacity: 0.4;
	filter: blur(8px);
	z-index: -1;
	animation: mp-ai-pulse 3s infinite;
}

.mp-ai-chat-toggle__icon {
	font-size: 32px;
	transition: transform 0.3s ease, opacity 0.3s ease;
}

.mp-ai-chat-toggle__close-icon {
	font-size: 28px;
	display: none;
	transition: transform 0.3s ease;
}

.mp-ai-chat-root.is-open .mp-ai-chat-toggle__icon {
	display: none;
}

.mp-ai-chat-root.is-open .mp-ai-chat-toggle__close-icon {
	display: block;
}

.mp-ai-chat-toggle__badge {
	position: absolute;
	top: 2px;
	right: 2px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: #10b981;
	border: 2px solid #ffffff;
}

@keyframes mp-ai-pulse {
	0%, 100% { transform: scale(1); opacity: 0.3; }
	50% { transform: scale(1.15); opacity: 0.6; }
}


/* ==========================================================================
   2. CHAT PANEL DRAWER (ALWAYS ANCHORED LEFT ON DESKTOP)
   ========================================================================== */
.mp-ai-chat-panel {
	position: fixed;
	bottom: 104px;
	left: 28px !important;
	right: auto !important;
	width: 410px;
	max-width: calc(100vw - 40px);
	height: 620px;
	max-height: calc(100vh - 130px);
	background: var(--mp-ai-bg);
	border: 1px solid var(--mp-ai-border);
	border-radius: var(--mp-ai-radius);
	box-shadow: var(--mp-ai-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transform: translateY(20px) scale(0.96);
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	z-index: 999999;
}

[dir="rtl"] .mp-ai-chat-panel {
	left: 28px !important;
	right: auto !important;
}

.mp-ai-chat-root.is-open .mp-ai-chat-panel {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
}


/* ==========================================================================
   3. PANEL HEADER
   ========================================================================== */
.mp-ai-chat-header {
	background: linear-gradient(135deg, #09172e 0%, #032b30 100%);
	color: #ffffff;
	padding: 16px 20px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
	flex-shrink: 0;
}

.mp-ai-chat-header__info {
	display: flex;
	align-items: center;
	gap: 12px;
}

.mp-ai-chat-avatar {
	width: 42px;
	height: 42px;
	border-radius: 12px;
	background: #0092a6;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #ffffff;
	position: relative;
	flex-shrink: 0;
}

.mp-ai-chat-avatar__status {
	position: absolute;
	bottom: -2px;
	right: -2px;
	width: 11px;
	height: 11px;
	border-radius: 50%;
	background: #10b981;
	border: 2px solid #09172e;
}

.mp-ai-chat-header__title {
	font-weight: 800;
	font-size: 0.95rem;
	line-height: 1.2;
}

.mp-ai-chat-header__sub {
	font-size: 0.75rem;
	color: #94a3b8;
	margin-top: 3px;
}

.mp-ai-chat-header__btn {
	background: rgba(255, 255, 255, 0.1);
	border: none;
	color: #ffffff;
	width: 34px;
	height: 34px;
	border-radius: 8px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s ease;
	-webkit-tap-highlight-color: transparent;
}

.mp-ai-chat-header__btn:hover {
	background: rgba(255, 255, 255, 0.2);
}


/* ==========================================================================
   4. PANEL BODY & MESSAGES
   ========================================================================== */
.mp-ai-chat-body {
	flex: 1;
	padding: 18px 16px;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 14px;
	background: #fbfcfe;
	-webkit-overflow-scrolling: touch;
}

.mp-ai-message {
	display: flex;
	flex-direction: column;
	max-width: 88%;
	animation: mp-ai-fade-in 0.25s ease-out;
}

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

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

.mp-ai-bubble {
	padding: 12px 16px;
	border-radius: 16px;
	font-size: 0.92rem;
	line-height: 1.6;
	word-break: break-word;
}

.mp-ai-message--bot .mp-ai-bubble {
	background: var(--mp-ai-bubble-bot);
	border: 1px solid var(--mp-ai-border);
	color: #1e293b;
	border-bottom-left-radius: 4px;
}

[dir="rtl"] .mp-ai-message--bot .mp-ai-bubble {
	border-bottom-left-radius: 16px;
	border-bottom-right-radius: 4px;
}

.mp-ai-message--user .mp-ai-bubble {
	background: linear-gradient(135deg, var(--mp-ai-primary) 0%, var(--mp-ai-primary-dark) 100%);
	color: #ffffff;
	border-bottom-right-radius: 4px;
}

[dir="rtl"] .mp-ai-message--user .mp-ai-bubble {
	border-bottom-right-radius: 16px;
	border-bottom-left-radius: 4px;
}

.mp-ai-message__time {
	font-size: 0.7rem;
	color: #94a3b8;
	margin-top: 4px;
	padding: 0 4px;
}

.mp-ai-message--user .mp-ai-message__time {
	text-align: left;
}

[dir="rtl"] .mp-ai-message--user .mp-ai-message__time {
	text-align: right;
}


/* ==========================================================================
   5. COURSE CARDS IN CHAT
   ========================================================================== */
.mp-ai-course-card {
	background: #ffffff;
	border: 1.5px solid #e2e8f0;
	border-radius: 14px;
	padding: 12px;
	margin-top: 10px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
	transition: all 0.2s ease;
}

.mp-ai-course-card:hover {
	border-color: var(--mp-ai-primary);
	transform: translateY(-2px);
}

.mp-ai-course-card__header {
	display: flex;
	gap: 10px;
	align-items: center;
}

.mp-ai-course-card__thumb {
	width: 54px;
	height: 40px;
	border-radius: 8px;
	object-fit: cover;
	background: #f1f5f9;
	flex-shrink: 0;
}

.mp-ai-course-card__title {
	font-weight: 700;
	font-size: 0.88rem;
	color: #0f172a;
	line-height: 1.3;
	flex: 1;
}

.mp-ai-course-card__meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 0.78rem;
	color: #64748b;
	padding-top: 6px;
	border-top: 1px solid #f1f5f9;
}

.mp-ai-course-card__price {
	font-weight: 800;
	color: var(--mp-ai-primary);
	font-size: 0.9rem;
}

.mp-ai-course-card__btn {
	background: #f0fdfa;
	color: var(--mp-ai-primary);
	border: 1px solid rgba(0, 146, 166, 0.2);
	border-radius: 8px;
	padding: 6px 12px;
	font-size: 0.78rem;
	font-weight: 700;
	text-decoration: none;
	text-align: center;
	display: block;
	transition: all 0.2s ease;
}

.mp-ai-course-card__btn:hover {
	background: var(--mp-ai-primary);
	color: #ffffff;
}


/* ==========================================================================
   6. WHATSAPP HANDOFF BUTTON
   ========================================================================== */
.mp-ai-whatsapp-handoff {
	background: #ecfdf5;
	border: 1.5px solid #a7f3d0;
	border-radius: 14px;
	padding: 12px 14px;
	margin-top: 10px;
	display: flex;
	align-items: center;
	gap: 12px;
}

.mp-ai-whatsapp-btn {
	background: #10b981;
	color: #ffffff !important;
	border-radius: 10px;
	padding: 8px 16px;
	font-size: 0.85rem;
	font-weight: 700;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
	transition: all 0.2s ease;
	width: 100%;
	justify-content: center;
}

.mp-ai-whatsapp-btn:hover {
	background: #059669;
	transform: translateY(-2px);
}


/* ==========================================================================
   7. QUICK SUGGESTIONS
   ========================================================================== */
.mp-ai-chat-suggestions {
	padding: 10px 14px;
	background: #ffffff;
	border-top: 1px solid #f1f5f9;
	display: flex;
	gap: 8px;
	overflow-x: auto;
	white-space: nowrap;
	scrollbar-width: none;
	flex-shrink: 0;
}

.mp-ai-chat-suggestions::-webkit-scrollbar {
	display: none;
}

.mp-ai-prompt-pill {
	background: #f1f5f9;
	border: 1px solid #e2e8f0;
	color: #334155;
	padding: 6px 14px;
	border-radius: 999px;
	font-size: 0.78rem;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s ease;
	user-select: none;
	flex-shrink: 0;
}

.mp-ai-prompt-pill:hover {
	background: #e0f2fe;
	color: #0284c7;
	border-color: #bae6fd;
}


/* ==========================================================================
   8. PANEL FOOTER & INPUT
   ========================================================================== */
.mp-ai-chat-footer {
	padding: 12px 14px;
	background: #ffffff;
	border-top: 1px solid var(--mp-ai-border);
	flex-shrink: 0;
}

.mp-ai-chat-form {
	display: flex;
	align-items: center;
	gap: 8px;
	background: #f8fafc;
	border: 1.5px solid #e2e8f0;
	border-radius: 14px;
	padding: 4px 8px;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.mp-ai-chat-form:focus-within {
	border-color: var(--mp-ai-primary);
	box-shadow: 0 0 0 3px rgba(0, 146, 166, 0.12);
	background: #ffffff;
}

.mp-ai-chat-input {
	flex: 1;
	border: none;
	background: transparent;
	padding: 8px 10px;
	font-size: 0.92rem;
	outline: none;
	color: #0f172a;
}

.mp-ai-chat-submit {
	width: 38px;
	height: 38px;
	border-radius: 10px;
	background: var(--mp-ai-primary);
	color: #ffffff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
	flex-shrink: 0;
}

.mp-ai-chat-submit:hover:not(:disabled) {
	background: var(--mp-ai-primary-dark);
}

.mp-ai-chat-submit:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.mp-ai-chat-footer__note {
	text-align: center;
	font-size: 0.7rem;
	color: #94a3b8;
	margin-top: 6px;
}


/* ==========================================================================
   9. TYPING INDICATOR & ANIMATIONS
   ========================================================================== */
.mp-ai-typing {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 10px 16px;
}

.mp-ai-typing__dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #94a3b8;
	animation: mp-ai-typing-bounce 1.4s infinite ease-in-out both;
}

.mp-ai-typing__dot:nth-child(1) { animation-delay: -0.32s; }
.mp-ai-typing__dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes mp-ai-typing-bounce {
	0%, 80%, 100% { transform: scale(0); }
	40% { transform: scale(1); }
}

@keyframes mp-ai-fade-in {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: translateY(0); }
}


/* ==========================================================================
   10. RESPONSIVE OPTIMIZATIONS FOR TABLETS & MOBILE PHONES
   ========================================================================== */
@media (max-width: 640px) {
	.mp-ai-chat-root {
		bottom: 20px !important;
		left: 18px !important;
		right: auto !important;
	}

	[dir="rtl"] .mp-ai-chat-root {
		left: 18px !important;
		right: auto !important;
	}

	.mp-ai-chat-toggle {
		width: 58px;
		height: 58px;
	}

	.mp-ai-chat-toggle__icon {
		font-size: 28px;
	}

	.mp-ai-chat-panel {
		bottom: 86px;
		left: 14px !important;
		right: 14px !important;
		width: calc(100vw - 28px) !important;
		max-width: 100vw;
		height: calc(100vh - 110px);
		max-height: 82vh;
		border-radius: 20px;
	}

	[dir="rtl"] .mp-ai-chat-panel {
		left: 14px !important;
		right: 14px !important;
	}
}

@media (max-width: 480px) {
	.mp-ai-chat-panel {
		bottom: 12px;
		left: 10px !important;
		right: 10px !important;
		width: calc(100vw - 20px) !important;
		height: calc(100vh - 24px);
		max-height: calc(100vh - 24px);
		border-radius: 18px;
	}

	[dir="rtl"] .mp-ai-chat-panel {
		left: 10px !important;
		right: 10px !important;
	}

	.mp-ai-chat-root.is-open .mp-ai-chat-toggle {
		display: none; /* Hide floating button when full-screen modal opens on mobile */
	}

	.mp-ai-chat-header {
		padding: 14px 16px;
	}

	.mp-ai-chat-body {
		padding: 14px 12px;
	}

	.mp-ai-bubble {
		font-size: 0.88rem;
		padding: 10px 14px;
	}
}
