# ==================== ATIVAR MOD_REWRITE ====================
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  # ==================== SEGURANÇA ====================
  # Bloquear acesso a arquivos sensíveis
  RewriteRule ^\.git - [F,L]
  RewriteRule ^\.env - [F,L]
  RewriteRule ^package\.json - [F,L]
  RewriteRule ^tsconfig\.json - [F,L]
  RewriteRule ^next\.config - [F,L]
  RewriteRule ^middleware\.ts - [F,L]

  # ==================== REDIRECIONAR RAIZ PARA LOGIN OFUSCADO ====================
  # Redirecionar / para a rota ofuscada de login (com redirect visível)
  RewriteRule ^/?$ /a7f2b9c1 [R=301,L]

  # ==================== MAPEAMENTO DE ROTAS OFUSCADAS ====================
  # Redirecionar rotas ofuscadas para rotas reais
  # Formato: /hash -> /rota-real
  
  RewriteRule ^a7f2b9c1/?$ /login [QSA,L]
  RewriteRule ^b3d4e8f2/?$ /dashboard [QSA,L]
  RewriteRule ^c5e6f7a3/?$ /analysis [QSA,L]
  RewriteRule ^d8f9a4b2/?$ /ai-operation [QSA,L]
  RewriteRule ^e2g3h5i7/?$ /ai-result [QSA,L]
  RewriteRule ^f4j6k8l9/?$ /automation [QSA,L]

  # ==================== REDIRECIONAR PARA NEXT.JS ====================
  # Permitir arquivos reais (imagens, CSS, JS, etc.)
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  
  # Redirecionar todos os requests para o Next.js (index.html)
  RewriteRule ^(.*)$ /index.html [QSA,L]
</IfModule>

# ==================== CABEÇALHOS DE SEGURANÇA ====================
<IfModule mod_headers.c>
  # CORS para fontes
  <FilesMatch "\.(woff2?|ttf|eot|otf|css)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>

  # Segurança adicional
  Header set X-Frame-Options "SAMEORIGIN"
  Header set X-Content-Type-Options "nosniff"
  Header set X-XSS-Protection "1; mode=block"
  Header set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

# ==================== COMPRESSÃO ====================
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json
</IfModule>

# ==================== CACHE DE ARQUIVOS ESTÁTICOS ====================
<FilesMatch "\.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot)$">
  Header set Cache-Control "max-age=31536000, public"
</FilesMatch>

# ==================== DESABILITAR LISTAGEM DE DIRETÓRIOS ====================
Options -Indexes
