/**
 * Airy Frontend Forms - Frontend Styles
 * 
 * @package Airy_Frontend_Forms
 */

/* ==========================================================================
   Form Wrapper & Container
   ========================================================================== */

.affcf-form-wrapper {
	max-width: 800px;
	margin: 2rem auto;
	padding: 2rem;
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 8px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.affcf-form {
	display: block;
}

/* ==========================================================================
   Field Wrappers
   ========================================================================== */

.affcf-field-wrapper {
	margin-bottom: 1.5rem;
}

.affcf-field-wrapper:last-child {
	margin-bottom: 0;
}

/* ==========================================================================
   Labels
   ========================================================================== */

.affcf-field-label {
	display: block;
	margin-bottom: 0.5rem;
	font-weight: 600;
	color: #333;
	font-size: 14px;
}

.affcf-required {
	color: #dc3545;
	font-weight: bold;
}

/* ==========================================================================
   Input Fields
   ========================================================================== */

.affcf-input {
	width: 100%;
	padding: 0.75rem;
	border: 1px solid #ddd;
	border-radius: 4px;
	font-size: 14px;
	line-height: 1.5;
	color: #333;
	background-color: #fff;
	transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.affcf-input:focus {
	outline: 0;
	border-color: #0073aa;
	box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.affcf-input:disabled,
.affcf-input[readonly] {
	background-color: #f5f5f5;
	cursor: not-allowed;
}

.affcf-input::placeholder {
	color: #999;
	opacity: 1;
}

/* Textarea specific */
.affcf-input-textarea {
	resize: vertical;
	min-height: 100px;
}

.affcf-input-content {
	min-height: 200px;
}

/* Number inputs */
.affcf-input-number {
	max-width: 200px;
}

/* ==========================================================================
   Select Dropdowns
   ========================================================================== */

.affcf-input-select {
	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;
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
}

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

/* ==========================================================================
   Checkbox & Radio Groups
   ========================================================================== */

.affcf-checkbox-group,
.affcf-radio-group {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.affcf-checkbox-label,
.affcf-radio-label {
	display: flex;
	align-items: center;
	cursor: pointer;
	font-weight: normal;
	margin-bottom: 0;
}

.affcf-checkbox-label input[type="checkbox"],
.affcf-radio-label input[type="radio"] {
	width: auto;
	margin-right: 0.5rem;
	cursor: pointer;
}

.affcf-true-false {
	font-weight: 600;
}

/* ==========================================================================
   File Upload
   ========================================================================== */

.affcf-image-upload-wrapper {
	position: relative;
}

.affcf-file-input {
	width: 100%;
	padding: 0.5rem;
	border: 2px dashed #ddd;
	border-radius: 4px;
	cursor: pointer;
}

.affcf-file-input:hover {
	border-color: #0073aa;
	background-color: #f8f9fa;
}

.affcf-image-preview {
	margin-top: 1rem;
	position: relative;
	display: inline-block;
}

.affcf-image-preview img {
	max-width: 300px;
	height: auto;
	border: 1px solid #ddd;
	border-radius: 4px;
}

.affcf-remove-image {
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;
	padding: 0.25rem 0.75rem;
	background: #dc3545;
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	font-size: 12px;
	font-weight: 600;
}

.affcf-remove-image:hover {
	background: #c82333;
}

/* ==========================================================================
   Help Text
   ========================================================================== */

.affcf-help-text {
	margin: 0.5rem 0 0;
	font-size: 13px;
	color: #666;
	font-style: italic;
}

/* ==========================================================================
   Submit Button
   ========================================================================== */

.affcf-submit-wrapper {
	margin-top: 2rem;
	padding-top: 1.5rem;
	border-top: 1px solid #eee;
}

.affcf-submit-button {
	display: inline-block;
	padding: 0.75rem 2rem;
	font-size: 16px;
	font-weight: 600;
	color: #fff;
	background-color: #0073aa;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	transition: background-color 0.15s ease-in-out;
}

.affcf-submit-button:hover {
	background-color: #005a87;
}

.affcf-submit-button:active {
	background-color: #004768;
}

.affcf-submit-button:disabled {
	background-color: #ccc;
	cursor: not-allowed;
}

.affcf-submit-button.affcf-submitting {
	position: relative;
	color: transparent;
}

.affcf-submit-button.affcf-submitting::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 20px;
	height: 20px;
	margin: -10px 0 0 -10px;
	border: 2px solid #fff;
	border-top-color: transparent;
	border-radius: 50%;
	animation: affcf-spin 0.6s linear infinite;
}

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

/* ==========================================================================
   Messages & Notices
   ========================================================================== */

.affcf-message,
.affcf-error,
.affcf-notice {
	padding: 1rem 1.5rem;
	margin-bottom: 1.5rem;
	border-radius: 4px;
	font-size: 14px;
}

.affcf-message {
	background-color: #d4edda;
	border: 1px solid #c3e6cb;
	color: #155724;
}

.affcf-error {
	background-color: #f8d7da;
	border: 1px solid #f5c6cb;
	color: #721c24;
}

.affcf-notice {
	background-color: #d1ecf1;
	border: 1px solid #bee5eb;
	color: #0c5460;
}

.affcf-notice-warning {
	background-color: #fff3cd;
	border: 1px solid #ffeeba;
	color: #856404;
}

.affcf-notice p {
	margin: 0 0 0.5rem 0;
}

.affcf-notice p:last-child {
	margin-bottom: 0;
}

.affcf-notice a {
	color: inherit;
	text-decoration: underline;
	font-weight: 600;
}

.affcf-notice a:hover {
	text-decoration: none;
}

.affcf-notice .dashicons {
	font-size: 14px;
	width: 14px;
	height: 14px;
	vertical-align: text-bottom;
}

/* ==========================================================================
   Validation States
   ========================================================================== */

.affcf-field-wrapper.affcf-has-error .affcf-input {
	border-color: #dc3545;
}

.affcf-field-wrapper.affcf-has-error .affcf-input:focus {
	border-color: #dc3545;
	box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.affcf-field-error {
	display: block;
	margin-top: 0.5rem;
	font-size: 13px;
	color: #dc3545;
}

.affcf-field-wrapper.affcf-has-success .affcf-input {
	border-color: #28a745;
}

/* ==========================================================================
   WordPress Editor Integration
   ========================================================================== */

.affcf-field-wrapper .wp-editor-wrap {
	margin-top: 0.5rem;
}

.affcf-field-wrapper .wp-editor-container {
	border: 1px solid #ddd;
	border-radius: 4px;
}

/* ==========================================================================
   Taxonomy Fields
   ========================================================================== */

.affcf-taxonomy-field .affcf-checkbox-group,
.affcf-taxonomy-field .affcf-radio-group {
	max-height: 300px;
	overflow-y: auto;
	padding: 0.75rem;
	border: 1px solid #ddd;
	border-radius: 4px;
	background: #f9f9f9;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
	.affcf-form-wrapper {
		padding: 1rem;
		margin: 1rem;
	}
	
	.affcf-submit-button {
		width: 100%;
	}
	
	.affcf-image-preview img {
		max-width: 100%;
	}
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.affcf-loading {
	position: relative;
	pointer-events: none;
	opacity: 0.6;
}

.affcf-loading::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 40px;
	height: 40px;
	margin: -20px 0 0 -20px;
	border: 4px solid #0073aa;
	border-top-color: transparent;
	border-radius: 50%;
	animation: affcf-spin 0.8s linear infinite;
}

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

.affcf-input:focus-visible,
.affcf-submit-button:focus-visible {
	outline: 2px solid #0073aa;
	outline-offset: 2px;
}

.screen-reader-text {
	clip: rect(1px, 1px, 1px, 1px);
	position: absolute !important;
	height: 1px;
	width: 1px;
	overflow: hidden;
}

/* ==========================================================================
   Advanced Field Types - Week 8
   ========================================================================== */

/* WYSIWYG Editor */
.affcf-field-wrapper .mce-tinymce {
	border-color: #ddd !important;
	border-radius: 4px;
}

/* File Upload */
.affcf-file-upload-wrapper {
	position: relative;
}

.affcf-file-preview {
	margin-top: 1rem;
	padding: 0.75rem;
	background: #f8f9fa;
	border: 1px solid #ddd;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.affcf-file-name {
	font-size: 14px;
	color: #333;
	word-break: break-all;
}

.affcf-remove-file {
	padding: 0.25rem 0.75rem;
	background: #dc3545;
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	font-size: 12px;
	font-weight: 600;
	margin-left: 1rem;
	flex-shrink: 0;
}

.affcf-remove-file:hover {
	background: #c82333;
}

/* Gallery Field */
.affcf-gallery-wrapper {
	position: relative;
}

/* Gallery Add Button */
.affcf-gallery-add-button-wrapper {
	margin-bottom: 1rem;
}

.affcf-gallery-add-button {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.75rem 1.5rem;
	background: #0073aa;
	color: #fff;
	border: none;
	border-radius: 4px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.2s ease;
	text-decoration: none;
}

.affcf-gallery-add-button:hover {
	background: #005a87;
	color: #fff;
}

.affcf-gallery-add-button .dashicon {
	font-size: 18px;
	line-height: 1;
}

/* Hidden file input */
.affcf-gallery-input-hidden {
	display: none !important;
}

/* Gallery Counter */
.affcf-gallery-count {
	margin-top: 0.5rem;
	margin-bottom: 0.5rem;
	font-size: 13px;
	color: #666;
}

.affcf-gallery-current-count {
	font-weight: 600;
	color: #0073aa;
}

.affcf-gallery-preview {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 1rem;
	margin-top: 1rem;
	padding: 1rem;
	background: #f8f9fa;
	border: 1px solid #ddd;
	border-radius: 4px;
	min-height: 150px;
}

.affcf-gallery-item {
	position: relative;
	aspect-ratio: 1;
	border: 2px solid #ddd;
	border-radius: 4px;
	overflow: hidden;
	background: #fff;
}

.affcf-gallery-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.affcf-remove-gallery-item {
	position: absolute;
	top: 0.25rem;
	right: 0.25rem;
	width: 24px;
	height: 24px;
	background: #dc3545;
	color: #fff;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	font-size: 16px;
	font-weight: bold;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
}

.affcf-remove-gallery-item:hover {
	background: #c82333;
}

/* Date/Time Pickers */
.affcf-input-date_picker,
.affcf-input-date_time_picker,
.affcf-input-time_picker {
	max-width: 250px;
}

/* Color Picker */
.affcf-input-color {
	max-width: 100px;
	height: 50px;
	padding: 0.25rem;
	cursor: pointer;
}

/* Repeater Field */
.affcf-repeater-wrapper {
	border: 1px solid #ddd;
	border-radius: 4px;
	padding: 1rem;
	background: #f8f9fa;
}

.affcf-repeater-rows {
	margin-bottom: 1rem;
}

.affcf-repeater-row {
	margin-bottom: 1rem;
	padding: 1rem;
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 4px;
}

.affcf-repeater-row:last-child {
	margin-bottom: 0;
}

.affcf-repeater-row-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding-bottom: 0.75rem;
	margin-bottom: 0.75rem;
	border-bottom: 1px solid #eee;
}

.affcf-row-number {
	font-weight: 600;
	color: #333;
	font-size: 14px;
}

.affcf-remove-repeater-row {
	padding: 0.25rem 0.5rem;
	background: transparent;
	color: #dc3545;
	border: 1px solid #dc3545;
	border-radius: 4px;
	cursor: pointer;
	font-size: 12px;
	display: flex;
	align-items: center;
	gap: 0.25rem;
}

.affcf-remove-repeater-row:hover {
	background: #dc3545;
	color: #fff;
}

.affcf-remove-repeater-row .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
}

.affcf-repeater-fields {
	display: grid;
	gap: 1rem;
}

.affcf-add-repeater-row {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.5rem 1rem;
	background: #0073aa;
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 600;
}

.affcf-add-repeater-row:hover {
	background: #005a87;
}

.affcf-add-repeater-row .dashicons {
	font-size: 18px;
	width: 18px;
	height: 18px;
}

.affcf-add-repeater-row:disabled {
	background: #ccc;
	cursor: not-allowed;
}

/* Group Field */
.affcf-group-wrapper {
	border: 1px solid #ddd;
	border-radius: 4px;
	padding: 1rem;
	background: #f8f9fa;
}

.affcf-group-fields {
	display: grid;
	gap: 1rem;
}

.affcf-group-fields .affcf-field-wrapper {
	margin-bottom: 0;
}

/* Sub-fields styling */
.affcf-sub-field {
	background: #fff;
	padding: 0.75rem;
	border-radius: 4px;
}

.affcf-sub-field .affcf-field-label {
	font-size: 13px;
	margin-bottom: 0.375rem;
}

.affcf-sub-field .affcf-input {
	font-size: 13px;
	padding: 0.5rem;
}

/* Repeater template (hidden) */
.affcf-repeater-template {
	display: none !important;
}

/* ==========================================================================
   Advanced Field Responsive
   ========================================================================== */

@media (max-width: 768px) {
	.affcf-gallery-preview {
		grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
		gap: 0.5rem;
		padding: 0.5rem;
	}
	
	.affcf-repeater-row-header {
		flex-direction: column;
		align-items: flex-start;
		gap: 0.5rem;
	}
	
	.affcf-file-preview {
		flex-direction: column;
		align-items: flex-start;
		gap: 0.5rem;
	}
	
	.affcf-remove-file {
		margin-left: 0;
		width: 100%;
	}
}


/* ===================================
   Success/Error Messages
   =================================== */

.affcf-message {
	padding: 15px 20px;
	margin-bottom: 20px;
	border-radius: 4px;
	border-left: 4px solid;
	font-size: 14px;
	line-height: 1.5;
}

.affcf-message p {
	margin: 0;
}

.affcf-message-success {
	background-color: #d4edda;
	border-color: #28a745;
	color: #155724;
}

.affcf-message-error {
	background-color: #f8d7da;
	border-color: #dc3545;
	color: #721c24;
}

.affcf-message-warning {
	background-color: #fff3cd;
	border-color: #ffc107;
	color: #856404;
}

.affcf-message-info {
	background-color: #d1ecf1;
	border-color: #17a2b8;
	color: #0c5460;
}

/* Auto-Save Indicator */
.affcf-draft-indicator {
	background-color: #f9f9f9;
	border: 1px solid #ddd;
	border-radius: 4px;
	padding: 10px 15px;
	margin-bottom: 20px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.affcf-draft-status {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 14px;
	color: #666;
}

.affcf-draft-icon {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background-color: #ccc;
	display: inline-block;
}

.affcf-draft-saving .affcf-draft-icon {
	background-color: #f0ad4e;
	animation: pulse 1s infinite;
}

.affcf-draft-saved .affcf-draft-icon {
	background-color: #5cb85c;
}

.affcf-draft-error .affcf-draft-icon {
	background-color: #d9534f;
}

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

.affcf-save-draft {
	background: none;
	border: none;
	color: #0073aa;
	text-decoration: underline;
	cursor: pointer;
	font-size: 14px;
}

.affcf-save-draft:hover {
	color: #005a87;
}
