/**
 * Floating & fixed messenger support buttons.
 */

:root {
	--shofy-support-primary: #0989ff;
	--shofy-support-offset: 20px;
	--shofy-support-z: 999999;
}

.shofy-support {
	position: relative;
	z-index: var(--shofy-support-z);
}

/* ── Floating widget ── */

.shofy-support-floating {
	position: fixed;
	bottom: var(--shofy-support-offset);
	z-index: calc(var(--shofy-support-z) + 1);
}

.shofy-support--bottom-right .shofy-support-floating {
	right: 20px;
	left: auto;
}

.shofy-support--bottom-left .shofy-support-floating {
	left: 20px;
	right: auto;
}

.shofy-support-floating__toggle {
	width: 56px;
	height: 56px;
	border: 0;
	border-radius: 50%;
	background: var(--shofy-support-primary);
	color: #fff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 4px 20px color-mix(in srgb, var(--shofy-support-primary) 45%, transparent);
	transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
	font-size: 22px;
	padding: 0;
	line-height: 1;
	list-style: none;
	position: relative;
	z-index: 2;
	overflow: visible;
	isolation: isolate;
}

/* Pulse ring — only when menu is closed */
.shofy-support-floating:not([open]) .shofy-support-floating__toggle::before,
.shofy-support-floating:not([open]) .shofy-support-floating__toggle::after {
	content: '';
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background: var(--shofy-support-primary);
	opacity: 0.35;
	z-index: -1;
	pointer-events: none;
	animation: shofySupportPulseRing 2.4s ease-out infinite;
}

.shofy-support-floating:not([open]) .shofy-support-floating__toggle::after {
	animation-delay: 1.2s;
}

.shofy-support-floating[open] > .shofy-support-floating__toggle::before,
.shofy-support-floating[open] > .shofy-support-floating__toggle::after {
	animation: none;
	opacity: 0;
}

.shofy-support-floating__toggle::-webkit-details-marker {
	display: none;
}

.shofy-support-floating__toggle::marker {
	content: '';
}

.shofy-support-floating__toggle:hover,
.shofy-support-floating[open] > .shofy-support-floating__toggle:hover {
	transform: scale(1.06);
	box-shadow: 0 6px 24px color-mix(in srgb, var(--shofy-support-primary) 55%, transparent);
}

.shofy-support-floating__toggle-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	position: relative;
	z-index: 1;
}

.shofy-support-floating:not([open]) .shofy-support-floating__toggle-icon--close {
	display: none !important;
}

.shofy-support-floating[open] .shofy-support-floating__toggle-icon--open {
	display: none !important;
}

.shofy-support-floating[open] > .shofy-support-floating__toggle {
	background: var(--shofy-support-primary);
	box-shadow: 0 4px 20px color-mix(in srgb, var(--shofy-support-primary) 45%, transparent);
}

.shofy-support-floating__list {
	position: absolute;
	bottom: calc(100% + 10px);
	left: 50%;
	transform: translateX(-50%);
	transform-origin: center bottom;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	margin: 0;
	padding: 0;
	z-index: 1;
	pointer-events: none;
	visibility: hidden;
}

.shofy-support-floating[open]:not(.is-closing) .shofy-support-floating__list {
	pointer-events: auto;
	visibility: visible;
	animation: shofySupportListOpen 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.shofy-support-floating[open].is-closing .shofy-support-floating__list {
	pointer-events: none;
	visibility: visible;
	animation: shofySupportListClose 0.28s cubic-bezier(0.55, 0, 1, 0.45) both;
}

.shofy-support-floating[open]:not(.is-closing) .shofy-support-floating__list .shofy-support__link--floating {
	animation: shofySupportItemOpen 0.38s cubic-bezier(0.34, 1.45, 0.64, 1) both;
	transform-origin: center bottom;
}

.shofy-support-floating[open].is-closing .shofy-support-floating__list .shofy-support__link--floating {
	animation: shofySupportItemClose 0.28s cubic-bezier(0.55, 0, 1, 0.45) both;
	transform-origin: center bottom;
	pointer-events: none;
}

.shofy-support-floating[open]:not(.is-closing) .shofy-support-floating__list .shofy-support__link--floating:nth-last-child(1) { animation-delay: 0.04s; }
.shofy-support-floating[open]:not(.is-closing) .shofy-support-floating__list .shofy-support__link--floating:nth-last-child(2) { animation-delay: 0.09s; }
.shofy-support-floating[open]:not(.is-closing) .shofy-support-floating__list .shofy-support__link--floating:nth-last-child(3) { animation-delay: 0.14s; }
.shofy-support-floating[open]:not(.is-closing) .shofy-support-floating__list .shofy-support__link--floating:nth-last-child(4) { animation-delay: 0.19s; }
.shofy-support-floating[open]:not(.is-closing) .shofy-support-floating__list .shofy-support__link--floating:nth-last-child(5) { animation-delay: 0.24s; }
.shofy-support-floating[open]:not(.is-closing) .shofy-support-floating__list .shofy-support__link--floating:nth-last-child(6) { animation-delay: 0.29s; }
.shofy-support-floating[open]:not(.is-closing) .shofy-support-floating__list .shofy-support__link--floating:nth-last-child(7) { animation-delay: 0.34s; }
.shofy-support-floating[open]:not(.is-closing) .shofy-support-floating__list .shofy-support__link--floating:nth-last-child(8) { animation-delay: 0.39s; }

.shofy-support-floating[open].is-closing .shofy-support-floating__list .shofy-support__link--floating:nth-child(1) { animation-delay: 0s; }
.shofy-support-floating[open].is-closing .shofy-support-floating__list .shofy-support__link--floating:nth-child(2) { animation-delay: 0.05s; }
.shofy-support-floating[open].is-closing .shofy-support-floating__list .shofy-support__link--floating:nth-child(3) { animation-delay: 0.1s; }
.shofy-support-floating[open].is-closing .shofy-support-floating__list .shofy-support__link--floating:nth-child(4) { animation-delay: 0.15s; }
.shofy-support-floating[open].is-closing .shofy-support-floating__list .shofy-support__link--floating:nth-child(5) { animation-delay: 0.2s; }
.shofy-support-floating[open].is-closing .shofy-support-floating__list .shofy-support__link--floating:nth-child(6) { animation-delay: 0.25s; }
.shofy-support-floating[open].is-closing .shofy-support-floating__list .shofy-support__link--floating:nth-child(7) { animation-delay: 0.3s; }
.shofy-support-floating[open].is-closing .shofy-support-floating__list .shofy-support__link--floating:nth-child(8) { animation-delay: 0.35s; }

.shofy-support__link--floating {
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: var(--shofy-support-channel-color, var(--shofy-support-primary));
	color: #fff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	text-decoration: none;
	box-shadow: 0 3px 12px rgba(0, 0, 0, 0.18);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	font-size: 20px;
	pointer-events: auto;
}

.shofy-support__link--floating:hover {
	transform: scale(1.08);
	color: #fff;
	box-shadow: 0 5px 16px rgba(0, 0, 0, 0.22);
}

.shofy-support__link--floating .shofy-support__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
}

.shofy-support__link--floating .shofy-support__icon svg,
.shofy-support__link--fixed .shofy-support__icon svg {
	width: 100%;
	height: 100%;
	display: block;
}

.shofy-support__link--bale { --shofy-support-channel-color: #21C594; }
.shofy-support__link--eitaa { --shofy-support-channel-color: #E87722; }
.shofy-support__link--rubika { --shofy-support-channel-color: #7B1FA2; }
.shofy-support__link--soroush { --shofy-support-channel-color: #00A651; }
.shofy-support__link--gap { --shofy-support-channel-color: #00BCD4; }
.shofy-support__link--igap { --shofy-support-channel-color: #0066CC; }

.shofy-support-svg {
	fill: currentColor;
}

/* ── Fixed bar ── */

.shofy-support-fixed {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: var(--shofy-support-z);
	display: flex;
	align-items: stretch;
	justify-content: center;
	flex-wrap: wrap;
	gap: 0;
	background: rgba(255, 255, 255, 0.97);
	border-top: 1px solid rgba(0, 0, 0, 0.08);
	box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
	backdrop-filter: blur(8px);
	padding: 0;
}

.shofy-support__link--fixed {
	flex: 1 1 auto;
	min-width: 0;
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	padding: 10px 8px;
	text-decoration: none;
	color: #333;
	font-size: 11px;
	font-weight: 500;
	transition: background 0.2s ease, color 0.2s ease;
	border-left: 1px solid rgba(0, 0, 0, 0.06);
	cursor: pointer;
	pointer-events: auto;
}

.shofy-support__link--fixed:first-child {
	border-left: 0;
}

.shofy-support__link--fixed:hover {
	background: rgba(0, 0, 0, 0.04);
	color: var(--shofy-support-channel-color, var(--shofy-support-primary));
}

.shofy-support__link--fixed .shofy-support__icon {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: var(--shofy-support-channel-color, var(--shofy-support-primary));
	color: #fff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
}

.shofy-support__link--fixed .shofy-support__icon svg {
	width: 16px;
	height: 16px;
}

.shofy-support__text {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
	line-height: 1.2;
}

.shofy-support:has(.shofy-support-fixed) .shofy-support-floating {
	bottom: calc(var(--shofy-support-offset) + 56px);
}

body:has(#tp-bottom-menu-sticky) .shofy-support-fixed {
	bottom: 56px;
}

body:has(#tp-bottom-menu-sticky) .shofy-support-floating {
	bottom: calc(var(--shofy-support-offset) + 56px);
}

body:has(#tp-bottom-menu-sticky) .shofy-support:has(.shofy-support-fixed) .shofy-support-floating {
	bottom: calc(var(--shofy-support-offset) + 112px);
}

@keyframes shofySupportListOpen {
	from {
		opacity: 0;
		transform: translateX(-50%) translateY(8px) scaleY(0.85);
	}
	to {
		opacity: 1;
		transform: translateX(-50%) translateY(0) scaleY(1);
	}
}

@keyframes shofySupportListClose {
	from {
		opacity: 1;
		transform: translateX(-50%) translateY(0) scaleY(1);
	}
	to {
		opacity: 0;
		transform: translateX(-50%) translateY(10px) scaleY(0.85);
	}
}

@keyframes shofySupportItemOpen {
	from {
		opacity: 0;
		transform: scale(0.35) translateY(18px);
	}
	to {
		opacity: 1;
		transform: scale(1) translateY(0);
	}
}

@keyframes shofySupportItemClose {
	from {
		opacity: 1;
		transform: scale(1) translateY(0);
	}
	to {
		opacity: 0;
		transform: scale(0.35) translateY(18px);
	}
}

@keyframes shofySupportPulseRing {
	0% {
		transform: scale(1);
		opacity: 0.4;
	}
	70% {
		transform: scale(1.85);
		opacity: 0;
	}
	100% {
		transform: scale(1.85);
		opacity: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.shofy-support-floating:not([open]) .shofy-support-floating__toggle::before,
	.shofy-support-floating:not([open]) .shofy-support-floating__toggle::after {
		animation: none;
		opacity: 0;
	}

	.shofy-support-floating[open] .shofy-support-floating__list,
	.shofy-support-floating[open] .shofy-support-floating__list .shofy-support__link--floating {
		animation: none !important;
	}
}

@media (max-width: 991px) {
	.shofy-support__link--fixed {
		padding: 8px 4px;
		font-size: 10px;
	}

	.shofy-support__link--fixed .shofy-support__icon {
		width: 24px;
		height: 24px;
		font-size: 12px;
	}
}

@media (min-width: 992px) {
	.shofy-support-fixed {
		max-width: 720px;
		left: 50%;
		right: auto;
		transform: translateX(-50%);
		border-radius: 12px 12px 0 0;
		bottom: 0;
	}

	.shofy-support__link--fixed {
		padding: 12px 16px;
		font-size: 12px;
	}
}
