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

Public Sub FormatarTabelaPadrao(ByVal rngAlvo As Range, ByVal strTituloHeader As String)
    With rngAlvo
        .Font.Name = "Segoe UI"
        .Font.Size = 10
        .Borders.Weight = xlThin
        .Borders.Color = RGB(200, 200, 200)
    End With
    
    With rngAlvo.Rows(1)
        .Font.Bold = True
        .Font.Color = RGB(255, 255, 255)
        .Interior.Color = RGB(0, 51, 102)
        .HorizontalAlignment = xlCenter
    End With
End Sub

Public Sub AplicarDescontoComercial(ByVal curOriginal As Currency, _
                                    ByVal dblPercentual As Double, _
                                    ByRef curFinal As Currency, _
                                    ByRef curEconomia As Currency)
    curEconomia = curOriginal * dblPercentual
    curFinal = curOriginal - curEconomia
End Sub

Public Sub RegistrarLogOperacao(ByVal strMensagem As String, ByVal strResponsavel As String)
    Dim wsLog As Worksheet
    Dim lngLinha As Long
    
    On Error Resume Next
    Set wsLog = ThisWorkbook.Worksheets("Auditoria_Logs")
    On Error GoTo 0
    
    If wsLog Is Nothing Then
        Set wsLog = ThisWorkbook.Worksheets.Add(After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count))
        wsLog.Name = "Auditoria_Logs"
        wsLog.Tab.Color = RGB(52, 73, 94)
        wsLog.Range("A1:C1").Value = Array("DATA_HORA", "RESPONSAVEL", "ACAO_REGISTRADA")
        wsLog.Range("A1:C1").Font.Bold = True
    End If
    
    lngLinha = wsLog.Cells(wsLog.Rows.Count, "A").End(xlUp).Row + 1
    wsLog.Cells(lngLinha, 1).Value = Now
    wsLog.Cells(lngLinha, 2).Value = strResponsavel
    wsLog.Cells(lngLinha, 3).Value = strMensagem
    wsLog.Columns("A:C").AutoFit
End Sub

' Desafio de Fixação: Sanitização Modular
Public Sub HigienizarIntervaloCélulas(ByVal rng As Range)
    Dim c As Range
    For Each c In rng
        If Not IsEmpty(c) And Not IsNumeric(c.Value) Then
            c.Value = UCase(Trim(c.Value))
        End If
    Next c
End Sub

