/* ==========================================================================
   دکمه شناور تماس - استایل فرانت‌اند
   ========================================================================== */

.fcb-widget, .fcb-widget * {
	box-sizing: border-box;
}

.fcb-widget :where(button, input, textarea) {
	all: unset;
	box-sizing: border-box;
	font-family: inherit;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
}
.fcb-widget :where(textarea) { cursor: text; white-space: pre-wrap; }
.fcb-widget :where(button) { display: flex; }
.fcb-widget :where(img, svg) { max-width: none; }

.fcb-widget {
	position: fixed;
	bottom: var(--fcb-desktop-y, 24px);
	z-index: var(--fcb-z, 999999);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, "Vazirmatn", "IRANSans", sans-serif;
	direction: rtl;
}

.fcb-widget.fcb-side-desktop-right { right: var(--fcb-desktop-x, 24px); left: auto; }
.fcb-widget.fcb-side-desktop-left  { left: var(--fcb-desktop-x, 24px); right: auto; }

/* ---------- دکمه اصلی ---------- */
.fcb-main-btn {
	position: relative;
	width: var(--fcb-size-desktop, 64px);
	height: var(--fcb-size-desktop, 64px);
	border-radius: 50% !important;
	border: none;
	cursor: pointer;
	background: linear-gradient(135deg, var(--fcb-main-bg1, #4f46e5), var(--fcb-main-bg2, #7c3aed));
	color: var(--fcb-main-color, #fff);
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 8px 24px rgba(0,0,0,.22), 0 2px 6px rgba(0,0,0,.15);
	transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s ease;
}
.fcb-main-btn:hover { transform: scale(1.06); box-shadow: 0 10px 28px rgba(0,0,0,.28); }
.fcb-main-btn:active { transform: scale(.96); }

.fcb-icon { position: absolute; width: 46%; height: 46%; display: flex; align-items: center; justify-content: center; transition: opacity .2s ease, transform .3s ease; }
.fcb-icon svg { width: 100%; height: 100%; }
.fcb-icon img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }

.fcb-icon-open  { opacity: 1; transform: rotate(0deg) scale(1); }
.fcb-icon-close { opacity: 0; transform: rotate(-90deg) scale(.5); }

.fcb-widget.fcb-open .fcb-icon-open  { opacity: 0; transform: rotate(90deg) scale(.5); }
.fcb-widget.fcb-open .fcb-icon-close { opacity: 1; transform: rotate(0deg) scale(1); }

.fcb-badge {
	position: absolute;
	top: -4px;
	left: -4px;
	background: #ef4444;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	min-width: 20px;
	height: 20px;
	border-radius: 999px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 4px;
	border: 2px solid #fff;
	animation: fcb-badge-bounce 2.4s ease-in-out infinite;
}

.fcb-widget.fcb-open .fcb-badge { display: none; }

/* ---------- انیمیشن‌های دکمه اصلی ---------- */
.fcb-anim-pulse .fcb-main-btn::before {
	content: '';
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background: inherit;
	z-index: -1;
	animation: fcb-pulse-ring 2.4s cubic-bezier(.4,0,.6,1) infinite;
}
.fcb-widget.fcb-open.fcb-anim-pulse .fcb-main-btn::before { animation: none; }

.fcb-anim-bounce .fcb-main-btn { animation: fcb-bounce 2.6s ease-in-out infinite; }
.fcb-widget.fcb-open.fcb-anim-bounce .fcb-main-btn { animation: none; }

@keyframes fcb-pulse-ring {
	0%   { transform: scale(1);   opacity: .45; }
	80%  { transform: scale(1.9); opacity: 0; }
	100% { transform: scale(1.9); opacity: 0; }
}
@keyframes fcb-bounce {
	0%, 100% { transform: translateY(0); }
	10%      { transform: translateY(-6px); }
	20%      { transform: translateY(0); }
}
@keyframes fcb-badge-bounce {
	0%, 100% { transform: scale(1); }
	50%      { transform: scale(1.15); }
}

/* ---------- حباب راهنما (Tooltip) ---------- */
.fcb-tooltip {
	position: absolute;
	bottom: 6px;
	background: #fff;
	color: #1f2937;
	padding: 10px 16px;
	border-radius: 14px;
	font-size: 13.5px;
	white-space: nowrap;
	box-shadow: 0 6px 20px rgba(0,0,0,.15);
	opacity: 0;
	transform: translateY(6px) scale(.94);
	pointer-events: none;
	transition: opacity .35s ease, transform .35s ease;
	animation: fcb-tooltip-in .4s ease .8s forwards;
}
.fcb-widget.fcb-side-desktop-right .fcb-tooltip { right: calc(var(--fcb-size-desktop, 64px) + 14px); left: auto; }
.fcb-widget.fcb-side-desktop-left  .fcb-tooltip { left: calc(var(--fcb-size-desktop, 64px) + 14px); right: auto; }
@keyframes fcb-tooltip-in { to { opacity: 1; transform: translateY(0) scale(1); } }
.fcb-widget.fcb-open .fcb-tooltip,
.fcb-tooltip.fcb-hide { opacity: 0 !important; transform: translateY(6px) scale(.94) !important; animation: none; }

/* ---------- لیست کانال‌ها ---------- */
.fcb-channels {
	position: absolute;
	bottom: calc(var(--fcb-size-desktop, 64px) + 14px);
	display: flex;
	flex-direction: column-reverse;
	gap: 12px;
	pointer-events: none;
}
.fcb-widget.fcb-side-desktop-right .fcb-channels { right: 0; left: auto; align-items: flex-start; }
.fcb-widget.fcb-side-desktop-left  .fcb-channels { left: 0; right: auto; align-items: flex-start; }

.fcb-channel-btn {
	pointer-events: none;
	display: flex !important;
	align-items: center;
	gap: 10px;
	border: none !important;
	cursor: pointer;
	border-radius: 999px !important;
	padding: 5px !important;
	height: 48px;
	box-shadow: 0 6px 18px rgba(0,0,0,.2) !important;
	opacity: 0;
	transform: translateY(14px) scale(.7);
	transition: transform .35s cubic-bezier(.34,1.56,.64,1), opacity .3s ease;
	transition-delay: 0ms;
	overflow: visible;
	flex-direction: row-reverse;
	white-space: nowrap;
	box-sizing: border-box !important;
}
.fcb-widget.fcb-side-desktop-left .fcb-channel-btn { flex-direction: row; }

.fcb-widget.fcb-open .fcb-channel-btn {
	display: flex !important;
	flex-direction: row;
	pointer-events: auto;
	opacity: 1;
	transform: translateY(0) scale(1);
	transition-delay: var(--fcb-delay, 0ms);
}

.fcb-channel-icon-circle {
	width: 38px;
	height: 38px;
	min-width: 38px;
	border-radius: 50% !important;
	background: rgba(255,255,255,.22);
	display: flex !important;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	overflow: hidden;
}
.fcb-channel-icon-circle svg,
.fcb-channel-icon-circle img { width: 24px; height: 24px; display: block; }
.fcb-channel-icon-circle img { object-fit: contain; border-radius: 50%; }

.fcb-channel-label {
	font-size: 13.5px;
	font-weight: 700;
	white-space: nowrap;
	padding-inline-end: 6px;
}
.fcb-widget.fcb-side-desktop-right .fcb-channel-label { padding-right: 4px; padding-left: 14px; }
.fcb-widget.fcb-side-desktop-left  .fcb-channel-label { padding-left: 4px; padding-right: 14px; }

.fcb-channel-btn:hover { transform: translateY(0) scale(1.05) !important; }

/* ---------- Overlay ---------- */
.fcb-overlay {
	position: fixed;
	inset: 0;
	background: rgba(15,23,42,.45);
	opacity: 0;
	pointer-events: none;
	transition: opacity .25s ease;
	z-index: -1;
}
.fcb-widget.fcb-panel-open .fcb-overlay {
	opacity: 1;
	pointer-events: auto;
	z-index: 1;
}

/* ---------- پنل فرم پیام ---------- */
.fcb-panel {
	position: fixed;
	bottom: calc(var(--fcb-desktop-y, 24px) + var(--fcb-size-desktop, 64px) + 16px);
	width: 340px;
	max-width: calc(100vw - 32px);
	background: #fff;
	border-radius: 18px;
	box-shadow: 0 20px 60px rgba(0,0,0,.25);
	overflow: hidden;
	opacity: 0;
	transform: translateY(16px) scale(.96);
	pointer-events: none;
	transition: opacity .3s cubic-bezier(.34,1.2,.64,1), transform .3s cubic-bezier(.34,1.2,.64,1);
	z-index: 2;
}
.fcb-widget.fcb-side-desktop-right .fcb-panel { right: var(--fcb-desktop-x, 24px); left: auto; }
.fcb-widget.fcb-side-desktop-left  .fcb-panel { left: var(--fcb-desktop-x, 24px); right: auto; }

.fcb-widget.fcb-panel-open .fcb-panel {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

.fcb-panel-header {
	position: relative;
	padding: 20px 20px 40px;
	background: var(--fcb-panel-color, linear-gradient(135deg, var(--fcb-main-bg1, #4f46e5), var(--fcb-main-bg2, #7c3aed)));
	color: #fff;
	transition: background .25s ease;
}
.fcb-panel-title { font-weight: 700; font-size: 14.5px; margin-bottom: 8px; padding-right: 0; padding-left: 34px; }
.fcb-panel-intro { margin: 0; font-size: 13px; line-height: 1.8; opacity: .95; padding-left: 6px; }

.fcb-close-btn {
	position: absolute !important;
	top: 14px;
	right: auto;
	left: 14px;
	background: rgba(255,255,255,.22);
	border: none !important;
	color: #fff;
	width: 28px;
	height: 28px;
	border-radius: 50% !important;
	display: flex !important;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background .2s ease, transform .15s ease;
	flex-shrink: 0;
	z-index: 1;
	appearance: none;
	-webkit-appearance: none;
	padding: 0 !important;
	background: none !important;

}
.fcb-close-btn:hover { background: rgba(255,255,255,.36); transform: scale(1.06); }
.fcb-close-btn svg { width: 14px; height: 14px; display: block; }

/* ---------- بخش گفتگو (کارت روییِ سفید که روی هدر می‌نشیند) ---------- */
.fcb-panel-chat {
	position: relative;
	background: #f7f8fa;
	margin-top: -22px;
	border-radius: 18px 18px 0 0;
	padding: 16px 16px 10px;
	box-shadow: 0 -6px 14px rgba(0,0,0,.03);
	z-index: 1;
}

.fcb-hours-note {
	background: #fffbeb;
	color: #92400e;
	font-size: 12px;
	padding: 8px 12px;
	border-radius: 10px;
	margin-bottom: 10px;
}

.fcb-greeting-row {
	display: flex;
	flex-direction: row-reverse;
	align-items: flex-end;
	gap: 8px;
}
.fcb-widget.fcb-side-desktop-left .fcb-greeting-row { flex-direction: row; }

.fcb-avatar {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--fcb-main-bg1, #4f46e5), var(--fcb-main-bg2, #7c3aed));
	color: #ffffff;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	border: 2px solid #fff;
	box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.fcb-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fcb-avatar svg { width: 58%; height: 58%; display: block; }

.fcb-greeting-bubble {
	background: #fff;
	color: #1f2937;
	font-size: 13.5px;
	line-height: 1.7;
	padding: 10px 14px;
	border-radius: 16px;
	border-end-start-radius: 4px;
	box-shadow: 0 2px 10px rgba(0,0,0,.06);
	max-width: 78%;
}
.fcb-widget.fcb-side-desktop-left .fcb-greeting-bubble { border-end-start-radius: 16px; border-end-end-radius: 4px; }

/* ---------- فوتر / ردیف ورودی پیام ---------- */
.fcb-panel-footer { background: #f7f8fa; padding: 10px 16px 16px; }

.fcb-input-row {
	display: flex !important;
	flex-direction: row-reverse;
	align-items: flex-end;
	gap: 8px;
	background: #fff !important;
	border: 1.5px solid #e5e7eb !important;
	border-radius: 22px !important;
	padding: 6px !important;
	transition: border-color .2s ease;
	box-shadow: none !important;
}
.fcb-widget.fcb-side-desktop-left .fcb-input-row { flex-direction: row; }
.fcb-input-row:focus-within { border-color: var(--fcb-panel-color, #4f46e5) !important; }

.fcb-textarea {
	flex: 1 1 auto !important;
	width: auto !important;
	min-width: 0;
	border: none !important;
	background: transparent !important;
	box-shadow: none !important;
	resize: none !important;
	font-size: 13.5px !important;
	font-family: inherit !important;
	line-height: 1.5 !important;
	padding: 8px 10px !important;
	margin: 0 !important;
	min-height: 20px !important;
	max-height: 110px !important;
	height: 36px;
	outline: none !important;
	color: #1f2937 !important;
	box-sizing: border-box !important;
}

.fcb-error {
	color: #dc2626;
	font-size: 12px;
	margin: 6px 4px 0;
}

.fcb-submit-btn {
	width: 38px !important;
	height: 38px !important;
	min-width: 38px !important;
	max-width: 38px !important;
	padding: 0 !important;
	flex-shrink: 0;
	border: none !important;
	border-radius: 50% !important;
	background: var(--fcb-panel-color, linear-gradient(135deg, var(--fcb-main-bg1, #4f46e5), var(--fcb-main-bg2, #7c3aed))) !important;
	color: #fff !important;
	display: flex !important;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
	box-shadow: 0 2px 6px rgba(0,0,0,.15) !important;
	transition: transform .15s ease, opacity .2s ease, background .25s ease;
}
.fcb-submit-btn:hover { transform: scale(1.07); }
.fcb-submit-btn:active { transform: scale(.96); }
.fcb-submit-btn[disabled] { opacity: .6; cursor: not-allowed; }
.fcb-send-icon { width: 16px !important; height: 16px !important; transform: scaleX(-1); display: block; stroke: #fff; }

.fcb-toast {
	position: fixed;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%) translateY(20px);
	background: #111827;
	color: #fff;
	padding: 10px 18px;
	border-radius: 10px;
	font-size: 13px;
	z-index: 9999999;
	opacity: 0;
	transition: opacity .3s ease, transform .3s ease;
	max-width: 90vw;
	text-align: center;
}
.fcb-toast.fcb-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ==========================================================================
   حالت موبایل
   ========================================================================== */
@media (max-width: 782px) {
	.fcb-widget {
		bottom: var(--fcb-mobile-y, 14px) !important;
	}
	.fcb-widget.fcb-side-desktop-right,
	.fcb-widget.fcb-side-mobile-right { right: var(--fcb-mobile-x, 14px) !important; left: auto !important; }
	.fcb-widget.fcb-side-desktop-left,
	.fcb-widget.fcb-side-mobile-left { left: var(--fcb-mobile-x, 14px) !important; right: auto !important; }

	.fcb-main-btn {
		width: var(--fcb-size-mobile, 54px);
		height: var(--fcb-size-mobile, 54px);
	}
	.fcb-tooltip { display: none; }
	.fcb-channels { bottom: calc(var(--fcb-size-mobile, 54px) + 12px); }
	.fcb-channel-btn { height: 42px; }
	.fcb-channel-icon-circle { width: 32px; height: 32px; min-width: 32px; }
	.fcb-channel-icon-circle svg, .fcb-channel-icon-circle img { width: 20px; height: 20px; }
	.fcb-channel-label { font-size: 12.5px; }

	.fcb-panel {
		left: 12px !important;
		right: 12px !important;
		width: auto;
		bottom: 0;
		border-radius: 20px 20px 0 0;
		transform: translateY(100%);
		position: fixed;
	}
	.fcb-widget.fcb-panel-open .fcb-panel { transform: translateY(0); }
}
