* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

/* Smooth scroll behavior with custom timing */
html {
	scroll-behavior: smooth;
	scroll-padding-top: 20px;
}

@media (prefers-reduced-motion: no-preference) {
	html {
		scroll-behavior: smooth;
	}
}

body {
	font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	min-height: 100vh;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 20px;
	padding-top: 40px;
}

.container {
	background: white;
	border-radius: 20px;
	box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
	padding: 40px;
	width: 100%;
	max-width: 600px;
	max-height: calc(100vh - 80px);
	text-align: center;
	overflow-y: auto;
	position: relative;
	transition: all 0.3s ease;
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.container.scrolling {
	box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
}

/* Hide native scrollbar but keep functionality */
.container::-webkit-scrollbar {
	width: 0px;
	background: transparent;
}

.container::-webkit-scrollbar-track {
	background: transparent;
}

.container::-webkit-scrollbar-thumb {
	background: transparent;
}

/* For Firefox */
.container {
	scrollbar-width: none;
	-ms-overflow-style: none;
}

h1 {
	color: #333;
	margin-bottom: 30px;
	font-size: 2.5rem;
	font-weight: 300;
}

.form-group {
	margin-bottom: 25px;
	text-align: left;
}

label {
	display: block;
	margin-bottom: 8px;
	color: #555;
	font-weight: 500;
}

textarea,
select,
input[type='range'],
input[type='color'],
input[type='text'] {
	width: 100%;
	padding: 15px;
	border: 2px solid #e1e1e1;
	border-radius: 10px;
	font-size: 16px;
	transition: border-color 0.3s ease;
	font-family: inherit;
}

input[type='color'] {
	height: 50px;
	padding: 5px;
	cursor: pointer;
}

input[type='range'] {
	padding: 10px 0;
}

textarea {
	resize: vertical;
	min-height: 120px;
}

textarea:focus,
select:focus,
input[type='range']:focus,
input[type='color']:focus,
input[type='text']:focus {
	outline: none;
	border-color: #667eea;
}

.generate-btn {
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: white;
	padding: 15px 40px;
	border: none;
	border-radius: 50px;
	font-size: 18px;
	font-weight: 500;
	cursor: pointer;
	transition:
		transform 0.2s ease,
		box-shadow 0.2s ease;
	margin: 20px 0;
}

.generate-btn:hover {
	transform: translateY(-2px);
	box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.generate-btn:active {
	transform: translateY(0);
}

/* Modern Loading States */
.loading {
	margin-top: 30px; /* Match result */
	padding: 30px; /* Match result exactly */
	background: #f8f9fa; /* Match result */
	border-radius: 15px; /* Match result */
	border: 2px solid #e9ecef; /* Match result */
	height: 460px; /* Desktop height */
	width: 100%;
	max-width: 600px;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 20px;
	opacity: 0;
	transform: translateY(10px);
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	overflow: visible; /* Ensure no internal scroll */
}

/* Animated QR Code Loader */
.animated-qr {
	width: 280px;
	height: 280px;
	border-radius: 15px;
	overflow: hidden;
	background: #ffffff;
	box-shadow: 0 8px 32px rgba(102, 126, 234, 0.12);
	position: relative;
}

.animated-qr svg {
	width: 100%;
	height: 100%;
}

.animated-qr rect {
	animation: qrPixelPop var(--duration, 3s) ease-out forwards;
	opacity: 0;
	transform: scale(0.3);
}

/* Progressive delays for wave effect */
.animated-qr rect:nth-child(1) {
	--duration: 2.8s;
	animation-delay: 0.05s;
}
.animated-qr rect:nth-child(2) {
	--duration: 2.9s;
	animation-delay: 0.1s;
}
.animated-qr rect:nth-child(3) {
	--duration: 3s;
	animation-delay: 0.15s;
}
.animated-qr rect:nth-child(4) {
	--duration: 2.7s;
	animation-delay: 0.2s;
}
.animated-qr rect:nth-child(5) {
	--duration: 2.6s;
	animation-delay: 0.25s;
}
.animated-qr rect:nth-child(6) {
	--duration: 3.1s;
	animation-delay: 0.3s;
}
.animated-qr rect:nth-child(7) {
	--duration: 2.8s;
	animation-delay: 0.35s;
}

/* Continue pattern but with calculated delays */
.animated-qr rect:nth-child(n + 8) {
	animation: qrPixelPop 2.5s ease-out forwards;
}

/* Create wave effect by row */
.animated-qr rect:nth-child(8n + 1) {
	animation-delay: calc(0.4s + var(--row-delay, 0s));
}
.animated-qr rect:nth-child(8n + 2) {
	animation-delay: calc(0.45s + var(--row-delay, 0s));
}
.animated-qr rect:nth-child(8n + 3) {
	animation-delay: calc(0.5s + var(--row-delay, 0s));
}
.animated-qr rect:nth-child(8n + 4) {
	animation-delay: calc(0.55s + var(--row-delay, 0s));
}
.animated-qr rect:nth-child(8n + 5) {
	animation-delay: calc(0.6s + var(--row-delay, 0s));
}
.animated-qr rect:nth-child(8n + 6) {
	animation-delay: calc(0.65s + var(--row-delay, 0s));
}
.animated-qr rect:nth-child(8n + 7) {
	animation-delay: calc(0.7s + var(--row-delay, 0s));
}
.animated-qr rect:nth-child(8n + 8) {
	animation-delay: calc(0.75s + var(--row-delay, 0s));
}

/* Stagger by groups for realistic effect */
.animated-qr rect:nth-child(n + 21):nth-child(-n + 40) {
	--row-delay: 0.3s;
}
.animated-qr rect:nth-child(n + 41):nth-child(-n + 60) {
	--row-delay: 0.6s;
}
.animated-qr rect:nth-child(n + 61):nth-child(-n + 80) {
	--row-delay: 0.9s;
}
.animated-qr rect:nth-child(n + 81):nth-child(-n + 100) {
	--row-delay: 1.2s;
}
.animated-qr rect:nth-child(n + 101):nth-child(-n + 120) {
	--row-delay: 1.5s;
}
.animated-qr rect:nth-child(n + 121):nth-child(-n + 140) {
	--row-delay: 1.8s;
}
.animated-qr rect:nth-child(n + 141):nth-child(-n + 160) {
	--row-delay: 2.1s;
}
.animated-qr rect:nth-child(n + 161):nth-child(-n + 180) {
	--row-delay: 2.4s;
}
.animated-qr rect:nth-child(n + 181):nth-child(-n + 200) {
	--row-delay: 2.7s;
}
.animated-qr rect:nth-child(n + 201) {
	--row-delay: 3s;
}

@keyframes qrPixelPop {
	0% {
		opacity: 0;
		transform: scale(0.3) rotate(45deg);
	}
	60% {
		opacity: 1;
		transform: scale(1.1) rotate(0deg);
	}
	100% {
		opacity: 1;
		transform: scale(1) rotate(0deg);
	}
}

/* Modern Spinner */
.modern-spinner {
	width: 40px;
	height: 40px;
	border: 3px solid #e2e8f0;
	border-top: 3px solid #667eea;
	border-radius: 50%;
	animation: spin 1s linear infinite;
	margin-bottom: 10px;
}

.loading-text {
	color: #64748b;
	font-size: 14px;
	font-weight: 500;
	opacity: 0.8;
}

@keyframes shimmer {
	0% {
		background-position: -200% 0;
	}
	100% {
		background-position: 200% 0;
	}
}

@keyframes pulse {
	0%,
	100% {
		opacity: 0.4;
		transform: scale(1);
	}
	50% {
		opacity: 0.8;
		transform: scale(1.1);
	}
}

@keyframes spin {
	0% {
		transform: rotate(0deg);
	}
	100% {
		transform: rotate(360deg);
	}
}

.result {
	margin-top: 30px; /* Match loading */
	padding: 30px; /* Match loading exactly */
	background: #f8f9fa; /* Match loading */
	border-radius: 15px; /* Match loading */
	border: 2px solid #e9ecef; /* Match loading */
	height: 460px; /* Desktop height */
	width: 100%;
	max-width: 600px;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 20px; /* Match loading gap */
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	opacity: 0;
	transform: translateY(10px);
	overflow: visible; /* Ensure no internal scroll */
}

/* Show states with smooth transitions */
.result.show {
	opacity: 1;
	transform: translateY(0);
}

.loading.show {
	opacity: 1;
	transform: translateY(0);
}

.result h2 {
	color: #333;
	margin: 0; /* Remove margin, using gap instead */
	font-size: 1.5rem;
	opacity: 0;
	animation: fadeInUp 0.5s ease-out 0.2s forwards;
}

#qr-display {
	margin: 0; /* Remove individual margins, use parent gap */
	display: flex;
	justify-content: center;
	align-items: center;
	width: 280px; /* Force exact width */
	/* height: 280px; Force exact height */
	opacity: 0;
	animation: fadeInScale 0.6s ease-out 0.4s forwards;
}

#qr-display img {
	width: 280px; /* Force exact size */
	/*height: 280px; /* Force exact size */
	object-fit: contain; /* Maintain aspect ratio */
	border-radius: 15px;
	box-shadow: 0 8px 32px rgba(102, 126, 234, 0.12);
	background: white; /* Ensure white background like animated version */
}

#qr-display svg {
	width: 280px; /* Force exact size */
	/*height: 280px; /* Force exact size */
	border-radius: 15px;
	box-shadow: 0 8px 32px rgba(102, 126, 234, 0.12);
}

.download-actions {
	display: flex;
	gap: 15px;
	justify-content: center;
	margin-top: 20px;
	opacity: 0;
	animation: fadeInUp 0.5s ease-out 0.6s forwards;
}

/* Animation keyframes */
@keyframes fadeInUp {
	from {
		opacity: 0;
		transform: translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes fadeInScale {
	from {
		opacity: 0;
		transform: scale(0.9);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

.download-btn,
.copy-btn {
	padding: 12px 25px;
	border: none;
	border-radius: 25px;
	font-size: 16px;
	cursor: pointer;
	transition: all 0.3s ease;
	font-weight: 500;
}

.download-btn {
	background: #28a745;
	color: white;
}

.download-btn:hover {
	background: #218838;
	transform: translateY(-1px);
}

.copy-btn {
	background: #17a2b8;
	color: white;
}

.copy-btn:hover {
	background: #138496;
	transform: translateY(-1px);
}

.error {
	color: #dc3545;
	background: #f8d7da;
	padding: 15px;
	border-radius: 10px;
	border: 1px solid #f5c6cb;
	margin-top: 20px;
}

.hidden {
	display: none;
}

/* Advanced Options Section */
.advanced-section {
	margin: 25px 0;
	border: 2px solid #e1e1e1;
	border-radius: 15px;
	overflow: hidden;
	transition: all 0.3s ease;
}

.advanced-header {
	padding: 20px;
	background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
	cursor: pointer;
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-weight: 500;
	color: #495057;
	transition: background 0.3s ease;
}

.advanced-header:hover {
	background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
}

.dropdown-arrow {
	font-size: 14px;
	transition: transform 0.3s ease;
}

.dropdown-arrow.rotated {
	transform: rotate(180deg);
}

.advanced-content {
	max-height: 0;
	overflow: hidden;
	transition: max-height 0.4s ease;
	background: #f8f9fa;
}

.advanced-content.expanded {
	max-height: 1500px;
	padding: 25px;
}

.color-group {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 20px;
	margin: 20px 0;
}

.range-value {
	display: inline-block;
	min-width: 60px;
	text-align: center;
	background: #667eea;
	color: white;
	padding: 5px 10px;
	border-radius: 15px;
	font-size: 14px;
	font-weight: 500;
	margin-left: 10px;
}

input[type='range'] {
	-webkit-appearance: none;
	appearance: none;
	height: 8px;
	background: #e1e1e1;
	border-radius: 4px;
	padding: 0;
	margin: 10px 0;
}

input[type='range']::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 20px;
	height: 20px;
	background: #667eea;
	border-radius: 50%;
	cursor: pointer;
	box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
	transition: all 0.3s ease;
}

input[type='range']::-webkit-slider-thumb:hover {
	background: #5a67d8;
	transform: scale(1.1);
}

input[type='range']::-moz-range-thumb {
	width: 20px;
	height: 20px;
	background: #667eea;
	border-radius: 50%;
	cursor: pointer;
	border: none;
	box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

#quality-group {
	display: none;
}

#quality-group.show {
	display: block;
}

/* Personalization Section */
.personalization-section {
	margin-top: 30px;
	padding-top: 25px;
	border-top: 2px solid #e1e1e1;
}

.personalization-section h4 {
	color: #495057;
	font-size: 18px;
	font-weight: 600;
	margin-bottom: 20px;
	display: flex;
	align-items: center;
	gap: 10px;
}

.personalization-section h4::before {
	content: '🎨';
	font-size: 20px;
}

.title-style-group {
	display: grid;
	grid-template-columns: 2fr 1fr;
	gap: 20px;
	margin: 15px 0;
}

input[type='text']#title {
	background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
	border: 2px solid #dee2e6;
	font-weight: 500;
}

input[type='text']#title:focus {
	border-color: #667eea;
	background: #ffffff;
	box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

input[type='text']#title::placeholder {
	color: #adb5bd;
	font-style: italic;
}

select#titleFont {
	background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
	cursor: pointer;
}

select#titlePosition {
	background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
	cursor: pointer;
}

/* Custom Scroll Indicators */
.scroll-progress {
	position: absolute;
	top: 20px;
	right: 20px;
	width: 4px;
	height: calc(100% - 40px);
	background: rgba(102, 126, 234, 0.1);
	border-radius: 2px;
	overflow: hidden;
	z-index: 1000;
	opacity: 0;
	transition: opacity 0.3s ease;
}

.container.scrolling .scroll-progress {
	opacity: 1;
}

.scroll-progress-bar {
	width: 100%;
	height: 0%;
	background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
	border-radius: 2px;
	transition: height 0.2s ease;
	position: relative;
}

.scroll-progress-bar::after {
	content: '';
	position: absolute;
	top: -10px;
	left: 0;
	width: 100%;
	height: 10px;
	background: linear-gradient(180deg, transparent 0%, #667eea 100%);
}

.scroll-position {
	position: absolute;
	bottom: 30px;
	right: 30px;
	width: 45px;
	height: 45px;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: white;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 18px;
	font-weight: bold;
	cursor: pointer;
	opacity: 0;
	transform: translateY(10px);
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	z-index: 1000;
	box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

.scroll-position:hover {
	transform: translateY(-2px) scale(1.05);
	box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.scroll-position:active {
	transform: translateY(0) scale(0.95);
}

/* Parallax effect for title */
h1 {
	transition: all 0.1s ease-out;
	will-change: transform, opacity;
}

@media (max-width: 768px) {
	.container {
		padding: 30px 20px;
		max-height: calc(100vh - 40px); /* Reduce for mobile */
	}

	h1 {
		font-size: 2rem;
	}

	/* Mobile adjustments for loading and result containers */
	.loading,
	.result {
		height: auto; /* Allow content to determine height */
		min-height: 450px; /* Increased minimum height for mobile */
		padding: 20px; /* Reduce padding for mobile */
		margin-top: 20px; /* Reduce margin for mobile */
		overflow: visible; /* No internal scroll */
	}

	/* Adjust QR display for mobile */
	.animated-qr {
		width: 240px;
		height: 240px;
	}

	#qr-display {
		width: 240px;
		max-width: 100%;
	}

	#qr-display img,
	#qr-display svg {
		width: 240px;
		height: auto;
		max-width: 100%;
	}

	.download-actions {
		flex-direction: column;
		margin-top: 15px;
	}

	.download-btn,
	.copy-btn {
		width: 100%;
	}

	.color-group {
		grid-template-columns: 1fr;
		gap: 15px;
	}

	.advanced-content.expanded {
		max-height: 1800px;
	}

	.scroll-progress {
		right: 10px;
		width: 3px;
	}

	.scroll-position {
		bottom: 20px;
		right: 20px;
		width: 40px;
		height: 40px;
		font-size: 16px;
	}
}
