/**
 * FloatChat Frontend Styles
 *
 * All rules are scoped under .floatchat-widget to avoid conflicts.
 *
 * @since 1.0.0
 */

/* Widget container */
.floatchat-widget {
	position: fixed;
	bottom: 20px;
	z-index: 999999;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 10px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	transition: opacity 0.4s ease, transform 0.4s ease;
}

.floatchat-widget *,
.floatchat-widget *::before,
.floatchat-widget *::after {
	box-sizing: border-box;
}

/* Visibility states */
.floatchat-widget.floatchat-hidden {
	opacity: 0;
	pointer-events: none;
	transform: translateY(20px);
}

.floatchat-widget.floatchat-visible {
	opacity: 1;
	pointer-events: auto;
	transform: translateY(0);
}

/* Position variants */
.floatchat-bottom-right {
	right: 20px;
	align-items: flex-end;
}

.floatchat-bottom-left {
	left: 20px;
	align-items: flex-start;
}

/* CTA Bubble */
.floatchat-cta {
	background: #fff;
	color: #333;
	padding: 8px 16px;
	border-radius: 20px;
	font-size: 14px;
	font-weight: 500;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
	white-space: nowrap;
	cursor: pointer;
	animation: floatchat-cta-bounce 0.5s ease-out;
	transition: opacity 0.3s ease;
}

.floatchat-widget.floatchat-open .floatchat-cta {
	opacity: 0;
	pointer-events: none;
	position: absolute;
}

/* Channels Container */
.floatchat-channels {
	display: flex;
	flex-direction: column;
	gap: 10px;
	opacity: 0;
	visibility: hidden;
	transform: translateY(10px);
	transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
	pointer-events: none;
}

.floatchat-widget.floatchat-open .floatchat-channels {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
	pointer-events: auto;
}

/* Individual Channel Link */
.floatchat-channel {
	display: flex;
	align-items: center;
	gap: 8px;
	text-decoration: none;
	opacity: 0;
	transform: translateY(15px) scale(0.8);
	transition: opacity 0.3s ease, transform 0.3s ease;
}

.floatchat-bottom-right .floatchat-channel {
	flex-direction: row-reverse;
}

.floatchat-bottom-left .floatchat-channel {
	flex-direction: row;
}

/* Staggered entry animation */
.floatchat-widget.floatchat-open .floatchat-channel {
	opacity: 1;
	transform: translateY(0) scale(1);
}

.floatchat-widget.floatchat-open .floatchat-channel:nth-child(1) { transition-delay: 0.05s; }
.floatchat-widget.floatchat-open .floatchat-channel:nth-child(2) { transition-delay: 0.1s; }
.floatchat-widget.floatchat-open .floatchat-channel:nth-child(3) { transition-delay: 0.15s; }
.floatchat-widget.floatchat-open .floatchat-channel:nth-child(4) { transition-delay: 0.2s; }

/* Channel Icon Circle */
.floatchat-icon {
	width: var(--floatchat-channel-size, 50px);
	height: var(--floatchat-channel-size, 50px);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	flex-shrink: 0;
}

.floatchat-icon:hover {
	transform: scale(1.1);
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.floatchat-icon svg {
	width: 24px;
	height: 24px;
	display: block;
}

/* Channel brand colours */
.floatchat-line .floatchat-icon      { background: #00B900; }
.floatchat-messenger .floatchat-icon { background: #0084FF; }
.floatchat-phone .floatchat-icon     { background: #25D366; }
.floatchat-email .floatchat-icon     { background: #EA4335; }

/* Channel Label Tooltip */
.floatchat-label {
	background: rgba(0, 0, 0, 0.75);
	color: #fff;
	padding: 4px 12px;
	border-radius: 14px;
	font-size: 13px;
	font-weight: 500;
	white-space: nowrap;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.floatchat-channel:hover .floatchat-label {
	opacity: 1;
}

/* Main Toggle Button */
.floatchat-toggle {
	width: var(--floatchat-btn-size, 60px);
	height: var(--floatchat-btn-size, 60px);
	border-radius: 50%;
	background: var(--floatchat-btn-color, #128C7E);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
	position: relative;
	outline: none;
	color: #fff;
	transition: transform 0.3s ease, box-shadow 0.3s ease;
	flex-shrink: 0;
	-webkit-tap-highlight-color: transparent;
}

.floatchat-toggle:hover {
	transform: scale(1.05);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.floatchat-toggle:active {
	transform: scale(0.95);
}

.floatchat-toggle:focus-visible {
	outline: 3px solid rgba(255, 255, 255, 0.6);
	outline-offset: 3px;
}

/* Toggle Icons */
.floatchat-toggle-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.3s ease, opacity 0.3s ease;
}

.floatchat-toggle-icon svg {
	width: 28px;
	height: 28px;
	display: block;
}

.floatchat-close-icon {
	display: none;
}

.floatchat-widget.floatchat-open .floatchat-open-icon {
	display: none;
}

.floatchat-widget.floatchat-open .floatchat-close-icon {
	display: flex;
}

/* Badge */
.floatchat-badge {
	position: absolute;
	top: -4px;
	right: -4px;
	background: #e74c3c;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	min-width: 18px;
	height: 18px;
	border-radius: 9px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 4px;
	border: 2px solid #fff;
	line-height: 1;
}

/* Pulse Animation */
.floatchat-pulse {
	animation: floatchat-pulse 2.5s ease-in-out infinite;
}

.floatchat-widget.floatchat-open .floatchat-pulse {
	animation: none;
}

@keyframes floatchat-pulse {
	0%, 100% {
		box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
	}
	50% {
		box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25),
		            0 0 0 10px rgba(18, 140, 126, 0.2);
	}
}

@keyframes floatchat-cta-bounce {
	0% {
		opacity: 0;
		transform: translateY(10px);
	}
	100% {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Mobile adjustments */
@media (max-width: 480px) {
	.floatchat-widget {
		bottom: 14px;
	}

	.floatchat-bottom-right {
		right: 14px;
	}

	.floatchat-bottom-left {
		left: 14px;
	}

	.floatchat-cta {
		font-size: 12px;
		padding: 6px 12px;
	}
}
