/* assets/css/app_loading.css
 * Global loading feedback (see assets/js/app_loading.js):
 *  - top progress bar while a request (XHR / fetch) or a page navigation takes time
 *  - skeleton placeholders (.app-skel-*) for lists and cards being loaded
 *  - inline spinner (.app-spinner), busy buttons (.app-busy) and loading blocks (.app-loading)
 */

:root {
	--app-loading-color: var(--primary);
	--app-skeleton-base: #efebe3;
	--app-skeleton-shine: #faf8f4;
}

/* ===================== Top progress bar ===================== */
#app-progress {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	height: 3px;
	z-index: 20000;
	overflow: hidden;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.2s ease;
}

#app-progress.on {
	opacity: 1;
}

#app-progress::before {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	left: -40%;
	width: 40%;
	background: var(--app-loading-color);
	border-radius: 0 3px 3px 0;
	animation: app-progress-slide 1.1s ease-in-out infinite;
}

@keyframes app-progress-slide {
	0% { left: -40%; width: 40%; }
	50% { width: 55%; }
	100% { left: 100%; width: 30%; }
}

/* ===================== Spinner ===================== */
.app-spinner {
	display: inline-block;
	width: 1.1em;
	height: 1.1em;
	border: 2px solid rgba(var(--primary-rgb), 0.2);
	border-top-color: var(--app-loading-color);
	border-radius: 50%;
	animation: app-spin 0.7s linear infinite;
	vertical-align: -0.2em;
	flex: none;
}

.app-spinner.lg {
	width: 2rem;
	height: 2rem;
	border-width: 3px;
}

@keyframes app-spin {
	to { transform: rotate(360deg); }
}

/* Centered spinner with an optional text (AppLoading.spinner()) */
.app-spinner-block {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 40px 16px;
	color: #8D817B;
	font-size: 13px;
}

/* Busy button (AppLoading.busy()): spinner before the label, clicks disabled */
.app-busy {
	pointer-events: none;
	opacity: 0.85;
}

.app-busy .app-spinner {
	width: 1em;
	height: 1em;
	margin-right: 6px;
	border-color: rgba(255, 255, 255, 0.35);
	border-top-color: currentColor;
}

/* Block being refreshed (AppLoading.block()): dimmed content and centered spinner */
.app-loading {
	position: relative;
	cursor: progress;
}

/* Content dimmed and not clickable while loading (no double submit) */
.app-loading > * {
	opacity: 0.45;
	pointer-events: none;
	transition: opacity 0.15s ease;
}

.app-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 28px;
	height: 28px;
	margin: -14px 0 0 -14px;
	border: 3px solid rgba(var(--primary-rgb), 0.2);
	border-top-color: var(--app-loading-color);
	border-radius: 50%;
	animation: app-spin 0.7s linear infinite;
	z-index: 5;
}

/* ===================== Skeletons ===================== */
.app-skel {
	display: block;
	border-radius: 6px;
	background: linear-gradient(90deg, var(--app-skeleton-base) 25%, var(--app-skeleton-shine) 50%, var(--app-skeleton-base) 75%);
	background-size: 200% 100%;
	animation: app-skeleton-shine 1.3s ease-in-out infinite;
}

.app-skel-line {
	height: 12px;
	margin-bottom: 10px;
}

.app-skel-line.sm { width: 40%; }
.app-skel-line.md { width: 65%; }
.app-skel-line.lg { width: 90%; }
.app-skel-line.title { height: 16px; width: 55%; }

.app-skel-circle {
	width: 48px;
	height: 48px;
	border-radius: 12px;
	flex: none;
}

.app-skel-pill {
	display: inline-block;
	width: 70px;
	height: 18px;
	border-radius: 999px;
}

/* Skeleton card (same frame as the application cards: no visible border, soft shadow) */
.app-skel-card {
	background: #fff;
	border-radius: 12px;
	border: 1px solid rgba(0, 0, 0, 0.02);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
	padding: 20px;
	height: 100%;
}

.app-skel-card .app-skel-head {
	display: flex;
	align-items: center;
	gap: 14px;
	margin-bottom: 16px;
}

.app-skel-card .app-skel-head > div {
	flex: 1;
}

/* Skeleton table row cells */
.app-skel-row td {
	padding-top: 14px !important;
	padding-bottom: 14px !important;
}

.app-skel-row .app-skel-line {
	margin: 0;
}

@keyframes app-skeleton-shine {
	0% { background-position: 100% 0; }
	100% { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
	#app-progress::before,
	.app-spinner,
	.app-loading::after,
	.app-skel {
		animation-duration: 3s;
	}
}

/* ===================== Paged lists (assets/js/app_paged_list.js) ===================== */
/* Sentinel below a list loaded on scroll: progress counter and fallback "Afficher plus" button */
.app-paged-sentinel {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	padding: 16px 0 24px;
}

.app-paged-sentinel[hidden],
.app-paged-sentinel .app-paged-more[hidden] {
	display: none;
}
