# ---------------------------------------------------------------
# Tent House Manager - Apache config
# ---------------------------------------------------------------
Options -Indexes
DirectoryIndex index.php

# Block access to SQL dumps, markdown, dotfiles, logs
<FilesMatch "(\.(sql|md|log|ini|bak)|^\..*)$">
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Deny from all
    </IfModule>
</FilesMatch>

# Correct MIME types for PWA files
<IfModule mod_mime.c>
    AddType application/manifest+json .webmanifest
    AddType application/json .json
    AddType image/svg+xml .svg
</IfModule>

# Service worker must never be stale
<Files "sw.js">
    <IfModule mod_headers.c>
        Header set Cache-Control "no-cache, no-store, must-revalidate"
    </IfModule>
</Files>

# Cache static assets (versioned with ?v=)
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 30 days"
    ExpiresByType application/javascript "access plus 30 days"
    ExpiresByType image/png "access plus 30 days"
    ExpiresByType image/jpeg "access plus 30 days"
    ExpiresByType image/svg+xml "access plus 30 days"
</IfModule>

# Gzip
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/css application/javascript application/json image/svg+xml
</IfModule>

# Force HTTPS on live hosting (uncomment after SSL is active - PWA install needs HTTPS)
# <IfModule mod_rewrite.c>
#     RewriteEngine On
#     RewriteCond %{HTTPS} off
#     RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# </IfModule>
