/* ===============================
   CSS VARIABLES
================================ */
:root {
	--chat-widget-brand: #2db5fa;
	--chat-widget-brand-dark: #199adf;
	--chat-widget-bg-light: #f6f9fc;
	--chat-widget-text-dark: #1f2937;
	--chat-widget-shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3);
	--chat-widget-shadow-md: 0 6px 16px rgba(0, 0, 0, 0.08);
	--chat-widget-shadow-lg: 0 10px 22px rgba(0, 0, 0, 0.12);
	--chat-widget-shadow-xl: 0 12px 30px rgba(0, 0, 0, 0.75);
	--chat-widget-shadow-2xl: 0 20px 40px rgba(0, 0, 0, 0.25);
	--chat-widget-border-color: #e5e7eb;
	--chat-widget-card-bg: #f9fafb;
	--chat-widget-whatsapp: #25D366;
	--chat-widget-whatsapp-hover: #20BA5A;
	--chat-widget-code-bg: #f3f4f6;
	--chat-widget-code-color: #dc2626;
	--chat-widget-badge-blue: #2563eb;
}

/* ===============================
   RESET (IFRAME & SITE SAFE)
================================ */
.chat-launcher,
.chat-widget,
.chat-widget * {
	box-sizing: border-box;
	font-family: "Inter", system-ui, -apple-system, sans-serif;
}

/* ===============================
   FLOATING CHAT LAUNCHER
================================ */
.chat-launcher {
	position: fixed;
	bottom: 8%;
	right: 24px;
	width: 56px;
	height: 56px;
	background: var(--chat-widget-bg-light);
	color: #fff;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: var(--chat-widget-shadow-xl);
	z-index: 9999;
	overflow: visible;
}

.chat-launcher-icon {
	width: 32px;
	height: 32px;
	object-fit: contain;
}

.chat-badge {
	position: absolute;
	top: -6px;
	right: -6px;
	width: 24px;
	height: 24px;
	background: var(--chat-widget-badge-blue);
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	padding: 3px 6px;
	border-radius: 12px;
	border: 2px solid #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
	box-shadow: var(--chat-widget-shadow-sm);
	z-index: 10000;
}

/* ===============================
   CHAT WIDGET
================================ */
.chat-widget {
	position: fixed;
	bottom: 90px;
	right: 24px;
	width: 340px;
	height: 550px;
	background: #fff;
	border-radius: 16px;
	overflow: hidden;
	box-shadow: var(--chat-widget-shadow-2xl);
	display: flex;
	flex-direction: column;
	z-index: 9999;
	animation: slideUp 0.25s ease;
	transition: opacity 0.25s ease, transform 0.25s ease;
}

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

.chat-widget-closing {
	opacity: 0;
	transform: translateY(20px);
	pointer-events: none;
}

/* ===============================
   HEADER
================================ */
.chat-widget .chat-header {
	background: linear-gradient(135deg, var(--chat-widget-brand), var(--chat-widget-brand-dark));
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.chat-widget .chat-title {
	display: flex;
	gap: 10px;
	align-items: center;
}

.chat-widget .chat-title strong {
	font-size: 14px;
}

.chat-widget .chat-title small {
	display: block;
	opacity: 0.85;
	font-size: 12px;
}

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

.chat-widget .chat-logo img {
	width: 24px;
	height: 24px;
	object-fit: contain;
}

.chat-widget .chat-actions {
	display: flex;
	align-items: center;
}

.chat-widget .chat-close {
	background: transparent;
	border: none;
	padding: 4px;
	cursor: pointer;
	color: rgba(255, 255, 255, 0.9);
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 4px;
	transition: background-color 0.2s ease, color 0.2s ease;
	width: 32px;
	height: 32px;
}

.chat-widget .chat-close:hover {
	background: rgba(255, 255, 255, 0.1);
	color: #fff;
}

.chat-widget .chat-close:active {
	background: rgba(255, 255, 255, 0.2);
}

.chat-widget .chat-close svg {
	width: 20px;
	height: 20px;
}

/* ===============================
   BODY
================================ */
.chat-widget .chat-body {
	padding: 16px;
	background: var(--chat-widget-bg-light);
	flex: 1;
	height: 400px;
	overflow-x: hidden;
	overflow-y: auto;
	scroll-behavior: smooth;
}

/* ===============================
   MESSAGES
================================ */
.chat-widget .bot-message {
	display: flex;
	gap: 10px;
	margin: 7px 0;
}

.chat-widget .bot-avatar {
	width: 32px;
	height: 32px;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.chat-widget .bot-avatar img {
	width: 28px;
	height: 28px;
	object-fit: contain;
	border-radius: 50%;
}

.chat-widget .bot-bubble {
	max-width: 80%;
	background: #fff;
	padding: 10px 14px;
	border-radius: 14px;
	box-shadow: var(--chat-widget-shadow-md);
	font-size: 14px;
	color: var(--chat-widget-text-dark);
	line-height: 1.5;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

.chat-widget .bot-bubble strong {
	font-weight: 600;
	color: var(--chat-widget-text-dark);
}

.chat-widget .bot-bubble em {
	font-style: italic;
}

.chat-widget .bot-bubble code {
	background: var(--chat-widget-code-bg);
	color: var(--chat-widget-code-color);
	padding: 2px 6px;
	border-radius: 4px;
	font-family: 'Courier New', monospace;
	font-size: 13px;
}

/* Typography */
.chat-widget .bot-bubble h1,
.chat-widget .bot-bubble h2,
.chat-widget .bot-bubble h3,
.chat-widget .bot-bubble h4,
.chat-widget .bot-bubble h5,
.chat-widget .bot-bubble h6 {
	margin: 12px 0 8px 0;
	font-weight: 600;
	color: var(--chat-widget-text-dark);
	line-height: 1.3;
}

.chat-widget .bot-bubble h1 { font-size: 18px; }
.chat-widget .bot-bubble h2 { font-size: 16px; }
.chat-widget .bot-bubble h3 { font-size: 15px; }
.chat-widget .bot-bubble h4 { font-size: 14px; }
.chat-widget .bot-bubble h5 { font-size: 13px; }
.chat-widget .bot-bubble h6 { font-size: 12px; }

.chat-widget .bot-bubble p {
	margin: 8px 0;
	font-size: 12px;
	line-height: 1.5;
}

.chat-widget .bot-bubble ul,
.chat-widget .bot-bubble ol {
	margin: 8px 0;
	padding-left: 20px;
	font-size: 12px;
	line-height: 1.6;
}

.chat-widget .bot-bubble li {
	margin: 4px 0;
	font-size: 12px;
	list-style: disc;
}

.chat-widget .bot-bubble ul ul,
.chat-widget .bot-bubble ol ol {
	margin: 4px 0;
	padding-left: 20px;
}

/* Cards */
.chat-widget .bot-bubble .chat-product-card,
.chat-widget .bot-bubble .plan-card {
	margin: 12px 0;
	padding: 12px;
	background: var(--chat-widget-card-bg);
	border: 1px solid var(--chat-widget-border-color);
	border-radius: 8px;
}

/* Buttons */
.chat-widget .read-more-btn {
	margin-top: 8px;
	padding: 6px 12px;
	background: var(--chat-widget-brand);
	color: #fff;
	border: none;
	border-radius: 6px;
	font-size: 12px;
	font-weight: 500;
	cursor: pointer;
	transition: background 0.2s ease;
}

.chat-widget .read-more-products-btn,
.chat-widget .read-more-pricing-btn {
	display: inline-block;
	margin-top: 12px;
	padding: 8px 16px;
	background: var(--chat-widget-brand);
	color: #fff;
	border: none;
	border-radius: 8px;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	text-decoration: none;
	transition: background 0.2s ease;
}

.chat-widget .read-more-products-btn:hover,
.chat-widget .read-more-pricing-btn:hover {
	background: var(--chat-widget-brand-dark);
	color: #fff;
}

.chat-widget .bot-bubble .whatsapp-support-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin-top: 12px;
	padding: 10px 16px;
	background: var(--chat-widget-whatsapp);
	color: #fff;
	border: none;
	border-radius: 8px;
	font-size: 12px;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
	transition: background 0.2s ease;
}

.chat-widget .bot-bubble .whatsapp-support-btn:hover {
	background: var(--chat-widget-whatsapp-hover);
}

.chat-widget .message-content {
	margin-bottom: 0;
}

.chat-widget .bot-bubble > div {
	margin-bottom: 0;
}

/* Video */
.chat-widget .video-preview {
	margin-top: 12px;
	border-radius: 12px;
	overflow: hidden;
	background: #000;
}

.chat-widget .video-preview iframe {
	width: 100%;
	height: 200px;
	border: 0;
}

/* ===============================
   THINKING ANIMATION
================================ */
.chat-widget .thinking-bubble {
	min-width: 60px;
	padding: 12px 16px;
}

.chat-widget .thinking-animation {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
}

.chat-widget .thinking-animation span {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--chat-widget-brand);
	animation: thinking-bounce 1.4s infinite ease-in-out;
	animation-fill-mode: both;
}

.chat-widget .thinking-animation span:nth-child(1) {
	animation-delay: -0.32s;
}

.chat-widget .thinking-animation span:nth-child(2) {
	animation-delay: -0.16s;
}

.chat-widget .thinking-animation span:nth-child(3) {
	animation-delay: 0;
}

@keyframes thinking-bounce {
	0%, 80%, 100% {
		transform: scale(0.8);
		opacity: 0.5;
	}
	40% {
		transform: scale(1.2);
		opacity: 1;
	}
}

/* ===============================
   QUICK ACTIONS
================================ */
.chat-widget .quick-actions {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
	margin-top: 10px;
}

.chat-widget .quick-actions button {
	border: none;
	background: #fff;
	padding: 10px;
	border-radius: 12px;
	font-size: 12px;
	cursor: pointer;
	box-shadow: var(--chat-widget-shadow-md);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.chat-widget .quick-actions button:hover {
	transform: translateY(-2px);
	box-shadow: var(--chat-widget-shadow-lg);
}

/* ===============================
   FOOTER
================================ */
.chat-widget .chat-footer {
	display: flex;
	gap: 10px;
	padding: 12px;
	background: #fff;
	border-top: 1px solid var(--chat-widget-border-color);
}

.chat-widget .chat-footer input {
	flex: 1;
	border: 1px solid var(--chat-widget-border-color);
	border-radius: 20px;
	padding: 10px 14px;
	font-size: 12px;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}

.chat-widget .chat-footer input:focus {
	border-color: var(--chat-widget-brand);
}

.chat-widget .send-btn {
	width: 40px;
	height: 40px;
	background: var(--chat-widget-brand);
	color: #fff;
	border: none;
	border-radius: 50%;
	font-size: 16px;
	cursor: pointer;
}

/* ===============================
   MOBILE (FULL SCREEN)
================================ */
@media (max-width: 640px) {
	.chat-widget {
		width: 100%;
		height: 100vh;
		height: var(--chat-widget-vh, 100vh);
		height: 100dvh;
		right: 0;
		bottom: 0;
		border-radius: 0;
		max-height: none;
		position: fixed;
		top: 0;
		left: 0;
	}

	.chat-widget .chat-body {
		flex: 1;
		min-height: 0;
		height: auto;
		padding-bottom: 8px;
		max-height: calc(var(--chat-widget-vh, 100vh) - 140px);
		max-height: calc(100dvh - 140px);
		overflow-y: auto;
		overflow-x: hidden;
		-webkit-overflow-scrolling: touch;
	}

	.chat-widget .chat-footer {
		flex-shrink: 0;
		padding: 12px;
		padding-bottom: max(12px, env(safe-area-inset-bottom));
		background: #fff;
		border-top: 1px solid var(--chat-widget-border-color);
		position: sticky;
		bottom: 0;
		width: 100%;
		z-index: 10;
	}

	.chat-widget .chat-footer input {
		font-size: 16px;
		min-height: 44px;
	}

	.chat-launcher {
		bottom: 16px;
		right: 16px;
		bottom: max(16px, env(safe-area-inset-bottom));
	}
}

@supports (-webkit-touch-callout: none) {
	@media (max-width: 640px) {
		.chat-widget {
			height: -webkit-fill-available;
		}

		.chat-widget .chat-body {
			max-height: calc(-webkit-fill-available - 140px);
		}
	}
}
