# 17 — Client Portal

## Context
Fogbreak replaces FUB, ShowingTime, Sisu, Paperless Pipeline, DocuSign, RealScout. Clients (buyers and sellers) need their own portal. This combines Sisu's Client Portal 2.0, ShowingTime's seller dashboard, RealScout's collaborative search, and DocuSign's signing interface into one branded experience.

## What to Build

### 1. Buyer Portal
Accessible via magic link (no login required) or account:
- **Property matches**: AI-recommended homes with reactions (love/like/dismiss)
- **Saved properties**: Bookmarked listings with notes
- **Showing schedule**: Upcoming and past showings
- **Transaction roadmap**: Visual progress from offer to close (if in deal)
- **Documents**: Required docs checklist, upload, view signed docs
- **eSign**: Sign documents directly in portal
- **Chat**: Message agent (AI responds when agent is unavailable)
- **Market feed**: New listings, price changes, sold comps in their search area

### 2. Seller Portal
- **Showing activity**: Real-time showing schedule and history
- **Feedback**: Buyer agent feedback from each showing
- **Activity charts**: Showings per week, price opinions, buyer interest levels
- **Market comparison**: Your listing activity vs. market average
- **Transaction roadmap**: Progress to closing
- **Documents**: View and sign listing agreements, disclosures
- **Marketing activity**: See social posts, virtual staging, video created for their listing
- **Countdown**: Days until close

### 3. Transaction Roadmap
Visual timeline showing:
- Milestones: listing/offer → inspection → appraisal → loan approval → closing
- Current position with progress indicator
- Completed items (green checkmarks)
- Upcoming items with dates
- Overdue items (red flags)
- Countdown to closing
- Next action required from client

### 4. Document Center
- Checklist: what's needed, what's received, what's missing
- Upload documents (drag-and-drop or camera on mobile)
- View signed documents
- Download copies
- Auto-reminders for missing documents
- Integration with eSign (instruction 08)

### 5. Vendor Ordering (from Sisu Client Portal 2.0)
Client can order services through the portal:
- Home inspection
- Appraisal
- Home warranty
- Moving services
- Recommended vendors per market (loaded from database)

### 6. Communication
- In-portal messaging with agent
- AI auto-responses when agent is offline
- Email notifications for portal updates
- SMS notifications for urgent items (document to sign, showing scheduled)

### 7. White-Label Branding
- Brokerage logo, colors, fonts from tenant config
- Custom domain (clients.yourbrokerage.com)
- Agent photo and contact info
- Brand-consistent email templates

### 8. Magic Link Access
- No password required
- Agent sends magic link via email/SMS
- Link valid for 30 days
- Token-based authentication
- Multiple active sessions allowed

## Endpoints
Extend `app/api/client.php`:
```
GET  /api/client.php?action=portal_data          # All portal data for client
GET  /api/client.php?action=matches              # Property matches
POST /api/client.php?action=react                # React to property
GET  /api/client.php?action=showings             # Showing schedule
GET  /api/client.php?action=transaction          # Transaction roadmap
GET  /api/client.php?action=documents            # Document checklist
POST /api/client.php?action=upload_document      # Upload document
POST /api/client.php?action=send_message         # Message agent
GET  /api/client.php?action=market_feed          # Market activity
GET  /api/client.php?action=marketing_activity   # Marketing for seller's listing
```

## Acceptance Criteria
- [ ] Buyer portal with property matches, reactions, saved homes
- [ ] Seller portal with showing activity, feedback, marketing
- [ ] Transaction roadmap with visual progress timeline
- [ ] Document center with checklist, upload, eSign
- [ ] Vendor ordering from recommended providers
- [ ] In-portal messaging with AI auto-response
- [ ] White-label branding from tenant config
- [ ] Magic link access (no password)
- [ ] Mobile-responsive portal
