/* -------------------------------------------------------------------------
 * Skeleton Component
 *
 * Reusable loading placeholders. Uses the project color variables and a
 * shimmer that matches the form-builder loading skeleton. Disable the
 * animation for users who prefer reduced motion.
 * ------------------------------------------------------------------------- */

.itg-skeleton {
	--itg-skeleton-base: #e3e7ea;
	--itg-skeleton-shine: #f4f6f8;
	display: block;
	width: 100%;
}

.itg-skeleton__line,
.itg-skeleton__avatar,
.itg-skeleton__badge,
.itg-skeleton__bar,
.itg-skeleton__card-header,
.itg-skeleton__stat-icon,
.itg-skeleton__profile-banner {
	background-color: var(--itg-skeleton-base);
	background-image: linear-gradient(
		100deg,
		var(--itg-skeleton-base) 30%,
		var(--itg-skeleton-shine) 50%,
		var(--itg-skeleton-base) 70%
	);
	background-size: 220% 100%;
	animation: itgSkeletonShimmer 1.8s ease-in-out infinite;
}

@keyframes itgSkeletonShimmer {
	0% {
		background-position: 180% 0;
	}
	100% {
		background-position: -80% 0;
	}
}

/* --- Lines --- */
.itg-skeleton__lines {
	display: flex;
	flex-direction: column;
	gap: 0.65rem;
	width: 100%;
}

.itg-skeleton__line {
	display: block;
	height: 14px;
	border-radius: 6px;
}

/* --- Avatar --- */
.itg-skeleton__avatar {
	display: block;
	width: 88px;
	height: 88px;
	border-radius: 50%;
	flex: 0 0 auto;
}

/* --- Badges --- */
.itg-skeleton__badges {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	width: 100%;
}

.itg-skeleton__badge {
	display: block;
	border-radius: 999px;
}

/* --- Card --- */
.itg-skeleton__card {
	display: block;
	background-color: #fff;
	border-radius: 12px;
	box-shadow: 0 5px 15px rgba(20, 58, 77, 0.06);
	overflow: hidden;
}

.itg-skeleton__card-header {
	display: flex;
	align-items: center;
	min-height: 56px;
	padding: 0 1.5rem;
	border-bottom: 1px solid rgba(20, 58, 77, 0.08);
	--itg-skeleton-base: #d3d9dd;
	--itg-skeleton-shine: #e6eaec;
}

.itg-skeleton__card-body {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	padding: 1.5rem;
}

/* --- Profile header card --- */
.itg-skeleton__profile-card {
	background-color: #fff;
	border-radius: 16px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
	margin-bottom: 2rem;
	overflow: hidden;
}

.itg-skeleton__profile-banner {
	height: 120px;
	--itg-skeleton-base: #ccd4d8;
	--itg-skeleton-shine: #e3e9eb;
}

.itg-skeleton__profile-body {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.75rem;
	padding: 0 1.5rem 1.5rem;
}

.itg-skeleton__profile-avatar {
	width: 120px;
	height: 120px;
	margin-top: -60px;
	border: 4px solid #fff;
}

/* --- Stat grid (dashboard) --- */
.itg-skeleton__stat-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 1.5rem;
	width: 100%;
}

.itg-skeleton__stat {
	display: flex;
	align-items: center;
	gap: 1rem;
	background-color: #fff;
	border-radius: 16px;
	padding: 1.5rem;
	box-shadow: 0 5px 20px rgba(0, 0, 0, 0.07);
}

.itg-skeleton__stat-icon {
	width: 52px;
	height: 52px;
	border-radius: 12px;
	flex: 0 0 auto;
}

.itg-skeleton__stat-body {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	flex: 1;
	min-width: 0;
}

/* --- Table --- */
.itg-skeleton__table {
	display: flex;
	flex-direction: column;
	gap: 0.85rem;
	width: 100%;
}

.itg-skeleton__table-row {
	display: flex;
	gap: 1rem;
}

.itg-skeleton__table-row .itg-skeleton__line {
	flex: 1;
	min-width: 0;
}

.itg-skeleton__table-row--head .itg-skeleton__line {
	--itg-skeleton-base: #cfd6db;
	--itg-skeleton-shine: #e4e9ec;
}

/* --- Bar --- */
.itg-skeleton__bar {
	display: block;
	width: 100%;
	border-radius: 12px;
}

/* -------------------------------------------------------------------------
 * Profile page loading state (used by templates/user/profile.php)
 *
 * The skeleton is absolutely positioned inside .itg-profile-shell so it
 * overlays the real content without occupying flow, which avoids the layout
 * jump that a display:none toggle would cause.
 * ------------------------------------------------------------------------- */

.itg-profile-shell {
	position: relative;
}

#loading-skeleton {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 50%;
	width: 100%;
	transform: translateX(-50%);
	z-index: 20;
	overflow: hidden;
	transition: opacity 0.4s ease-in-out;
}

#loading-skeleton.itg-skeleton-hidden {
	opacity: 0;
	pointer-events: none;
}

#main-content {
	opacity: 0;
	transition: opacity 0.4s ease-in-out;
	/* Safety net: reveal the content if JavaScript never runs. */
	animation: itgProfileReveal 0s 6s forwards;
}

#main-content.itg-profile-ready {
	opacity: 1;
}

@keyframes itgProfileReveal {
	to {
		opacity: 1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.itg-skeleton__line,
	.itg-skeleton__avatar,
	.itg-skeleton__badge,
	.itg-skeleton__bar,
	.itg-skeleton__card-header,
	.itg-skeleton__stat-icon,
	.itg-skeleton__profile-banner {
		animation: none;
		background-image: none;
	}

	#loading-skeleton,
	#main-content {
		transition: none;
	}
}
