import SwiftUI

/// Persistent connectivity indicator (UX_IOS §6). Connectivity is unambiguous: green LAN
/// when live, amber while reconnecting, gray when the Mac is unreachable.
struct ConnectionChip: View {
    @EnvironmentObject var store: RemoteStore

    var body: some View {
        HStack(spacing: 6) {
            Circle().fill(color).frame(width: 8, height: 8)
            Text(store.connectivity.label).font(.footnote.weight(.medium))
        }
        .padding(.horizontal, 12).padding(.vertical, 6)
        .background(.ultraThinMaterial, in: Capsule())
    }

    private var color: Color {
        switch store.connectivity {
        case .connected: .green
        case .connecting, .reconnecting: .orange
        case .hostOffline, .unpaired: .gray
        case .failed: .red
        }
    }
}
