/**
 * WooTweaks Infinite Scroll - Frontend Styles
 *
 * Styles for loading indicators, animations, and infinite scroll UI elements.
 *
 * @package WooTweaks
 * @subpackage Tweaks/InfiniteScroll
 */

/* ==========================================================================
   Loading Indicator
   ========================================================================== */

.wt-infinite-scroll-loading {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 40px 20px;
	margin: 20px 0;
	text-align: center;
	clear: both;
}

.wt-infinite-scroll-text {
	margin-top: 15px;
	font-size: 14px;
	color: #666;
	font-weight: 500;
}

/* ==========================================================================
   Loading Spinner Animation
   ========================================================================== */

.wt-infinite-scroll-spinner {
	width: 50px;
	height: 50px;
	border: 4px solid rgba(0, 0, 0, 0.1);
	border-top-color: #008037;
	border-radius: 50%;
	animation: wt-spinner-rotate 1s linear infinite;
}

@keyframes wt-spinner-rotate {
	0% {
		transform: rotate(0deg);
	}
	100% {
		transform: rotate(360deg);
	}
}

/* ==========================================================================
   Observer Trigger (Invisible Element)
   ========================================================================== */

.wt-infinite-scroll-trigger {
	height: 1px;
	width: 100%;
	clear: both;
	visibility: hidden;
}

/* ==========================================================================
   Error Message
   ========================================================================== */

.wt-infinite-scroll-error {
	display: none;
	padding: 15px 20px;
	margin: 20px 0;
	background-color: #f8d7da;
	border: 1px solid #f5c6cb;
	border-radius: 4px;
	color: #721c24;
	text-align: center;
	font-size: 14px;
}

/* ==========================================================================
   Hide Default Pagination
   ========================================================================== */

.woocommerce-pagination {
	display: none !important;
}

/* ==========================================================================
   Product Grid Compatibility
   ========================================================================== */

/* Ensure products maintain grid layout after AJAX load */
.woocommerce ul.products li.product {
	float: left;
	clear: none;
	margin: 0 3.8% 2.992em 0;
	width: 22.05%;
	position: relative;
	transition: transform 0.4s ease, opacity 0.4s ease;
}

/* Clear fix for product grid */
.woocommerce ul.products::after {
	content: "";
	display: table;
	clear: both;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media screen and (max-width: 768px) {
	.wt-infinite-scroll-loading {
		padding: 30px 15px;
		margin: 15px 0;
	}

	.wt-infinite-scroll-spinner {
		width: 40px;
		height: 40px;
		border-width: 3px;
	}

	.wt-infinite-scroll-text {
		margin-top: 12px;
		font-size: 13px;
	}

	.wt-infinite-scroll-error {
		padding: 12px 15px;
		font-size: 13px;
	}
}

@media screen and (max-width: 480px) {
	.wt-infinite-scroll-loading {
		padding: 20px 10px;
		margin: 10px 0;
	}

	.wt-infinite-scroll-spinner {
		width: 35px;
		height: 35px;
		border-width: 2px;
	}

	.wt-infinite-scroll-text {
		margin-top: 10px;
		font-size: 12px;
	}
}

/* ==========================================================================
   Theme Compatibility Overrides
   ========================================================================== */

/* Storefront theme compatibility */
.storefront-full-width-content .wt-infinite-scroll-loading {
	max-width: 100%;
}

/* Astra theme compatibility */
.ast-woocommerce-container .wt-infinite-scroll-loading {
	margin: 20px auto;
}

/* GeneratePress theme compatibility */
.generate-columns-container .wt-infinite-scroll-loading {
	grid-column: 1 / -1;
}

/* OceanWP theme compatibility */
.oceanwp-row .wt-infinite-scroll-loading {
	flex-basis: 100%;
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Screen reader only text */
.wt-infinite-scroll-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Focus styles for keyboard navigation */
.wt-infinite-scroll-loading:focus {
	outline: 2px solid #008037;
	outline-offset: 2px;
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
	.wt-infinite-scroll-text {
		color: #ccc;
	}

	.wt-infinite-scroll-spinner {
		border-color: rgba(255, 255, 255, 0.1);
		border-top-color: #80c09b;
	}

	.wt-infinite-scroll-error {
		background-color: #5a1f1f;
		border-color: #8b2c2c;
		color: #f8d7da;
	}
}

/* ==========================================================================
   Performance Optimizations
   ========================================================================== */

/* Hardware acceleration for animations */
.wt-infinite-scroll-spinner {
	will-change: transform;
	transform: translateZ(0);
	backface-visibility: hidden;
}

/* Smooth fade transitions */
.wt-infinite-scroll-loading,
.wt-infinite-scroll-error {
	transition: opacity 0.2s ease-in-out;
}
