//
//  GameItemRow.swift
//  SportsTime
//
//  Row view for displaying a game in the itinerary. Prominent card styling with sport color accent.
//  Games are not reorderable so no drag handle is shown.
//

import SwiftUI

struct GameItemRow: View {
    let game: RichGame

    @Environment(\.colorScheme) private var colorScheme

    var body: some View {
        HStack(spacing: Theme.Spacing.md) {
            // Sport color bar
            SportColorBar(sport: game.game.sport)

            VStack(alignment: .leading, spacing: 4) {
                // Sport badge + Matchup
                HStack(spacing: 6) {
                    HStack(spacing: 3) {
                        Image(systemName: game.game.sport.iconName)
                            .font(.caption2)
                            .accessibilityHidden(true)
                        Text(game.game.sport.rawValue)
                            .font(.caption2)
                    }
                    .foregroundStyle(game.game.sport.themeColor)

                    HStack(spacing: 4) {
                        Text(game.awayTeam.abbreviation)
                            .font(.body)
                        Text("@")
                            .foregroundStyle(Theme.textMuted(colorScheme))
                        Text(game.homeTeam.abbreviation)
                            .font(.body)
                    }
                    .foregroundStyle(Theme.textPrimary(colorScheme))
                }

                // Stadium
                HStack(spacing: 4) {
                    Image(systemName: "building.2")
                        .font(.caption2)
                        .accessibilityHidden(true)
                    Text(game.stadium.name)
                        .font(.subheadline)
                }
                .foregroundStyle(Theme.textSecondary(colorScheme))
            }

            Spacer()

            // Time
            Text(game.localGameTimeShort)
                .font(.subheadline)
                .foregroundStyle(Theme.warmOrange)
        }
        .accessibilityElement(children: .combine)
        .padding(Theme.Spacing.md)
        .background(Theme.cardBackgroundElevated(colorScheme))
        .clipShape(RoundedRectangle(cornerRadius: Theme.CornerRadius.medium))
        .overlay {
            RoundedRectangle(cornerRadius: Theme.CornerRadius.medium)
                .strokeBorder(game.game.sport.themeColor.opacity(0.3), lineWidth: 1)
        }
    }
}
