# ═══════════════════════════════════════════════════════════════
# PHASE 7: SPORTS & ACTIVITIES MODULE
# Module directory: /modules/sports/
# ═══════════════════════════════════════════════════════════════
# READ THE MASTER PROMPT FIRST.

## YOUR TABLES
sport_categories, sports, sport_seasons, sport_coaches, sport_coach_certifications,
sport_classes, sport_class_schedules, sport_class_enrollments, sport_class_attendance,
sport_class_waitlist, sport_teams, sport_team_members, sport_leagues, sport_league_teams,
sport_matches, sport_match_results, sport_tournaments, sport_tournament_registrations,
sport_equipment, sport_equipment_rentals, sport_memberships, sport_member_achievements,
sport_rules, sport_locker_rooms, sport_lockers, sport_locker_assignments

## PAGES TO BUILD

### 1. Sports Catalog (`GET /sports`)
- Grid/card view of all sports with icons and categories
- CRUD for sports and sport_categories

### 2. Seasons (`GET /sports/seasons`)
- CRUD for sport_seasons per sport
- Status management (upcoming → registration → active → completed)

### 3. Coaches (`GET /sports/coaches`)
- DataTable and CRUD for sport_coaches
- Certification management (sport_coach_certifications)
- Coach profile page with schedule, classes, certifications

### 4. Classes (`GET /sports/classes`)
- DataTable with vw_sport_class_summary
- Create/Edit class with schedules (sport_class_schedules)
- Enrollment management:
  - Enroll member/dependent
  - Waitlist when full
  - Withdraw
- Attendance tracking:
  - Date-based attendance sheet
  - Mark present/absent/late/excused
  - Attendance reports per class

### 5. Teams (`GET /sports/teams`)
- CRUD for sport_teams
- Team member management (add/remove players)
- Captain/vice-captain assignment
- Team roster view

### 6. Leagues (`GET /sports/leagues`)
- CRUD for sport_leagues
- Team registration
- Standings table (sport_league_teams)
- Match scheduling

### 7. Matches (`GET /sports/matches`)
- DataTable of all matches
- Create match (select teams, facility, date/time)
- Record results (scores)
- Match events (goals, cards, etc.) via sport_match_results

### 8. Tournaments (`GET /sports/tournaments`)
- CRUD for sport_tournaments
- Registration management
- Bracket generation (store in brackets_data JSON)
- Winner recording

### 9. Equipment (`GET /sports/equipment`)
- Inventory DataTable
- CRUD for sport_equipment
- Rental management:
  - Issue to member
  - Return processing
  - Damage/loss handling
  - Deposit tracking

### 10. Lockers (`GET /sports/lockers`)
- Locker rooms and lockers CRUD
- Assignment to members
- Availability view (visual grid)

### 11. Sport Memberships (`GET /sports/memberships`)
- Enroll members in specific sports
- Track per-sport membership levels

### 12. Achievements (`GET /sports/achievements`)
- Record and display member achievements per sport

## BUSINESS LOGIC
- Class enrollment validates age/gender/membership restrictions
- Full classes auto-set to 'full' status (DB trigger)
- Team member count tracked (DB trigger)
- Match results auto-update league standings (DB trigger)
- Equipment rental updates available quantity (DB trigger)

## DASHBOARD WIDGETS
1. **Active Classes** — Count with enrollment stats
2. **Upcoming Matches** — Next 5 matches
3. **Equipment Alerts** — Low stock or overdue rentals

## PERMISSIONS
sports.view, sports.manage, classes.view, classes.manage, classes.attendance,
teams.view, teams.manage, tournaments.view, tournaments.manage,
equipment.view, equipment.manage