/**
 * FORM LOADERS & SPINNERS
 * -----------------------------------------------------------------------------
 * Custom loading animations and spinners for ACF and Gravity Forms
 * 
 * @package HoustonRestaurantWeeks
 */

/* =============================================================================
   ACF Form Loading Spinner
   ============================================================================= */
/* Hide the small button spinner */
.acf-multistep-nav .acf-spinner {
	display: none !important;
}

/* Full screen overlay for ACF form submissions */
.acf-form-submit .acf-spinner.is-active {
	position: fixed !important;
	top: 0 !important;
	left: 0 !important;
	right: 0 !important;
	bottom: 0 !important;
	width: 100vw !important;
	height: 100vh !important;
	background: rgba(0, 0, 0, 0.7) !important;
	backdrop-filter: blur(4px) !important;
	z-index: 999999 !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	margin: 0 !important;
	padding: 0 !important;
	border: none !important;
	border-radius: 0 !important;
	animation: none !important;
}

/* Large centered spinner for ACF */
.acf-form-submit .acf-spinner.is-active::before {
	content: "" !important;
	width: 80px !important;
	height: 80px !important;
	border: 4px solid rgba(255, 255, 255, 0.3) !important;
	border-top: 4px solid #8bc540 !important;
	border-radius: 50% !important;
	animation: hrw-modern-spin 1.2s linear infinite !important;
	position: relative !important;
	z-index: 1 !important;
}

/* Loading text for ACF */
.acf-form-submit .acf-spinner.is-active::after {
	content: "Saving your menu..." !important;
	position: absolute !important;
	top: 50% !important;
	left: 50% !important;
	transform: translate(-50%, calc(-50% + 60px)) !important;
	color: white !important;
	font-size: 18px !important;
	font-weight: 500 !important;
	text-align: center !important;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
	text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5) !important;
	animation: hrw-text-pulse 2s ease-in-out infinite !important;
	z-index: 1 !important;
}

/* Style the submit button container */
.acf-multistep-nav {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-top: 20px;
	padding: 20px 0;
	position: relative;
	z-index: 11;
}

/* Enhanced submit button styling */
.acf-multistep-nav .acf-next {
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 140px;
	position: relative;
	transition: all 0.3s ease;
	border-width: 0 !important;
}

/* Enhanced previous button */
.acf-multistep-nav .acf-prev {
	transition: all 0.3s ease;
}

.acf-multistep-nav .acf-prev:hover:not(.disabled) {
	transform: translateX(-2px);
}

/* =============================================================================
   Gravity Forms Loading Spinner (Form 9 - Payment)
   ============================================================================= */

/* Make the Gravity Forms spinner full-screen but transparent - JavaScript will add content */
#gform_ajax_spinner_9:not([style*="display: none"]),
.gform_wrapper img.gform_ajax_spinner:not([style*="display: none"]) {
	position: fixed !important;
	top: 0 !important;
	left: 0 !important;
	right: 0 !important;
	bottom: 0 !important;
	width: 100vw !important;
	height: 100vh !important;
	background: rgba(0, 0, 0, 0.7) !important;
	backdrop-filter: blur(4px) !important;
	z-index: 999999 !important;
	opacity: 1 !important;
	visibility: visible !important;
	/* Hide the actual gif image */
	text-indent: -9999px !important;
	overflow: hidden !important;
}

/* Custom overlay created by JavaScript - VERY STRONG SPECIFICITY */
body .hrw-gf-loading-overlay,
html body .hrw-gf-loading-overlay,
.hrw-gf-loading-overlay {
	position: fixed !important;
	top: 0 !important;
	left: 0 !important;
	right: 0 !important;
	bottom: 0 !important;
	width: 100vw !important;
	height: 100vh !important;
	background: rgba(0, 0, 0, 0.8) !important;
	backdrop-filter: blur(4px) !important;
	z-index: 999999 !important;
	display: flex !important;
	flex-direction: column !important;
	align-items: center !important;
	justify-content: center !important;
	margin: 0 !important;
	padding: 0 !important;
	border: none !important;
	border-radius: 0 !important;
	opacity: 1 !important;
	visibility: visible !important;
	pointer-events: auto !important;
}

/* Spinner inside the overlay - VERY STRONG SPECIFICITY */
body .hrw-gf-loading-overlay .hrw-spinner,
html body .hrw-gf-loading-overlay .hrw-spinner,
.hrw-gf-loading-overlay .hrw-spinner {
	width: 80px !important;
	height: 80px !important;
	border: 4px solid rgba(255, 255, 255, 0.3) !important;
	border-top: 4px solid #8bc540 !important;
	border-radius: 50% !important;
	animation: hrw-modern-spin 1.2s linear infinite !important;
	margin-bottom: 20px !important;
	display: block !important;
	opacity: 1 !important;
	visibility: visible !important;
}

/* Loading text inside the overlay - VERY STRONG SPECIFICITY */
body .hrw-gf-loading-overlay .hrw-loading-text,
html body .hrw-gf-loading-overlay .hrw-loading-text,
.hrw-gf-loading-overlay .hrw-loading-text {
	color: white !important;
	font-size: 18px !important;
	font-weight: 500 !important;
	text-align: center !important;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
	text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5) !important;
	animation: hrw-text-pulse 2s ease-in-out infinite !important;
	display: block !important;
	opacity: 1 !important;
	visibility: visible !important;
}

/* =============================================================================
   Shared Animations
   ============================================================================= */

/* Modern spin animation */
@keyframes hrw-modern-spin {
	0% {
		transform: rotate(0deg);
	}

	100% {
		transform: rotate(360deg);
	}
}

/* Text pulse animation */
@keyframes hrw-text-pulse {

	0%,
	100% {
		opacity: 0.8;
	}

	50% {
		opacity: 1;
	}
}

/* Spinner rotation animation */
@keyframes hrw-spin {
	0% {
		transform: translate(-50%, -50%) rotate(0deg);
	}

	100% {
		transform: translate(-50%, -50%) rotate(360deg);
	}
}


/* =============================================================================
   Mobile Responsiveness
   ============================================================================= */

@media (max-width: 768px) {

	/* Mobile navigation layout */
	.acf-multistep-nav {
		flex-direction: column;
		gap: 15px;
	}

	.acf-multistep-nav .acf-next,
	.acf-multistep-nav .acf-prev {
		width: 100%;
		justify-content: center;
	}

	/* Slightly smaller spinner on mobile for both ACF and Gravity Forms */
	.acf-form-submit .acf-spinner.is-active::before {
		width: 60px !important;
		height: 60px !important;
	}

	.acf-form-submit .acf-spinner.is-active::after {
		font-size: 16px !important;
		transform: translate(-50%, calc(-50% + 45px)) !important;
	}

	.hrw-gf-loading-overlay .hrw-spinner {
		width: 60px !important;
		height: 60px !important;
	}

	.hrw-gf-loading-overlay .hrw-loading-text {
		font-size: 16px !important;
	}
}

/* =============================================================================
   Accessibility & Browser Compatibility
   ============================================================================= */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {

	.acf-form-submit .acf-spinner.is-active::before,
	.hrw-gf-loading-overlay .hrw-spinner {
		animation: none !important;
	}

	.acf-form-submit .acf-spinner.is-active::after,
	.hrw-gf-loading-overlay .hrw-loading-text {
		animation: none !important;
	}
}

/* Fallback for older browsers without backdrop-filter */
@supports not (backdrop-filter: blur(2px)) {

	.acf-form-submit .acf-spinner.is-active,
	#gform_ajax_spinner_9:not([style*="display: none"]),
	.gform_wrapper img.gform_ajax_spinner:not([style*="display: none"]),
	.hrw-gf-loading-overlay {
		background: rgba(0, 0, 0, 0.9) !important;
	}
}

/* =============================================================================
 CSS for mukltistep form nav
   ============================================================================= */
.acf-multistep-indicator {
	display: flex;
	list-style: none;
	padding: 0;
	margin-bottom: 1.5em;
	counter-reset: step;

}

.acf-multistep-indicator li {
	flex: 1;
	text-align: center;
	position: relative;

}

.acf-multistep-indicator li::before {
	counter-increment: step;
	content: '';
	display: inline-block;
	width: 2em;
	height: 2em;
	line-height: 2em;
	border-radius: 50%;
	background: #e0e0e0;
	color: #666;
}

/* Style the new span to look like the old pseudo-element number */
.acf-multistep-indicator li .step-number-container {
	position: absolute;
	top: 0;
	left: 50%;
	transform: translateX(-50%);
	color: #666;
	width: 2em;
	height: 2em;
	line-height: 2em;
	text-align: center;
	z-index: 1;
}

.acf-multistep-indicator li.active .step-number-container,
.acf-multistep-indicator li.completed .step-number-container {
	color: #fff;
}

.acf-multistep-indicator li.active::before,
.acf-multistep-indicator li.completed::before {
	background: #0073aa;
	color: #fff;
}

.acf-multistep-indicator li::after {
	content: '';
	position: absolute;
	top: 1em;
	right: -50%;
	width: 100%;
	height: 4px;
	background: #e0e0e0;
	z-index: -1;
}

.acf-multistep-indicator li.completed::after {
	background: #0073aa;
}

.acf-multistep-indicator li:last-child::after {
	display: none;
}

.acf-multistep-indicator .step-label {
	display: block;
	margin-top: 0.5em;
	font-size: 0.9em;
	color: #333;
}



/* Nav buttons */
.acf-multistep-nav {
	display: flex;
	justify-content: space-between;
	margin-top: 1em;
}

.acf-multistep-nav .acf-prev {
	background: #f1f1f1;
	color: #333;
}

.acf-multistep-nav .acf-next {

	/* uses default .button-primary colors */

}

.hrw-add-step-form-section table.acf-table thead tr th {
	background-color: #44B3E2;
	color: #fff;
}

.select2-container--open .select2-dropdown {
	top: 32px;
}

.multistep-form-container {
	margin-top: 2em;
	max-width: 1200px;
	margin-left: auto;
	margin-right: auto;
}

.hrw_agreement_item a {
	color: #019ae9 !important;
}

/* =============================================================================
   CSS for courses nested repeater
   ============================================================================= */

/* Adjust dish title and description column widths in nested repeater */
.acf-th[data-name="add_title"] {
	width: 40% !important;
}

.acf-th[data-name="add_value"] {
	width: 60% !important;
}

.acf-field[data-name="add_title"] {
	width: 40% !important;
}

.acf-field[data-name="add_value"] {
	width: 60% !important;
}

/* Style the "Additional Choice" button to look more like a proper button */
.acf-button.acf-repeater-add-row {
	background: #0073aa !important;
	color: white !important;
	border: none !important;
	padding: 12px 20px !important;
	border-radius: 6px !important;
	font-size: 14px !important;
	font-weight: 500 !important;
	text-decoration: none !important;
	display: inline-block !important;
	cursor: pointer !important;
	transition: background-color 0.2s ease !important;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.acf-button.acf-repeater-add-row:hover {
	background: #005a87 !important;
	box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15) !important;
}

.acf-button.acf-repeater-add-row:active {
	background: #004a73 !important;
	transform: translateY(1px) !important;
}

/* Optional: Add some spacing around the button */
.acf-actions {
	text-align: center !important;
	padding: 15px 0 !important;
}

/* Hide the label for the course title field */
.acf-field[data-name="add_course_title"] .acf-label {
	display: none !important;
}

/* Mobile responsiveness - stack dish title and description */
@media (max-width: 768px) {

	/* Force the nested repeater table to stack */
	.acf-repeater.-table .acf-table,
	.acf-repeater.-table .acf-table thead,
	.acf-repeater.-table .acf-table tbody,
	.acf-repeater.-table .acf-table th,
	.acf-repeater.-table .acf-table td,
	.acf-repeater.-table .acf-table tr {
		display: block !important;
		width: 100% !important;
	}

	/* Hide table headers on mobile */
	.acf-repeater.-table .acf-table thead {
		display: none !important;
	}

	/* Style individual rows */
	.acf-repeater.-table .acf-table tr {
		border: 1px solid #ddd !important;
		margin-bottom: 15px !important;
		padding: 15px !important;
		border-radius: 6px !important;
		background: #f9f9f9 !important;
	}

	/* Style the fields */
	.acf-repeater.-table .acf-table td.acf-field {
		border: none !important;
		padding: 8px 0 !important;
		margin-bottom: 10px !important;
	}

	/* Add labels before fields on mobile */
	.acf-repeater.-table .acf-table td.acf-field[data-name="add_title"]:before {
		content: "Dish Title:";
		display: block;
		font-weight: bold;
		margin-bottom: 5px;
		color: #333;
	}

	.acf-repeater.-table .acf-table td.acf-field[data-name="add_value"]:before {
		content: "Dish Description:";
		display: block;
		font-weight: bold;
		margin-bottom: 5px;
		color: #333;
	}

	/* Reset widths on mobile */
	.acf-th[data-name="add_title"],
	.acf-th[data-name="add_value"],
	.acf-field[data-name="add_title"],
	.acf-field[data-name="add_value"] {
		width: 100% !important;
	}

	/* Style row handles on mobile */
	.acf-repeater.-table .acf-table .acf-row-handle {
		position: relative !important;
		text-align: right !important;
		margin-bottom: 10px !important;
	}
}