import SwiftUI

struct ErrorView: View {
    let message: String
    let retryAction: () -> Void

    var body: some View {
        VStack(spacing: OrganicSpacing.cozy) {
            ZStack {
                Circle()
                    .fill(Color.appError.opacity(0.1))
                    .frame(width: 100, height: 100)

                Image(systemName: "exclamationmark.triangle")
                    .font(.system(size: 44, weight: .medium))
                    .foregroundColor(Color.appError)
            }
            .accessibilityHidden(true)

            Text("Error: \(message)")
                .font(.system(size: 15, weight: .medium))
                .foregroundColor(Color.appTextSecondary)
                .multilineTextAlignment(.center)

            Button(action: retryAction) {
                Text("Retry")
                    .font(.system(size: 16, weight: .semibold))
                    .padding(.horizontal, 32)
                    .padding(.vertical, 14)
                    .background(Color.appPrimary)
                    .foregroundColor(Color.appTextOnPrimary)
                    .clipShape(RoundedRectangle(cornerRadius: 14, style: .continuous))
                    .naturalShadow(.subtle)
            }
            .accessibilityLabel(A11y.Common.retryButton)
        }
        .padding(OrganicSpacing.comfortable)
    }
}

#Preview {
    ErrorView(message: "Failed to load data") {
        print("Retry tapped")
    }
}
