RewriteEngine On
RewriteBase /

# Remove .php extension for files in root
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^.]+)$ $1.php [L]

# Handle admin subfolder
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^admin/([^.]+)$ admin/$1.php [L]

# Handle client subfolder
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^client/([^.]+)$ client/$1.php [L]

# Redirect .php URLs to clean version
RewriteCond %{THE_REQUEST} \.php
RewriteRule ^(.*)\.php$ /$1 [R=301,L]

Options -Indexes

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