.smart-cta-widget {
	--smart-cta-primary: #1f9d55;
	--smart-cta-primary-dark: #14763f;
	--smart-cta-accent: #f97316;
	--smart-cta-text: #12212e;
	--smart-cta-muted: #596579;
	--smart-cta-surface: #ffffff;
	--smart-cta-border: rgba(18, 33, 46, 0.08);
	--smart-cta-shadow: 0 24px 70px rgba(18, 33, 46, 0.2);
	position: fixed;
	right: 18px;
	bottom: 18px;
	z-index: 9999;
	font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

[dir="rtl"] .smart-cta-widget {
	right: auto;
	left: 18px;
}

.smart-cta-widget *,
.smart-cta-widget *::before,
.smart-cta-widget *::after {
	box-sizing: border-box;
}

/* ── Trigger ── */
.smart-cta-widget__trigger {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 58px;
	padding: 0 18px 0 16px;
	border: 0;
	border-radius: 999px;
	background: linear-gradient(135deg, var(--smart-cta-primary), #25d366);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 18px 38px rgba(31, 157, 85, 0.34);
	transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.smart-cta-widget__trigger:hover,
.smart-cta-widget__trigger:focus-visible {
	transform: translateY(-2px);
	box-shadow: 0 24px 44px rgba(31, 157, 85, 0.4);
	outline: none;
}

.smart-cta-widget__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	flex-shrink: 0;
}

.smart-cta-widget__icon svg {
	width: 28px;
	height: 28px;
	fill: currentColor;
}

.smart-cta-widget__label {
	font-size: 14px;
	font-weight: 700;
	line-height: 1;
}

.smart-cta-widget__badge {
	position: absolute;
	top: -4px;
	right: -4px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border: 2px solid #fff;
	border-radius: 999px;
	background: var(--smart-cta-accent);
	color: #fff;
	font-size: 12px;
	font-weight: 700;
}

[dir="rtl"] .smart-cta-widget__badge {
	right: auto;
	left: -4px;
}

/* ── Popup (desktop default) ── */
.smart-cta-widget__popup {
	position: absolute;
	right: 0;
	bottom: 76px;
	width: min(360px, calc(100vw - 24px));
	max-width: calc(100vw - 24px);
	max-height: min(78vh, 620px);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: 22px 20px 18px;
	border: 1px solid var(--smart-cta-border);
	border-radius: 24px;
	background:
		radial-gradient(circle at top right, rgba(37, 211, 102, 0.12), transparent 28%),
		radial-gradient(circle at top left, rgba(249, 115, 22, 0.12), transparent 22%),
		var(--smart-cta-surface);
	box-shadow: var(--smart-cta-shadow);
	color: var(--smart-cta-text);
	opacity: 0;
	transform: translateY(12px) scale(0.96);
	pointer-events: none;
	transition: opacity 0.24s ease, transform 0.24s ease;
}

[dir="rtl"] .smart-cta-widget__popup {
	right: auto;
	left: 0;
}

/* Desktop open state */
.chat-popup.active,
.smart-cta-widget.is-open .smart-cta-widget__popup {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

/* Swipe handle — hidden on desktop */
.smart-cta-widget__swipe-handle {
	display: none;
	width: 36px;
	height: 4px;
	margin: 0 auto 14px;
	border-radius: 999px;
	background: rgba(18, 33, 46, 0.15);
}

/* ── Close ── */
.smart-cta-widget__close {
	position: absolute;
	top: 12px;
	right: 12px;
	width: 34px;
	height: 34px;
	border: 0;
	border-radius: 999px;
	background: rgba(18, 33, 46, 0.06);
	color: var(--smart-cta-text);
	cursor: pointer;
	font-size: 24px;
	line-height: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.smart-cta-widget__close:hover,
.smart-cta-widget__close:focus-visible {
	background: rgba(18, 33, 46, 0.12);
	outline: none;
}

[dir="rtl"] .smart-cta-widget__close {
	right: auto;
	left: 12px;
}

/* ── Content ── */
.smart-cta-widget__eyebrow {
	margin-bottom: 10px;
	color: var(--smart-cta-primary-dark);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.smart-cta-widget__title {
	margin: 0 28px 10px 0;
	font-size: 24px;
	line-height: 1.15;
}

[dir="rtl"] .smart-cta-widget__title {
	margin: 0 0 10px 28px;
}

.smart-cta-widget__message {
	color: var(--smart-cta-muted);
	font-size: 15px;
	line-height: 1.6;
}

.smart-cta-widget__message p {
	margin: 0;
}

/* ── Actions ── */
.smart-cta-widget__actions {
	display: grid;
	gap: 10px;
	margin-top: 18px;
}

.smart-cta-widget__action {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	padding: 12px 16px;
	border: 0;
	border-radius: 14px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.3;
	text-align: center;
	text-decoration: none;
	transition: transform 0.2s ease, background-color 0.2s ease;
	word-break: break-word;
}

.smart-cta-widget__action:hover,
.smart-cta-widget__action:focus-visible {
	transform: translateY(-1px);
	outline: none;
}

.smart-cta-widget__action--primary {
	background: linear-gradient(135deg, var(--smart-cta-primary), #25d366);
	color: #fff;
}

.smart-cta-widget__action--secondary {
	background: #effaf3;
	color: var(--smart-cta-primary-dark);
}

.smart-cta-widget__action--ghost {
	background: rgba(18, 33, 46, 0.06);
	color: var(--smart-cta-text);
}

/* ════════════════════════════════════════
   MOBILE  ≤ 640px
   كل حاجة هنا بتـ override الـ desktop
   ════════════════════════════════════════ */
@media (max-width: 640px) {

	/* الـ widget container: دايرة صغيرة في اليمين */
	.smart-cta-widget {
		right: 16px !important;
		left: auto !important;
		bottom: 16px !important;
		width: 60px !important;
		height: 60px !important;
	}

	[dir="rtl"] .smart-cta-widget {
		right: auto !important;
		left: 16px !important;
	}

	/* الزر: دايري 60×60 بس — بنـ override أي width جاي من الـ theme */
	.smart-cta-widget__trigger {
		width: 60px !important;
		max-width: 60px !important;
		min-width: 60px !important;
		height: 60px !important;
		min-height: 60px !important;
		padding: 0 !important;
		justify-content: center !important;
		flex: 0 0 60px !important;
		align-self: auto !important;
	}

	/* إخفاء النص، تكبير الأيقونة */
	.smart-cta-widget__label {
		display: none !important;
	}

	.smart-cta-widget__icon {
		width: 34px !important;
		height: 34px !important;
	}

	.smart-cta-widget__icon svg {
		width: 34px !important;
		height: 34px !important;
	}

	/* الـ popup: bottom-sheet يطلع من تحت */
	.smart-cta-widget__popup {
		position: fixed !important;
		right: 0 !important;
		left: 0 !important;
		bottom: 0 !important;
		top: auto !important;
		width: 100% !important;
		max-width: 100% !important;
		max-height: 85vh !important;
		border-radius: 20px 20px 0 0 !important;
		padding: 8px 16px 24px !important;
		padding-bottom: max(24px, env(safe-area-inset-bottom)) !important;
		/* مخفي: ينزل لتحت الشاشة */
		opacity: 1 !important;
		transform: translateY(100%) !important;
		transition: transform 0.3s ease !important;
	}

	/* مفتوح: يصعد للشاشة */
	.smart-cta-widget.is-open .smart-cta-widget__popup,
	.chat-popup.active {
		transform: translateY(0) !important;
		pointer-events: auto !important;
	}

	.smart-cta-widget__swipe-handle {
		display: block !important;
	}

	.smart-cta-widget__title {
		font-size: 21px;
	}

	.smart-cta-widget__message {
		font-size: 14px;
	}

	.smart-cta-widget__action {
		min-height: 52px;
		font-size: 15px;
	}
}

@media (max-width: 360px) {
	.smart-cta-widget__action {
		font-size: 13px;
		padding: 10px 12px;
	}
}

/* High-specificity override — يمنع أي theme من يـ override الـ FAB على الموبايل */
@media (max-width: 640px) {
	.smart-cta-widget.smart-cta-widget {
		position: fixed !important;
		right: 16px !important;
		left: auto !important;
		bottom: 16px !important;
		width: 60px !important;
		height: 60px !important;
		max-width: 60px !important;
		min-width: 0 !important;
		margin: 0 !important;
		padding: 0 !important;
	}

	.smart-cta-widget.smart-cta-widget .smart-cta-widget__trigger {
		display: inline-flex !important;
		width: 60px !important;
		max-width: 60px !important;
		min-width: 0 !important;
		height: 60px !important;
		min-height: 60px !important;
		padding: 0 !important;
		border-radius: 999px !important;
		justify-content: center !important;
		align-items: center !important;
		box-sizing: border-box !important;
	}

	.smart-cta-widget.smart-cta-widget .smart-cta-widget__label {
		display: none !important;
		visibility: hidden !important;
		width: 0 !important;
		overflow: hidden !important;
	}
}

/* ════════════════════════════════════════
   PHP-DETECTED MOBILE CLASS
   أعلى specificity — مش بيعتمد على media query
   ════════════════════════════════════════ */
.smart-cta-widget--mobile {
	position: fixed !important;
	right: 16px !important;
	left: auto !important;
	bottom: 16px !important;
	width: 60px !important;
	height: 60px !important;
	max-width: 60px !important;
	padding: 0 !important;
	margin: 0 !important;
}

[dir="rtl"] .smart-cta-widget--mobile {
	right: auto !important;
	left: 16px !important;
}

.smart-cta-widget--mobile .smart-cta-widget__trigger {
	display: inline-flex !important;
	width: 60px !important;
	height: 60px !important;
	max-width: 60px !important;
	min-width: 0 !important;
	min-height: 60px !important;
	padding: 0 !important;
	border-radius: 50% !important;
	justify-content: center !important;
	align-items: center !important;
	flex: none !important;
}

.smart-cta-widget--mobile .smart-cta-widget__icon {
	width: 34px !important;
	height: 34px !important;
}

.smart-cta-widget--mobile .smart-cta-widget__icon svg {
	width: 34px !important;
	height: 34px !important;
}

.smart-cta-widget--mobile .smart-cta-widget__popup {
	position: fixed !important;
	right: 0 !important;
	left: 0 !important;
	bottom: 0 !important;
	top: auto !important;
	width: 100% !important;
	max-width: 100% !important;
	max-height: 85vh !important;
	border-radius: 20px 20px 0 0 !important;
	padding: 8px 16px max(24px, env(safe-area-inset-bottom)) !important;
	opacity: 1 !important;
	transform: translateY(100%) !important;
	transition: transform 0.3s ease !important;
}

.smart-cta-widget--mobile.is-open .smart-cta-widget__popup,
.smart-cta-widget--mobile .smart-cta-widget__popup.active {
	transform: translateY(0) !important;
	pointer-events: auto !important;
}

.smart-cta-widget--mobile .smart-cta-widget__swipe-handle {
	display: block !important;
}
