/*
 * Frontdesk Live Chat — widget.
 * Every colour and size comes from the custom properties below; the values saved under
 * Live Chat → Settings are printed after this file and override them.
 */

.fdlc-root {
	--fdlc-accent: #0e5c63;
	--fdlc-accent-text: #ffffff;
	--fdlc-panel-bg: #ffffff;
	--fdlc-panel-text: #1b2430;
	--fdlc-agent-bg: #eef2f1;
	--fdlc-agent-text: #1b2430;
	--fdlc-visitor-bg: #0e5c63;
	--fdlc-visitor-text: #ffffff;
	--fdlc-radius: 16px;
	--fdlc-font-size: 15px;
	--fdlc-launcher: 60px;
	--fdlc-offset-x: 24px;
	--fdlc-offset-y: 24px;
	--fdlc-font: inherit;

	/* Derived. */
	--fdlc-line: rgba(0, 0, 0, 0.1);
	--fdlc-muted: rgba(0, 0, 0, 0.55);
	--fdlc-bubble-radius: min(var(--fdlc-radius), 18px);
	--fdlc-danger: #b3261e;

	position: fixed;
	right: var(--fdlc-offset-x);
	bottom: var(--fdlc-offset-y);
	z-index: 999990;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 14px;
	pointer-events: none;
	font-family: var(--fdlc-font);
	font-size: var(--fdlc-font-size);
	font-weight: 400;
	line-height: 1.45;
	letter-spacing: normal;
	text-align: left;
	text-transform: none;
	color: var(--fdlc-panel-text);
	-webkit-font-smoothing: antialiased;
}

@supports (color: color-mix(in srgb, red 50%, blue)) {
	.fdlc-root {
		--fdlc-line: color-mix(in srgb, var(--fdlc-panel-text) 12%, transparent);
		--fdlc-muted: color-mix(in srgb, var(--fdlc-panel-text) 62%, transparent);
	}
}

.fdlc-root.fdlc-left {
	right: auto;
	left: var(--fdlc-offset-x);
	align-items: flex-start;
}

/* The container lets clicks through to the page; only the panel and the button catch them. */
.fdlc-root > .fdlc-panel,
.fdlc-root > .fdlc-launcher {
	pointer-events: auto;
}

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

.fdlc-root [hidden] {
	display: none !important;
}

/* Keep theme styles for form controls out of the widget. */
.fdlc-root button,
.fdlc-root input,
.fdlc-root textarea {
	all: unset;
	box-sizing: border-box;
	font: inherit;
	color: inherit;
}

.fdlc-root p {
	margin: 0;
	padding: 0;
}

.fdlc-root img {
	display: block;
	max-width: none;
	margin: 0;
	padding: 0;
	border: 0;
	box-shadow: none;
}

.fdlc-root button {
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.fdlc-root :focus-visible {
	outline: 2px solid var(--fdlc-accent);
	outline-offset: 2px;
}

/* ------------------------------------------------------------------ Avatars */

.fdlc-avatar {
	position: relative;
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	overflow: hidden;
	border-radius: 50%;
	background: var(--fdlc-accent);
	color: var(--fdlc-accent-text);
	font-size: 11px;
	font-weight: 600;
	line-height: 1;
	user-select: none;
}

.fdlc-root .fdlc-avatar img {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	object-fit: cover;
}

.fdlc-avatar svg {
	width: 55%;
	height: 55%;
}

.fdlc-avatar--spacer {
	visibility: hidden;
	height: 0;
}

/* ----------------------------------------------------------------- Launcher */

.fdlc-root .fdlc-launcher {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--fdlc-launcher);
	height: var(--fdlc-launcher);
	border-radius: 50%;
	background: var(--fdlc-accent);
	color: var(--fdlc-accent-text);
	box-shadow: 0 2px 6px rgba(15, 25, 35, 0.16), 0 10px 28px rgba(15, 25, 35, 0.22);
	transition: transform 0.15s ease;
}

.fdlc-root .fdlc-launcher:hover {
	transform: scale(1.05);
}

.fdlc-root .fdlc-launcher:active {
	transform: scale(0.97);
}

.fdlc-launcher-face {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	border-radius: 50%;
	overflow: hidden;
}

.fdlc-launcher-face svg {
	width: 46%;
	height: 46%;
}

/* Once a team member is handling the chat, the launcher shows their picture. */
.fdlc-root .fdlc-launcher-face img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border: 3px solid var(--fdlc-accent);
	border-radius: 50%;
}

.fdlc-badge {
	position: absolute;
	top: -3px;
	right: -3px;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border: 2px solid var(--fdlc-panel-bg);
	border-radius: 11px;
	background: #d92d20;
	color: #ffffff;
	font-size: 12px;
	font-weight: 700;
	line-height: 18px;
	text-align: center;
}

/* -------------------------------------------------------------------- Panel */

.fdlc-panel {
	display: flex;
	flex-direction: column;
	width: min(376px, calc(100vw - 2 * var(--fdlc-offset-x)));
	height: min(600px, calc(100vh - var(--fdlc-launcher) - var(--fdlc-offset-y) - 40px));
	overflow: hidden;
	border-radius: var(--fdlc-radius);
	background: var(--fdlc-panel-bg);
	color: var(--fdlc-panel-text);
	box-shadow: 0 0 0 1px rgba(15, 25, 35, 0.06), 0 6px 16px rgba(15, 25, 35, 0.1), 0 24px 60px rgba(15, 25, 35, 0.22);
	transform-origin: bottom right;
	animation: fdlc-open 0.18s ease-out;
}

.fdlc-left .fdlc-panel {
	transform-origin: bottom left;
}

@keyframes fdlc-open {
	from {
		opacity: 0;
		transform: translateY(8px) scale(0.97);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.fdlc-header {
	flex: none;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 12px 16px 18px;
	background: var(--fdlc-accent);
	color: var(--fdlc-accent-text);
}

.fdlc-header-avatars {
	flex: none;
	display: flex;
}

.fdlc-header-avatars:empty {
	display: none;
}

.fdlc-header-avatars .fdlc-avatar {
	width: 44px;
	height: 44px;
	border: 2px solid var(--fdlc-accent);
	background: var(--fdlc-accent-text);
	color: var(--fdlc-accent);
	font-size: 15px;
}

.fdlc-header-avatars .fdlc-avatar + .fdlc-avatar {
	margin-left: -16px;
}

.fdlc-header-text {
	flex: 1;
	min-width: 0;
}

.fdlc-title {
	overflow: hidden;
	font-size: 1.1em;
	font-weight: 600;
	line-height: 1.25;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.fdlc-subtitle {
	margin-top: 2px;
	font-size: 0.87em;
	line-height: 1.35;
	opacity: 0.85;
}

.fdlc-root .fdlc-close {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	color: var(--fdlc-accent-text);
	opacity: 0.85;
}

.fdlc-root .fdlc-close:hover {
	background: rgba(255, 255, 255, 0.16);
	opacity: 1;
}

.fdlc-root .fdlc-header :focus-visible {
	outline-color: var(--fdlc-accent-text);
}

.fdlc-close svg {
	width: 18px;
	height: 18px;
}

.fdlc-body {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 4px 16px 16px;
}

/* ----------------------------------------------------------------- Messages */

.fdlc-msg {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	margin-top: 3px;
}

.fdlc-msg--first {
	margin-top: 14px;
}

.fdlc-msg--visitor {
	flex-direction: column;
	align-items: flex-end;
}

.fdlc-msg-main {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	min-width: 0;
	max-width: 80%;
}

.fdlc-msg--visitor .fdlc-msg-main {
	align-items: flex-end;
}

.fdlc-name {
	margin: 0 0 3px 2px;
	font-size: 0.8em;
	font-weight: 600;
	line-height: 1.3;
}

.fdlc-time {
	margin-left: 6px;
	font-weight: 400;
	color: var(--fdlc-muted);
}

.fdlc-bubble {
	max-width: 100%;
	padding: 9px 13px;
	border-radius: var(--fdlc-bubble-radius);
	background: var(--fdlc-agent-bg);
	color: var(--fdlc-agent-text);
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	word-break: break-word;
}

.fdlc-msg--agent.fdlc-msg--first .fdlc-bubble {
	border-top-left-radius: min(var(--fdlc-bubble-radius), 4px);
}

.fdlc-msg--visitor .fdlc-bubble {
	background: var(--fdlc-visitor-bg);
	color: var(--fdlc-visitor-text);
}

.fdlc-msg--visitor.fdlc-msg--first .fdlc-bubble {
	border-top-right-radius: min(var(--fdlc-bubble-radius), 4px);
}

.fdlc-root .fdlc-bubble a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.fdlc-msg--pending .fdlc-bubble {
	opacity: 0.6;
}

.fdlc-msg--failed .fdlc-bubble {
	opacity: 0.6;
}

.fdlc-root .fdlc-retry {
	margin-top: 4px;
	color: var(--fdlc-danger);
	font-size: 0.8em;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* ----------------------------------------------------------------- Pre-chat */

.fdlc-prechat {
	display: flex;
	flex-direction: column;
	gap: 12px;
	margin: 0;
	padding: 16px 2px 0;
}

.fdlc-prechat-intro {
	margin-bottom: 2px;
	white-space: pre-wrap;
}

.fdlc-field {
	display: flex;
	flex-direction: column;
	gap: 5px;
	margin: 0;
	font-size: 0.87em;
	font-weight: 600;
}

.fdlc-root .fdlc-input {
	display: block;
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--fdlc-line);
	border-radius: min(var(--fdlc-radius), 10px);
	background: var(--fdlc-panel-bg);
	color: var(--fdlc-panel-text);
	font-size: var(--fdlc-font-size);
	font-weight: 400;
	cursor: text;
}

.fdlc-root .fdlc-input:focus {
	border-color: var(--fdlc-accent);
	box-shadow: 0 0 0 1px var(--fdlc-accent);
	outline: none;
}

.fdlc-root .fdlc-button {
	display: block;
	width: 100%;
	padding: 11px 16px;
	border-radius: min(var(--fdlc-radius), 10px);
	background: var(--fdlc-accent);
	color: var(--fdlc-accent-text);
	font-weight: 600;
	text-align: center;
}

.fdlc-root .fdlc-button:hover {
	filter: brightness(1.08);
}

.fdlc-error {
	color: var(--fdlc-danger);
	font-size: 0.87em;
}

/* ----------------------------------------------------------------- Composer */

.fdlc-composer {
	flex: none;
	margin: 0;
	padding: 10px 10px 10px 16px;
	border-top: 1px solid var(--fdlc-line);
	background: var(--fdlc-panel-bg);
}

.fdlc-composer .fdlc-error {
	margin: 0 0 8px;
}

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

.fdlc-root .fdlc-textarea {
	flex: 1;
	display: block;
	min-width: 0;
	height: 40px;
	max-height: 120px;
	padding: 9px 0;
	overflow-y: auto;
	color: var(--fdlc-panel-text);
	line-height: 1.45;
	white-space: pre-wrap;
	overflow-wrap: break-word;
	resize: none;
	cursor: text;
}

.fdlc-root .fdlc-textarea::placeholder,
.fdlc-root .fdlc-input::placeholder {
	color: var(--fdlc-muted);
	opacity: 1;
}

.fdlc-root .fdlc-textarea:focus-visible {
	outline: none;
}

.fdlc-composer:focus-within {
	border-top-color: var(--fdlc-accent);
}

.fdlc-root .fdlc-send {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--fdlc-accent);
	color: var(--fdlc-accent-text);
	transition: opacity 0.15s ease;
}

.fdlc-root .fdlc-send[disabled] {
	opacity: 0.35;
	cursor: default;
}

.fdlc-send svg {
	width: 18px;
	height: 18px;
}

/* ------------------------------------------------------------ Small screens */

@media (max-width: 480px) {
	.fdlc-root.fdlc-is-open {
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
	}

	.fdlc-is-open .fdlc-panel {
		width: 100%;
		height: 100%;
		border-radius: 0;
	}

	.fdlc-root.fdlc-is-open .fdlc-launcher {
		display: none;
	}

	/* Stops iOS from zooming the page when a field gets focus. */
	.fdlc-root .fdlc-textarea,
	.fdlc-root .fdlc-input {
		font-size: max(16px, var(--fdlc-font-size));
	}
}

@media (prefers-reduced-motion: reduce) {
	.fdlc-panel {
		animation: none;
	}

	.fdlc-root .fdlc-launcher,
	.fdlc-root .fdlc-send {
		transition: none;
	}
}

/* --------------------------------------- Preview on the admin settings page */

.fdlc-root.fdlc-preview {
	position: relative;
	right: auto;
	bottom: auto;
	left: auto;
	z-index: auto;
}

.fdlc-preview .fdlc-panel {
	width: 100%;
	max-width: 376px;
	height: 500px;
	animation: none;
}

.fdlc-preview .fdlc-launcher {
	cursor: default;
}
