' === Pratica Obrigatoria 1 (ATIVO) ===
Option Explicit

' Procedimento de Desproteção Segura (Desafio de Fixação)
Sub DesprotegerTodasAsAbas()
    Dim strSenha As String
    Dim ws As Worksheet
    
    strSenha = InputBox("Digite a senha de administrador da FastLog:", "Liberação de Pasta")
    
    If strSenha <> "FastLog2026" Then
        MsgBox "Acesso Negado! Senha incorreta.", vbCritical, "Segurança"
        Exit Sub
    End If
    
    For Each ws In ThisWorkbook.Worksheets
        ws.Unprotect Password:=strSenha
    Next ws
    
    MsgBox "Todas as " & ThisWorkbook.Worksheets.Count & " abas foram desprotegidas para manutenção!", _
           vbInformation, "Modo Manutenção Ativo"
End Sub

' Rotina Corporativa Padronizada
Sub ExecutarOtimizacaoCompleta()
    Dim tInicio As Double
    Dim ws As Worksheet
    
    tInicio = Timer
    
    ' Quarteto de Performance
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    Application.EnableEvents = False
    Application.DisplayAlerts = False
    
    For Each ws In ThisWorkbook.Worksheets
        ws.Unprotect "FastLog2026"
        
        With ws.Range("A1")
            .Value = "FASTLOG S.A. - " & UCase(ws.Name)
            .Font.Bold = True
            .Font.Color = RGB(0, 51, 102)
        End With
        
        ws.Columns.AutoFit
        ws.Protect Password:="FastLog2026"
    Next ws
    
    ' Restauração
    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic
    Application.EnableEvents = True
    Application.DisplayAlerts = True
    
    MsgBox "Otimização e padronização concluídas em " & Format(Timer - tInicio, "0.000") & " s!", _
           vbInformation, "FastLog Performance"
End Sub

