.back-to-top {
	--btt-size: 48px;
	--btt-bg: rgba(255, 255, 255, 0.95);
	--btt-bg-hover: rgba(255, 255, 255, 1);
	--btt-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
	--btt-shadow-hover: 0 6px 30px rgba(0, 0, 0, 0.2);
	--btt-arrow-color: #1a1a2e;
	--btt-progress-bg: rgba(0, 0, 0, 0.08);
	--btt-progress-color: #6366f1;
	--btt-border-radius: 50%;

	position: fixed;
	bottom: 32px;
	right: 32px;
	z-index: 48;

	display: flex;
	align-items: center;
	justify-content: center;

	width: var(--btt-size);
	height: var(--btt-size);
	padding: 0;

	background: var(--btt-bg);
	border: none;
	border-radius: var(--btt-border-radius);
	box-shadow: var(--btt-shadow);

	cursor: pointer;
	opacity: 0;
	visibility: hidden;
	transform: translateY(20px) scale(0.8);
	transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s ease,
		box-shadow 0.2s ease;

	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
}

/* Visible state */
.back-to-top--visible {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
}

/* Hover state */
.back-to-top:hover {
	background: var(--btt-bg-hover);
	box-shadow: var(--btt-shadow-hover);
	transform: translateY(-4px) scale(1.05);
}

.back-to-top:hover .back-to-top__arrow {
	transform: translateY(-2px);
}

/* Active/Click state */
.back-to-top:active,
.back-to-top--clicked {
	transform: translateY(0) scale(0.95);
}

/* Focus state */
.back-to-top:focus {
	outline: none;
	box-shadow: var(--btt-shadow), 0 0 0 3px rgba(99, 102, 241, 0.4);
}

.back-to-top:focus:not(:focus-visible) {
	box-shadow: var(--btt-shadow);
}

.back-to-top:focus-visible {
	box-shadow: var(--btt-shadow), 0 0 0 3px rgba(99, 102, 241, 0.4);
}

/* Progress Ring */
.back-to-top__progress {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	transform: rotate(-90deg);
	pointer-events: none;
}

.back-to-top__progress-bg {
	fill: none;
	stroke: var(--btt-progress-bg);
	stroke-width: 3;
}

.back-to-top__progress-ring {
	fill: none;
	stroke: var(--btt-progress-color);
	stroke-width: 3;
	stroke-linecap: round;
	stroke-dasharray: 125.6;
	stroke-dashoffset: 125.6;
	transition: stroke-dashoffset 0.1s ease;
}

/* Arrow Icon */
.back-to-top__arrow {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
	color: var(--btt-arrow-color);
	transition: transform 0.3s ease;
}

.back-to-top__arrow svg {
	width: 100%;
	height: 100%;
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
	.back-to-top {
		--btt-bg: rgba(30, 30, 40, 0.95);
		--btt-bg-hover: rgba(40, 40, 55, 1);
		--btt-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
		--btt-shadow-hover: 0 6px 30px rgba(0, 0, 0, 0.5);
		--btt-arrow-color: #f0f0f5;
		--btt-progress-bg: rgba(255, 255, 255, 0.1);
		--btt-progress-color: #818cf8;
	}
}

/* Manual dark mode class */
.dark .back-to-top,
[data-theme='dark'] .back-to-top {
	--btt-bg: rgba(30, 30, 40, 0.95);
	--btt-bg-hover: rgba(40, 40, 55, 1);
	--btt-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
	--btt-shadow-hover: 0 6px 30px rgba(0, 0, 0, 0.5);
	--btt-arrow-color: #f0f0f5;
	--btt-progress-bg: rgba(255, 255, 255, 0.1);
	--btt-progress-color: #818cf8;
}

/* Responsive Design */
@media (max-width: 768px) {
	.back-to-top {
		--btt-size: 44px;
		bottom: 24px;
		right: 24px;
	}

	.back-to-top__arrow {
		width: 18px;
		height: 18px;
	}
}

@media (max-width: 480px) {
	.back-to-top {
		--btt-size: 40px;
		bottom: 20px;
		right: 20px;
	}

	.back-to-top__arrow {
		width: 16px;
		height: 16px;
	}
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
	.back-to-top {
		transition: opacity 0.2s ease, visibility 0.2s ease;
	}

	.back-to-top:hover {
		transform: none;
	}

	.back-to-top--visible {
		transform: none;
	}

	.back-to-top__arrow {
		transition: none;
	}

	.back-to-top:hover .back-to-top__arrow {
		transform: none;
	}
}

/* Print - Hide */
@media print {
	.back-to-top {
		display: none !important;
	}
}
