//
//  CozyInterestTag.swift
//  lichunWebsocket
//
//  Cozy interest tag with optional icon
//

import SwiftUI

struct CozyInterestTag: View {
    let interest: String
    var isShared: Bool = false
    var icon: String? = nil

    var body: some View {
        HStack(spacing: 6) {
            if let icon = icon {
                Image(systemName: icon)
                    .font(.system(size: 11, weight: .semibold))
            }

            Text(interest.capitalized)
                .font(.system(size: 13, weight: .semibold, design: .rounded))
        }
        .padding(.horizontal, 12)
        .padding(.vertical, 7)
        .background(
            Group {
                if isShared {
                    LinearGradient(
                        colors: [
                            AppColors.primary.opacity(0.2),
                            AppColors.primary.opacity(0.15)
                        ],
                        startPoint: .topLeading,
                        endPoint: .bottomTrailing
                    )
                } else {
                    AppColors.surfaceElevated
                }
            }
        )
        .foregroundColor(isShared ? AppColors.primary : AppColors.primaryText)
        .cornerRadius(16)
        .overlay(
            RoundedRectangle(cornerRadius: 16)
                .strokeBorder(
                    isShared ? AppColors.primary.opacity(0.3) : Color.clear,
                    lineWidth: 1.5
                )
        )
        .shadow(
            color: isShared ? AppColors.primary.opacity(0.2) : Color.black.opacity(0.04),
            radius: 4,
            x: 0,
            y: 2
        )
    }
}

// MARK: - Preview
#if DEBUG
struct CozyInterestTag_Previews: PreviewProvider {
    static var previews: some View {
        VStack(spacing: 20) {
            HStack {
                CozyInterestTag(interest: "Reading", icon: "book.fill")
                CozyInterestTag(interest: "Gaming", isShared: true, icon: "gamecontroller.fill")
                CozyInterestTag(interest: "Cooking", icon: "fork.knife")
            }
        }
        .padding()
        .background(AppColors.background)
    }
}
#endif
