import SwiftUI

struct IncomingMessageBanner: Identifiable {
    let id = UUID()
    let message: MessageItem
    let senderName: String
    let messagePreview: String
}

struct NewMessageBannerView: View {
    let banner: IncomingMessageBanner
    let onOpen: () -> Void
    let onDismiss: () -> Void

    var body: some View {
        HStack(alignment: .center, spacing: 12) {
            Image(systemName: "bubble.left.and.bubble.right.fill")
                .foregroundColor(.accentColor)
                .imageScale(.medium)

            VStack(alignment: .leading, spacing: 4) {
                Text(banner.senderName)
                    .font(.headline)
                    .foregroundColor(.primary)
                    .lineLimit(1)

                Text(banner.messagePreview)
                    .font(.subheadline)
                    .foregroundColor(.secondary)
                    .lineLimit(2)
            }

            Spacer(minLength: 8)

            Button(action: onDismiss) {
                Image(systemName: "xmark")
                    .font(.footnote.weight(.semibold))
                    .foregroundColor(.secondary)
                    .padding(6)
                    .background(Color.secondary.opacity(0.15), in: Circle())
            }
            .buttonStyle(.plain)
        }
        .padding(.horizontal, 16)
        .padding(.vertical, 14)
        .background(.ultraThinMaterial, in: RoundedRectangle(cornerRadius: 18, style: .continuous))
        .shadow(color: Color.black.opacity(0.12), radius: 12, y: 6)
        .contentShape(Rectangle())
        .onTapGesture(perform: onOpen)
    }
}
