/* The tokens follow the linove plugin's (see its product-widgets.css) and fall back
   to the same values when this plugin runs without it. Custom properties inherit
   into Deep Chat's shadow root, so the chat-widget.js styles read them too. */
.lva-chat {
	--lva-primary: var(--primary-color, #093854);
	--lva-primary-hover: #0c4a6e;
	--lva-text: var(--dark-color, #1a1a1a);
	--lva-muted: rgba(9, 56, 84, 0.72);
	--lva-line: rgba(9, 56, 84, 0.12);
	--lva-bg: #fbfaf3;
	--lva-bg-alt: #f0f2f5;
	--lva-radius: 16px;
	--lva-height: 600px;
	font-family: var(--global-font, "Manrope", sans-serif);
	color: var(--lva-text);
}

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

.lva-chat__title {
	margin: 0 0 16px;
}

/* A <dialog open>: it sits in the page until the visitor opens it full screen,
   when showModal() lifts it above everything without moving Deep Chat in the DOM. */
.lva-chat .lva-chat__panel {
	position: relative;
	inset: auto;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: none;
	height: auto;
	max-height: none;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 1px solid var(--lva-line);
	border-radius: var(--lva-radius);
	background: #fff;
	color: inherit;
	box-shadow: 0 6px 24px rgba(9, 56, 84, 0.08);
}

.lva-chat__header {
	flex: none;
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 60px;
	padding: 8px 8px 8px 16px;
	background: var(--lva-primary);
	color: #fff;
}

.lva-chat__avatar {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--lva-bg);
	color: var(--lva-primary);
	font: 400 20px/1 var(--primary-font, "Libre Caslon Text", serif);
}

.lva-chat__avatar--image {
	overflow: hidden;
}

.lva-chat__avatar--image img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.lva-chat__avatar--plain {
	border-radius: 0;
	background: none;
}

.lva-chat__avatar--plain img {
	object-fit: contain;
}

.lva-chat__identity {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.lva-chat__name,
.lva-chat__status {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.lva-chat__name {
	font-size: 16px;
	font-weight: 700;
	line-height: 1.25;
}

.lva-chat__status {
	font-size: 13px;
	line-height: 1.25;
	opacity: 0.8;
}

.lva-chat__actions {
	flex: none;
	display: flex;
	align-items: center;
	gap: 2px;
	margin-left: auto;
}

/* Theme button styles reach every <button>, so the buttons here carry the element name and their states. */
.lva-chat button.lva-chat__expand,
.lva-chat button.lva-chat__expand:hover,
.lva-chat button.lva-chat__expand:focus,
.lva-chat button.lva-chat__minimize,
.lva-chat button.lva-chat__minimize:hover,
.lva-chat button.lva-chat__minimize:focus,
.lva-chat button.lva-chat__delete--icon,
.lva-chat button.lva-chat__delete--icon:hover,
.lva-chat button.lva-chat__delete--icon:focus {
	flex: none;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	box-shadow: none;
	color: #fff;
	font: inherit;
	line-height: 0;
	text-decoration: none;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.lva-chat button.lva-chat__expand,
.lva-chat button.lva-chat__expand:hover,
.lva-chat button.lva-chat__expand:focus {
	display: none;
}

.lva-chat button.lva-chat__delete--icon:not([hidden]),
.lva-chat button.lva-chat__delete--icon:not([hidden]):hover,
.lva-chat button.lva-chat__delete--icon:not([hidden]):focus {
	display: flex;
}

.lva-chat button.lva-chat__expand:hover,
.lva-chat button.lva-chat__expand:active,
.lva-chat button.lva-chat__minimize:hover,
.lva-chat button.lva-chat__minimize:active,
.lva-chat button.lva-chat__delete--icon:hover,
.lva-chat button.lva-chat__delete--icon:active {
	background: rgba(255, 255, 255, 0.14);
}

.lva-chat button.lva-chat__expand:focus-visible,
.lva-chat button.lva-chat__minimize:focus-visible,
.lva-chat button.lva-chat__delete--icon:focus-visible {
	outline: 2px solid #fff;
	outline-offset: -4px;
}

.lva-chat__expand svg,
.lva-chat__minimize svg,
.lva-chat__delete--icon svg {
	width: 22px;
	height: 22px;
}

.lva-chat__expand .lva-chat__icon-close,
.lva-chat__panel[data-fullscreen] .lva-chat__expand .lva-chat__icon-open {
	display: none;
}

.lva-chat__panel[data-fullscreen] .lva-chat__expand .lva-chat__icon-close {
	display: block;
}

/* The popup of the floating chat button, which chat-launcher.js fills. It sizes
   the panel to the container chat-launcher.css gives it, and shows the expand
   button at every width. A full screen panel hides the minimize button,
   because the expand button leaves full screen and returns to the popup. */
.lva-chat[data-popup] {
	height: 100%;
}

.lva-chat[data-popup] .lva-chat__panel:not([data-fullscreen]) {
	height: 100%;
	min-height: 0;
	box-shadow: 0 12px 40px rgba(9, 56, 84, 0.28);
}

.lva-chat[data-popup] .lva-chat__panel:not([data-fullscreen]) .lva-chat__mount {
	flex: 1 1 0;
	height: auto;
	min-height: 0;
}

.lva-chat[data-popup] button.lva-chat__expand,
.lva-chat[data-popup] button.lva-chat__expand:hover,
.lva-chat[data-popup] button.lva-chat__expand:focus,
.lva-chat[data-popup] button.lva-chat__minimize,
.lva-chat[data-popup] button.lva-chat__minimize:hover,
.lva-chat[data-popup] button.lva-chat__minimize:focus {
	display: flex;
}

.lva-chat[data-popup] .lva-chat__panel[data-fullscreen] button.lva-chat__minimize,
.lva-chat[data-popup] .lva-chat__panel[data-fullscreen] button.lva-chat__minimize:hover,
.lva-chat[data-popup] .lva-chat__panel[data-fullscreen] button.lva-chat__minimize:focus {
	display: none;
}

/* Never taller than the screen, so on a phone the page still scrolls past the chat. */
.lva-chat__mount {
	flex: none;
	width: 100%;
	min-height: 320px;
	height: var(--lva-height);
	height: min(var(--lva-height), max(320px, 100svh - 220px));
}

.lva-chat__footer {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 2px 16px;
	margin-top: 8px;
	font-size: 13px;
	line-height: 1.45;
	color: var(--lva-muted);
}

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

.lva-chat__disclaimer {
	flex: 1 1 100%;
	margin: 0;
}

.lva-chat .lva-chat__privacy,
.lva-chat .lva-chat__delete:not(.lva-chat__delete--icon),
.lva-chat .lva-chat__delete:not(.lva-chat__delete--icon):hover,
.lva-chat .lva-chat__delete:not(.lva-chat__delete--icon):focus {
	display: inline-block;
	margin: 0;
	padding: 6px 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: var(--lva-primary);
	font: inherit;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 2px;
	cursor: pointer;
}

.lva-chat .lva-chat__delete[hidden] {
	display: none;
}

.lva-chat .lva-chat__privacy:focus-visible,
.lva-chat .lva-chat__delete:not(.lva-chat__delete--icon):focus-visible {
	outline: 2px solid var(--lva-primary);
	outline-offset: 2px;
}

/* A page cached before the panel existed still has the chat and footer as direct children. */
.lva-chat > .lva-chat__mount {
	overflow: hidden;
	border: 1px solid var(--lva-line);
	border-radius: var(--lva-radius);
	background: #fff;
}

/* Full screen is offered where the chat is cramped: phones and tablets. */
@media (max-width: 1024px) {
	.lva-chat button.lva-chat__expand,
	.lva-chat button.lva-chat__expand:hover,
	.lva-chat button.lva-chat__expand:focus {
		display: flex;
	}
}

@media (max-width: 767px) {
	.lva-chat__title {
		margin-bottom: 12px;
	}

	/* On a phone the whole panel takes about four fifths of the screen, whatever height the editor set. */
	.lva-chat .lva-chat__panel:not([data-fullscreen]) {
		height: 80vh;
		height: 80svh;
		min-height: 400px;
	}

	.lva-chat__panel:not([data-fullscreen]) .lva-chat__mount {
		flex: 1 1 0;
		height: auto;
		min-height: 0;
	}

	.lva-chat__footer {
		font-size: 12px;
	}
}

/* --lva-vv-height and --lva-vv-top track the visual viewport, which is what the
   on-screen keyboard shrinks; the layout viewport and 100dvh stay as they were. */
.lva-chat .lva-chat__panel[data-fullscreen] {
	position: fixed;
	top: var(--lva-vv-top, 0px);
	left: 0;
	z-index: 2147483000;
	width: 100%;
	height: var(--lva-vv-height, 100vh);
	border: 0;
	border-radius: 0;
	box-shadow: none;
	overscroll-behavior: contain;
}

.lva-chat__panel[data-fullscreen]::backdrop {
	background: #fff;
}

.lva-chat .lva-chat__panel[data-fullscreen] button.lva-chat__expand,
.lva-chat .lva-chat__panel[data-fullscreen] button.lva-chat__expand:hover,
.lva-chat .lva-chat__panel[data-fullscreen] button.lva-chat__expand:focus {
	display: flex;
}

.lva-chat__panel[data-fullscreen] .lva-chat__header {
	padding-top: calc(8px + env(safe-area-inset-top, 0px));
	padding-left: calc(16px + env(safe-area-inset-left, 0px));
	padding-right: calc(8px + env(safe-area-inset-right, 0px));
}

.lva-chat__panel[data-fullscreen] .lva-chat__mount {
	flex: 1 1 0;
	height: auto;
	min-height: 0;
	padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

/* The whole screen goes to the conversation. The small print stays under the chat in the page. */
.lva-chat__panel[data-fullscreen] .lva-chat__footer {
	display: none;
}

html.lva-chat-lock,
html.lva-chat-lock body {
	overflow: hidden !important;
}

/* overflow:hidden on the body alone makes iOS drop touch scrolling inside the
   dialog. Pinning the body keeps the page still and leaves the message list scrolling. */
html.lva-chat-lock body {
	position: fixed;
	top: var(--lva-lock-top, 0px);
	left: 0;
	right: 0;
	width: 100%;
}

@media (prefers-reduced-motion: no-preference) {
	.lva-chat__panel[data-fullscreen] {
		animation: lva-chat-open 0.18s ease-out;
	}
}

@keyframes lva-chat-open {
	from {
		opacity: 0;
		transform: translateY(12px);
	}
}
