<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /var/www/html

    <Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
        DirectoryIndex index.php index.html
    </Directory>

    # Enable URL rewriting
    RewriteEngine On

    # Static asset directories - serve files directly
    RewriteRule ^(assets|js)/.*$ - [L]

    # API routes
    RewriteRule ^api/(.*)$ api/index.php [QSA,L]

    # Admin routes
    RewriteRule ^admin/(.*)$ admin/index.php [QSA,L]

    # Frontend routes (SPA)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php [QSA,L]

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>