/*
 * The chat bubble and its window. It floats over somebody else's theme, so it sets its own type size, box model and
 * colors, all from the brand tokens printed beside it.
 */

.glw-chat {
	position: fixed;
	bottom: 22px;
	z-index: 99990;
	color: var(--glw-c-text);
	font-size: 15px;
	line-height: 1.45;
	-webkit-font-smoothing: antialiased;
}

/* Open, it is what the visitor is using, so it sits over other floating buttons, such as a booking tab, that would cover the message box. */
.glw-chat.is-open {
	z-index: 100001;
}

.glw-chat.is-right {
	right: 22px;
}

.glw-chat.is-left {
	left: 22px;
}

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

.glw-chat [hidden] {
	display: none !important;
}

/* Themes style every button and field on the page; in here they start from nothing and each part sets its own look. */
body .glw-chat button,
body .glw-chat input,
body .glw-chat textarea {
	min-width: 0;
	min-height: 0;
	height: auto;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: inherit;
	font: inherit;
	letter-spacing: normal;
	line-height: inherit;
	text-transform: none;
	text-decoration: none;
	text-shadow: none;
}

.glw-chat svg {
	width: 22px;
	height: 22px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* ------------------------------------------------------------------ bubble */

.glw-chat .glw-chat-launch {
	position: relative;
	display: grid;
	place-items: center;
	width: 58px;
	height: 58px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--glw-f-accent);
	color: var(--glw-f-on);
	box-shadow: 0 14px 30px -12px var(--glw-c-shadow);
	cursor: pointer;
	transition: transform 180ms cubic-bezier(0.32, 0.72, 0, 1), box-shadow 180ms ease;
}

.glw-chat.is-left .glw-chat-launch {
	margin-right: auto;
}

.glw-chat.is-right .glw-chat-launch {
	margin-left: auto;
}

.glw-chat .glw-chat-launch:hover {
	transform: translateY(-2px) scale(1.03);
	box-shadow: 0 18px 34px -12px var(--glw-c-shadow);
}

.glw-chat .glw-chat-launch:focus-visible {
	outline: 3px solid var(--glw-f-accent);
	outline-offset: 3px;
}

.glw-chat .glw-chat-launch svg {
	position: absolute;
	width: 26px;
	height: 26px;
	transition: transform 220ms cubic-bezier(0.32, 0.72, 0, 1), opacity 160ms ease;
}

.glw-chat .glw-chat-icon-shut {
	opacity: 0;
	transform: rotate(-90deg) scale(0.6);
}

.glw-chat.is-open .glw-chat-icon-open {
	opacity: 0;
	transform: rotate(90deg) scale(0.6);
}

.glw-chat.is-open .glw-chat-icon-shut {
	opacity: 1;
	transform: none;
}

.glw-chat .glw-chat-badge {
	position: absolute;
	top: -3px;
	right: -3px;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border: 2px solid var(--glw-c-paper);
	border-radius: 999px;
	background: var(--glw-c-bad);
	color: var(--glw-c-paper);
	font-size: 11px;
	font-weight: 700;
	line-height: 18px;
	text-align: center;
	font-variant-numeric: tabular-nums;
	animation: glw-chat-pop 300ms cubic-bezier(0.32, 0.72, 0, 1);
}

/* ------------------------------------------------------------------ window */

.glw-chat .glw-chat-panel {
	display: flex;
	flex-direction: column;
	width: 370px;
	height: min(560px, calc(100vh - 120px));
	margin-bottom: 14px;
	overflow: hidden;
	border: 1px solid var(--glw-c-line);
	border-radius: 20px;
	background: var(--glw-c-paper);
	box-shadow: 0 28px 60px -24px var(--glw-c-shadow);
	animation: glw-chat-rise 260ms cubic-bezier(0.32, 0.72, 0, 1);
}

.glw-chat.is-right .glw-chat-panel {
	transform-origin: bottom right;
}

.glw-chat.is-left .glw-chat-panel {
	transform-origin: bottom left;
}

.glw-chat .glw-chat-head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 16px 16px 18px;
	background: var(--glw-f-accent);
	color: var(--glw-f-on);
}

.glw-chat .glw-chat-mark {
	display: grid;
	flex: none;
	place-items: center;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: color-mix(in srgb, var(--glw-f-on) 18%, transparent);
	font-weight: 700;
}

.glw-chat .glw-chat-who {
	display: flex;
	flex: 1;
	flex-direction: column;
	min-width: 0;
}

.glw-chat .glw-chat-who b {
	overflow: hidden;
	font-size: 15px;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.glw-chat .glw-chat-status {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 12.5px;
	opacity: 0.88;
}

.glw-chat .glw-chat-status::before {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: color-mix(in srgb, var(--glw-f-on) 55%, transparent);
	content: "";
}

.glw-chat.is-online .glw-chat-status::before {
	background: var(--glw-f-on);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--glw-f-on) 25%, transparent);
}

.glw-chat .glw-chat-x {
	display: grid;
	flex: none;
	place-items: center;
	width: 34px;
	height: 34px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	cursor: pointer;
	transition: background 150ms ease;
}

.glw-chat .glw-chat-x:hover,
.glw-chat .glw-chat-x:focus-visible {
	background: color-mix(in srgb, var(--glw-f-on) 16%, transparent);
	outline: 0;
}

.glw-chat .glw-chat-x svg {
	width: 18px;
	height: 18px;
}

/* -------------------------------------------------------------------- log */

.glw-chat .glw-chat-log {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 6px;
	padding: 18px 16px;
	overflow-y: auto;
	background: var(--glw-c-page);
	overscroll-behavior: contain;
}

.glw-chat .glw-chat-msg {
	display: flex;
	flex-direction: column;
	max-width: 82%;
	animation: glw-chat-in 220ms cubic-bezier(0.32, 0.72, 0, 1);
}

.glw-chat .glw-chat-msg + .glw-chat-msg:not(.is-visitor) .glw-chat-name {
	margin-top: 8px;
}

.glw-chat .glw-chat-name {
	margin: 0 0 3px 4px;
	color: var(--glw-c-soft);
	font-size: 11.5px;
	font-weight: 600;
}

.glw-chat .glw-chat-text {
	padding: 10px 14px;
	border-radius: 18px;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.glw-chat .glw-chat-text a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.glw-chat .glw-chat-msg.is-agent,
.glw-chat .glw-chat-msg.is-bot {
	align-self: flex-start;
}

.glw-chat .glw-chat-msg.is-agent .glw-chat-text,
.glw-chat .glw-chat-msg.is-bot .glw-chat-text {
	border: 1px solid var(--glw-c-line);
	border-bottom-left-radius: 6px;
	background: var(--glw-c-paper);
	color: var(--glw-c-text);
}

.glw-chat .glw-chat-msg.is-visitor {
	align-self: flex-end;
}

.glw-chat .glw-chat-msg.is-visitor .glw-chat-text {
	border-bottom-right-radius: 6px;
	background: var(--glw-f-accent);
	color: var(--glw-f-on);
}

.glw-chat .glw-chat-msg.is-visitor + .glw-chat-msg.is-visitor .glw-chat-text {
	border-top-right-radius: 6px;
}

.glw-chat .glw-chat-msg.is-pending {
	opacity: 0.55;
}

.glw-chat .glw-chat-msg.is-system {
	align-self: center;
	max-width: 90%;
	margin: 6px 0;
}

.glw-chat .glw-chat-msg.is-system .glw-chat-text {
	padding: 4px 12px;
	background: var(--glw-c-tint);
	color: var(--glw-c-ink);
	font-size: 12.5px;
	text-align: center;
}

.glw-chat .glw-chat-msg.is-typing .glw-chat-text {
	display: inline-flex;
	gap: 4px;
	padding: 14px 16px;
}

.glw-chat .glw-chat-msg.is-typing i {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--glw-c-soft);
	animation: glw-chat-dot 1s infinite ease-in-out;
}

.glw-chat .glw-chat-msg.is-typing i:nth-child(2) {
	animation-delay: 0.15s;
}

.glw-chat .glw-chat-msg.is-typing i:nth-child(3) {
	animation-delay: 0.3s;
}

.glw-chat .glw-chat-slot:empty {
	display: none;
}

.glw-chat .glw-chat-slot {
	padding: 10px 14px 0;
	background: var(--glw-c-page);
}

.glw-chat .glw-chat-error {
	margin: 0;
	padding: 8px 16px;
	background: color-mix(in srgb, var(--glw-c-bad) 10%, var(--glw-c-paper));
	color: var(--glw-c-bad);
	font-size: 13px;
}

/* --------------------------------------------------------- contact card */

.glw-chat .glw-chat-contact {
	display: grid;
	grid-template-columns: 1fr 1fr auto;
	gap: 8px;
	margin: 0;
	padding: 12px 14px;
	border-top: 1px solid var(--glw-c-line);
	background: var(--glw-c-tint);
	animation: glw-chat-in 220ms cubic-bezier(0.32, 0.72, 0, 1);
}

.glw-chat .glw-chat-contact-ask {
	grid-column: 1 / -1;
	margin: 0;
	color: var(--glw-c-ink);
	font-size: 13px;
	font-weight: 600;
}

.glw-chat .glw-chat-field {
	width: 100%;
	min-width: 0;
	height: 38px;
	margin: 0;
	padding: 0 10px;
	border: 1px solid var(--glw-c-line);
	border-radius: 10px;
	background: var(--glw-c-paper);
	color: var(--glw-c-text);
	font: inherit;
	font-size: 14px;
}

.glw-chat .glw-chat-field:focus {
	border-color: var(--glw-f-accent);
	outline: 0;
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--glw-f-accent) 25%, transparent);
}

.glw-chat .glw-chat-save {
	height: 38px;
	margin: 0;
	padding: 0 14px;
	border: 0;
	border-radius: 10px;
	background: var(--glw-f-accent);
	color: var(--glw-f-on);
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

.glw-chat .glw-chat-save:disabled {
	opacity: 0.6;
}

/* ------------------------------------------------------------- composer */

.glw-chat .glw-chat-compose {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	margin: 0;
	padding: 12px 12px 12px 16px;
	border-top: 1px solid var(--glw-c-line);
	background: var(--glw-c-paper);
}

.glw-chat .glw-chat-input {
	flex: 1;
	min-height: 40px;
	max-height: 120px;
	margin: 0;
	padding: 9px 2px;
	border: 0;
	background: transparent;
	color: var(--glw-c-text);
	font: inherit;
	font-size: 15px;
	line-height: 1.45;
	resize: none;
	box-shadow: none;
}

.glw-chat .glw-chat-input:focus {
	outline: 0;
	box-shadow: none;
}

.glw-chat .glw-chat-input::placeholder {
	color: var(--glw-c-soft);
}

.glw-chat .glw-chat-send {
	display: grid;
	flex: none;
	place-items: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--glw-f-accent);
	color: var(--glw-f-on);
	cursor: pointer;
	transition: transform 150ms ease, opacity 150ms ease;
}

.glw-chat .glw-chat-send:hover {
	transform: scale(1.06);
}

.glw-chat .glw-chat-send:disabled {
	opacity: 0.5;
	cursor: default;
	transform: none;
}

.glw-chat .glw-chat-send svg {
	width: 18px;
	height: 18px;
	fill: currentColor;
	stroke-width: 1.2;
}

/* ----------------------------------------------------------------- motion */

@keyframes glw-chat-rise {
	from {
		opacity: 0;
		transform: translateY(12px) scale(0.96);
	}
}

@keyframes glw-chat-in {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
}

@keyframes glw-chat-dot {
	0%,
	80%,
	100% {
		opacity: 0.3;
		transform: translateY(0);
	}

	40% {
		opacity: 1;
		transform: translateY(-3px);
	}
}

@keyframes glw-chat-pop {
	from {
		transform: scale(0.4);
	}
}

/* ----------------------------------------------------------------- phones */

@media (max-width: 520px) {
	.glw-chat {
		bottom: 16px;
	}

	.glw-chat.is-right {
		right: 16px;
	}

	.glw-chat.is-left {
		left: 16px;
	}

	.glw-chat.is-open {
		inset: 0;
	}

	body.admin-bar .glw-chat.is-open {
		top: 46px;
	}

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

	.glw-chat.is-open .glw-chat-launch {
		display: none;
	}

	.glw-chat .glw-chat-contact {
		grid-template-columns: 1fr;
	}
}

@media (prefers-reduced-motion: reduce) {
	.glw-chat *,
	.glw-chat .glw-chat-panel {
		animation: none !important;
		transition: none !important;
	}
}
