/**
 * Front-end widget styles. Everything is scoped under .wplc.
 */

.wplc {
	--wplc-accent: #2563eb;
	--wplc-ink: #0f172a;
	--wplc-muted: #64748b;
	--wplc-line: #e2e8f0;
	--wplc-surface: #ffffff;
	--wplc-canvas: #f8fafc;

	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
	color: var(--wplc-ink);
}

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

.wplc [hidden] {
	display: none !important;
}

/* Launcher */

.wplc-launcher {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 2147483000;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 58px;
	height: 58px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--wplc-accent);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 12px 30px rgba(15, 23, 42, 0.28);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.wplc-launcher:hover {
	transform: translateY(-2px);
	box-shadow: 0 16px 36px rgba(15, 23, 42, 0.32);
}

.wplc-launcher:focus-visible {
	outline: 3px solid rgba(37, 99, 235, 0.45);
	outline-offset: 3px;
}

.wplc--left .wplc-launcher {
	right: auto;
	left: 24px;
}

.wplc-icon-open,
.wplc-icon-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.wplc-icon-close {
	display: none;
}

.wplc--open .wplc-icon-open {
	display: none;
}

.wplc--open .wplc-icon-close {
	display: inline-flex;
}

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

/* Panel */

.wplc-panel {
	position: fixed;
	right: 24px;
	bottom: 96px;
	z-index: 2147483000;
	display: flex;
	flex-direction: column;
	width: 370px;
	max-width: calc(100vw - 32px);
	height: min(560px, calc(100vh - 140px));
	overflow: hidden;
	border-radius: 18px;
	background: var(--wplc-surface);
	box-shadow: 0 30px 70px rgba(15, 23, 42, 0.3);
	opacity: 0;
	transform: translateY(14px) scale(0.985);
	pointer-events: none;
	transition: opacity 0.18s ease, transform 0.18s ease;
}

.wplc--open .wplc-panel {
	opacity: 1;
	transform: none;
	pointer-events: auto;
}

.wplc--left .wplc-panel {
	right: auto;
	left: 24px;
}

.wplc-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	background: var(--wplc-accent);
	color: #fff;
}

.wplc-avatar {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.2);
	font-weight: 700;
	text-transform: uppercase;
}

.wplc-header-text {
	display: flex;
	flex-direction: column;
	min-width: 0;
	flex: 1 1 auto;
}

.wplc-header-text strong {
	font-size: 15px;
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.wplc-presence {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	opacity: 0.9;
}

.wplc-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #4ade80;
	box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3);
}

.wplc-presence.is-offline .wplc-dot {
	background: #cbd5e1;
	box-shadow: 0 0 0 2px rgba(203, 213, 225, 0.35);
}

.wplc-away {
	margin: 0;
	padding: 9px 16px;
	border-bottom: 1px solid var(--wplc-line);
	background: #fffbeb;
	color: #92400e;
	font-size: 12.5px;
	line-height: 1.4;
}

.wplc-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.wplc-close:hover {
	background: rgba(255, 255, 255, 0.16);
}

.wplc-close:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 1px;
}

/* Messages */

.wplc-messages {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 10px;
	overflow-y: auto;
	padding: 16px;
	background: var(--wplc-canvas);
}

.wplc-msg {
	display: flex;
	flex-direction: column;
	max-width: 84%;
}

.wplc-msg--in {
	align-self: flex-start;
	align-items: flex-start;
}

.wplc-msg--out {
	align-self: flex-end;
	align-items: flex-end;
}

.wplc-bubble {
	padding: 10px 13px;
	border-radius: 14px;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.wplc-msg--in .wplc-bubble {
	background: #fff;
	border: 1px solid var(--wplc-line);
	border-bottom-left-radius: 5px;
}

.wplc-msg--out .wplc-bubble {
	background: var(--wplc-accent);
	color: #fff;
	border-bottom-right-radius: 5px;
}

.wplc-time {
	margin-top: 3px;
	color: var(--wplc-muted);
	font-size: 11px;
}

/* Composer */

.wplc-form {
	padding: 10px 12px 12px;
	border-top: 1px solid var(--wplc-line);
	background: var(--wplc-surface);
}

.wplc-fields {
	display: flex;
	gap: 8px;
	margin-bottom: 8px;
}

.wplc-input-text {
	flex: 1 1 0;
	min-width: 0;
	padding: 8px 10px;
	border: 1px solid var(--wplc-line);
	border-radius: 9px;
	font: inherit;
	font-size: 14px;
	color: var(--wplc-ink);
	background: #fff;
}

.wplc-composer {
	display: flex;
	align-items: flex-end;
	gap: 8px;
}

.wplc-input {
	flex: 1 1 auto;
	min-height: 40px;
	max-height: 120px;
	padding: 10px 12px;
	border: 1px solid var(--wplc-line);
	border-radius: 12px;
	resize: none;
	font: inherit;
	line-height: 1.4;
	color: var(--wplc-ink);
	background: #fff;
}

.wplc-input-text:focus,
.wplc-input:focus {
	outline: none;
	border-color: var(--wplc-accent);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.wplc-send {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--wplc-accent);
	color: #fff;
	cursor: pointer;
}

.wplc-send:disabled {
	opacity: 0.55;
	cursor: default;
}

.wplc-error {
	margin: 8px 2px 0;
	color: #b91c1c;
	font-size: 12px;
}

.wplc-closed {
	margin: 8px 2px 0;
	color: var(--wplc-muted);
	font-size: 12px;
}

/* Small screens: full-width bottom sheet. */

@media (max-width: 480px) {
	.wplc-panel {
		right: 12px;
		left: 12px;
		bottom: 88px;
		width: auto;
		height: min(72vh, 560px);
	}

	.wplc--left .wplc-panel {
		right: 12px;
		left: 12px;
	}

	.wplc-launcher {
		right: 16px;
		bottom: 16px;
	}

	.wplc--left .wplc-launcher {
		right: auto;
		left: 16px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wplc-panel,
	.wplc-launcher {
		transition: none;
	}
}
