# 12 — Virtual Staging

## Context
Fogbreak adds AI virtual staging — a capability none of the 6 replaced platforms (FUB, ShowingTime, Sisu, Paperless Pipeline, DocuSign, RealScout) offer. Transform empty rooms into furnished, styled spaces.

## What to Build

### 1. Staging API Integration
Create `app/api/staging.php`:

Primary provider: **Collov AI** ($0.23-$0.27/image)
Premium tier: **RoomX AI** ($199/mo unlimited)

```
POST /api/staging.php?action=stage              # Submit image for staging
GET  /api/staging.php?action=status&job_id=X    # Check processing status
GET  /api/staging.php?action=result&job_id=X    # Get staged image
GET  /api/staging.php?action=history&prop=X     # All staging jobs for property
POST /api/staging.php?action=restyle             # Re-stage with different style
GET  /api/staging.php?action=credits             # Check remaining credits
```

### 2. Room Type & Style Selection
- Room types: living room, bedroom, kitchen, bathroom, dining room, office, outdoor
- Styles: modern, contemporary, farmhouse, coastal, mid-century, traditional, minimalist, luxury, Scandinavian
- Market-appropriate defaults (coastal for beach towns, farmhouse for rural)

### 3. Before/After Gallery
- Side-by-side comparison (slider or toggle)
- Full-screen view
- Download staged images for MLS upload
- Share via link (branded)
- Include in listing presentation

### 4. Staging Credits System
For multi-tenant billing:
```sql
CREATE TABLE staging_credits (
    id SERIAL PRIMARY KEY,
    tenant_id INT NOT NULL,
    credits_remaining INT DEFAULT 0,
    credits_used INT DEFAULT 0,
    plan_type VARCHAR(20) DEFAULT 'pay_per_use',
    monthly_limit INT,
    reset_date DATE,
    created_at TIMESTAMPTZ DEFAULT NOW()
);
```

### 5. Batch Staging
- Upload all photos for a listing at once
- AI auto-detects room type
- Apply consistent style across all rooms
- Progress tracking per image

### 6. Integration Points
- Auto-attach staged images to listing in `properties` table
- Include staged images in property alerts (instruction 09)
- Use staged images in social posts (instruction 11)
- Include in virtual tours/video generation (instruction 13)

## Acceptance Criteria
- [ ] Collov AI integration for staging ($0.23/image)
- [ ] Room type and style selection
- [ ] Before/after gallery with slider
- [ ] Staging credits system for billing
- [ ] Batch staging with auto room detection
- [ ] Staged images flow into listings, alerts, social, video
