/* Root reset so themes cannot leak styles into the widget */
#tlc-widget,
#tlc-widget * {
	box-sizing: border-box;
}

/* hidden must win over display:flex on the toggled screens */
#tlc-widget .tlc-w__intro[hidden],
#tlc-widget .tlc-w__body[hidden],
#tlc-widget .tlc-w__form[hidden] {
	display: none !important;
}

#tlc-widget {
	--tlc-w-blue: #2aabee;
	--tlc-w-blue-dark: #229ed9;
	--tlc-w-ink: #1c2733;
	--tlc-w-muted: #8a97a4;
	--tlc-w-line: #e8edf2;
	--tlc-w-bg-body: #f4f7fa;
	--tlc-w-bg-form: #ffffff;
	all: initial;
	position: fixed;
	right: 22px;
	bottom: 22px;
	z-index: 2147483000;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	line-height: 1.45;
}

/* Launcher */
#tlc-widget .tlc-w__launcher {
	all: unset;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--tlc-w-blue), var(--tlc-w-blue-dark));
	color: #fff;
	cursor: pointer;
	box-shadow: 0 8px 24px rgba(34, 158, 217, .4);
	transition: transform .15s ease, box-shadow .15s ease;
}

#tlc-widget .tlc-w__launcher:hover {
	transform: scale(1.06);
	box-shadow: 0 10px 28px rgba(34, 158, 217, .5);
}

#tlc-widget.is-open .tlc-w__launcher {
	transform: scale(.9);
	opacity: 0;
	pointer-events: none;
}

/* Panel */
#tlc-widget .tlc-w__panel {
	position: absolute;
	right: 0;
	bottom: 0;
	width: 360px;
	max-width: calc(100vw - 32px);
	height: 520px;
	max-height: calc(100vh - 110px);
	display: flex;
	flex-direction: column;
	background: #fff;
	border-radius: 18px;
	overflow: hidden;
	box-shadow: 0 16px 50px rgba(20, 40, 60, .25);
	transform: translateY(16px) scale(.96);
	opacity: 0;
	pointer-events: none;
	transition: transform .2s ease, opacity .2s ease;
}

#tlc-widget.is-open .tlc-w__panel {
	transform: translateY(0) scale(1);
	opacity: 1;
	pointer-events: auto;
}

/* Header */
#tlc-widget .tlc-w__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	background: linear-gradient(135deg, var(--tlc-w-blue), var(--tlc-w-blue-dark));
	color: #fff;
	flex: 0 0 auto;
}

#tlc-widget .tlc-w__head-info {
	display: flex;
	align-items: center;
	gap: 10px;
}

#tlc-widget .tlc-w__avatar {
	position: relative;
	width: 38px;
	height: 38px;
	flex: 0 0 38px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .22);
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
}

/* Round the image itself, so the parent can stay overflow:visible for the status dot. */
#tlc-widget .tlc-w__avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	border-radius: 50%;
}

#tlc-widget .tlc-w__online {
	position: absolute;
	right: -1px;
	bottom: -1px;
	width: 11px;
	height: 11px;
	border-radius: 50%;
	background: #4ade80;
	border: 2px solid var(--tlc-w-blue-dark);
	box-sizing: border-box;
}

#tlc-widget .tlc-w__title {
	font-size: 15px;
	font-weight: 700;
	color: #fff;
}

#tlc-widget .tlc-w__close {
	all: unset;
	cursor: pointer;
	font-size: 26px;
	line-height: 1;
	color: #fff;
	opacity: .85;
	padding: 0 4px;
}

#tlc-widget .tlc-w__close:hover { opacity: 1; }

/* Intro / name screen */
#tlc-widget .tlc-w__intro {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 30px 24px;
	background: #f4f7fa;
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
}

#tlc-widget .tlc-w__avatar--lg {
	width: 72px;
	height: 72px;
	flex: 0 0 72px;
	background: linear-gradient(135deg, var(--tlc-w-blue), var(--tlc-w-blue-dark));
	margin-bottom: 16px;
	box-shadow: 0 6px 18px rgba(34, 158, 217, .35);
}

#tlc-widget .tlc-w__welcome {
	margin: 0 0 20px;
	font-size: 15px;
	color: var(--tlc-w-ink);
}

#tlc-widget .tlc-w__name-form {
	width: 100%;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

#tlc-widget .tlc-w__name-input {
	all: unset;
	width: 100%;
	box-sizing: border-box;
	padding: 11px 14px;
	border: 1px solid var(--tlc-w-line);
	border-radius: 12px;
	font-size: 14px;
	color: var(--tlc-w-ink);
	background: #fff;
	text-align: center;
}

#tlc-widget .tlc-w__name-input:focus { border-color: var(--tlc-w-blue); }

#tlc-widget .tlc-w__name-btn {
	all: unset;
	cursor: pointer;
	padding: 11px 14px;
	border-radius: 12px;
	background: var(--tlc-w-blue);
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	text-align: center;
	transition: background .15s;
}

#tlc-widget .tlc-w__name-btn:hover { background: var(--tlc-w-blue-dark); }

/* Body */
#tlc-widget .tlc-w__body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 18px;
	background: var(--tlc-w-bg-body);
	display: flex;
	flex-direction: column;
	gap: 10px;
}

#tlc-widget .tlc-msg-row {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	max-width: 85%;
}

#tlc-widget .tlc-msg-row--in {
	align-self: flex-end;
	flex-direction: row-reverse;
}

#tlc-widget .tlc-msg-row--out { align-self: flex-start; }

#tlc-widget .tlc-msg-avatar {
	width: 28px;
	height: 28px;
	flex: 0 0 28px;
	border-radius: 50%;
	background-size: cover;
	background-position: center;
	background-color: #dde6ee;
}

#tlc-widget .tlc-msg {
	padding: 9px 13px;
	border-radius: 14px;
	font-size: 14px;
	color: var(--tlc-w-ink);
	white-space: pre-wrap;
	word-wrap: break-word;
}

#tlc-widget .tlc-msg--in {
	background: var(--tlc-w-blue);
	color: #fff;
	border-bottom-right-radius: 4px;
}

#tlc-widget .tlc-msg--out {
	background: #fff;
	border: 1px solid var(--tlc-w-line);
	border-bottom-left-radius: 4px;
}

/* Form */
#tlc-widget .tlc-w__form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px;
	background: var(--tlc-w-bg-form);
	border-top: 1px solid var(--tlc-w-line);
	flex: 0 0 auto;
}

#tlc-widget .tlc-w__input {
	all: unset;
	flex: 1 1 auto;
	max-height: 110px;
	min-height: 22px;
	overflow-y: auto;
	padding: 9px 12px;
	border: 1px solid var(--tlc-w-line);
	border-radius: 12px;
	font-size: 14px;
	color: var(--tlc-w-ink);
	background: #fafcfe;
	font-family: inherit;
	resize: none;
	white-space: pre-wrap;
	word-wrap: break-word;
}

#tlc-widget .tlc-w__input:focus {
	border-color: var(--tlc-w-blue);
	background: #fff;
}

#tlc-widget .tlc-w__send {
	all: unset;
	cursor: pointer;
	flex: 0 0 auto;
	width: 42px;
	height: 42px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 12px;
	background: var(--tlc-w-blue);
	color: #fff;
	transition: background .15s;
}

#tlc-widget .tlc-w__send:hover { background: var(--tlc-w-blue-dark); }
#tlc-widget .tlc-w__send[disabled] { opacity: .5; cursor: default; }

@media (max-width: 480px) {
	#tlc-widget { right: 14px; bottom: 14px; }
	#tlc-widget .tlc-w__panel {
		width: calc(100vw - 28px);
		height: 70vh;
		height: 70dvh;
		max-height: 560px;
	}

	/* 16px prevents iOS Safari from zooming in on focus */
	#tlc-widget .tlc-w__input,
	#tlc-widget .tlc-w__name-input {
		font-size: 16px;
	}
}
