//
//  SidebarHelpNoticeCardView.swift
//  USB Meter
//

import SwiftUI

struct SidebarHelpNoticeCardView: View {
    let reason: SidebarHelpReason
    let cloudSyncHelpTitle: String
    let cloudSyncHelpMessage: String

    var body: some View {
        VStack(alignment: .leading, spacing: 8) {
            Text(helpNoticeTitle)
                .font(.subheadline.weight(.semibold))
            Text(helpNoticeDetail)
                .font(.caption)
                .foregroundColor(.secondary)
        }
        .frame(maxWidth: .infinity, alignment: .leading)
        .padding(14)
        .meterCard(tint: reason.tint, fillOpacity: 0.14, strokeOpacity: 0.20, cornerRadius: 18)
    }

    private var helpNoticeTitle: String {
        switch reason {
        case .bluetoothPermission:
            return "Bluetooth access needs attention"
        case .cloudSyncUnavailable:
            return cloudSyncHelpTitle
        case .noDevicesDetected:
            return "No supported meters found yet"
        }
    }

    private var helpNoticeDetail: String {
        switch reason {
        case .bluetoothPermission:
            return "Open Bluetooth help to review the permission state and jump into Settings if access is blocked."
        case .cloudSyncUnavailable:
            return cloudSyncHelpMessage
        case .noDevicesDetected:
            return "Open Device help for quick checks like meter power, Bluetooth availability on the meter, or an existing connection to another phone."
        }
    }
}