/**
 * Stylish Font Generator — Professional UI
 * Inspired by fontgen.cool, elevated with cleaner typography & scroll-sync nav.
 */

/* ── Design tokens ── */
.fg-container {
	--fg-bg: #f4f6fb;
	--fg-surface: #ffffff;
	--fg-surface-2: #f8f9fc;
	--fg-border: #e4e8f0;
	--fg-border-hover: #c8d0e0;
	--fg-text: #111827;
	--fg-text-muted: #6b7280;
	--fg-text-light: #9ca3af;
	--fg-radius: 14px;
	--fg-radius-sm: 10px;
	--fg-radius-pill: 999px;
	--fg-preview-size: 20px;
	--fg-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	--fg-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
	--fg-shadow: 0 4px 24px rgba(15, 23, 42, 0.07);
	--fg-shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.10);
	--fg-sticky-top: 0px;
	--fg-nav-height: 52px;

	all: unset;
	display: block;
	font-family: var(--fg-font);
	background: var(--fg-bg);
	color: var(--fg-text);
	border-radius: var(--fg-radius);
	overflow: clip;
	position: relative;
	box-sizing: border-box;
	-webkit-font-smoothing: antialiased;
}


.fg-container *,
.fg-container *::before,
.fg-container *::after {
	box-sizing: border-box;
}

.fg-container button {
	font-family: inherit;
	cursor: pointer;
}

/* ── Sticky control stack ── */
.fg-sticky-stack {
	will-change: transform;
	transform: translateZ(0);
	position: sticky;
	top: var(--fg-sticky-top);
	z-index: 200;
	background: rgba(244, 246, 251, 0.92);
	backdrop-filter: blur(20px) saturate(1.4);
	-webkit-backdrop-filter: blur(20px) saturate(1.4);
	border-bottom: 1px solid var(--fg-border);
	padding: 20px 20px 0;
	box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04);
}

.fg-sticky-stack.is-scrolled {
	box-shadow: var(--fg-shadow);
}

/* ── Text input ── */
.fg-input-section {
	margin-bottom: 14px;
}

.fg-input-wrapper {
	position: relative;
	margin-bottom: 10px;
}

.fg-textarea {
	display: block;
	width: 100%;
	height: 64px;
	min-height: 64px;
	max-height: 64px;
	padding: 20px 45px 20px 16px;
	font-size: 16px;
	font-weight: 400;
	line-height: 22px;
	border: 1px solid var(--fg-accent);
	border-radius: 6px;
	background: var(--fg-surface);
	color: var(--fg-text);
	font-family: var(--fg-font);
	resize: none;
	overflow: hidden;
	white-space: nowrap;
	outline: none;
	transition: border-color 0.2s, box-shadow 0.2s;
	box-shadow: var(--fg-shadow-sm);
}

.fg-textarea:focus {
	border-color: var(--fg-accent);
	box-shadow: 0 0 0 4px rgba(var(--fg-accent-rgb), 0.12);
	animation: fgInputFocus 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fgInputFocus {
	from {
		box-shadow: 0 0 0 0px rgba(var(--fg-accent-rgb), 0);
	}
	to {
		box-shadow: 0 0 0 4px rgba(var(--fg-accent-rgb), 0.12);
	}
}

.fg-textarea::placeholder {
	color: var(--fg-text-light);
	font-weight: 400;
}

.fg-clear-btn {
	position: absolute;
	right: 14px;
	top: 50%;
	transform: translateY(-50%);
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: var(--fg-surface-2);
	border: 1px solid var(--fg-border);
	color: var(--fg-text-muted);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: background 0.15s, color 0.15s, transform 0.15s;
}

.fg-clear-btn:hover {
	background: #fee2e2;
	border-color: #fca5a5;
	color: #dc2626;
	transform: translateY(-50%) scale(1.05);
}

/* ── Toolbar (size + copy all) ── */
.fg-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 14px;
	flex-wrap: wrap;
}

.fg-size-control {
	display: flex;
	align-items: center;
	gap: 12px;
	flex: 1;
	min-width: 200px;
}

.fg-size-label {
	font-size: 13px;
	font-weight: 600;
	color: var(--fg-text-muted);
	white-space: nowrap;
}

.fg-slider-track {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 1;
	max-width: 280px;
	background: var(--fg-surface);
	border: 1px solid var(--fg-border);
	border-radius: var(--fg-radius-pill);
	padding: 8px 16px;
}

.fg-slider-icon {
	font-size: 11px;
	font-weight: 700;
	color: var(--fg-text-light);
	user-select: none;
}

.fg-slider-icon-lg {
	font-size: 16px;
}

.fg-size-slider {
	-webkit-appearance: none;
	appearance: none;
	flex: 1;
	height: 4px;
	border-radius: 2px;
	background: var(--fg-border);
	outline: none;
	cursor: pointer;
}

.fg-size-slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--fg-accent);
	cursor: pointer;
	box-shadow: 0 2px 8px rgba(var(--fg-accent-rgb), 0.35);
	border: 2px solid #fff;
	transition: transform 0.15s;
}

.fg-size-slider::-webkit-slider-thumb:hover {
	transform: scale(1.15);
}

.fg-size-slider::-moz-range-thumb {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--fg-accent);
	cursor: pointer;
	border: 2px solid #fff;
	box-shadow: 0 2px 8px rgba(var(--fg-accent-rgb), 0.35);
}

.fg-copy-all-btn {
	padding: 10px 18px;
	border-radius: var(--fg-radius-pill);
	background: var(--fg-surface);
	border: 1px solid var(--fg-border);
	color: var(--fg-text);
	font-size: 13px;
	font-weight: 600;
	white-space: nowrap;
	transition: all 0.18s;
	box-shadow: var(--fg-shadow-sm);
}

.fg-copy-all-btn:hover {
	background: var(--fg-accent);
	border-color: var(--fg-accent);
	color: #fff;
	box-shadow: 0 4px 14px rgba(var(--fg-accent-rgb), 0.3);
	transform: translateY(-2px) scale(1.05);
	animation: fgCopyBtnHover 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fgCopyBtnHover {
	from {
		transform: translateY(0) scale(1);
	}
	to {
		transform: translateY(-2px) scale(1.05);
	}
}

.fg-copy-all-btn:active {
	transform: translateY(0) scale(0.95);
	transition: transform 0.1s;
}

/* ── Category tabs + scroll progress ── */
.fg-tabs-nav {
	position: relative;
	margin: 0 -20px;
	padding: 0 20px;
}

.fg-tabs-progress {
	position: absolute;
	top: 0;
	left: 20px;
	right: 20px;
	height: 3px;
	background: var(--fg-border);
	border-radius: 2px;
	overflow: hidden;
}

.fg-tabs-progress-fill {
	height: 100%;
	width: 0%;
	background: linear-gradient(90deg, var(--fg-accent), rgba(var(--fg-accent-rgb), 0.6));
	border-radius: 2px;
	transition: width 0.25s ease;
}

.fg-tabs-scroller {
	display: flex;
	gap: 6px;
	overflow-x: auto;
	padding: 10px 0 14px;
	scrollbar-width: none;
	-ms-overflow-style: none;
	-webkit-overflow-scrolling: touch;
}

.fg-tabs-scroller::-webkit-scrollbar {
	display: none;
}

.fg-tab-btn {
	flex-shrink: 0;
	padding: 9px 18px;
	border-radius: var(--fg-radius-pill);
	background: transparent;
	border: 1px solid transparent;
	color: var(--fg-text-muted);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.18s ease;
	outline: none;
}

.fg-tab-btn:hover {
	color: var(--fg-text);
	background: var(--fg-surface);
	border-color: var(--fg-border);
	transform: translateY(-1px);
	animation: fgTabHover 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fgTabHover {
	from {
		transform: translateY(0);
	}
	to {
		transform: translateY(-1px);
	}
}

.fg-tab-btn.active {
	background: var(--fg-accent);
	color: #fff;
	border-color: var(--fg-accent);
	box-shadow: 0 4px 14px rgba(var(--fg-accent-rgb), 0.28);
	animation: fgTabActive 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fgTabActive {
	from {
		transform: scale(0.95);
		opacity: 0.8;
	}
	to {
		transform: scale(1);
		opacity: 1;
	}
}

/* ── Content area ── */
.fg-content-area {
	padding: 8px 20px 40px;
}

/* ── Category sections ── */
.fg-category-section {
	contain: layout style;
	margin-bottom: 36px;
	scroll-margin-top: 220px;
}


.fg-section-header {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 14px;
	padding-bottom: 10px;
	border-bottom: 2px solid var(--fg-border);
}

.fg-section-title {
	margin: 0;
	font-size: 18px;
	font-weight: 700;
	color: var(--fg-text);
	letter-spacing: -0.02em;
	position: relative;
	padding-left: 14px;
}

.fg-section-title::before {
	content: '';
	position: absolute;
	left: 0;
	top: 50%;
	transform: translateY(-50%);
	width: 4px;
	height: 20px;
	background: var(--fg-accent);
	border-radius: 2px;
}

.fg-section-count {
	font-size: 12px;
	font-weight: 600;
	color: var(--fg-text-muted);
	background: var(--fg-surface);
	border: 1px solid var(--fg-border);
	padding: 3px 10px;
	border-radius: var(--fg-radius-pill);
}

/* ── Font list rows (fontgen.cool style) ── */
.fg-font-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.fg-font-row {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 16px 18px;
	background: var(--fg-surface);
	border: 1px solid var(--fg-border);
	border-radius: var(--fg-radius-sm);
	cursor: pointer;
	position: relative;
	transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
	box-shadow: var(--fg-shadow-sm);
	content-visibility: auto;
	contain-intrinsic-size: 80px;
}


.fg-font-row:hover {
	border-color: rgba(var(--fg-accent-rgb), 0.5);
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
	transform: translateY(-2px);
	z-index: 10;
}

/* ── Scroll Instant Display ── */
.reveal-on-scroll {
	opacity: 1 !important;
	transform: none !important;
	transition: none !important;
}

.reveal-on-scroll.is-visible {
	opacity: 1 !important;
	transform: none !important;
}


.fg-font-row:active {
	transform: translateY(0) scale(0.99);
	transition: transform 0.1s;
}

.fg-font-row.fg-row-copied {
	border-color: #22c55e;
	background: #f0fdf4;
	animation: fgRowCopied 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fgRowCopied {
	0% {
		transform: scale(1);
	}
	50% {
		transform: scale(1.02);
	}
	100% {
		transform: scale(1);
	}
}

.fg-row-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.fg-row-name {
	font-size: 12px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--fg-text-muted);
}

.fg-row-actions {
	display: flex;
	gap: 4px;
	opacity: 0;
	transition: opacity 0.15s;
}

.fg-font-row:hover .fg-row-actions {
	opacity: 1;
}

.fg-row-action-btn {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: var(--fg-surface-2);
	border: 1px solid var(--fg-border);
	color: var(--fg-text-muted);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
	padding: 0;
	transition: all 0.15s;
}

.fg-row-action-btn:hover {
	background: var(--fg-surface);
	border-color: var(--fg-border-hover);
	color: var(--fg-text);
	transform: scale(1.15) rotate(5deg);
	animation: fgActionBtnHover 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fgActionBtnHover {
	from {
		transform: scale(1) rotate(0deg);
	}
	to {
		transform: scale(1.15) rotate(5deg);
	}
}

.fg-row-action-btn.fg-fav-active {
	color: #ef4444;
	border-color: #fca5a5;
	background: #fef2f2;
}

.fg-row-preview {
	font-size: var(--fg-preview-size);
	line-height: 1.45;
	color: var(--fg-text);
	word-break: break-word;
	overflow-wrap: anywhere;
	padding-right: 80px;
}

.fg-row-copy-hint {
	position: absolute;
	right: 16px;
	bottom: 16px;
	font-size: 11px;
	font-weight: 600;
	color: var(--fg-accent);
	background: rgba(var(--fg-accent-rgb), 0.08);
	border: 1px solid rgba(var(--fg-accent-rgb), 0.15);
	padding: 4px 10px;
	border-radius: var(--fg-radius-pill);
	opacity: 0;
	transition: opacity 0.15s;
	pointer-events: none;
}

.fg-font-row:hover .fg-row-copy-hint {
	opacity: 1;
}

/* Grid layout option (admin setting) */
.fg-container.fg-layout-grid .fg-font-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 12px;
}

.fg-container.fg-layout-grid .fg-font-row {
	min-height: 130px;
}

.fg-container.fg-layout-grid .fg-row-preview {
	padding-right: 0;
}

/* ── End marker ── */
.fg-end-marker {
	text-align: center;
	padding: 32px 20px;
	color: var(--fg-text-muted);
	font-size: 14px;
	font-weight: 500;
	border-top: 1px dashed var(--fg-border);
	margin-top: 12px;
}

/* ── Share modal ── */
.fg-modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, 0.45);
	backdrop-filter: blur(6px);
	z-index: 10000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.fg-modal-overlay[hidden] {
	display: none;
}

.fg-modal {
	background: var(--fg-surface);
	border-radius: var(--fg-radius);
	padding: 24px;
	width: 100%;
	max-width: 440px;
	box-shadow: var(--fg-shadow-lg);
}

.fg-modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 16px;
}

.fg-modal-header h3 {
	margin: 0;
	font-size: 18px;
	font-weight: 700;
}

.fg-modal-close {
	background: none;
	border: none;
	font-size: 24px;
	color: var(--fg-text-muted);
	line-height: 1;
	padding: 4px;
}

.fg-share-preview-lbl {
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--fg-text-muted);
	margin: 0 0 8px;
}

.fg-share-preview-text {
	background: var(--fg-surface-2);
	border: 1px solid var(--fg-border);
	padding: 14px;
	border-radius: var(--fg-radius-sm);
	margin-bottom: 16px;
	font-size: 16px;
	word-break: break-all;
	line-height: 1.4;
}

.fg-share-buttons {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
}

.fg-share-btn {
	text-decoration: none;
	padding: 10px;
	border-radius: var(--fg-radius-sm);
	text-align: center;
	font-weight: 700;
	font-size: 12px;
	color: #fff;
	transition: opacity 0.15s, transform 0.15s;
}

.fg-share-whatsapp { background: #25d366; }
.fg-share-telegram { background: #0088cc; }
.fg-share-twitter  { background: #1d9bf0; }

.fg-share-btn:hover {
	opacity: 0.9;
	transform: translateY(-1px);
	color: #fff;
}

/* ── Toast ── */
.fg-toast-container {
	position: fixed;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 10001;
	display: flex;
	flex-direction: column;
	gap: 8px;
	pointer-events: none;
}

.fg-toast {
	background: #111827;
	color: #fff;
	padding: 12px 20px;
	border-radius: var(--fg-radius-pill);
	box-shadow: var(--fg-shadow-lg);
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	font-weight: 600;
	animation: fgToastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
	pointer-events: auto;
}

.fg-toast-icon {
	color: #4ade80;
	font-size: 15px;
}

@keyframes fgToastIn {
	from { opacity: 0; transform: translateY(12px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* ── Back to top ── */
.fg-back-to-top {
	position: fixed;
	bottom: 24px;
	right: 24px;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: var(--fg-accent);
	color: #fff;
	border: none;
	box-shadow: 0 4px 14px rgba(var(--fg-accent-rgb), 0.4);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	z-index: 150;
	opacity: 0;
	visibility: hidden;
	transform: translateY(12px);
	transition: all 0.25s ease;
}

.fg-back-to-top.visible {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.fg-back-to-top:hover {
	background: var(--fg-accent);
	color: #fff;
	transform: translateY(-2px) scale(1.1);
	box-shadow: 0 6px 20px rgba(var(--fg-accent-rgb), 0.5);
	animation: fgBttHover 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fgBttHover {
	from {
		transform: translateY(0) scale(1);
	}
	to {
		transform: translateY(-2px) scale(1.1);
	}
}

.fg-controls-hidden .fg-input-section,
.fg-controls-hidden .fg-size-control {
	display: none !important;
}

.fg-controls-hidden .fg-toolbar {
	justify-content: flex-end;
}

/* ── Responsive ── */
@media (max-width: 768px) {
	.fg-container *,
	.fg-container *::before,
	.fg-container *::after {
		animation: none !important;
		transition: none !important;
	}

	.fg-font-row,
	.reveal-on-scroll {
		opacity: 1 !important;
		transform: none !important;
		transition: none !important;
		animation: none !important;
	}
	.fg-desktop-only {
		display: none !important;
	}

	.fg-container {
		margin-left: calc(50% - 50vw);
		margin-right: calc(50% - 50vw);
		width: 100vw;
		max-width: 100vw;
		border-radius: 0;
		border-left: none;
		border-right: none;
	}

	.fg-font-row {
		padding: 12px 12px;
	}

	.fg-sticky-stack {
	will-change: transform;
	transform: translateZ(0);
		padding: 14px 14px 0;
	}

	.fg-textarea {
		font-size: 18px;
		min-height: 60px;
		height: 60px;
		max-height: 60px;
		padding: 18px 48px 18px 16px;
	}

	.fg-quick-filters {
		flex-wrap: nowrap;
		overflow-x: auto;
		scrollbar-width: none;
		padding-bottom: 4px;
	}

	.fg-quick-filters::-webkit-scrollbar {
		display: none;
	}

	.fg-quick-btn {
		flex-shrink: 0;
		padding: 7px 12px;
		font-size: 12px;
	}


	.fg-copy-all-btn {
		width: 100%;
		text-align: center;
		justify-content: center;
	}

	.fg-tabs-nav {
		margin: 0 -14px;
		padding: 0 14px;
	}

	.fg-tabs-progress {
		left: 14px;
		right: 14px;
	}

	.fg-content-area {
		padding: 8px 14px 32px;
	}

	.fg-category-section {
	contain: layout style;
		scroll-margin-top: 260px;
	}

	.fg-row-actions {
		opacity: 1;
	}

	.fg-row-action-btn {
		width: 42px;
		height: 42px;
		font-size: 20px;
	}

	.fg-row-copy-hint {
		opacity: 1;
		position: static;
		align-self: flex-end;
		margin-top: 4px;
	}

	.fg-row-preview {
		padding-right: 0;
	}

	.fg-back-to-top {
		width: 36px;
		height: 36px;
		bottom: 16px;
		right: 16px;
	}

	.fg-back-to-top svg {
		width: 16px;
		height: 16px;
	}

	.fg-section-title {
		font-size: 16px;
	}
}

@media (max-width: 400px) {
	.fg-tab-btn {
		padding: 8px 14px;
		font-size: 12px;
	}
}

/* Show button PC/Laptop view color */
@media (min-width: 769px) {
	#fg-toggle-controls-btn {
		background: #5448db !important;
		color: #ffffff !important;
		border-color: #5448db !important;
	}
}

@media (max-width: 768px) { 
	.fg-textarea { 
		height: 60px; 
		min-height: 60px; 
		max-height: 60px; 
		padding: 18px 45px 18px 16px; 
		font-size: 16px; 
	} 
}


/* ── View Favorites Button & Mobile Layout Fix ── */
.fg-view-favs-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	border-radius: var(--fg-radius-pill);
	font-size: 12px;
	font-weight: 600;
	border: 1px solid #ef4444;
	background: #fef2f2;
	color: #ef4444;
	white-space: nowrap;
	flex-shrink: 0;
	cursor: pointer;
	transition: background 0.2s ease, transform 0.2s ease;
}

.fg-view-favs-btn:hover {
	background: #fee2e2;
	transform: scale(1.03);
}

@media (max-width: 640px) {
	.fg-toolbar {
		flex-direction: column;
		align-items: stretch;
		gap: 12px;
	}
	.fg-size-control {
		width: 100%;
		min-width: 0;
	}
	.fg-slider-track {
		max-width: none;
		flex: 1;
	}
	.fg-toolbar-actions {
		width: 100%;
		justify-content: flex-end;
	}
}
