/* Maxshelf Chat Widget – front end */
#mxcw {
	--mxcw-bottom: 20px;
	--mxcw-side: 20px;
	--mxcw-size: 56px;
	--mxcw-z: 99990;
	--mxcw-main-bg: #1aa64a;
	--mxcw-main-fg: #fff;
	--mxcw-badge: #c8102e;
	--mxcw-gbg: #fff;
	--mxcw-gfg: #1d1d1f;
	--mxcw-gfs: 15px;
	--mxcw-gap: 12px;

	position: fixed;
	bottom: calc(var(--mxcw-bottom) + env(safe-area-inset-bottom, 0px));
	z-index: var(--mxcw-z);
	display: flex;
	flex-direction: column;
	gap: var(--mxcw-gap);
	pointer-events: none;
	-webkit-tap-highlight-color: transparent;
	line-height: 1.4;
}
#mxcw *,
#mxcw *::before,
#mxcw *::after { box-sizing: border-box; }
#mxcw [hidden] { display: none !important; }
#mxcw > * { pointer-events: auto; }

#mxcw.mxcw--right { right: calc(var(--mxcw-side) + env(safe-area-inset-right, 0px)); align-items: flex-end; }
#mxcw.mxcw--left  { left: calc(var(--mxcw-side) + env(safe-area-inset-left, 0px));  align-items: flex-start; }

/* ---------- Channel buttons ---------- */
#mxcw .mxcw-channels {
	display: flex;
	flex-direction: column;
	gap: var(--mxcw-gap);
	align-items: inherit;
	margin: 0;
	padding: 0;
}
#mxcw .mxcw-btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--mxcw-size);
	height: var(--mxcw-size);
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--mxcw-bg, #25d366);
	color: var(--mxcw-fg, #fff);
	text-decoration: none;
	box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
	transition: transform .2s ease, box-shadow .2s ease;
	cursor: pointer;
}
#mxcw .mxcw-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0, 0, 0, .24); color: var(--mxcw-fg, #fff); }
#mxcw .mxcw-btn:focus-visible,
#mxcw .mxcw-main:focus-visible,
#mxcw .mxcw-greeting__close:focus-visible,
#mxcw .mxcw-greeting__body:focus-visible { outline: 3px solid #ffb900; outline-offset: 3px; }
#mxcw .mxcw-btn__icon { display: flex; width: 54%; height: 54%; }
#mxcw svg { display: block; width: 100%; height: 100%; }

/* Tooltip (desktop hover only) */
#mxcw .mxcw-tooltip {
	position: absolute;
	top: 50%;
	padding: 6px 10px;
	border-radius: 6px;
	background: #111e3f;
	color: #fff;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.2;
	white-space: nowrap;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translateY(-50%);
	transition: opacity .15s ease;
}
#mxcw.mxcw--right .mxcw-tooltip { right: calc(100% + 12px); }
#mxcw.mxcw--left  .mxcw-tooltip { left: calc(100% + 12px); }
@media (hover: hover) {
	#mxcw .mxcw-btn:hover .mxcw-tooltip,
	#mxcw .mxcw-btn:focus-visible .mxcw-tooltip { opacity: 1; visibility: visible; }
}
@media (hover: none) { #mxcw .mxcw-tooltip { display: none; } }
#mxcw.mxcw--no-tooltips .mxcw-tooltip { display: none; }

/* Badge */
#mxcw .mxcw-badge {
	position: absolute;
	top: -6px;
	right: -6px;
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 22px;
	height: 22px;
	padding: 0 5px;
	border: 2px solid #fff;
	border-radius: 11px;
	background: var(--mxcw-badge);
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	line-height: 1;
	animation: mxcw-pop .3s ease;
}

/* ---------- Collapsed layout ---------- */
#mxcw.mxcw--collapsed .mxcw-channels {
	position: absolute;
	bottom: calc(100% + var(--mxcw-gap));
	opacity: 0;
	visibility: hidden;
	transform: translateY(12px);
	transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
}
#mxcw.mxcw--collapsed.mxcw--open .mxcw-channels {
	opacity: 1;
	visibility: visible;
	transform: none;
	transition: opacity .2s ease, transform .2s ease, visibility 0s;
}
#mxcw.mxcw--collapsed:not(.mxcw--open) .mxcw-channels { pointer-events: none; }
#mxcw.mxcw--collapsed.mxcw--right .mxcw-channels { right: 0; }
#mxcw.mxcw--collapsed.mxcw--left .mxcw-channels { left: 0; }

#mxcw .mxcw-main {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--mxcw-size);
	min-width: 0;
	height: var(--mxcw-size);
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--mxcw-main-bg);
	color: var(--mxcw-main-fg);
	font: inherit;
	font-size: calc(var(--mxcw-size) * .42);
	font-weight: 700;
	line-height: 1;
	letter-spacing: 0;
	text-transform: none;
	box-shadow: 0 4px 14px rgba(0, 0, 0, .2);
	cursor: pointer;
	transition: transform .2s ease, box-shadow .2s ease;
}
#mxcw .mxcw-main:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0, 0, 0, .26); background: var(--mxcw-main-bg); color: var(--mxcw-main-fg); }
#mxcw .mxcw-main--label { width: auto; padding: 0 22px 0 18px; border-radius: 10px; }
#mxcw .mxcw-main__open,
#mxcw .mxcw-main__close { display: inline-flex; align-items: center; gap: 10px; }
#mxcw .mxcw-main__open svg { width: calc(var(--mxcw-size) * .48); height: calc(var(--mxcw-size) * .48); flex: none; }
#mxcw .mxcw-main__close { display: none; }
#mxcw .mxcw-main__close svg { width: calc(var(--mxcw-size) * .44); height: calc(var(--mxcw-size) * .44); }
#mxcw.mxcw--open .mxcw-main__open { display: none; }
#mxcw.mxcw--open .mxcw-main__close { display: inline-flex; }
#mxcw.mxcw--open .mxcw-main--label { width: var(--mxcw-size); padding: 0; }

/* ---------- Greeting bubble ---------- */
#mxcw .mxcw-greeting {
	position: relative;
	width: max-content;
	max-width: min(320px, calc(100vw - (var(--mxcw-side) * 2)));
	padding: 16px 18px;
	border-radius: 14px;
	background: var(--mxcw-gbg);
	color: var(--mxcw-gfg);
	font-size: var(--mxcw-gfs);
	box-shadow: 0 8px 30px rgba(0, 0, 0, .16);
	opacity: 0;
	transform: translateY(10px) scale(.98);
	transform-origin: bottom right;
	transition: opacity .3s ease, transform .3s ease;
}
#mxcw.mxcw--left .mxcw-greeting { transform-origin: bottom left; }
#mxcw .mxcw-greeting.is-visible { opacity: 1; transform: none; }
#mxcw .mxcw-greeting::after {
	content: "";
	position: absolute;
	bottom: -7px;
	width: 14px;
	height: 14px;
	background: var(--mxcw-gbg);
	transform: rotate(45deg);
	box-shadow: 4px 4px 6px rgba(0, 0, 0, .05);
}
#mxcw.mxcw--right .mxcw-greeting::after { right: calc(var(--mxcw-size) / 2 - 7px); }
#mxcw.mxcw--left  .mxcw-greeting::after { left: calc(var(--mxcw-size) / 2 - 7px); }

#mxcw .mxcw-greeting__body {
	display: block;
	padding-right: 18px;
	color: inherit;
	font-size: inherit;
	line-height: 1.5;
	text-decoration: none;
	cursor: pointer;
}
#mxcw .mxcw-greeting__body:hover { color: inherit; }
#mxcw .mxcw-greeting__title { display: block; margin-bottom: 4px; font-weight: 700; }
#mxcw .mxcw-greeting__text { display: block; }

#mxcw .mxcw-greeting__close {
	position: absolute;
	top: 6px;
	right: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	min-height: 0;
	margin: 0;
	padding: 5px;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #8a8a8e;
	box-shadow: none;
	cursor: pointer;
}
#mxcw .mxcw-greeting__close:hover { background: rgba(0, 0, 0, .06); color: #1d1d1f; }

#mxcw .mxcw-greeting__reply {
	display: flex;
	gap: 8px;
	align-items: center;
	margin: 12px 0 0;
}
#mxcw .mxcw-greeting__reply input {
	flex: 1 1 auto;
	width: 100%;
	min-width: 0;
	height: 40px;
	margin: 0;
	padding: 0 14px;
	border: 1px solid #d6d6db;
	border-radius: 20px;
	background: #fff;
	color: #1d1d1f;
	font: inherit;
	font-size: 16px; /* prevents iOS zoom */
	box-shadow: none;
}
#mxcw .mxcw-greeting__reply input:focus { border-color: #25d366; outline: none; }
#mxcw .mxcw-greeting__reply button {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	min-height: 0;
	margin: 0;
	padding: 10px;
	border: 0;
	border-radius: 50%;
	background: #25d366;
	color: #fff;
	box-shadow: none;
	cursor: pointer;
}

#mxcw .mxcw-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* ---------- Pulse ---------- */
#mxcw.mxcw--pulse .mxcw-main::before,
#mxcw.mxcw--pulse.mxcw--stacked .mxcw-btn:first-child::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	background: var(--mxcw-bg, var(--mxcw-main-bg));
	z-index: -1;
	animation: mxcw-pulse 2s ease-out 1s 5;
}
#mxcw.mxcw--pulse .mxcw-main::before { background: var(--mxcw-main-bg); }
#mxcw.mxcw--pulse .mxcw-main--label::before { animation-name: mxcw-pulse-sm; }
@keyframes mxcw-pulse-sm {
	0%   { transform: scale(1);    opacity: .5; }
	100% { transform: scale(1.18, 1.35); opacity: 0; }
}
#mxcw.mxcw--interacted .mxcw-main::before,
#mxcw.mxcw--interacted .mxcw-btn::before { animation: none; display: none; }

@keyframes mxcw-pulse {
	0%   { transform: scale(1);   opacity: .55; }
	100% { transform: scale(1.6); opacity: 0; }
}
@keyframes mxcw-pop {
	0%   { transform: scale(0); }
	80%  { transform: scale(1.15); }
	100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
	#mxcw *, #mxcw *::before, #mxcw *::after { animation: none !important; transition: none !important; }
}
@media print { #mxcw { display: none !important; } }
