#lcw-widget-root {
	--lcw-primary: #4F46E5;
	--lcw-secondary: #06B6D4;
	--lcw-text: #1F2937;
	--lcw-bg: #ffffff;
	--lcw-bg-soft: #F7F7FB;
	--lcw-radius: 18px;
	--lcw-shadow: 0 18px 50px rgba(24, 20, 60, .22), 0 4px 14px rgba(24,20,60,.12);
	position: fixed;
	z-index: 999999;
	bottom: 24px;
	right: 24px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	line-height: 1.4;
	color: var(--lcw-text);
}
#lcw-widget-root.lcw-pos-bottom-left { right: auto; left: 24px; }
#lcw-widget-root *, #lcw-widget-root *::before, #lcw-widget-root *::after { box-sizing: border-box; }

/* ---------- Launcher ---------- */
.lcw-launcher {
	width: 62px;
	height: 62px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	background: linear-gradient(135deg, var(--lcw-primary), var(--lcw-secondary));
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: var(--lcw-shadow);
	position: relative;
	transition: transform .18s ease, box-shadow .18s ease;
}
.lcw-launcher:hover { transform: translateY(-2px) scale(1.04); }
.lcw-launcher:active { transform: scale(.96); }
.lcw-launcher .lcw-icon-close { display: none; }
#lcw-widget-root.lcw-open .lcw-launcher .lcw-icon-chat { display: none; }
#lcw-widget-root.lcw-open .lcw-launcher .lcw-icon-close { display: flex; }
.lcw-launcher-icon { display: flex; align-items: center; justify-content: center; }
.lcw-launcher-icon-img {
	width: 28px;
	height: 28px;
	object-fit: contain;
	border-radius: 50%;
	display: block;
}
.lcw-launcher-badge {
	position: absolute;
	top: -2px;
	right: -2px;
	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;
	border: 2px solid #fff;
	padding: 0 4px;
}

/* ---------- Panel ---------- */
.lcw-panel {
	position: fixed;
	bottom: 100px;
	right: 24px;
	width: 370px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 130px);
	background: var(--lcw-bg);
	border-radius: var(--lcw-radius);
	box-shadow: var(--lcw-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: lcw-pop-in .22s cubic-bezier(.2,.9,.3,1.2);
	transform-origin: bottom right;
}
#lcw-widget-root.lcw-pos-bottom-left .lcw-panel { right: auto; left: 24px; transform-origin: bottom left; }

@keyframes lcw-pop-in {
	from { opacity: 0; transform: translateY(16px) scale(.94); }
	to { opacity: 1; transform: translateY(0) scale(1); }
}

.lcw-panel-header {
	background: linear-gradient(120deg, var(--lcw-primary), var(--lcw-secondary));
	color: #fff;
	padding: 14px 10px 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
	cursor: grab;
	user-select: none;
}
.lcw-panel-header.lcw-dragging { cursor: grabbing; }
.lcw-header-info { display: flex; align-items: center; gap: 10px; }
.lcw-avatar {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: rgba(255,255,255,.22);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}
.lcw-header-title { font-weight: 700; font-size: 14.5px; }
.lcw-header-status { display: flex; align-items: center; gap: 5px; font-size: 12px; opacity: .92; }
.lcw-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #9ca3af; display: inline-block; }
.lcw-status-dot.online { background: #4ade80; box-shadow: 0 0 0 2px rgba(74,222,128,.35); }
.lcw-status-dot.offline { background: #d1d5db; }
.lcw-header-actions { display: flex; gap: 4px; }
.lcw-header-btn {
	background: rgba(255,255,255,.18);
	border: none;
	color: #fff;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background .15s ease;
}
.lcw-header-btn:hover { background: rgba(255,255,255,.32); }

/* ---------- Messages ---------- */
.lcw-messages {
	flex-grow: 1;
	overflow-y: auto;
	padding: 16px;
	background: var(--lcw-bg-soft);
	display: flex;
	flex-direction: column;
	gap: 4px;
}
.lcw-bubble-row { display: flex; margin-bottom: 8px; }
.lcw-bubble-row.visitor { justify-content: flex-end; }
.lcw-bubble-row.agent, .lcw-bubble-row.system { justify-content: flex-start; }
.lcw-bubble {
	max-width: 78%;
	padding: 9px 13px;
	border-radius: 16px;
	font-size: 13.6px;
	word-wrap: break-word;
}
.lcw-bubble-row.visitor .lcw-bubble {
	background: linear-gradient(120deg, var(--lcw-primary), var(--lcw-secondary));
	color: #fff;
	border-bottom-right-radius: 4px;
}
.lcw-bubble-row.agent .lcw-bubble {
	background: #fff;
	border: 1px solid #ececf3;
	border-bottom-left-radius: 4px;
}
.lcw-bubble-row.system .lcw-bubble {
	background: transparent;
	color: #9096a3;
	font-size: 12px;
	margin: 0 auto;
	text-align: center;
}
.lcw-bubble img { max-width: 100%; border-radius: 10px; display: block; margin-top: 2px; cursor: zoom-in; }
.lcw-bubble audio { width: 210px; height: 34px; margin-top: 2px; }
.lcw-bubble .lcw-file-chip {
	display: flex;
	align-items: center;
	gap: 8px;
	background: rgba(0,0,0,.04);
	padding: 8px 10px;
	border-radius: 10px;
	text-decoration: none;
	color: inherit;
	font-size: 12.6px;
}
.lcw-time { font-size: 10.5px; opacity: .6; margin-top: 3px; display: block; }

.lcw-typing-hint {
	padding: 0 16px 4px;
	font-size: 12px;
	color: #8b8fa3;
	font-style: italic;
	flex-shrink: 0;
}

/* ---------- Composer ---------- */
.lcw-composer {
	display: flex;
	align-items: flex-end;
	gap: 6px;
	padding: 10px 12px;
	border-top: 1px solid #eef0f4;
	flex-shrink: 0;
	background: #fff;
}
.lcw-text-input {
	flex-grow: 1;
	border: 1px solid #e3e5ec;
	background: var(--lcw-bg-soft);
	border-radius: 14px;
	padding: 9px 12px;
	resize: none;
	max-height: 90px;
	font-size: 13.6px;
	font-family: inherit;
	outline: none;
}
.lcw-text-input:focus { border-color: var(--lcw-primary); }
.lcw-composer-btn, .lcw-send-btn {
	border: none;
	background: var(--lcw-bg-soft);
	color: #6b7280;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
	transition: background .15s ease, color .15s ease;
}
.lcw-composer-btn:hover { background: #ececf6; color: var(--lcw-primary); }
.lcw-composer-btn.lcw-recording { background: #fee2e2; color: #ef4444; animation: lcw-pulse-red 1.2s infinite; }
.lcw-send-btn {
	background: linear-gradient(120deg, var(--lcw-primary), var(--lcw-secondary));
	color: #fff;
}
.lcw-send-btn:hover { filter: brightness(1.06); }

.lcw-recording-bar {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 14px;
	border-top: 1px solid #eef0f4;
	background: #fff5f5;
	font-size: 12.5px;
	flex-shrink: 0;
}
.lcw-rec-dot { width: 9px; height: 9px; border-radius: 50%; background: #ef4444; animation: lcw-pulse-red 1s infinite; }
.lcw-rec-label { color: #ef4444; flex-grow: 1; }
.lcw-rec-cancel, .lcw-rec-send {
	border: none;
	border-radius: 8px;
	padding: 5px 10px;
	cursor: pointer;
	font-size: 12px;
	font-weight: 600;
}
.lcw-rec-cancel { background: #f0f0f4; color: #555; }
.lcw-rec-send { background: var(--lcw-primary); color: #fff; }

@keyframes lcw-pulse-red {
	0%, 100% { opacity: 1; }
	50% { opacity: .35; }
}

.lcw-hidden { display: none !important; }

/* ---------- Pre-chat gate ---------- */
.lcw-prechat-gate {
	flex-grow: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 28px 24px;
	background: var(--lcw-bg-soft);
}
.lcw-prechat-icon {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--lcw-primary), var(--lcw-secondary));
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-bottom: 14px;
}
.lcw-prechat-title { font-size: 15.5px; font-weight: 700; margin-bottom: 4px; }
.lcw-prechat-sub { font-size: 12.5px; color: #8b8fa3; margin-bottom: 18px; max-width: 260px; }
.lcw-prechat-form { width: 100%; max-width: 260px; display: flex; flex-direction: column; gap: 10px; }
.lcw-prechat-input {
	border: 1px solid #e3e5ec;
	background: #fff;
	border-radius: 10px;
	padding: 10px 12px;
	font-size: 13.6px;
	font-family: inherit;
	outline: none;
	width: 100%;
}
.lcw-prechat-input:focus { border-color: var(--lcw-primary); }
.lcw-prechat-error { color: #ef4444; font-size: 12px; text-align: left; }
.lcw-prechat-submit {
	border: none;
	border-radius: 10px;
	padding: 10px 14px;
	background: linear-gradient(120deg, var(--lcw-primary), var(--lcw-secondary));
	color: #fff;
	font-weight: 600;
	font-size: 13.6px;
	cursor: pointer;
	margin-top: 4px;
}
.lcw-prechat-submit:hover { filter: brightness(1.06); }
.lcw-chat-body { display: flex; flex-direction: column; flex-grow: 1; min-height: 0; }

/* ---------- Call overlay ---------- */
.lcw-call-overlay {
	position: absolute;
	inset: 0;
	background: linear-gradient(160deg, rgba(30,27,75,.96), rgba(15,23,42,.96));
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--lcw-radius);
	z-index: 5;
}
.lcw-call-card { text-align: center; color: #fff; position: relative; }
.lcw-call-avatar {
	width: 74px; height: 74px;
	margin: 0 auto 14px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--lcw-primary), var(--lcw-secondary));
	display: flex; align-items: center; justify-content: center;
	position: relative;
	z-index: 1;
}
.lcw-call-pulse {
	position: absolute;
	top: 50%; left: 50%;
	width: 74px; height: 74px;
	margin-top: -37px; margin-left: -37px;
	border-radius: 50%;
	background: var(--lcw-primary);
	opacity: .5;
	animation: lcw-call-ring 1.6s ease-out infinite;
}
@keyframes lcw-call-ring {
	0% { transform: scale(1); opacity: .5; }
	100% { transform: scale(2.1); opacity: 0; }
}
.lcw-call-status { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.lcw-call-timer { font-size: 12.5px; opacity: .75; margin-bottom: 18px; font-variant-numeric: tabular-nums; }
.lcw-call-actions { display: flex; justify-content: center; margin-top: 18px; }
.lcw-call-btn {
	width: 54px; height: 54px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	display: flex; align-items: center; justify-content: center;
}
.lcw-call-hangup { background: #ef4444; }
.lcw-call-hangup:hover { background: #dc2626; }

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
	#lcw-widget-root { bottom: 16px; right: 16px; }
	#lcw-widget-root.lcw-pos-bottom-left { left: 16px; }
	.lcw-launcher { width: 56px; height: 56px; }
	.lcw-panel {
		position: fixed;
		top: 0; left: 0; right: 0; bottom: 0;
		width: 100vw;
		height: 100vh;
		max-height: 100vh;
		max-width: 100vw;
		border-radius: 0;
		bottom: auto;
	}
	.lcw-panel-header { padding-top: max(14px, env(safe-area-inset-top)); }
	.lcw-composer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}

/* When user has manually dragged the panel, JS sets inline top/left and clears bottom/right/transform-origin */
.lcw-panel.lcw-dragged { animation: none; }

/* ---------- Front-end agent mode ---------- */
.lcw-agent-status-select {
	background: rgba(255,255,255,.18);
	color: #fff;
	border: 1px solid rgba(255,255,255,.35);
	border-radius: 6px;
	font-size: 11.5px;
	padding: 2px 6px;
}
.lcw-agent-status-select option { color: #1F2937; }

.lcw-agent-list-view, .lcw-agent-thread-view { flex-grow: 1; display: flex; flex-direction: column; min-height: 0; }
.lcw-agent-list { flex-grow: 1; overflow-y: auto; background: var(--lcw-bg-soft); }
.lcw-conv-item {
	display: block;
	width: 100%;
	text-align: left;
	padding: 12px 16px;
	border: 0;
	border-bottom: 1px solid #ececf3;
	background: #fff;
	cursor: pointer;
	font: inherit;
	color: inherit;
}
.lcw-conv-item:hover { background: #f5f6ff; }
.lcw-conv-item-name { font-weight: 700; font-size: 13.5px; display: flex; justify-content: space-between; align-items: center; }
.lcw-unread-badge {
	background: #ef4444; color: #fff; border-radius: 999px;
	font-size: 10.5px; padding: 1px 7px; font-weight: 700;
}
.lcw-conv-item-preview { font-size: 12px; color: #888; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lcw-conv-item-phone { font-size: 11.5px; color: #6b7280; margin-top: 1px; }
.lcw-conv-empty { padding: 30px 16px; color: #9096a3; text-align: center; font-size: 13px; }
.lcw-agent-thread-view #lcw-agent-messages { flex-grow: 1; }
