/**
 * XProfile Editor Styles
 * 
 * Provides visual feedback for field editing with save states,
 * validation errors, and accessible animations.
 * 
 * @package GW_BuddyPress_Elementor
 * @since 2.12.0
 */

/* Field Wrapper */
.gw-xprofile-field-wrapper {
	margin-bottom: 1.5rem;
	position: relative;
}

/* Label Styles */
.gw-xprofile-label {
	display: block;
	margin-bottom: 0.5rem;
	font-weight: 600;
	color: inherit;
}

.gw-required {
	color: #d63638;
	margin-left: 0.25rem;
}

/* Input Wrapper */
.gw-xprofile-input-wrapper {
	position: relative;
}

/* Common Input Styles */
.gw-xprofile-input,
.gw-xprofile-input:focus {
	width: 100%;
	padding: 0.75rem;
	border: 1px solid #ddd;
	border-radius: 4px;
	font-size: 1rem;
	line-height: 1.5;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.gw-xprofile-input:focus {
	outline: none;
	border-color: #2271b1;
	box-shadow: 0 0 0 1px #2271b1;
}

/* Textarea Specific */
textarea.gw-xprofile-input {
	resize: vertical;
	min-height: 120px;
}

/* Select Specific */
select.gw-xprofile-input {
	cursor: pointer;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0.75rem center;
	background-size: 12px;
	padding-right: 2.5rem;
}

select.gw-xprofile-input[multiple] {
	background-image: none;
	padding-right: 0.75rem;
	min-height: 120px;
}

/* Radio and Checkbox Groups */
.gw-xprofile-radio-group,
.gw-xprofile-checkbox-group {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.gw-xprofile-radio-label,
.gw-xprofile-checkbox-label {
	display: flex;
	align-items: center;
	cursor: pointer;
	user-select: none;
}

.gw-xprofile-radio-label input,
.gw-xprofile-checkbox-label input {
	width: auto;
	margin-right: 0.5rem;
	cursor: pointer;
}

.gw-xprofile-checkbox {
	flex-shrink: 0;
}

/* Feedback Container */
.gw-xprofile-feedback {
	margin-top: 0.5rem;
	font-size: 0.875rem;
	min-height: 1.5rem;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

/* Saving State */
.gw-xprofile-field-wrapper.is-saving .gw-xprofile-input {
	opacity: 0.6;
	pointer-events: none;
	border-color: #2271b1;
}

.gw-xprofile-feedback.saving {
	color: #2271b1;
}

.gw-xprofile-feedback.saving::before {
	content: '';
	display: inline-block;
	width: 1rem;
	height: 1rem;
	border: 2px solid #2271b1;
	border-radius: 50%;
	border-top-color: transparent;
	animation: gw-spinner 0.6s linear infinite;
}

@keyframes gw-spinner {
	to {
		transform: rotate(360deg);
	}
}

/* Success State */
.gw-xprofile-field-wrapper.is-success .gw-xprofile-input {
	border-color: #00a32a;
	animation: gw-success-pulse 0.6s ease;
}

.gw-xprofile-feedback.success {
	color: #00a32a;
	font-weight: 500;
}

.gw-xprofile-feedback.success::before {
	content: '✓';
	font-weight: bold;
	font-size: 1.2rem;
}

@keyframes gw-success-pulse {
	0% {
		border-color: #00a32a;
		box-shadow: 0 0 0 0 rgba(0, 163, 42, 0.4);
	}
	50% {
		box-shadow: 0 0 0 4px rgba(0, 163, 42, 0);
	}
	100% {
		border-color: #00a32a;
		box-shadow: 0 0 0 0 rgba(0, 163, 42, 0);
	}
}

/* Error State */
.gw-xprofile-field-wrapper.is-error .gw-xprofile-input {
	border-color: #d63638;
}

.gw-xprofile-feedback.error {
	color: #d63638;
	font-weight: 500;
}

.gw-xprofile-feedback.error::before {
	content: '⚠';
	font-weight: bold;
	font-size: 1.2rem;
}

/* Retry Button */
.gw-retry-button {
	margin-left: 0.5rem;
	padding: 0.25rem 0.75rem;
	background: #2271b1;
	color: white;
	border: none;
	border-radius: 3px;
	cursor: pointer;
	font-size: 0.875rem;
	transition: background 0.2s ease;
}

.gw-retry-button:hover {
	background: #135e96;
}

.gw-retry-button:active {
	transform: translateY(1px);
}

/* Warning Message */
.gw-xprofile-warning {
	margin-top: 0.5rem;
	padding: 0.5rem;
	background: #fff8e5;
	border-left: 3px solid #f0b429;
	font-size: 0.875rem;
	color: #646970;
}

/* Group Editor Specific Styles */
.gw-xprofile-group-editor {
	display: flex;
	flex-direction: column;
	gap: 1.5rem;
}

.gw-xprofile-group-heading {
	margin: 0 0 1rem 0;
	padding-bottom: 0.5rem;
	border-bottom: 2px solid #ddd;
}

/* Grid Layout for Group Editor */
.gw-xprofile-group-editor.layout-grid {
	display: grid;
	gap: 1.5rem;
}

.gw-xprofile-group-editor.layout-grid.columns-2 {
	grid-template-columns: repeat(2, 1fr);
}

.gw-xprofile-group-editor.layout-grid.columns-3 {
	grid-template-columns: repeat(3, 1fr);
}

/* Responsive Grid */
@media (max-width: 768px) {
	.gw-xprofile-group-editor.layout-grid {
		grid-template-columns: 1fr;
	}
}

/* Accessibility */
.gw-xprofile-input:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
	.gw-xprofile-input {
		border-width: 2px;
	}
	
	.gw-xprofile-field-wrapper.is-success .gw-xprofile-input {
		border-width: 3px;
	}
	
	.gw-xprofile-field-wrapper.is-error .gw-xprofile-input {
		border-width: 3px;
	}
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
	.gw-xprofile-input,
	.gw-retry-button {
		transition: none;
	}
	
	@keyframes gw-spinner {
		to {
			transform: rotate(360deg);
		}
	}
	
	@keyframes gw-success-pulse {
		0%, 100% {
			border-color: #00a32a;
		}
	}
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
	.gw-xprofile-input {
		background: #1e1e1e;
		color: #fff;
		border-color: #555;
	}
	
	.gw-xprofile-input:focus {
		border-color: #4a9eff;
		box-shadow: 0 0 0 1px #4a9eff;
	}
	
	.gw-xprofile-warning {
		background: #3d3100;
		border-left-color: #f0b429;
		color: #e0e0e0;
	}
}

/* Elementor Editor Preview Mode */
.elementor-editor-active .gw-xprofile-field-wrapper {
	opacity: 0.8;
	pointer-events: none;
}

.elementor-editor-active .gw-xprofile-input::after {
	content: 'Preview Only - Editing Disabled in Elementor Editor';
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background: rgba(0, 0, 0, 0.8);
	color: white;
	padding: 0.5rem 1rem;
	border-radius: 4px;
	font-size: 0.875rem;
	white-space: nowrap;
	z-index: 10;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.3s ease;
}

.elementor-editor-active .gw-xprofile-field-wrapper:hover .gw-xprofile-input::after {
	opacity: 1;
}

/* Multi-Value Field Display Badges */
.gw-xfield-value {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	align-items: flex-start;
	width: 100%;
}

.gwmultioption {
	display: inline-flex;
	align-items: center;
	font-size: 0.875rem;
	line-height: 1.4;
	transition: all 0.2s ease;
}

/* Badge Style */
.gwmultioption.xfg-badge {
	padding: 0.4rem 0.75rem;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: #ffffff;
	border-radius: 20px;
	font-weight: 500;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gwmultioption.xfg-badge:hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Alternative color schemes for badges */
.field-type-checkbox .gwmultioption.xfg-badge:nth-child(4n+1) {
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.field-type-checkbox .gwmultioption.xfg-badge:nth-child(4n+2) {
	background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.field-type-checkbox .gwmultioption.xfg-badge:nth-child(4n+3) {
	background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.field-type-checkbox .gwmultioption.xfg-badge:nth-child(4n+4) {
	background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

/* List Style */
.gwmultioption.xfg-list-item {
	padding: 0.5rem 0;
	border-bottom: 1px solid #e5e7eb;
	width: 100%;
}

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

/* Inline Style */
.gwmultioption.xfg-inline {
	padding-right: 0.5rem;
}

.gwmultioption.xfg-inline:not(:last-child)::after {
	content: ',';
	margin-left: 0.25rem;
}

/* Responsive Badge Sizing */
@media (max-width: 768px) {
	.gwmultioption.xfg-badge {
		padding: 0.35rem 0.6rem;
		font-size: 0.8125rem;
	}
	
	.gw-xfield-value {
		gap: 0.4rem;
	}
}

/* Accessibility: Focus States for Interactive Badges */
.gwmultioption.xfg-badge:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

/* Print Styles */
@media print {
	.gwmultioption.xfg-badge {
		background: #f3f4f6 !important;
		color: #1f2937 !important;
		border: 1px solid #d1d5db;
		box-shadow: none;
	}
}

/* Dark Mode Support for Badges */
@media (prefers-color-scheme: dark) {
	.gwmultioption.xfg-badge {
		box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
	}
	
	.gwmultioption.xfg-badge:hover {
		box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
	}
	
	.gwmultioption.xfg-list-item {
		border-bottom-color: #374151;
	}
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
	.gwmultioption.xfg-badge {
		border: 2px solid currentColor;
		font-weight: 600;
	}
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
	.gwmultioption.xfg-badge {
		transition: none;
	}
	
	.gwmultioption.xfg-badge:hover {
		transform: none;
	}
}

/* XField Widget Alignment Support */
.gw-xfield-widget.has-inline-label {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
}

.gw-xfield-widget.has-block-label .gw-xfield-label-wrapper {
	width: 100%;
}

/* Image Field Alignment */
.gw-xfield-image {
	display: inline-block;
	max-width: 100%;
}

.gw-xfield-image img {
	display: inline-block;
	max-width: 100%;
	height: auto;
}
