/* Live Chat to WhatsApp - Frontend Styles */

.lwc-widget {
	position: fixed;
	bottom: 24px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 14px;
	line-height: 1.45;
	box-sizing: border-box;
}

.lwc-widget *,
.lwc-widget *::before,
.lwc-widget *::after {
	box-sizing: border-box;
}

.lwc-pos-right {
	right: 24px;
}

.lwc-pos-left {
	left: 24px;
}

/* ===== Launcher Button ===== */
.lwc-launcher {
	display: flex;
	align-items: center;
	gap: 8px;
	background: var(--lwc-primary, #25D366);
	color: #fff;
	border: none;
	border-radius: 50px;
	padding: 14px 20px;
	cursor: pointer;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	position: relative;
	font-weight: 600;
	font-size: 15px;
}

.lwc-launcher:hover {
	transform: scale(1.05);
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
}

.lwc-launcher:active {
	transform: scale(0.98);
}

.lwc-launcher-icon {
	display: flex;
	align-items: center;
	justify-content: center;
}

.lwc-launcher-icon svg {
	display: block;
}

.lwc-badge {
	position: absolute;
	top: -6px;
	right: -6px;
	background: #e74c3c;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	min-width: 20px;
	height: 20px;
	border-radius: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 5px;
	box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* ===== Chat Window ===== */
.lwc-window {
	position: absolute;
	bottom: 70px;
	width: 370px;
	max-width: calc(100vw - 32px);
	height: 520px;
	max-height: calc(100vh - 120px);
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: lwc-slide-up 0.25s ease;
}

.lwc-pos-right .lwc-window {
	right: 0;
}

.lwc-pos-left .lwc-window {
	left: 0;
}

@keyframes lwc-slide-up {
	from {
		opacity: 0;
		transform: translateY(20px) scale(0.96);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

/* Header */
.lwc-header {
	background: var(--lwc-header-bg, #128C7E);
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.lwc-header-info {
	display: flex;
	align-items: center;
	gap: 12px;
}

.lwc-avatar {
	width: 40px;
	height: 40px;
	background: rgba(255,255,255,0.2);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
}

.lwc-header-title {
	font-weight: 600;
	font-size: 16px;
}

.lwc-header-status {
	font-size: 12px;
	opacity: 0.9;
	display: flex;
	align-items: center;
	gap: 5px;
	margin-top: 1px;
}

.lwc-status-dot {
	width: 8px;
	height: 8px;
	background: #4ade80;
	border-radius: 50%;
	display: inline-block;
	box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3);
}

.lwc-close {
	background: transparent;
	border: none;
	color: #fff;
	cursor: pointer;
	padding: 6px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0.85;
	transition: opacity 0.15s, background 0.15s;
}

.lwc-close:hover {
	opacity: 1;
	background: rgba(255,255,255,0.15);
}

/* Body */
.lwc-body {
	flex: 1;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	background: #f0f2f5;
}

/* Pre-chat form */
.lwc-prechat {
	padding: 20px;
	overflow-y: auto;
	flex: 1;
}

.lwc-welcome {
	background: #fff;
	padding: 14px 16px;
	border-radius: 12px;
	margin: 0 0 18px;
	box-shadow: 0 1px 2px rgba(0,0,0,0.06);
	font-size: 14px;
	line-height: 1.5;
	color: #333;
}

.lwc-field {
	margin-bottom: 12px;
}

.lwc-field input {
	width: 100%;
	padding: 12px 14px;
	border: 1px solid #d1d5db;
	border-radius: 10px;
	font-size: 14px;
	outline: none;
	transition: border-color 0.15s, box-shadow 0.15s;
	background: #fff;
}

.lwc-field input:focus {
	border-color: var(--lwc-primary, #25D366);
	box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}

.lwc-field small {
	display: block;
	margin-top: 4px;
	font-size: 11px;
	color: #6b7280;
}

.lwc-btn {
	display: block;
	width: 100%;
	padding: 13px 16px;
	border: none;
	border-radius: 10px;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s, transform 0.1s;
}

.lwc-btn-primary {
	background: var(--lwc-primary, #25D366);
	color: #fff;
	margin-top: 6px;
}

.lwc-btn-primary:hover {
	filter: brightness(1.05);
}

.lwc-btn-primary:active {
	transform: scale(0.98);
}

.lwc-btn-primary:disabled {
	opacity: 0.65;
	cursor: not-allowed;
}

/* Messages area */
.lwc-messages-wrap {
	flex: 1;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.lwc-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}

.lwc-message {
	display: flex;
	flex-direction: column;
	max-width: 85%;
	animation: lwc-msg-in 0.2s ease;
}

@keyframes lwc-msg-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.lwc-message-visitor {
	align-self: flex-end;
}

.lwc-message-agent {
	align-self: flex-start;
}

.lwc-bubble {
	padding: 10px 14px;
	border-radius: 16px;
	position: relative;
	word-wrap: break-word;
	white-space: pre-wrap;
	font-size: 14px;
	line-height: 1.45;
}

.lwc-message-visitor .lwc-bubble {
	background: var(--lwc-primary, #25D366);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.lwc-message-agent .lwc-bubble {
	background: #fff;
	color: #1f2937;
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.lwc-time {
	display: block;
	font-size: 10px;
	opacity: 0.7;
	margin-top: 4px;
	text-align: right;
}

.lwc-message-agent .lwc-time {
	text-align: left;
	color: #6b7280;
}

.lwc-sender-name {
	font-size: 11px;
	color: #6b7280;
	margin-top: 3px;
	margin-left: 4px;
}

/* System / welcome as agent style */
.lwc-message-system .lwc-bubble {
	background: #e5e7eb;
	color: #4b5563;
	font-size: 13px;
	text-align: center;
	border-radius: 10px;
	max-width: 100%;
	align-self: center;
}

/* Footer / Input */
.lwc-footer {
	background: #fff;
	border-top: 1px solid #e5e7eb;
	padding: 10px 12px 8px;
	flex-shrink: 0;
}

#lwc-message-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
}

#lwc-input {
	flex: 1;
	border: 1px solid #d1d5db;
	border-radius: 20px;
	padding: 10px 16px;
	font-size: 14px;
	resize: none;
	max-height: 100px;
	outline: none;
	font-family: inherit;
	line-height: 1.4;
	transition: border-color 0.15s;
}

#lwc-input:focus {
	border-color: var(--lwc-primary, #25D366);
}

.lwc-send {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: var(--lwc-primary, #25D366);
	color: #fff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: transform 0.15s, filter 0.15s;
}

.lwc-send:hover {
	filter: brightness(1.08);
	transform: scale(1.05);
}

.lwc-send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
}

.lwc-footer-links {
	text-align: center;
	margin-top: 6px;
}

.lwc-wa-link {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font-size: 12px;
	color: #25D366;
	text-decoration: none;
	font-weight: 500;
}

.lwc-wa-link:hover {
	text-decoration: underline;
}

/* Mobile full screen-ish */
@media (max-width: 480px) {
	.lwc-widget {
		bottom: 16px;
	}

	.lwc-pos-right {
		right: 16px;
	}

	.lwc-pos-left {
		left: 16px;
	}

	.lwc-window {
		position: fixed;
		bottom: 0;
		left: 0 !important;
		right: 0 !important;
		width: 100%;
		max-width: 100%;
		height: 85vh;
		max-height: 85vh;
		border-radius: 16px 16px 0 0;
	}

	.lwc-launcher {
		padding: 12px 16px;
	}
}

/* Hide when not ready */
.lwc-widget.lwc-ready {
	display: block !important;
}
