#lct-widget, #lct-widget * { box-sizing: border-box; }
#lct-widget [hidden] { display: none !important; }
#lct-widget {
	position: fixed;
	bottom: calc(var(--lct-bottom, 20px) + env(safe-area-inset-bottom, 0px));
	z-index: 999990;
	font-family: var(--lct-font, inherit);
	font-size: 14px;
	line-height: 1.7;
	color: #1f2937;
	--lct-color: #2563eb;
	--lct-fg: #ffffff;
	--lct-side: 20px;
	--lct-fab: 58px;
	--lct-fab-r: 50%;
	--lct-radius: 16px;
	--lct-w: 360px;
	--lct-h: 520px;
}
#lct-widget.lct-pos-left { left: var(--lct-side); }
#lct-widget.lct-pos-right { right: var(--lct-side); }

#lct-widget button,
#lct-widget input,
#lct-widget textarea { font: inherit; letter-spacing: normal; text-transform: none; }

/* دکمه شناور */
#lct-widget .lct-fab {
	position: relative;
	display: flex; align-items: center; justify-content: center;
	gap: 8px; min-width: var(--lct-fab); height: var(--lct-fab); padding: 0; margin: 0;
	border: 0; border-radius: var(--lct-fab-r);
	background: var(--lct-color); color: var(--lct-fg);
	box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
	cursor: pointer;
	transition: transform .15s ease;
}
#lct-widget .lct-fab:hover { transform: scale(1.06); }
#lct-widget .lct-fab:focus-visible,
#lct-widget .lct-x:focus-visible,
#lct-widget .lct-send:focus-visible,
#lct-widget .lct-btn:focus-visible { outline: 3px solid rgba(37, 99, 235, .45); outline-offset: 2px; }
#lct-widget .lct-fab svg { width: calc(var(--lct-fab) * .45); height: calc(var(--lct-fab) * .45); flex: none; }
#lct-widget .lct-fab.lct-has-label { padding: 0 18px; font-weight: 600; white-space: nowrap; border-radius: calc(var(--lct-fab) / 2); }
#lct-widget.lct-pos-left .lct-fab { margin-right: auto; }
#lct-widget.lct-pos-right .lct-fab { margin-left: auto; }

#lct-widget .lct-badge {
	position: absolute; top: -4px; right: -4px;
	min-width: 22px; height: 22px; padding: 0 6px;
	border-radius: 11px; background: #dc2626; color: #fff;
	font-size: 12px; font-weight: 700; line-height: 22px; text-align: center;
	border: 2px solid #fff;
}

/* پنل */
#lct-widget .lct-panel {
	position: absolute; bottom: calc(var(--lct-fab) + 12px);
	width: var(--lct-w); max-width: calc(100vw - 24px);
	height: var(--lct-h); max-height: calc(100vh - var(--lct-fab) - var(--lct-bottom, 20px) - 50px);
	display: flex; flex-direction: column;
	background: #fff; border-radius: var(--lct-radius); overflow: hidden;
	box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
	border: 1px solid rgba(0, 0, 0, .06);
}
#lct-widget.lct-pos-left .lct-panel { left: 0; }
#lct-widget.lct-pos-right .lct-panel { right: 0; }

#lct-widget .lct-head {
	display: flex; align-items: center; justify-content: space-between; gap: 10px;
	padding: 14px 16px; background: var(--lct-color); color: var(--lct-fg);
}
#lct-widget .lct-title { font-weight: 700; font-size: 15px; }
#lct-widget .lct-sub { font-size: 12px; opacity: .85; }
#lct-widget .lct-x {
	width: 32px; height: 32px; padding: 0; margin: 0; border: 0; border-radius: 50%;
	background: rgba(255, 255, 255, .18); color: inherit; font-size: 22px; line-height: 1; cursor: pointer;
}
#lct-widget .lct-x:hover { background: rgba(255, 255, 255, .3); }

#lct-widget .lct-msgs {
	flex: 1 1 auto; overflow-y: auto; padding: 14px;
	background: #f3f4f6; display: flex; flex-direction: column; gap: 8px;
	overscroll-behavior: contain;
}
#lct-widget .lct-m { display: flex; }
#lct-widget .lct-m.lct-out { justify-content: flex-end; }
#lct-widget .lct-m.lct-in { justify-content: flex-start; }
#lct-widget[dir="rtl"] .lct-m.lct-out { justify-content: flex-start; }
#lct-widget[dir="rtl"] .lct-m.lct-in { justify-content: flex-end; }
#lct-widget .lct-bubble {
	max-width: 82%; padding: 8px 12px; border-radius: 14px;
	white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
}
#lct-widget .lct-out .lct-bubble { background: var(--lct-color); color: var(--lct-fg); }
#lct-widget .lct-in .lct-bubble { background: #fff; color: #1f2937; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
#lct-widget .lct-time { display: block; margin-top: 2px; font-size: 10px; opacity: .65; }
#lct-widget .lct-failed .lct-bubble { opacity: .55; outline: 1px dashed #dc2626; }

/* فرم ها */
#lct-widget .lct-form { display: flex; gap: 8px; padding: 10px; background: #fff; border-top: 1px solid #e5e7eb; }
#lct-widget .lct-ident { flex-direction: column; }
#lct-widget .lct-form input,
#lct-widget .lct-form textarea {
	width: 100%; margin: 0; padding: 9px 12px;
	border: 1px solid #d1d5db; border-radius: 10px; background: #fff; color: #111827;
	box-shadow: none; outline: none;
}
#lct-widget .lct-form input:focus,
#lct-widget .lct-form textarea:focus { border-color: var(--lct-color); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
#lct-widget .lct-compose textarea { flex: 1 1 auto; resize: none; max-height: 110px; min-height: 40px; line-height: 1.5; }
#lct-widget .lct-send,
#lct-widget .lct-btn {
	margin: 0; padding: 0 16px; border: 0; border-radius: 10px;
	background: var(--lct-color); color: var(--lct-fg); font-weight: 600; cursor: pointer;
}
#lct-widget .lct-send { align-self: flex-end; height: 40px; }
#lct-widget .lct-btn { height: 42px; }
#lct-widget .lct-err { padding: 0 12px; color: #b91c1c; font-size: 12px; background: #fff; }
#lct-widget .lct-err:empty { display: none; }
#lct-widget .lct-ident .lct-err { padding: 0; }
#lct-widget .lct-privacy { padding: 6px 12px 10px; background: #fff; color: #6b7280; font-size: 11px; line-height: 1.6; }

/* پیش نمایش پیام پشتیبان */
#lct-widget .lct-teaser {
	position: absolute; bottom: calc(var(--lct-fab) + 12px); width: 260px; max-width: calc(100vw - 24px);
	padding: 12px 14px; background: #fff; color: #1f2937; border-radius: 14px;
	box-shadow: 0 8px 28px rgba(0, 0, 0, .22); cursor: pointer;
}
#lct-widget.lct-pos-left .lct-teaser { left: 0; }
#lct-widget.lct-pos-right .lct-teaser { right: 0; }
#lct-widget .lct-teaser-x {
	position: absolute; top: 2px; inset-inline-end: 6px;
	border: 0; background: transparent; color: #6b7280; font-size: 18px; line-height: 1; cursor: pointer; padding: 2px 4px;
}
#lct-widget .lct-teaser-txt { padding-inline-end: 14px; overflow-wrap: anywhere; }

@media (max-width: 480px) {
	#lct-widget.lct-pos-left { left: min(var(--lct-side), 16px); }
	#lct-widget.lct-pos-right { right: min(var(--lct-side), 16px); }
	#lct-widget .lct-panel,
	#lct-widget.lct-pos-left .lct-panel,
	#lct-widget.lct-pos-right .lct-panel {
		position: fixed; bottom: calc(var(--lct-fab) + var(--lct-bottom, 20px) + 12px + env(safe-area-inset-bottom, 0px));
		left: 12px; right: 12px; width: auto;
		height: var(--lct-h); max-height: calc(100vh - var(--lct-fab) - var(--lct-bottom, 20px) - 40px);
	}
	#lct-widget .lct-form input,
	#lct-widget .lct-form textarea { font-size: 16px; } /* جلوگیری از زوم خودکار iOS */
}

/* موبایل: وقتی چت باز است، کل صفحه را می گیرد */
@media (max-width: 600px) {
	#lct-widget.lct-open .lct-panel,
	#lct-widget.lct-open.lct-pos-left .lct-panel,
	#lct-widget.lct-open.lct-pos-right .lct-panel {
		position: fixed; top: var(--lct-vtop, 0px); left: 0; right: 0; bottom: auto;
		width: 100%; max-width: none;
		height: var(--lct-vh, 100vh); height: var(--lct-vh, 100dvh); max-height: none;
		border-radius: 0; border: 0; box-shadow: none;
	}
	#lct-widget.lct-open .lct-fab,
	#lct-widget.lct-open .lct-teaser { display: none; }
	#lct-widget.lct-open .lct-head { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
	#lct-widget.lct-open .lct-compose { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
	#lct-widget.lct-open .lct-privacy { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
	#lct-widget.lct-open .lct-x { width: 40px; height: 40px; }
}
html.lct-lock, html.lct-lock body { overflow: hidden !important; overscroll-behavior: none; }

@media (prefers-reduced-motion: reduce) {
	#lct-widget .lct-fab { transition: none; }
}

/* لوگو در دکمه و هدر */
#lct-widget .lct-fab-logo {
	width: calc(var(--lct-fab) * .62); height: calc(var(--lct-fab) * .62);
	object-fit: contain; border-radius: 50%; flex: none; display: block;
}
#lct-widget .lct-fab.lct-has-logo svg { display: none; }
#lct-widget.lct-logo-white .lct-fab-logo { background: #fff; padding: 3px; }
#lct-widget .lct-logo {
	width: 38px; height: 38px; object-fit: contain; border-radius: 50%; flex: none;
	margin-inline-end: 10px; display: block;
}
#lct-widget.lct-logo-white .lct-logo { background: #fff; padding: 3px; }
#lct-widget .lct-head-t { flex: 1 1 auto; min-width: 0; }

/* لینک داخل پیام: کامل و قابل کلیک */
#lct-widget .lct-link { color: inherit; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; word-break: break-all; unicode-bidi: isolate; text-align: left; }
#lct-widget .lct-out .lct-link { color: var(--lct-fg); }

/* «پشتیبان در حال نوشتن است» */
#lct-widget .lct-typing .lct-bubble { display: flex; align-items: center; gap: 8px; color: #6b7280; font-size: 12px; }
#lct-widget .lct-dots { display: inline-flex; gap: 3px; }
#lct-widget .lct-dots i { width: 5px; height: 5px; border-radius: 50%; background: #9ca3af; animation: lct-bounce 1.2s infinite ease-in-out; }
#lct-widget .lct-dots i:nth-child(2) { animation-delay: .15s; }
#lct-widget .lct-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes lct-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #lct-widget .lct-dots i { animation: none; } }
