# Error Pages Documentation

## Overview

Custom error pages have been created for all common HTTP error codes that can occur in the Invoice Generator application. These pages provide a consistent, user-friendly experience when errors occur, matching the application's design aesthetic.

## Error Pages Created

### 1. **401 - Unauthorized Access**
   - **File**: `resources/views/errors/401.blade.php`
   - **When it occurs**: When a user tries to access a resource that requires authentication but they are not logged in
   - **Features**: 
     - Redirect to login page
     - Go home option
     - Red warning icon

### 2. **403 - Access Forbidden**
   - **File**: `resources/views/errors/403.blade.php`
   - **When it occurs**: When a user tries to access a resource they don't have permission to access
   - **Features**:
     - Redirect to dashboard (if logged in) or login page
     - Go back button
     - Orange warning icon

### 3. **404 - Page Not Found**
   - **File**: `resources/views/errors/404.blade.php`
   - **When it occurs**: When a requested page or resource doesn't exist
   - **Features**:
     - Go to dashboard/home button
     - Go back button
     - Quick links to invoices and clients (if authenticated)
     - Blue info icon

### 4. **419 - Page Expired**
   - **File**: `resources/views/errors/419.blade.php`
   - **When it occurs**: When a CSRF token expires (form has been open too long)
   - **Features**:
     - Refresh page button
     - Login again option
     - Helpful tip about form expiration
     - Yellow warning icon

### 5. **429 - Too Many Requests**
   - **File**: `resources/views/errors/429.blade.php`
   - **When it occurs**: When rate limiting is triggered (too many requests in a short time)
   - **Features**:
     - Try again button
     - Countdown timer (30 seconds)
     - Go home option
     - Purple warning icon

### 6. **500 - Internal Server Error**
   - **File**: `resources/views/errors/500.blade.php`
   - **When it occurs**: When a server-side error occurs
   - **Features**:
     - Refresh page button
     - Go home option
     - Helpful troubleshooting tips
     - Red error icon

### 7. **503 - Service Unavailable**
   - **File**: `resources/views/errors/503.blade.php`
   - **When it occurs**: During maintenance or when service is temporarily unavailable
   - **Features**:
     - Check again button
     - Maintenance status indicator
     - Animated pulse indicator
     - Indigo settings icon

## Design Features

All error pages share the following design characteristics:

### Consistent Styling
- **Framework**: Tailwind CSS
- **Color Scheme**: Teal primary color (matches application theme)
- **Dark Mode**: Full dark mode support
- **Responsive**: Mobile-friendly design

### Visual Elements
- Application logo at the top
- Large error code (e.g., "404")
- Clear error title
- Descriptive error message
- Color-coded icons for each error type
- Action buttons for navigation

### User Experience
- Clear, friendly error messages
- Multiple navigation options (Go Home, Go Back, Refresh, etc.)
- Context-aware buttons (e.g., Dashboard for authenticated users)
- Helpful tips and troubleshooting information
- Smooth transitions and hover effects

## How Laravel Uses These Pages

Laravel automatically uses these error pages when corresponding HTTP errors occur:

1. **Automatic Detection**: Laravel looks for error views in `resources/views/errors/{status_code}.blade.php`
2. **No Configuration Needed**: The framework automatically uses these pages when errors are thrown
3. **Exception Handling**: These pages are rendered when exceptions with specific status codes are thrown

## Testing Error Pages

You can test these error pages by:

1. **404**: Navigate to a non-existent URL (e.g., `/non-existent-page`)
2. **403**: Try accessing a resource you don't own (e.g., another user's invoice)
3. **401**: Access a protected route while logged out
4. **419**: Submit a form after the CSRF token expires
5. **429**: Make too many requests quickly (requires rate limiting configuration)
6. **500**: Trigger a server error (development mode)
7. **503**: Enable maintenance mode: `php artisan down`

## Customization

To customize these error pages:

1. Edit the specific error page file in `resources/views/errors/`
2. Modify the colors, icons, or messages as needed
3. Add additional functionality (e.g., contact forms, error reporting)
4. Update the logo path if needed (currently uses `asset('logo.png')`)

## Notes

- All pages use the same layout structure for consistency
- Error pages are standalone (no layout inheritance) for reliability
- All pages include proper meta tags and favicon
- Pages work even if the main application has issues
- Icons use Heroicons SVG format for crisp rendering
- All navigation routes use Laravel's route helpers for reliability

