#lwd-chat-widget {
	position: fixed;
	bottom: 24px;
	z-index: 9998;
	font-family: var(--font-body, "Inter", sans-serif);
}
#lwd-chat-widget.lwd-chat-right { right: 24px; }
#lwd-chat-widget.lwd-chat-left { left: 24px; }

#lwd-chat-bubble {
	height: 60px;
	border-radius: 999px;
	background-color: var(--lwd-chat-color, #f7941d) !important;
	background: var(--lwd-chat-color, #f7941d) !important;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
	position: relative;
	padding: 0 20px 0 8px;
	transition: transform 0.25s ease, box-shadow 0.25s ease, padding 0.25s ease, width 0.25s ease;
}
#lwd-chat-bubble:hover { transform: scale(1.05); box-shadow: 0 14px 36px rgba(0, 0, 0, 0.3); }
#lwd-chat-bubble.is-open { width: 60px; padding: 0; border-radius: 50%; }

.lwd-chat-bubble-closed {
	display: flex;
	align-items: center;
	gap: 8px;
}
#lwd-chat-bubble.is-open .lwd-chat-bubble-closed { display: none; }
.lwd-chat-bubble-closed img {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: #fff;
	padding: 3px;
	flex-shrink: 0;
}
.lwd-chat-bubble-closed span {
	color: #fff;
	font-weight: 700;
	font-size: 14.5px;
	white-space: nowrap;
	font-family: var(--font-head, inherit);
}

.lwd-chat-bubble-open { display: none; align-items: center; justify-content: center; }
#lwd-chat-bubble.is-open .lwd-chat-bubble-open { display: flex; }

.lwd-chat-badge {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	border-radius: 999px;
	background: #ef4444;
	color: #fff;
	font-size: 11px;
	font-weight: 800;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2px solid #fff;
}

.lwd-chat-panel {
	position: absolute;
	bottom: 76px;
	width: 340px;
	max-width: calc(100vw - 48px);
	height: 480px;
	max-height: calc(100vh - 140px);
	background: #fff;
	border-radius: 18px;
	box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}
.lwd-chat-right .lwd-chat-panel { right: 0; }
.lwd-chat-left .lwd-chat-panel { left: 0; }

.lwd-chat-panel-header {
	background: var(--lwd-chat-color, #f7941d);
	color: #fff;
	padding: 18px 20px;
	flex-shrink: 0;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 10px;
}
.lwd-chat-panel-header strong { display: block; font-size: 15px; font-family: var(--font-head, sans-serif); }
.lwd-chat-status { display: flex; align-items: center; gap: 6px; font-size: 12.5px; opacity: 0.95; margin-top: 4px; }
.lwd-chat-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; display: inline-block; }
#lwd-chat-widget[data-online="0"] .lwd-chat-dot { background: #fde68a; }
.lwd-chat-human-note { display: block; font-size: 11px; opacity: 0.8; margin-top: 2px; }

.lwd-chat-end-btn {
	background-color: rgba(255, 255, 255, 0.18) !important;
	background: rgba(255, 255, 255, 0.18) !important;
	color: #fff;
	border: none;
	border-radius: 999px;
	font-size: 11.5px;
	font-weight: 700;
	padding: 6px 12px;
	cursor: pointer;
	flex-shrink: 0;
	-webkit-tap-highlight-color: transparent !important;
	appearance: none;
	-webkit-appearance: none;
}
.lwd-chat-end-btn:hover,
.lwd-chat-end-btn:focus { background-color: rgba(255, 255, 255, 0.3) !important; outline: none; }
.lwd-chat-end-btn[hidden] { display: none !important; }

/* Message timestamps */
.lwd-chat-msg-time {
	display: block;
	font-size: 10.5px;
	opacity: 0.6;
	margin-top: 3px;
}
.lwd-chat-msg.visitor .lwd-chat-msg-time { text-align: right; }

/* Ended state + feedback */
.lwd-chat-ended {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 24px;
	gap: 14px;
}
.lwd-chat-ended[hidden] { display: none !important; }
.lwd-chat-ended p { margin: 0; color: var(--gray-500, #64748b); font-size: 14px; }
.lwd-chat-feedback p { font-weight: 600; color: var(--ink, #0f172a); margin-bottom: 10px; }
.lwd-chat-feedback-btns { display: flex; gap: 14px; justify-content: center; }
.lwd-chat-feedback-btn {
	width: 52px;
	height: 52px;
	border-radius: 50%;
	border: 2px solid #e2e8f0;
	background-color: #fff !important;
	background: #fff !important;
	font-size: 22px;
	cursor: pointer;
	transition: transform 0.15s ease, border-color 0.15s ease;
	-webkit-tap-highlight-color: transparent !important;
	appearance: none;
	-webkit-appearance: none;
}
.lwd-chat-feedback-btn:hover { transform: scale(1.08); }
.lwd-chat-feedback-btn.is-selected { border-color: var(--lwd-chat-color, #f7941d); background-color: #fff7ed !important; }
.lwd-chat-feedback-thanks { color: #22c55e; font-weight: 700; font-size: 14px; }
.lwd-chat-feedback-thanks[hidden] { display: none !important; }

/* Typing indicator */
.lwd-chat-typing {
	display: flex;
	gap: 6px;
	align-items: center;
	padding: 4px 16px 10px;
	flex-shrink: 0;
}
.lwd-chat-typing[hidden] { display: none !important; }
.lwd-chat-typing-label { font-size: 12px; color: #94a3b8; font-style: italic; }
.lwd-chat-typing-dots { display: flex; gap: 4px; align-items: center; }
.lwd-chat-typing-dots i {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #94a3b8;
	animation: lwd-typing-bounce 1.2s infinite;
	display: block;
}
.lwd-chat-typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.lwd-chat-typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes lwd-typing-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
	30% { transform: translateY(-4px); opacity: 1; }
}

.lwd-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #f8fafc;
}
.lwd-chat-msg {
	max-width: 80%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.5;
	white-space: pre-wrap;
	word-break: break-word;
}
.lwd-chat-msg.visitor {
	align-self: flex-end;
	background: var(--lwd-chat-color, #f7941d);
	color: #fff;
	border-bottom-right-radius: 4px;
}
.lwd-chat-msg.admin {
	align-self: flex-start;
	background: #fff;
	color: #0f172a;
	border: 1px solid #e2e8f0;
	border-bottom-left-radius: 4px;
}
.lwd-chat-msg.system {
	align-self: center;
	background: transparent;
	color: #64748b;
	font-size: 12.5px;
	text-align: center;
	max-width: 100%;
}

.lwd-chat-precontact {
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	border-top: 1px solid #e2e8f0;
	flex-shrink: 0;
}
.lwd-chat-precontact input {
	padding: 11px 14px;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	font-size: 14px;
	font-family: inherit;
}
.lwd-chat-precontact input:focus { outline: none; border-color: var(--lwd-chat-color, #f7941d); }
.lwd-chat-precontact .lwd-btn { width: 100%; padding: 12px; font-size: 14px; }

.lwd-chat-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid #e2e8f0;
	flex-shrink: 0;
}
.lwd-chat-form textarea {
	flex: 1;
	resize: none;
	max-height: 90px;
	padding: 10px 12px;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	font-size: 14px;
	font-family: inherit;
	line-height: 1.4;
}
.lwd-chat-form textarea:focus { outline: none; border-color: var(--lwd-chat-color, #f7941d); }
.lwd-chat-send-btn {
	height: 40px;
	padding: 0 16px;
	border-radius: 999px;
	border: none;
	-webkit-tap-highlight-color: transparent !important;
	background-color: var(--lwd-chat-color, #f7941d) !important;
	background: var(--lwd-chat-color, #f7941d) !important;
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	cursor: pointer;
	flex-shrink: 0;
	font-family: var(--font-head, inherit);
	font-weight: 700;
	font-size: 13.5px;
	transition: transform 0.2s ease;
}
.lwd-chat-send-btn:hover { transform: scale(1.04); }

.lwd-chat-empty { text-align: center; color: #94a3b8; font-size: 13px; padding: 24px; }

.lwd-chat-msg-img {
	max-width: 180px;
	max-height: 180px;
	border-radius: 10px;
	display: block;
	cursor: zoom-in;
}

.lwd-chat-toolbar {
	position: relative;
	display: flex;
	gap: 4px;
	padding: 6px 12px 0;
	flex-shrink: 0;
}
.lwd-chat-toolbar[hidden] { display: none !important; }
.lwd-chat-tool-btn {
	background-color: transparent !important;
	background: none !important;
	border: none;
	font-size: 18px;
	cursor: pointer;
	padding: 4px 6px;
	border-radius: 6px;
	line-height: 1;
	-webkit-tap-highlight-color: transparent !important;
	-webkit-appearance: none;
	appearance: none;
}
.lwd-chat-tool-btn:hover,
.lwd-chat-tool-btn:focus,
.lwd-chat-tool-btn:active { background-color: #f1f5f9 !important; outline: none; }

.lwd-chat-emoji-picker {
	position: absolute;
	bottom: 38px;
	left: 12px;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
	padding: 8px;
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	gap: 2px;
	z-index: 5;
}
.lwd-chat-emoji-picker[hidden] { display: none !important; }
.lwd-chat-emoji-picker button {
	background-color: transparent !important;
	background: none !important;
	border: none;
	font-size: 18px;
	cursor: pointer;
	padding: 4px;
	border-radius: 6px;
	-webkit-tap-highlight-color: transparent !important;
	-webkit-appearance: none;
	appearance: none;
}
.lwd-chat-emoji-picker button:hover,
.lwd-chat-emoji-picker button:focus { background-color: #f1f5f9 !important; outline: none; }

.lwd-chat-panel[hidden],
.lwd-chat-precontact[hidden],
.lwd-chat-form[hidden] { display: none !important; }

@media (max-width: 480px) {
	#lwd-chat-widget.lwd-chat-right, #lwd-chat-widget.lwd-chat-left { right: 16px; left: 16px; bottom: 16px; }
	.lwd-chat-panel { width: auto; left: 0; right: 0; bottom: 76px; }
}
