Options -Indexes
DirectoryIndex index.php

RewriteEngine On
RewriteBase /gmind/

# Block access to hidden/config files
RewriteRule ^\. - [F,L]
RewriteRule ^composer\.(json|lock) - [F,L]
RewriteRule ^README\.md - [F,L]

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

# ============================================================
# Performance: Browser Caching
# ============================================================
<IfModule mod_expires.c>
    ExpiresActive On
    
    # Images - cache for 1 month
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/webp "access plus 1 month"
    ExpiresByType image/svg+xml "access plus 1 month"
    ExpiresByType image/x-icon "access plus 1 month"
    
    # CSS & JS - cache for 1 week
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType application/javascript "access plus 1 week"
    ExpiresByType text/javascript "access plus 1 week"
    
    # Fonts - cache for 1 month
    ExpiresByType font/woff2 "access plus 1 month"
    ExpiresByType font/woff "access plus 1 month"
    ExpiresByType application/font-woff2 "access plus 1 month"
    ExpiresByType application/font-woff "access plus 1 month"
    
    # HTML - short cache
    ExpiresByType text/html "access plus 0 seconds"
</IfModule>

# ============================================================
# Security Headers
# ============================================================
<IfModule mod_headers.c>
    # Cache-Control for static assets
    <FilesMatch "\.(jpg|jpeg|png|gif|webp|ico|svg|css|js|woff2|woff)$">
        Header set Cache-Control "public, max-age=604800, immutable"
    </FilesMatch>
    
    # X-Content-Type-Options
    Header set X-Content-Type-Options "nosniff"
</IfModule>

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

# Route all other requests through index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?route=$1 [QSA,L]
