/**
 * Galyam Lead Chat Widget — Frontend
 * Scoped, RTL-first, refined.
 */
#bcfl-root {
	--bcfl-primary: #1d3557;
	--bcfl-accent: #d4a373;
	--bcfl-bubble-bg: #f7f3ee;
	--bcfl-text: #1f2937;
	--bcfl-text-soft: #6b7280;
	--bcfl-border: #e5e7eb;
	--bcfl-bg: #ffffff;
	--bcfl-user-bg: #1d3557;
	--bcfl-user-text: #ffffff;
	/* Granular bubble colors (overridable via settings) */
	--bcfl-bot-bg: #ffffff;
	--bcfl-bot-text: #1f2937;
	--bcfl-success-bg: #e8f0ea;
	--bcfl-success-text: #1d3557;
	--bcfl-radius: 14px;
	--bcfl-shadow: 0 12px 28px -10px rgba( 17, 24, 39, .18 ), 0 4px 10px -4px rgba( 17, 24, 39, .08 );
	font-family: 'Heebo', 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var( --bcfl-text );
	direction: rtl;
}
#bcfl-root *, #bcfl-root *::before, #bcfl-root *::after {
	box-sizing: border-box;
}

/* =========================================================
   Launcher
   ========================================================= */
#bcfl-root .bcfl-launcher {
	position: fixed;
	bottom: var( --bcfl-launcher-y, 22px );
	width: 58px;
	height: 58px;
	border-radius: 50%;
	background: var( --bcfl-primary );
	color: #fff;
	border: none;
	cursor: pointer;
	box-shadow: var( --bcfl-shadow );
	z-index: 2147483646;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .2s ease, box-shadow .2s ease;
}
#bcfl-root[data-position="left"] .bcfl-launcher { left: var( --bcfl-launcher-x, 22px ); right: auto; }
#bcfl-root[data-position="right"] .bcfl-launcher { right: var( --bcfl-launcher-x, 22px ); left: auto; }
#bcfl-root .bcfl-launcher:hover { transform: translateY( -1px ); }
#bcfl-root .bcfl-launcher:focus-visible {
	outline: 3px solid var( --bcfl-accent );
	outline-offset: 3px;
}
#bcfl-root .bcfl-launcher-icon svg {
	width: 26px;
	height: 26px;
}

/* CTA tooltip */
#bcfl-root .bcfl-cta {
	position: fixed;
	bottom: calc( var( --bcfl-launcher-y, 22px ) + 70px );
	max-width: 280px;
	background: #fff;
	color: var( --bcfl-text );
	padding: 14px 16px 14px 32px;
	border-radius: var( --bcfl-radius );
	box-shadow: var( --bcfl-shadow );
	border: 1px solid var( --bcfl-border );
	cursor: pointer;
	opacity: 0;
	transform: translateY( 8px );
	pointer-events: none;
	transition: opacity .25s ease, transform .25s ease;
	z-index: 2147483645;
}
#bcfl-root[data-position="left"] .bcfl-cta { left: var( --bcfl-launcher-x, 22px ); right: auto; }
#bcfl-root[data-position="right"] .bcfl-cta { right: var( --bcfl-launcher-x, 22px ); left: auto; }
#bcfl-root .bcfl-cta-visible {
	opacity: 1;
	transform: translateY( 0 );
	pointer-events: auto;
}
#bcfl-root .bcfl-cta-title {
	font-weight: 600;
	color: var( --bcfl-primary );
	margin-bottom: 4px;
	font-size: 15px;
}
#bcfl-root .bcfl-cta-sub {
	color: var( --bcfl-text-soft );
	font-size: 13.5px;
	line-height: 1.45;
}
#bcfl-root .bcfl-cta-close {
	position: absolute;
	top: 4px;
	background: transparent;
	border: none;
	font-size: 20px;
	color: var( --bcfl-text-soft );
	cursor: pointer;
	width: 24px;
	height: 24px;
	line-height: 1;
	padding: 0;
}
#bcfl-root[data-position="left"] .bcfl-cta-close { left: 6px; right: auto; }
#bcfl-root[data-position="right"] .bcfl-cta-close { right: 6px; left: auto; }

/* =========================================================
   Panel
   ========================================================= */
#bcfl-root .bcfl-panel {
	position: fixed;
	bottom: calc( var( --bcfl-launcher-y, 22px ) + 70px );
	width: 360px;
	max-width: calc( 100vw - 32px );
	height: 560px;
	max-height: calc( 100vh - 120px );
	background: var( --bcfl-bg );
	border-radius: 18px;
	box-shadow: var( --bcfl-shadow );
	border: 1px solid var( --bcfl-border );
	display: none;
	flex-direction: column;
	overflow: hidden;
	z-index: 2147483647;
	opacity: 0;
	transform: translateY( 12px );
	transition: opacity .22s ease, transform .22s ease;
}
#bcfl-root[data-position="left"] .bcfl-panel { left: var( --bcfl-launcher-x, 22px ); right: auto; }
#bcfl-root[data-position="right"] .bcfl-panel { right: var( --bcfl-launcher-x, 22px ); left: auto; }
#bcfl-root.bcfl-open .bcfl-panel {
	display: flex;
	opacity: 1;
	transform: translateY( 0 );
}
#bcfl-root.bcfl-open .bcfl-launcher { display: none; }

/* Header */
#bcfl-root .bcfl-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	background: var( --bcfl-primary );
	color: #fff;
}
#bcfl-root .bcfl-header-info {
	display: flex;
	align-items: center;
	gap: 12px;
}
#bcfl-root .bcfl-avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: rgba( 255, 255, 255, .12 );
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	overflow: hidden; /* clip uploaded square images into a circle */
	flex-shrink: 0;
}
#bcfl-root .bcfl-avatar svg { width: 22px; height: 22px; }
#bcfl-root .bcfl-avatar .bcfl-avatar-img {
	/* These !importants defeat common theme rules like `img { height: auto }`
	   that would otherwise letterbox the avatar inside its circular frame. */
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	max-height: none !important;
	min-width: 0 !important;
	min-height: 0 !important;
	object-fit: cover !important;
	object-position: center center !important;
	display: block !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 50%;
}
#bcfl-root .bcfl-avatar .bcfl-avatar-svg-wrap {
	display: inline-flex;
	align-items: center;
	justify-content: center;
}
#bcfl-root .bcfl-header-name {
	font-weight: 600;
	font-size: 15px;
}
#bcfl-root .bcfl-header-status {
	font-size: 12px;
	opacity: .75;
	margin-top: 2px;
}
#bcfl-root .bcfl-header-actions { display: flex; gap: 2px; }
#bcfl-root .bcfl-icon-btn {
	background: transparent;
	border: none;
	color: rgba( 255, 255, 255, .85 );
	cursor: pointer;
	width: 32px;
	height: 32px;
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background .15s ease;
}
#bcfl-root .bcfl-icon-btn:hover { background: rgba( 255, 255, 255, .12 ); }
#bcfl-root .bcfl-icon-btn svg { width: 16px; height: 16px; }

/* Body */
#bcfl-root .bcfl-body {
	flex: 1;
	overflow-y: auto;
	background: var( --bcfl-bubble-bg );
	padding: 16px;
}
#bcfl-root .bcfl-messages {
	display: flex;
	flex-direction: column;
	gap: 10px;
}
#bcfl-root .bcfl-msg {
	display: flex;
	max-width: 85%;
	animation: bcfl-fade-in .2s ease;
}
#bcfl-root .bcfl-msg-bot { align-self: flex-start; }
#bcfl-root .bcfl-msg-user { align-self: flex-end; }
#bcfl-root .bcfl-msg-bubble {
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14.5px;
	line-height: 1.55;
	word-wrap: break-word;
	white-space: pre-wrap;
}
#bcfl-root .bcfl-msg-bot .bcfl-msg-bubble {
	background: var( --bcfl-bot-bg );
	color: var( --bcfl-bot-text );
	border-top-right-radius: 4px;
	box-shadow: 0 1px 2px rgba( 17, 24, 39, .04 );
}
#bcfl-root .bcfl-msg-user .bcfl-msg-bubble {
	background: var( --bcfl-user-bg );
	color: var( --bcfl-user-text );
	border-top-left-radius: 4px;
}
/* Success bubble — the final confirmation message after a successful submit. */
#bcfl-root .bcfl-msg-bot.bcfl-msg-success .bcfl-msg-bubble {
	background: var( --bcfl-success-bg );
	color: var( --bcfl-success-text );
	font-weight: 500;
}

/* Typing indicator */
#bcfl-root .bcfl-typing {
	background: var( --bcfl-bot-bg );
	border-radius: 14px;
	border-top-right-radius: 4px;
	padding: 12px 14px;
	display: flex;
	gap: 4px;
	align-items: center;
	box-shadow: 0 1px 2px rgba( 17, 24, 39, .04 );
}
#bcfl-root .bcfl-typing-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var( --bcfl-text-soft );
	opacity: .5;
	animation: bcfl-dot 1.2s infinite ease-in-out;
}
#bcfl-root .bcfl-typing-dot:nth-child( 2 ) { animation-delay: .15s; }
#bcfl-root .bcfl-typing-dot:nth-child( 3 ) { animation-delay: .3s; }
@keyframes bcfl-dot {
	0%, 60%, 100% { opacity: .35; transform: translateY( 0 ); }
	30% { opacity: 1; transform: translateY( -2px ); }
}
@keyframes bcfl-fade-in {
	from { opacity: 0; transform: translateY( 4px ); }
	to { opacity: 1; transform: translateY( 0 ); }
}

/* Footer */
#bcfl-root .bcfl-footer {
	padding: 12px 14px 14px;
	border-top: 1px solid var( --bcfl-border );
	background: #fff;
	display: flex;
	flex-direction: column;
	gap: 8px;
	min-height: 60px;
}
#bcfl-root .bcfl-input-row {
	display: flex;
	gap: 8px;
	align-items: flex-end;
}
#bcfl-root .bcfl-input {
	flex: 1;
	background: #f9fafb;
	border: 1px solid var( --bcfl-border );
	border-radius: 12px;
	padding: 10px 14px;
	font: inherit;
	font-size: 14.5px;
	color: var( --bcfl-text );
	direction: rtl;
	transition: border-color .15s ease, background .15s ease;
}
#bcfl-root .bcfl-input:focus {
	outline: none;
	border-color: var( --bcfl-primary );
	background: #fff;
}
#bcfl-root .bcfl-textarea {
	resize: none;
	max-height: 100px;
	line-height: 1.4;
}
#bcfl-root .bcfl-send-btn {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: var( --bcfl-primary );
	color: #fff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background .15s ease;
}
#bcfl-root .bcfl-send-btn:hover { background: #15263f; }
#bcfl-root .bcfl-send-btn svg { width: 18px; height: 18px; }

#bcfl-root .bcfl-skip-btn {
	background: transparent;
	border: none;
	color: var( --bcfl-text-soft );
	font: inherit;
	font-size: 13px;
	cursor: pointer;
	padding: 4px 0;
	text-decoration: underline;
	align-self: flex-end;
}

#bcfl-root .bcfl-error {
	color: #b91c1c;
	font-size: 13px;
	min-height: 0;
}

/* Choice buttons */
#bcfl-root .bcfl-choices {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}
#bcfl-root .bcfl-choice-btn {
	background: #fff;
	border: 1.5px solid var( --bcfl-border );
	color: var( --bcfl-text );
	font: inherit;
	font-size: 14px;
	padding: 9px 14px;
	border-radius: 24px;
	cursor: pointer;
	transition: all .15s ease;
}
#bcfl-root .bcfl-choice-btn:hover {
	border-color: var( --bcfl-primary );
	background: #f7f9fc;
	color: var( --bcfl-primary );
}

/* Final actions */
#bcfl-root .bcfl-final-actions {
	display: flex;
	flex-direction: column;
	gap: 8px;
}
#bcfl-root .bcfl-wa-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	background: #25d366;
	color: #fff;
	text-decoration: none;
	padding: 12px 18px;
	border-radius: 12px;
	font-weight: 600;
	font-size: 15px;
	transition: background .15s ease;
}
#bcfl-root .bcfl-wa-btn:hover { background: #1da851; }
#bcfl-root .bcfl-wa-ico svg { width: 20px; height: 20px; }
#bcfl-root .bcfl-restart-btn {
	background: transparent;
	border: 1px solid var( --bcfl-border );
	color: var( --bcfl-text-soft );
	font: inherit;
	font-size: 13.5px;
	padding: 9px;
	border-radius: 10px;
	cursor: pointer;
	transition: all .15s ease;
}
#bcfl-root .bcfl-restart-btn:hover {
	border-color: var( --bcfl-text-soft );
	color: var( --bcfl-text );
}

/* Privacy note */
#bcfl-root .bcfl-privacy {
	padding: 8px 16px 12px;
	background: #fff;
	color: var( --bcfl-text-soft );
	font-size: 11.5px;
	text-align: center;
	border-top: 1px solid var( --bcfl-border );
}

/* =========================================================
   Mobile
   ========================================================= */
@media ( max-width: 480px ) {
	#bcfl-root .bcfl-panel {
		bottom: 0;
		width: 100vw;
		max-width: 100vw;
		height: 100dvh;
		max-height: 100dvh;
		border-radius: 0;
		left: 0 !important;
		right: 0 !important;
	}
	#bcfl-root .bcfl-launcher {
		width: 54px;
		height: 54px;
		bottom: 16px;
	}
	#bcfl-root[data-position="left"] .bcfl-launcher { left: 16px; }
	#bcfl-root[data-position="right"] .bcfl-launcher { right: 16px; }
	#bcfl-root .bcfl-cta {
		max-width: calc( 100vw - 88px );
		bottom: 84px;
	}
	#bcfl-root[data-position="left"] .bcfl-cta { left: 16px; }
	#bcfl-root[data-position="right"] .bcfl-cta { right: 16px; }
	#bcfl-root .bcfl-choice-btn { font-size: 14.5px; padding: 11px 16px; }
	#bcfl-root .bcfl-send-btn { width: 44px; height: 44px; }

	/* When the mobile action strip is enabled, hide the floating launcher + CTA on mobile.
	   The strip replaces them — keeping both would be visual clutter. */
	#bcfl-root[data-strip="1"] .bcfl-launcher,
	#bcfl-root[data-strip="1"] .bcfl-cta {
		display: none !important;
	}
}

/* =========================================================
   Mobile action strip — full-width bottom bar
   Visible only on mobile (max-width 480px), regardless of launcher position.
   ========================================================= */
#bcfl-root .bcfl-mobile-strip {
	display: none;
}
@media ( max-width: 480px ) {
	#bcfl-root .bcfl-mobile-strip {
		position: fixed !important;
		bottom: 0 !important;
		left: 0 !important;
		right: 0 !important;
		width: 100vw !important;
		max-width: 100vw !important;
		display: flex !important;
		/* Max z-index to overlay reCAPTCHA badge ( default z-index 2000000000 )
		   and any third-party floating widgets. Panel stays one notch higher. */
		z-index: 2147483646 !important;
		min-height: 60px;
		/* Height: configurable as a percentage of viewport height (default 7vh, range 5-15).
		   Floor of 60px ensures touch targets remain usable on short screens. */
		height: max( 60px, var( --bcfl-strip-height, 7vh ) );
		background: #ffffff;
		border-top: 1px solid #e8e3dc;
		box-shadow: 0 -6px 18px rgba( 29, 53, 87, 0.10 );
		padding-bottom: env( safe-area-inset-bottom );
		font-family: "Heebo", "Rubik", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
	}
	/* When the chat panel is open it covers everything; hide the strip
	   so a stale browser z-index doesn't leak it on top of the panel. */
	#bcfl-root.bcfl-open .bcfl-mobile-strip {
		display: none !important;
	}
	#bcfl-root .bcfl-strip-btn {
		flex: 1 1 0;
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 8px;
		padding: 10px 8px;
		background: transparent;
		border: 0;
		color: var( --bcfl-primary, #1d3557 );
		font-size: 15.5px;
		font-weight: 500;
		font-family: inherit;
		text-decoration: none;
		cursor: pointer;
		-webkit-tap-highlight-color: rgba( 29, 53, 87, 0.08 );
		transition: background 0.15s;
	}
	#bcfl-root .bcfl-strip-btn:active {
		background: var( --bcfl-bubble-bg, #f7f3ee );
	}
	#bcfl-root .bcfl-strip-btn + .bcfl-strip-btn {
		border-right: 1px solid #ece7df; /* RTL: separator between the two buttons */
	}
	#bcfl-root .bcfl-strip-ico {
		display: inline-flex;
		width: 22px;
		height: 22px;
		color: var( --bcfl-primary, #1d3557 );
	}
	#bcfl-root .bcfl-strip-ico svg {
		width: 100%;
		height: 100%;
	}
	#bcfl-root .bcfl-strip-call .bcfl-strip-ico { color: #25d366; }
	#bcfl-root .bcfl-strip-label {
		line-height: 1.2;
	}
}

