import SwiftUI

extension Color {
    static let healthyGreen = Color.green
    static let warningAmber = Color.yellow
    static let criticalRed  = Color.red
    static let neutralGray  = Color.gray
}

enum DeviceColor: String, CaseIterable, Identifiable {
    case blue, green, orange, red, purple, teal, indigo, pink

    var id: String { rawValue }

    var color: Color {
        switch self {
        case .blue:   return .blue
        case .green:  return .green
        case .orange: return .orange
        case .red:    return .red
        case .purple: return .purple
        case .teal:   return .teal
        case .indigo: return .indigo
        case .pink:   return .pink
        }
    }
}

struct SeverityBadge: View {
    let delta: Int
    var dimmed: Bool = false

    var body: some View {
        let (label, color) = badge
        Text(label)
            .font(.caption2.weight(.semibold))
            .padding(.horizontal, 6)
            .padding(.vertical, 2)
            .background(color.opacity(0.15))
            .foregroundStyle(color)
            .clipShape(Capsule())
            .opacity(dimmed ? 0.4 : 1)
    }

    private var badge: (String, Color) {
        if delta > 0 { return ("+\(delta)", .healthyGreen) }
        if delta < 0 { return ("\(delta)", .neutralGray) }
        return ("–", .neutralGray)
    }
}

struct EmptyStateView: View {
    let icon: String
    let title: String
    let message: String

    var body: some View {
        VStack(spacing: 12) {
            Image(systemName: icon)
                .font(.system(size: 44))
                .foregroundStyle(.secondary)
            Text(title)
                .font(.headline)
            Text(message)
                .font(.subheadline)
                .foregroundStyle(.secondary)
                .multilineTextAlignment(.center)
        }
        .padding(32)
    }
}
