import SwiftUI
import AppKit

// MARK: - Native Apple Model Card View
struct NativeAppleModelCardView: View {
    let model: NativeAppleModel
    let isCurrent: Bool
    var setDefaultAction: () -> Void
    
    var body: some View {
        HStack(alignment: .top, spacing: ProatSpacing.m) {
            // Main Content
            VStack(alignment: .leading, spacing: ProatSpacing.xs - 2) {
                headerSection
                metadataSection
                descriptionSection
            }
            .frame(maxWidth: .infinity, alignment: .leading)

            // Action Controls
            actionSection
        }
        .padding(ProatSpacing.m)
        .background(ProatModelCardBackground(isSelected: isCurrent))
    }

    private var headerSection: some View {
        HStack(alignment: .firstTextBaseline) {
            Text(model.displayName)
                .font(ProatFont.sectie)
                .foregroundColor(.proatText1)

            Spacer()
        }
    }

    private var metadataSection: some View {
        HStack(spacing: ProatSpacing.s) {
            // Native Apple
            Label("Apple-native", systemImage: "apple.logo")
                .font(ProatFont.klein)
                .foregroundColor(.proatText2)
                .lineLimit(1)

            // Language
            Label(model.language, systemImage: "globe")
                .font(ProatFont.klein)
                .foregroundColor(.proatText2)
                .lineLimit(1)

            // On-Device
            Label("Op apparaat", systemImage: "checkmark.shield")
                .font(ProatFont.klein)
                .foregroundColor(.proatText2)
                .lineLimit(1)

            // Requires macOS 26+
            Label("macOS 26+", systemImage: "macbook")
                .font(ProatFont.klein)
                .foregroundColor(.proatText2)
                .lineLimit(1)
        }
        .lineLimit(1)
    }

    private var descriptionSection: some View {
        Text(model.description)
            .font(ProatFont.klein)
            .foregroundColor(.proatText3)
            .lineLimit(2)
            .fixedSize(horizontal: false, vertical: true)
            .padding(.top, ProatSpacing.xs / 2)
    }

    private var actionSection: some View {
        HStack(spacing: ProatSpacing.xs) {
            if isCurrent {
                Text("Standaardmodel")
                    .font(.system(size: 12, weight: .medium))
                    .foregroundColor(.proatTeal)
            } else {
                Button(action: setDefaultAction) {
                    Text("Als standaard instellen")
                        .font(.system(size: 12))
                }
                .buttonStyle(.bordered)
                .controlSize(.small)
            }
        }
    }
}
