/* ============================================================
   FORM VALIDATION & LOADING STATES
   Reusable across all forms in the app
   ============================================================ */

/* ---------- Field Error States ---------- */

input.field-error,
select.field-error,
textarea.field-error {
    border-color: #d4574c !important;
    background-color: #fff9f8 !important;
    box-shadow: 0 0 0 3px rgba(212, 87, 76, 0.1) !important;
}

input.field-error:focus,
select.field-error:focus,
textarea.field-error:focus {
    outline: none;
    border-color: #d4574c !important;
    box-shadow: 0 0 0 3px rgba(212, 87, 76, 0.2) !important;
}

.field-error-message {
    display: none;
    color: #d4574c;
    font-size: 0.813rem;
    font-weight: 500;
    margin-top: 0.375rem;
    line-height: 1.4;
    animation: errorSlideIn 0.2s ease;
}

@keyframes errorSlideIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- Field Success State ---------- */

input.field-valid,
select.field-valid {
    border-color: #4caf50 !important;
}

/* ---------- Button Loading State ---------- */

.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem;
}

.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinnerRotate 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes spinnerRotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Button content alignment when spinner is present */
.btn-loading .btn-spinner + * {
    margin-left: 0.25rem;
}

/* Disabled button styles */
.btn:disabled,
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-loading:disabled {
    opacity: 0.8;
}

/* ---------- Success Messages ---------- */

.success-message {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: #4caf50;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
    background: rgba(76, 175, 80, 0.1);
    border-radius: var(--radius-sm);
    animation: successPop 0.3s ease;
}

.success-message.hidden {
    display: none;
}

@keyframes successPop {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.success-visible {
    display: inline-flex !important;
}

/* ---------- Form Helper Text ---------- */

.form-helper {
    display: block;
    font-size: 0.813rem;
    color: var(--slate);
    margin-top: 0.375rem;
    line-height: 1.4;
}

/* ---------- Inline Validation Icon (optional) ---------- */

.form-group {
    position: relative;
}

.field-valid-icon {
    position: absolute;
    right: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: #4caf50;
    font-size: 1rem;
    pointer-events: none;
}

/* ---------- Form Loading Overlay ---------- */

.form-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.form-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.5);
    z-index: 1;
}

/* ---------- Mobile Adjustments ---------- */

@media (max-width: 768px) {
    .field-error-message {
        font-size: 0.875rem;
    }
    
    .success-message {
        font-size: 0.938rem;
    }
}
