/**
 * Advanced Form Validation Styles
 * 
 * Custom styles for form validation in the Pet Digital ID system.
 */

/* Form validation styles */
.needs-validation .form-control:focus,
.needs-validation .form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 0.25rem rgba(59, 130, 246, 0.25);
}

.needs-validation .is-valid {
    border-color: #059669 !important;
}

.needs-validation .is-valid:focus {
    border-color: #059669 !important;
    box-shadow: 0 0 0 0.25rem rgba(5, 150, 105, 0.25) !important;
}

.needs-validation .is-invalid {
    border-color: #dc2626 !important;
}

.needs-validation .is-invalid:focus {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 0.25rem rgba(220, 38, 38, 0.25) !important;
}

.needs-validation .invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #dc2626;
}

.needs-validation .was-validated .form-control:invalid,
.needs-validation .form-control.is-invalid {
    border-color: #dc2626;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc2626'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc2626' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.needs-validation .was-validated .form-control:valid,
.needs-validation .form-control.is-valid {
    border-color: #059669;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23059669' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.needs-validation .is-invalid ~ .invalid-feedback {
    display: block;
}

/* Password strength meter */
.password-strength-meter {
    height: 0.5rem;
    background-color: #e5e7eb;
    border-radius: 0.25rem;
    margin-top: 0.5rem;
    overflow: hidden;
}

.password-strength-meter-fill {
    height: 100%;
    border-radius: 0.25rem;
    transition: width 0.3s ease;
}

.password-strength-meter-fill.weak {
    width: 25%;
    background-color: #ef4444;
}

.password-strength-meter-fill.medium {
    width: 50%;
    background-color: #f59e0b;
}

.password-strength-meter-fill.strong {
    width: 75%;
    background-color: #3b82f6;
}

.password-strength-meter-fill.very-strong {
    width: 100%;
    background-color: #059669;
}

.password-strength-text {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.password-strength-text.weak {
    color: #ef4444;
}

.password-strength-text.medium {
    color: #f59e0b;
}

.password-strength-text.strong {
    color: #3b82f6;
}

.password-strength-text.very-strong {
    color: #059669;
}

/* Form field hints */
.form-hint {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* Floating labels */
.form-floating {
    position: relative;
}

.form-floating > .form-control,
.form-floating > .form-select {
    height: calc(3.5rem + 2px);
    padding: 1rem 0.75rem;
}

.form-floating > label {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    padding: 1rem 0.75rem;
    pointer-events: none;
    border: 1px solid transparent;
    transform-origin: 0 0;
    transition: opacity 0.1s ease-in-out, transform 0.1s ease-in-out;
}

.form-floating > .form-control:focus,
.form-floating > .form-control:not(:placeholder-shown),
.form-floating > .form-select:focus,
.form-floating > .form-select:not(:placeholder-shown) {
    padding-top: 1.625rem;
    padding-bottom: 0.625rem;
}

.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label,
.form-floating > .form-select:focus ~ label,
.form-floating > .form-select:not(:placeholder-shown) ~ label {
    opacity: 0.65;
    transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem);
}

/* Dark mode adjustments */
[data-theme="dark"] .needs-validation .invalid-feedback {
    color: #f87171;
}

[data-theme="dark"] .form-hint {
    color: #9ca3af;
}

[data-theme="dark"] .password-strength-meter {
    background-color: #374151;
}

/* Accessibility focus styles */
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(59, 130, 246, 0.25);
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .form-floating > label {
        transition: none;
    }
    
    .password-strength-meter-fill {
        transition: none;
    }
}

/* Form Validation Styles */
.form-field {
  position: relative;
  margin-bottom: 1rem;
}

.form-field.error input,
.form-field.error textarea,
.form-field.error select {
  border-color: #ef4444;
  box-shadow: 0 0 0 1px #ef4444;
}

.form-field.success input,
.form-field.success textarea,
.form-field.success select {
  border-color: #10b981;
  box-shadow: 0 0 0 1px #10b981;
}

.error-message {
  color: #ef4444;
  font-size: 0.875rem;
  margin-top: 0.25rem;
  display: block;
}

.input-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 1px #ef4444 !important;
}

.validation-icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #6b7280;
}

.validation-icon.error {
  color: #ef4444;
}

.validation-icon.success {
  color: #10b981;
}