/**
 * Floating Support — frontend widget styles.
 *
 * All selectors are namespaced under .floating-support and use the `fs-`
 * prefix to avoid clashing with themes and other plugins. The accent colour
 * is injected at runtime via the --fs-accent custom property.
 */

.floating-support {
	--fs-accent: #2563eb;
	--fs-accent-contrast: #ffffff;
	--fs-bg: #ffffff;
	--fs-text: #1f2733;
	--fs-muted: #5b6573;
	--fs-radius: 16px;
	--fs-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
	--fs-z: 99990;
	--fs-icon-size: 48px;

	position: fixed;
	bottom: 24px;
	z-index: var(--fs-z);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Arial, sans-serif;
	box-sizing: border-box;
	line-height: 1.5;
}

.floating-support *,
.floating-support *::before,
.floating-support *::after {
	box-sizing: border-box;
}

.floating-support.fs-pos-right {
	right: 24px;
}

.floating-support.fs-pos-left {
	left: 24px;
}

/* --------------------------------------------------------------------------
 * Toggle button
 * ----------------------------------------------------------------------- */
.floating-support .fs-toggle {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	color: var(--fs-accent-contrast);
	background: var(--fs-accent);
	box-shadow: 0 10px 28px rgba(15, 23, 42, 0.28);
	transition: transform 0.25s ease, box-shadow 0.25s ease;
	-webkit-appearance: none;
	appearance: none;
	outline: none;
}

.floating-support .fs-toggle:hover {
	transform: translateY(-2px) scale(1.04);
	box-shadow: 0 14px 34px rgba(15, 23, 42, 0.34);
}

.floating-support .fs-toggle:focus-visible {
	box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.35);
}

.floating-support .fs-toggle__icon {
	position: absolute;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.3s ease, opacity 0.3s ease;
}

.floating-support .fs-toggle__icon--close {
	transform: rotate(-90deg) scale(0.4);
	opacity: 0;
}

.floating-support[data-state="open"] .fs-toggle__icon--open {
	transform: rotate(90deg) scale(0.4);
	opacity: 0;
}

.floating-support[data-state="open"] .fs-toggle__icon--close {
	transform: rotate(0) scale(1);
	opacity: 1;
}

/* --------------------------------------------------------------------------
 * Custom toggle icon
 *
 * When a custom icon is configured the root gets the .fs-has-custom-icon class.
 * The icon image is sized from the --fs-icon-size custom property (set from the
 * plugin settings), and the round toggle button grows to comfortably contain it
 * so its appearance stays intact across the allowed 20–120px range.
 * ----------------------------------------------------------------------- */
.floating-support .fs-toggle__custom-icon {
	display: block;
	width: var(--fs-icon-size);
	height: var(--fs-icon-size);
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}

.floating-support.fs-has-custom-icon .fs-toggle {
	width: max(56px, calc(var(--fs-icon-size) + 16px));
	height: max(56px, calc(var(--fs-icon-size) + 16px));
}

/* Keep the open panel anchored above the (possibly larger) button. */
.floating-support.fs-has-custom-icon .fs-panel {
	bottom: max(76px, calc(var(--fs-icon-size) + 32px));
}

/* --------------------------------------------------------------------------
 * Panel
 * ----------------------------------------------------------------------- */
.floating-support .fs-panel {
	position: absolute;
	bottom: 76px;
	width: 300px;
	max-width: calc(100vw - 48px);
	padding: 18px;
	background: var(--fs-bg);
	color: var(--fs-text);
	border-radius: var(--fs-radius);
	box-shadow: var(--fs-shadow);
	transform-origin: bottom right;
	opacity: 0;
	transform: translateY(12px) scale(0.96);
	pointer-events: none;
	transition: opacity 0.25s ease, transform 0.25s ease;
}

.floating-support.fs-pos-right .fs-panel {
	right: 0;
	transform-origin: bottom right;
}

.floating-support.fs-pos-left .fs-panel {
	left: 0;
	transform-origin: bottom left;
}

.floating-support[data-state="open"] .fs-panel {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

.floating-support .fs-panel__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-bottom: 6px;
}

.floating-support .fs-panel__title {
	font-size: 16px;
	font-weight: 700;
	color: var(--fs-text);
}

.floating-support .fs-panel__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	color: var(--fs-muted);
	background: transparent;
	transition: background 0.2s ease, color 0.2s ease;
	-webkit-appearance: none;
	appearance: none;
}

.floating-support .fs-panel__close:hover {
	background: rgba(15, 23, 42, 0.06);
	color: var(--fs-text);
}

.floating-support .fs-panel__greeting {
	margin: 0 0 14px;
	font-size: 14px;
	color: var(--fs-muted);
}

/* --------------------------------------------------------------------------
 * Channels
 * ----------------------------------------------------------------------- */
.floating-support .fs-channels {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.floating-support .fs-channel {
	margin: 0;
	padding: 0;
	opacity: 0;
	transform: translateY(8px);
}

.floating-support[data-state="open"] .fs-channel {
	animation: fs-fade-in 0.35s ease forwards;
}

.floating-support[data-state="open"] .fs-channel:nth-child(1) { animation-delay: 0.05s; }
.floating-support[data-state="open"] .fs-channel:nth-child(2) { animation-delay: 0.12s; }
.floating-support[data-state="open"] .fs-channel:nth-child(3) { animation-delay: 0.19s; }

.floating-support .fs-channel__link {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 11px 14px;
	border-radius: 12px;
	text-decoration: none;
	color: var(--fs-text);
	background: #f4f6f9;
	border: 1px solid transparent;
	transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.floating-support .fs-channel__link:hover {
	transform: translateX(2px);
	background: #eef2f7;
	border-color: rgba(15, 23, 42, 0.08);
}

.floating-support .fs-channel__link:focus-visible {
	outline: none;
	border-color: var(--fs-accent);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.floating-support .fs-channel__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	flex: 0 0 40px;
	border-radius: 50%;
	color: #ffffff;
}

.floating-support .fs-channel__label {
	font-size: 15px;
	font-weight: 600;
}

/* Brand colours per messenger. */
.floating-support .fs-channel--telegram .fs-channel__icon { background: #2aabee; }
.floating-support .fs-channel--whatsapp .fs-channel__icon { background: #25d366; }
.floating-support .fs-channel--bale .fs-channel__icon { background: transparent; }

/* --------------------------------------------------------------------------
 * Animations
 * ----------------------------------------------------------------------- */
@keyframes fs-fade-in {
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* --------------------------------------------------------------------------
 * Responsive
 * ----------------------------------------------------------------------- */
@media (max-width: 480px) {
	.floating-support {
		bottom: 16px;
	}

	.floating-support.fs-pos-right {
		right: 16px;
	}

	.floating-support.fs-pos-left {
		left: 16px;
	}

	.floating-support .fs-panel {
		width: calc(100vw - 32px);
	}
}

/* Respect users who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
	.floating-support .fs-toggle,
	.floating-support .fs-toggle__icon,
	.floating-support .fs-panel,
	.floating-support .fs-channel,
	.floating-support .fs-channel__link {
		transition: none;
		animation: none;
	}
}
