Options -Indexes
RewriteEngine On

# ── Serve static files (uploads, assets) langsung
RewriteRule ^uploads/(.*)$ uploads/$1 [L]
RewriteRule ^assets/(.*)$  assets/$1  [L]

# ── AUTH
RewriteRule ^api/login$                  api/auth.php   [QSA,L]
RewriteRule ^api/change-password$        api/auth.php   [QSA,L]

# ── PROFILE
RewriteRule ^api/profile/avatar$         api/profile.php [QSA,L]
RewriteRule ^api/profile$                api/profile.php [QSA,L]
RewriteRule ^api/users/([0-9]+)/profile$ api/profile.php [QSA,L]

# ── USERS ADMIN
RewriteRule ^api/admin/users$            api/users.php  [QSA,L]
RewriteRule ^api/admin/users/([0-9]+)$   api/users.php  [QSA,L]

# ── CATEGORIES
RewriteRule ^api/categories$                    api/articles.php   [QSA,L]
RewriteRule ^api/admin/categories$              api/categories.php [QSA,L]
RewriteRule ^api/admin/categories/(.+)$         api/categories.php [QSA,L]

# ── ARTICLES PUBLIC
RewriteRule ^api/articles$               api/articles.php [QSA,L]
RewriteRule ^api/articles/([0-9]+)$      api/articles.php [QSA,L]

# ── ARTICLES ADMIN
RewriteRule ^api/admin/articles$                         api/articles.php [QSA,L]
RewriteRule ^api/admin/articles/([0-9]+)$                api/articles.php [QSA,L]
RewriteRule ^api/admin/articles/([0-9]+)/toggle$         api/articles.php [QSA,L]

# ── COMMENTS
RewriteRule ^api/comments$                   api/comments.php [QSA,L]
RewriteRule ^api/admin/comments$             api/comments.php [QSA,L]
RewriteRule ^api/admin/comments/([0-9]+)$    api/comments.php [QSA,L]

# ── GALLERY
RewriteRule ^api/gallery$    api/gallery.php [QSA,L]