import SwiftUI

struct SummaryStatView: View {
    let icon: String
    let value: String
    let label: String

    var body: some View {
        VStack(spacing: OrganicSpacing.compact) {
            ZStack {
                Circle()
                    .fill(Color.appPrimary.opacity(0.1))
                    .frame(width: 44, height: 44)

                if icon == "outline" {
                    Image("outline")
                        .renderingMode(.template)
                        .resizable()
                        .aspectRatio(contentMode: .fit)
                        .frame(width: 20, height: 20)
                        .foregroundColor(Color.appPrimary)
                } else {
                    Image(systemName: icon)
                        .font(.system(size: 18, weight: .semibold))
                        .foregroundColor(Color.appPrimary)
                }
            }

            Text(value)
                .font(.system(size: 20, weight: .bold, design: .rounded))
                .foregroundColor(Color.appTextPrimary)

            Text(label)
                .font(.system(size: 12, weight: .medium))
                .foregroundColor(Color.appTextSecondary)
                .multilineTextAlignment(.center)
        }
        .frame(maxWidth: .infinity)
        .accessibilityElement(children: .combine)
        .accessibilityLabel(A11y.Common.stat(value: value, label: label))
    }
}

#Preview {
    HStack(spacing: 20) {
        SummaryStatView(
            icon: "outline",
            value: "3",
            label: "Properties"
        )

        SummaryStatView(
            icon: "list.bullet",
            value: "12",
            label: "Total Tasks"
        )
    }
    .padding()
}
