/**
 * Global Page Loading Styles
 * Reusable loading indicators and skeleton screens for the entire website
 */

/* ==========================================
   SKELETON LOADING ANIMATIONS
   ========================================== */
@keyframes skeleton-loading {
	0% {
		background-position: 200% 0;
	}
	100% {
		background-position: -200% 0;
	}
}

@keyframes skeleton-pulse {
	0%,
	100% {
		opacity: 1;
	}
	50% {
		opacity: 0.5;
	}
}

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

/* ==========================================
   PAGE LOADING OVERLAY
   ========================================== */
.page-loading-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(255, 255, 255, 0.95);
	backdrop-filter: blur(8px);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 9999;
	transition: opacity 0.4s ease, visibility 0.4s ease;
}

.page-loading-overlay.hidden {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

.page-loading-content {
	text-align: center;
	padding: 2rem;
}

.loading-spinner {
	width: 60px;
	height: 60px;
	border: 5px solid #f0f0f0;
	border-top: 5px solid #e47a2e;
	border-radius: 50%;
	animation: spin 1s linear infinite;
	margin: 0 auto 1.5rem;
}

.loading-spinner.sm {
	width: 40px;
	height: 40px;
	border-width: 3px;
}

.loading-spinner.lg {
	width: 80px;
	height: 80px;
	border-width: 6px;
}

.loading-text {
	color: #6c757d;
	font-size: 1rem;
	font-weight: 500;
	animation: skeleton-pulse 1.5s infinite;
}

.loading-subtext {
	color: #adb5bd;
	font-size: 0.875rem;
	margin-top: 0.5rem;
}

/* ==========================================
   SKELETON COMPONENTS
   ========================================== */
.skeleton {
	background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
	background-size: 200% 100%;
	animation: skeleton-loading 1.5s infinite;
	border-radius: 6px;
	display: inline-block;
}

/* Skeleton Box */
.skeleton-box {
	width: 100%;
	height: 20px;
	margin-bottom: 10px;
}

/* Skeleton Text Lines */
.skeleton-text {
	height: 16px;
	margin-bottom: 8px;
	border-radius: 4px;
}

.skeleton-text.short {
	width: 40%;
}

.skeleton-text.medium {
	width: 60%;
}

.skeleton-text.long {
	width: 80%;
}

.skeleton-text.full {
	width: 100%;
}

/* Skeleton Image */
.skeleton-image {
	width: 100%;
	height: 200px;
	border-radius: 8px;
	margin-bottom: 1rem;
}

.skeleton-image.square {
	aspect-ratio: 1;
	height: auto;
}

.skeleton-image.circle {
	border-radius: 50%;
	aspect-ratio: 1;
	height: auto;
}

/* Skeleton Card */
.skeleton-card {
	background: #fff;
	border: 1px solid #e0e0e0;
	border-radius: 8px;
	padding: 1rem;
	margin-bottom: 1rem;
}

.skeleton-card .skeleton-image {
	margin-bottom: 1rem;
}

.skeleton-card .skeleton-title {
	height: 24px;
	width: 70%;
	margin-bottom: 0.75rem;
	border-radius: 4px;
}

.skeleton-card .skeleton-text {
	height: 16px;
	margin-bottom: 0.5rem;
}

.skeleton-card .skeleton-button {
	height: 40px;
	width: 100%;
	margin-top: 1rem;
	border-radius: 6px;
}

/* ==========================================
   SKELETON PRODUCT GRID
   ========================================== */
.skeleton-product-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
	gap: 1.5rem;
	margin-bottom: 2rem;
}

@media (max-width: 768px) {
	.skeleton-product-grid {
		grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
		gap: 1rem;
	}
}

.skeleton-product {
	background: #fff;
	border: 1px solid #e0e0e0;
	border-radius: 12px;
	padding: 1rem;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.skeleton-product .skeleton-image {
	width: 100%;
	aspect-ratio: 1;
	height: auto;
	border-radius: 8px;
	margin-bottom: 1rem;
}

.skeleton-product .skeleton-title {
	height: 20px;
	width: 80%;
	margin-bottom: 0.5rem;
}

.skeleton-product .skeleton-price {
	height: 24px;
	width: 50%;
	margin-bottom: 1rem;
}

.skeleton-product .skeleton-button {
	height: 36px;
	width: 100%;
	border-radius: 6px;
}

/* ==========================================
   SKELETON LIST ITEMS
   ========================================== */
.skeleton-list-item {
	padding: 0.75rem 0;
	border-bottom: 1px solid #f0f0f0;
}

.skeleton-list-item:last-child {
	border-bottom: none;
}

.skeleton-list-item .skeleton {
	height: 18px;
	width: 70%;
}

/* ==========================================
   INLINE LOADING SPINNER
   ========================================== */
.spinner-inline {
	display: inline-block;
	width: 20px;
	height: 20px;
	border: 2px solid #f0f0f0;
	border-top: 2px solid #e47a2e;
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
	vertical-align: middle;
}

/* ==========================================
   BUTTON LOADING STATE
   ========================================== */
.btn-loading {
	position: relative;
	color: transparent !important;
	pointer-events: none;
}

.btn-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 20px;
	height: 20px;
	border: 2px solid #fff;
	border-top: 2px solid transparent;
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}

.btn-loading.btn-outline-primary::after,
.btn-loading.btn-outline-secondary::after {
	border-color: currentColor;
	border-top-color: transparent;
}

/* ==========================================
   CONTENT FADE IN
   ========================================== */
@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.content-loaded {
	animation: fadeIn 0.4s ease-out;
}

/* ==========================================
   UTILITY CLASSES
   ========================================== */
.loading-container {
	position: relative;
	min-height: 200px;
}

.loading-container.is-loading::after {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(255, 255, 255, 0.8);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10;
}

.shimmer {
	background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
	background-size: 200% 100%;
	animation: skeleton-loading 1.5s infinite;
}

/* Hide content until loaded */
.hide-until-loaded {
	opacity: 0;
	transition: opacity 0.3s ease;
}

.hide-until-loaded.loaded {
	opacity: 1;
}
