# ==============================================================================
# cPanel / Apache Configuration for THE CUT Barbershop SPA
# ==============================================================================

# Enable Rewrite Engine
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  # Serve existing files and directories directly
  RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule ^ - [L]

  # Fallback all other SPA routes to index.html
  RewriteRule ^ index.html [L]
</IfModule>

# ==============================================================================
# MIME Types for Modern Web Formats
# ==============================================================================
<IfModule mod_mime.c>
  AddType image/webp .webp
  AddType video/mp4 .mp4
  AddType application/javascript .js
  AddType text/css .css
</IfModule>

# ==============================================================================
# GZIP / Deflate Compression
# ==============================================================================
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript application/json image/svg+xml
</IfModule>

# ==============================================================================
# Browser Caching Headers
# ==============================================================================
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 1 month"

  # Images and Video
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType video/mp4 "access plus 1 year"

  # CSS and JavaScript
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"
</IfModule>

# ==============================================================================
# Security Headers
# ==============================================================================
<IfModule mod_headers.c>
  Header set X-Content-Type-Options "nosniff"
  Header set X-Frame-Options "SAMEORIGIN"
  Header set X-XSS-Protection "1; mode=block"
</IfModule>
