sequenceDiagram
    participant Staff as Staff Member
    participant App as KROW Staff App
    participant Client as Client
    participant Backend as Backend

    Staff->>App: Opens shift and taps "Clock In"

    activate App
    App->>App: **1. Geofencing Check (GPS) BEFORE scan**

    alt Proximity Validated
        App->>Client: Requests QR Code
        Client-->>Staff: Presents QR Code
        Staff->>App: Scans the code
        App->>Backend: Validates Clock In with eventId
        Backend-->>App: Confirmation
        App->>Staff: Displays "Clock In Successful"
    else Proximity Failed (GPS bug, too far)
        App->>Staff: Displays "Error: You are too far"
    end
    deactivate App

    loop Continuous Monitoring DURING the shift
        App->>App: **2. Checks GPS position (anti-fraud)**
        opt Staff member leaves the > 500m area
            App->>Backend: Notifies area exit
            Backend-->>App: Triggers a "Force Clock-Out"
        end
    end

    %% Clock Out process follows a similar logic (Geofencing + QR Code) %%