server {
    listen 80;
    server_name localhost;

    root /usr/share/nginx/html;
    index index.html;

    # Enable gzip compression
    gzip on;
    gzip_types text/css application/javascript application/json image/jpeg image/png application/wasm;
    gzip_min_length 1000;

    # Cache static assets
    location ~* \.(jpg|jpeg|png|gif|ico|css|js|wasm|json)$ {
        expires 1h;
        add_header Cache-Control "public, max-age=3600";
    }

    # Blazor framework files - longer cache
    location /_framework/ {
        expires 1y;
        add_header Cache-Control "public, max-age=31536000, immutable";
    }

    # MIME types for Blazor WebAssembly
    types {
        application/wasm wasm;
        application/octet-stream dll;
        application/json json;
    }

    # Main location - support client-side routing
    location / {
        try_files $uri $uri/ /index.html;
    }

    # Security headers
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-XSS-Protection "1; mode=block" always;
}
