import SwiftUI

struct ErrorMessageView: View {
    let message: String
    let onDismiss: () -> Void

    var body: some View {
        HStack {
            Image(systemName: "exclamationmark.triangle.fill")
                .foregroundColor(Color.appError)
                .accessibilityHidden(true)

            Text(message)
                .font(.caption)
                .foregroundColor(Color.appError)

            Spacer()

            Button(action: onDismiss) {
                Image(systemName: "xmark.circle.fill")
                    .foregroundColor(Color.appError)
            }
            .accessibilityLabel(A11y.Common.dismissError)
        }
        .padding()
        .background(Color.appError.opacity(0.1))
        .cornerRadius(8)
    }
}

#Preview {
    VStack {
        ErrorMessageView(message: "Invalid username or password") {
            print("Dismissed")
        }
        .padding()

        Spacer()
    }
}
