/**
 * Form Validation Styles
 * Styles for client-side form validation feedback
 */

/* Error state for form fields */
input.error,
textarea.error,
select.error {
  border-color: #ef4444 !important;
  background-color: rgba(239, 68, 68, 0.05) !important;
}

[data-theme="light"] input.error,
[data-theme="light"] textarea.error,
[data-theme="light"] select.error {
  border-color: #dc2626 !important;
  background-color: rgba(220, 38, 38, 0.05) !important;
}

/* Validation error message */
.validation-error {
  color: #ef4444;
  font-size: 13px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  animation: slideDown 0.2s ease-out;
}

[data-theme="light"] .validation-error {
  color: #dc2626;
}

.validation-error::before {
  content: "⚠";
  font-size: 14px;
}

/* Form-level error message */
.form-error-message {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  font-size: 14px;
  animation: slideDown 0.3s ease-out;
}

[data-theme="light"] .form-error-message {
  background: rgba(220, 38, 38, 0.1);
  border-color: rgba(220, 38, 38, 0.3);
  color: #dc2626;
}

/* Success state (optional) */
input.success,
textarea.success,
select.success {
  border-color: #22c55e !important;
  background-color: rgba(34, 197, 94, 0.05) !important;
}

[data-theme="light"] input.success,
[data-theme="light"] textarea.success,
[data-theme="light"] select.success {
  border-color: #16a34a !important;
  background-color: rgba(22, 163, 74, 0.05) !important;
}

/* Animation */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Focus state for error fields */
input.error:focus,
textarea.error:focus,
select.error:focus {
  outline: 2px solid #ef4444;
  outline-offset: 2px;
}

[data-theme="light"] input.error:focus,
[data-theme="light"] textarea.error:focus,
[data-theme="light"] select.error:focus {
  outline-color: #dc2626;
}

/* Loading state for submit buttons */
button[type="submit"].loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

button[type="submit"].loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Disabled state */
input:disabled,
textarea:disabled,
select:disabled,
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Required field indicator */
label.required::after {
  content: " *";
  color: #ef4444;
}

[data-theme="light"] label.required::after {
  color: #dc2626;
}

/* Help text */
.help-text {
  font-size: 13px;
  color: #999;
  margin-top: 4px;
}

[data-theme="light"] .help-text {
  color: #666;
}

/* Character counter */
.char-counter {
  font-size: 12px;
  color: #999;
  text-align: right;
  margin-top: 4px;
}

[data-theme="light"] .char-counter {
  color: #666;
}

.char-counter.warning {
  color: #f59e0b;
}

.char-counter.error {
  color: #ef4444;
}

/* Accessibility improvements */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid #fbcb0c;
  outline-offset: 2px;
}

/* Skip to main content link - Accessibility feature for keyboard navigation */
.skip-to-main {
  position: absolute;
  top: -9999px;
  left: 0;
  background: #fbcb0c;
  color: #0a0a0a;
  padding: 8px 16px;
  text-decoration: none;
  font-weight: 600;
  z-index: 10000;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.skip-to-main:focus {
  top: 0;
  width: auto;
  height: auto;
  overflow: visible;
  clip-path: none;
}
