# Service-Specific Scheduling System

## Overview
Enhanced salon appointment system where each service has its own availability schedule. Services can be available on different days and times, with customizable booking limits per time slot.

## ✅ What's New

### 🎯 **Service-Specific Availability**
- **Individual Schedules**: Each service can have its own unique schedule
- **Flexible Days**: Services can be available on any combination of days
- **Custom Time Ranges**: Different start/end times for each service per day
- **Booking Limits**: Configure how many people can book the same time slot

### 📅 **Day & Time Configuration**
- **Monday-Sunday**: Configure each day independently
- **Multiple Time Blocks**: Services can have multiple time blocks per day
- **30-Minute Intervals**: Automatic time slot generation
- **Conflict Prevention**: Smart booking conflict detection

### 👩‍💼 **Admin Management**
- **Schedule Manager**: Easy-to-use interface for setting service availability
- **Visual Schedule View**: See all service schedules at a glance
- **Quick Setup**: Default schedule templates for common patterns
- **Bulk Configuration**: Set schedules for multiple services efficiently

## 🏗️ **System Architecture**

### New Database Table: `salon_service_schedules`
```sql
- id (primary key)
- service_id (foreign key to salon_services)
- day_of_week (monday-sunday)
- start_time (time)
- end_time (time)
- max_appointments_per_slot (integer)
- is_available (boolean)
- notes (text, optional)
```

### Enhanced Models
- **SalonServiceSchedule**: Manages individual service schedules
- **SalonService**: Extended with schedule relationships and availability methods

## 🎮 **How It Works**

### 1. **Admin Setup Process**
1. **Create Service**: Admin creates a new salon service
2. **Configure Schedule**: Set up when the service is available
3. **Set Capacity**: Choose how many bookings per time slot
4. **Activate**: Service becomes bookable by customers

### 2. **Customer Booking Process**
1. **Select Service**: Choose from available services
2. **View Available Days**: Only days with service schedules are shown
3. **Pick Date**: Select a date when the service is available
4. **Choose Time**: See available time slots based on service schedule
5. **Book Appointment**: Instant confirmation with conflict checking

### 3. **Smart Availability Logic**
- **Service Check**: Is the service available on this day?
- **Time Validation**: Is the requested time within service hours?
- **Capacity Check**: Is there space in this time slot?
- **Duration Check**: Does the service fit before the next booking?

## 🛠️ **Admin Interface Features**

### Service Schedule Management (`/admin/services/{service}/schedule`)
- **Day Toggles**: Enable/disable each day of the week
- **Time Pickers**: Set start and end times for each day
- **Capacity Settings**: Configure maximum bookings per slot (1-5 people)
- **Quick Templates**: Apply common schedule patterns
- **Visual Preview**: See the schedule summary

### Services Overview (`/admin/services`)
- **Schedule Status**: See which services have schedules configured
- **Quick Actions**: Direct links to schedule management
- **Visual Indicators**: Color-coded status for easy management
- **Statistics**: Track services with/without schedules

## 📋 **Example Service Schedules**

### Hair Services
- **Tuesday-Friday**: 9:00 AM - 5:00 PM
- **Saturday**: 10:00 AM - 4:00 PM
- **Capacity**: 1 person per slot
- **Sunday-Monday**: Closed

### Nail Services
- **Monday-Friday**: 9:00 AM - 5:00 PM
- **Saturday**: 10:00 AM - 4:00 PM
- **Capacity**: 2 people per slot (multiple stations)
- **Sunday**: Closed

### Massage Therapy
- **Monday, Tuesday, Thursday**: 11:00 AM - 5:00 PM
- **Saturday**: 11:00 AM - 3:00 PM
- **Capacity**: 1 person per slot
- **Wednesday, Friday, Sunday**: Closed

### Facial Treatments
- **Monday, Wednesday, Friday**: 10:00 AM - 4:00 PM
- **Capacity**: 1 person per slot
- **Other days**: Closed

## 🔧 **Technical Implementation**

### Calendar Controller Updates
- **Service-Specific Queries**: Get availability based on selected service
- **Dynamic Time Slots**: Generate slots based on service schedule
- **Capacity Checking**: Validate against max appointments per slot
- **Error Messages**: Helpful feedback when services aren't available

### Frontend Enhancements
- **Service Selection**: Shows only services with schedules
- **Dynamic Updates**: Time slots update when service changes
- **Visual Feedback**: Clear messages about availability
- **Improved UX**: Better guidance through booking process

## 🚀 **Benefits**

### For Salon Owners
- **Flexible Scheduling**: Different services available at optimal times
- **Resource Management**: Better staff and equipment allocation
- **Capacity Control**: Prevent overbooking popular services
- **Professional Image**: Organized, systematic approach

### For Customers
- **Clear Availability**: Know exactly when services are offered
- **Realistic Expectations**: No disappointment from unavailable services
- **Better Planning**: Can see service patterns for future bookings
- **Faster Booking**: Only see relevant time slots

### For Staff
- **Organized Workload**: Services scheduled at appropriate times
- **Predictable Schedule**: Know when specific services are offered
- **Better Preparation**: Can prepare for service-specific busy periods
- **Reduced Conflicts**: Less scheduling confusion

## 📈 **Usage Scenarios**

### Scenario 1: Hair Salon
- **Hair Cuts**: Available Tuesday-Saturday
- **Color Treatments**: Wednesday-Friday only (when colorist is available)
- **Styling**: Tuesday-Saturday
- **Treatments**: Monday, Wednesday, Friday

### Scenario 2: Full Service Spa
- **Massages**: Monday-Thursday, Saturday
- **Facials**: Monday, Wednesday, Friday
- **Body Treatments**: Tuesday, Thursday, Saturday
- **Nail Services**: Monday-Saturday (multiple slots available)

### Scenario 3: Beauty Salon
- **Makeup**: Tuesday-Saturday (wedding bookings)
- **Eyebrow Services**: Monday-Friday
- **Eyelash Extensions**: Wednesday-Saturday
- **Skin Consultations**: By appointment only, specific days

## 🎛️ **Configuration Options**

### Per Service Settings
- **Available Days**: Choose any combination of days
- **Time Ranges**: Set start and end times for each day
- **Capacity Limits**: 1-5 people per time slot
- **Special Notes**: Add notes for specific scheduling information

### Global Settings
- **Time Slot Intervals**: 30-minute intervals (configurable)
- **Advance Booking**: How far ahead customers can book
- **Cancellation Policy**: Service-specific cancellation rules
- **Notification Settings**: Reminders and confirmations

## 🔄 **Migration from Global Schedule**

If upgrading from a global salon schedule:

1. **Backup Data**: Export existing appointments
2. **Run Migrations**: Add new service schedule tables
3. **Configure Services**: Set up individual service schedules
4. **Test Booking**: Verify the booking process works
5. **Train Staff**: Familiarize team with new system

## 💡 **Best Practices**

### Schedule Planning
- **Staff Availability**: Align service schedules with staff schedules
- **Equipment Needs**: Consider equipment availability for services
- **Peak Times**: Schedule popular services during busy periods
- **Recovery Time**: Allow time between intensive services

### Customer Communication
- **Clear Descriptions**: Explain when services are available
- **Advance Notice**: Inform customers of schedule changes
- **Alternatives**: Suggest similar services if first choice unavailable
- **Seasonal Adjustments**: Update schedules for holidays/seasons

## 🔮 **Future Enhancements**

### Planned Features
- **Staff Assignment**: Link schedules to specific staff members
- **Seasonal Schedules**: Different schedules for different seasons
- **Holiday Management**: Special scheduling for holidays
- **Group Bookings**: Support for multiple people booking together
- **Recurring Appointments**: Regular appointment scheduling
- **Waitlist System**: Queue for fully booked time slots

This service-specific scheduling system provides the flexibility and control needed to run a professional salon operation while maintaining an excellent customer booking experience.
