/* =====================================================
   Mahi AI Chatbot — Premium Skincare UI
   Version: 1.0.0
   ===================================================== */

:root {
	--mahi-primary: #8B7355;
	--mahi-primary-dark: #7a6449;
	--mahi-primary-light: rgba(139, 115, 85, 0.12);
	--mahi-bg: #FDFAF7;
	--mahi-surface: #FFFFFF;
	--mahi-surface-2: #F7F3EE;
	--mahi-border: #EAE4DC;
	--mahi-text: #2D2420;
	--mahi-text-muted: #8A7F76;
	--mahi-text-light: #B5ADA5;
	--mahi-user-bubble: #8B7355;
	--mahi-bot-bubble: #FFFFFF;
	--mahi-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
	--mahi-shadow-md: 0 8px 32px rgba(0, 0, 0, 0.10);
	--mahi-shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.14);
	--mahi-radius: 20px;
	--mahi-radius-sm: 12px;
	--mahi-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
	--mahi-transition: cubic-bezier(0.4, 0, 0.2, 1);
	--mahi-window-width: 500px;
	--mahi-window-height: 650px;
}

/* =====================================================
   THEME RESET — SVG & BUTTON NORMALIZATION
   Overrides common theme rules that hide or collapse SVGs
   ===================================================== */

#mahi-chatbot-wrapper svg {
	display: inline-block !important;
	visibility: visible !important;
	overflow: visible !important;
	max-width: none !important;
	max-height: none !important;
	width: auto;
	height: auto;
	pointer-events: none;
	flex-shrink: 0;
}

#mahi-chat-toggle svg,
.mahi-header-close svg,
#mahi-send-btn svg {
	display: block !important;
}

#mahi-chat-toggle,
.mahi-header-close,
#mahi-send-btn {
	-webkit-appearance: none;
	appearance: none;
	line-height: 1;
}

/* =====================================================
   WRAPPER & POSITIONING
   ===================================================== */

#mahi-chatbot-wrapper {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 999999;
	font-family: var(--mahi-font);
	font-size: 15px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 12px;
}

/* =====================================================
   WHATSAPP FLOATING BUTTON
   ===================================================== */

#mahi-whatsapp-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: #25D366;
	box-shadow: 0 4px 18px rgba(37, 211, 102, 0.40), 0 1px 4px rgba(0, 0, 0, 0.12);
	color: #ffffff;
	text-decoration: none;
	flex-shrink: 0;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#mahi-whatsapp-btn:hover {
	transform: scale(1.10);
	box-shadow: 0 6px 24px rgba(37, 211, 102, 0.55), 0 2px 6px rgba(0, 0, 0, 0.14);
}

#mahi-whatsapp-btn svg {
	display: block !important;
	width: 26px !important;
	height: 26px !important;
}

/* =====================================================
   TOGGLE BUTTON
   ===================================================== */

#mahi-chat-toggle {
	position: relative;
	height: 48px;
	border-radius: 28px;
	padding: 0 18px 0 14px;
	width: auto;
	background: var(--mahi-primary);
	background: linear-gradient(135deg, var(--mahi-primary) 0%, var(--mahi-primary-dark) 100%);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0;
	box-shadow: 0 4px 18px rgba(139, 115, 85, 0.42), 0 1px 4px rgba(0, 0, 0, 0.10);
	transition: transform 0.2s var(--mahi-transition),
	            box-shadow 0.2s var(--mahi-transition),
	            opacity 0.2s ease;
	color: #ffffff;
	outline: none;
	margin-left: auto;
}

#mahi-chat-toggle.is-chat-open {
	opacity: 0;
	pointer-events: none;
	transform: translateY(6px) scale(0.95);
}

#mahi-chat-toggle:hover {
	background: var(--mahi-primary-dark);
	transform: translateY(-2px);
	box-shadow: 0 8px 24px rgba(139, 115, 85, 0.48), 0 2px 6px rgba(0, 0, 0, 0.12);
}

#mahi-chat-toggle:active {
	transform: translateY(0) scale(0.97);
}

#mahi-chat-toggle:focus-visible {
	outline: 3px solid var(--mahi-primary);
	outline-offset: 3px;
}

.mahi-toggle-inner {
	display: flex;
	align-items: center;
	gap: 8px;
}

.mahi-toggle-svg-wrap {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	flex-shrink: 0;
}

.mahi-toggle-text {
	font-size: 13.5px;
	font-weight: 600;
	letter-spacing: -0.01em;
	white-space: nowrap;
	line-height: 1;
}

.mahi-notification-dot {
	position: absolute;
	top: 4px;
	right: 4px;
	width: 10px;
	height: 10px;
	background: #E76F51;
	border-radius: 50%;
	border: 2px solid #fff;
	animation: mahi-pulse 2.5s ease-in-out infinite;
}

.mahi-notification-dot.hidden {
	display: none;
}

@keyframes mahi-pulse {
	0%, 100% { transform: scale(1); opacity: 1; }
	50% { transform: scale(1.2); opacity: 0.8; }
}

/* =====================================================
   CHAT WINDOW
   ===================================================== */

#mahi-chat-window {
	position: absolute;
	bottom: 5px;
	right: 0;
	width: var(--mahi-window-width);
	height: var(--mahi-window-height);
	background: var(--mahi-bg);
	border-radius: var(--mahi-radius);
	box-shadow: var(--mahi-shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.04);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
	transform: scale(0.92) translateY(10px);
	opacity: 0;
	pointer-events: none;
	transition: transform 0.28s var(--mahi-transition),
	            opacity 0.25s var(--mahi-transition);
	will-change: transform, opacity;
}

#mahi-chat-window.is-open {
	transform: scale(1) translateY(0);
	opacity: 1;
	pointer-events: all;
}

/* =====================================================
   HEADER
   ===================================================== */

.mahi-chat-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 18px;
	background: var(--mahi-primary);
	background: linear-gradient(135deg, var(--mahi-primary) 0%, var(--mahi-primary-dark) 100%);
	flex-shrink: 0;
}

.mahi-header-avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.20);
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	flex-shrink: 0;
}

.mahi-header-info {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.mahi-header-name {
	font-size: 15px;
	font-weight: 700;
	color: #ffffff;
	letter-spacing: -0.01em;
}

.mahi-header-status {
	font-size: 11.5px;
	color: rgba(255, 255, 255, 0.82);
	display: flex;
	align-items: center;
	gap: 5px;
}

.mahi-status-dot {
	width: 6px;
	height: 6px;
	background: #A8E6CF;
	border-radius: 50%;
	animation: mahi-status-blink 2.5s ease-in-out infinite;
}

@keyframes mahi-status-blink {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.5; }
}

.mahi-header-close {
	background: rgba(255, 255, 255, 0.15);
	border: none;
	border-radius: var(--btn-brd-radius, 22px) !important;
	width: 30px;
	height: 30px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: rgba(255, 255, 255, 0.90);
	transition: background 0.15s ease;
	flex-shrink: 0;
	
}

.mahi-header-close:hover {
	background: rgba(255, 255, 255, 0.25);
	color: #fff;
}

/* =====================================================
   MESSAGES AREA
   ===================================================== */

.mahi-messages {
	flex: 1;
	overflow-y: auto;
	padding: 18px 14px 10px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	scroll-behavior: smooth;
}

.mahi-messages::-webkit-scrollbar {
	width: 4px;
}

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

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

/* Message Rows */
.mahi-message-row {
	display: flex;
	flex-direction: column;
	gap: 6px;
	animation: mahi-msg-in 0.28s var(--mahi-transition) both;
}

@keyframes mahi-msg-in {
	from { opacity: 0; transform: translateY(8px); }
	to { opacity: 1; transform: translateY(0); }
}

.mahi-message-row.is-user {
	align-items: flex-end;
}

.mahi-message-row.is-bot {
	align-items: flex-start;
}

/* Bubbles */
.mahi-bubble {
	max-width: 82%;
	padding: 10px 14px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.6;
	word-break: break-word;
}

.mahi-message-row.is-user .mahi-bubble {
	background: var(--mahi-user-bubble);
	color: #ffffff;
	border-bottom-right-radius: 4px;
}

.mahi-message-row.is-bot .mahi-bubble {
	background: var(--mahi-bot-bubble);
	color: var(--mahi-text);
	border-bottom-left-radius: 4px;
	box-shadow: var(--mahi-shadow-sm), 0 0 0 1px var(--mahi-border);
}

.mahi-bubble p {
	margin: 0 0 6px;
}

.mahi-bubble p:last-child {
	margin-bottom: 0;
}

.mahi-bubble strong {
	font-weight: 600;
}

/* Timestamp */
.mahi-msg-time {
	font-size: 11px;
	color: var(--mahi-text-light);
	padding: 0 4px;
}

/* =====================================================
   TYPING INDICATOR
   ===================================================== */

.mahi-typing-row {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	animation: mahi-msg-in 0.2s ease both;
}

.mahi-typing-bubble {
	background: var(--mahi-bot-bubble);
	border-radius: 16px;
	border-bottom-left-radius: 4px;
	padding: 12px 16px;
	box-shadow: var(--mahi-shadow-sm), 0 0 0 1px var(--mahi-border);
	display: flex;
	gap: 5px;
	align-items: center;
}

.mahi-typing-dot {
	width: 7px;
	height: 7px;
	background: var(--mahi-primary);
	border-radius: 50%;
	animation: mahi-typing 1.3s ease-in-out infinite;
	opacity: 0.7;
}

.mahi-typing-dot:nth-child(1) { animation-delay: 0s; }
.mahi-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.mahi-typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes mahi-typing {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
	30% { transform: translateY(-5px); opacity: 1; }
}

/* =====================================================
   INLINE SUGGESTION CHIPS (in-conversation recovery chips)
   ===================================================== */

.mahi-inline-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	margin-top: 10px;
	padding-top: 4px;
}

.mahi-inline-chip {
	background: var(--mahi-surface);
	border: 1.5px solid var(--mahi-border);
	border-radius: 20px;
	padding: 5px 13px;
	font-size: 12px;
	font-weight: 500;
	color: var(--mahi-text-muted);
	cursor: pointer;
	font-family: var(--mahi-font);
	line-height: 1.4;
	white-space: nowrap;
	transition: background 0.15s ease, color 0.15s ease,
	            border-color 0.15s ease, transform 0.12s ease,
	            box-shadow 0.15s ease;
	box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.mahi-inline-chip:hover {
	background: var(--mahi-primary-light);
	border-color: var(--mahi-primary);
	color: var(--mahi-primary-dark);
	transform: translateY(-1px);
	box-shadow: 0 3px 8px rgba(139, 115, 85, 0.18);
}

.mahi-inline-chip:active {
	transform: translateY(0);
	box-shadow: none;
}

/* =====================================================
   RETRY BUTTON (shown below error messages)
   ===================================================== */

.mahi-retry-btn {
	display: inline-block;
	margin-top: 10px;
	padding: 6px 18px;
	background: transparent;
	border: 1.5px solid var(--mahi-primary);
	border-radius: 20px;
	color: var(--mahi-primary);
	font-size: 12px;
	font-weight: 600;
	font-family: var(--mahi-font);
	cursor: pointer;
	letter-spacing: 0.3px;
	transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.mahi-retry-btn:hover {
	background: var(--mahi-primary);
	color: #fff;
	transform: translateY(-1px);
}

.mahi-retry-btn:active {
	transform: translateY(0);
}

/* =====================================================
   PRODUCT CARDS
   ===================================================== */

.mahi-product-cards {
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-width: 100%;
	margin-top: 4px;
}

.mahi-product-card {
	background: var(--mahi-surface);
	border-radius: var(--mahi-radius-sm);
	border: 1px solid var(--mahi-border);
	overflow: hidden;
	display: flex;
	align-items: stretch;
	text-decoration: none;
	color: inherit;
	transition: transform 0.18s ease, box-shadow 0.18s ease;
	box-shadow: var(--mahi-shadow-sm);
	animation: mahi-msg-in 0.3s var(--mahi-transition) both;
}

.mahi-product-card:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 20px rgba(139, 115, 85, 0.15);
	border-color: var(--mahi-primary);
	text-decoration: none;
	color: inherit;
}

.mahi-product-card-img-wrap {
	width: 80px;
	height: 80px;
	flex-shrink: 0;
	overflow: hidden;
	background: var(--mahi-surface-2);
	position: relative;
}

.mahi-product-card-img-wrap img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.3s ease;
}

.mahi-product-card:hover .mahi-product-card-img-wrap img {
	transform: scale(1.05);
}

.mahi-product-card-body {
	flex: 1;
	padding: 10px 12px;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	gap: 6px;
	min-width: 0;
}

.mahi-product-card-name {
	font-size: 13px;
	font-weight: 600;
	color: var(--mahi-text);
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	line-clamp: 2;
	overflow: hidden;
}

.mahi-product-card-bottom {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 6px;
}

.mahi-product-card-price {
	font-size: 13px;
	font-weight: 700;
	color: var(--mahi-primary);
}

.mahi-product-card-price ins {
	text-decoration: none;
}

.mahi-product-card-price del {
	opacity: 0.55;
	font-weight: 400;
	font-size: 11px;
}

.mahi-product-card-cta {
	font-size: 11.5px;
	font-weight: 600;
	color: var(--mahi-primary);
	background: var(--mahi-primary-light);
	border: 1px solid rgba(139, 115, 85, 0.20);
	border-radius: 6px;
	padding: 4px 10px;
	white-space: nowrap;
	transition: background 0.15s ease, color 0.15s ease;
	flex-shrink: 0;
}

.mahi-product-card:hover .mahi-product-card-cta {
	background: var(--mahi-primary);
	color: #fff;
	border-color: var(--mahi-primary);
}

.mahi-sale-badge {
	position: absolute;
	top: 6px;
	left: 6px;
	background: #E76F51;
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	padding: 2px 6px;
	border-radius: 4px;
	letter-spacing: 0.04em;
}

/* =====================================================
   QUICK REPLIES
   ===================================================== */

.mahi-quick-replies {
	padding: 10px 14px 12px;
	display: flex;
	flex-wrap: nowrap;
	gap: 7px;
	flex-shrink: 0;
	border-top: 1px solid var(--mahi-border);
	background: var(--mahi-bg);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

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

.mahi-quick-replies.is-hidden {
	display: none;
}

.mahi-quick-reply {
	scroll-snap-align: start;
	flex-shrink: 0;
	background: var(--mahi-surface);
	border: 1.5px solid var(--mahi-border);
	border-radius: 20px;
	padding: 6px 13px;
	font-size: 12.5px;
	font-weight: 500;
	color: var(--mahi-text-muted);
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease,
	            border-color 0.15s ease, transform 0.12s ease,
	            box-shadow 0.15s ease;
	font-family: var(--mahi-font);
	line-height: 1.4;
	white-space: nowrap;
	box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.mahi-quick-reply:hover {
	background: var(--mahi-primary-light);
	border-color: var(--mahi-primary);
	color: var(--mahi-primary-dark);
	transform: translateY(-1px);
	box-shadow: 0 3px 8px rgba(139, 115, 85, 0.18);
}

.mahi-quick-reply:active {
	transform: translateY(0);
	box-shadow: none;
}

/* =====================================================
   INPUT AREA
   ===================================================== */

.mahi-chat-footer {
	padding: 10px 14px 12px;
	background: var(--mahi-surface);
	border-top: 1px solid var(--mahi-border);
	flex-shrink: 0;
}

.mahi-input-wrap {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	background: var(--mahi-surface-2);
	border: 1.5px solid var(--mahi-border);
	border-radius: 14px;
	padding: 8px 8px 8px 14px;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.mahi-input-wrap:focus-within {
	border-color: var(--mahi-primary);
	box-shadow: 0 0 0 3px rgba(139, 115, 85, 0.12);
}

#mahi-user-input {
	flex: 1;
	border: none;
	background: transparent;
	font-family: var(--mahi-font);
	font-size: 14px;
	color: var(--mahi-text);
	resize: none;
	outline: none;
	min-height: 22px;
	max-height: 100px;
	line-height: 1.5;
}

#mahi-user-input::placeholder {
	color: var(--mahi-text-light);
}

#mahi-send-btn {
	width: 34px;
	height: 34px;
	border-radius: 10px;
	background: var(--mahi-primary);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #ffffff;
	transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
	flex-shrink: 0;
}

#mahi-send-btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
	transform: none;
}

#mahi-send-btn:not(:disabled):hover {
	background: var(--mahi-primary-dark);
	transform: translateY(-1px);
}

#mahi-send-btn:not(:disabled):active {
	transform: translateY(0) scale(0.95);
}

.mahi-footer-note {
	text-align: center;
	font-size: 10.5px;
	color: var(--mahi-text-light);
	margin: 7px 0 0;
	letter-spacing: 0.01em;
}

/* =====================================================
   ERROR MESSAGE
   ===================================================== */

.mahi-error-bubble {
	background: #FFF5F5;
	border: 1px solid #FED7D7;
	color: #C53030;
	border-radius: 12px;
	padding: 10px 14px;
	font-size: 13px;
	max-width: 85%;
}

/* =====================================================
   MOBILE RESPONSIVE
   ===================================================== */

@media (max-width: 540px) {
	#mahi-chatbot-wrapper {
		bottom: 60px;
		right: 16px;
	}

	#mahi-chat-window {
		position: fixed;
		bottom: 0;
		right: 0;
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
		border-radius: 0;
		transform-origin: bottom center;
	}

	#mahi-chat-window.is-open {
		transform: scale(1) translateY(0);
	}

	.mahi-chat-header {
		padding-top: max(16px, env(safe-area-inset-top));
	}

	.mahi-chat-footer {
		padding-bottom: max(12px, env(safe-area-inset-bottom));
	}
}

@media (max-width: 360px) {
	.mahi-quick-reply {
		font-size: 11px;
		padding: 4px 10px;
	}
}

/* =====================================================
   REDUCED MOTION
   ===================================================== */

@media (prefers-reduced-motion: reduce) {
	#mahi-chat-window,
	.mahi-message-row,
	.mahi-product-card,
	#mahi-chat-toggle {
		transition: none;
		animation: none;
	}

	.mahi-notification-dot,
	.mahi-status-dot,
	.mahi-typing-dot {
		animation: none;
	}
}
