namespace PlanTempus.Application.Features.Employees.Components;

/// <summary>
/// Shared catalog for employee detail data.
/// Used by all EmployeeDetail* ViewComponents.
/// </summary>
public static class EmployeeDetailCatalog
{
    private static readonly Dictionary<string, EmployeeDetailRecord> Employees = new()
    {
        ["employee-1"] = new EmployeeDetailRecord
        {
            Key = "employee-1",
            Initials = "MJ",
            Name = "Maria Jensen",
            Email = "maria@salonbeauty.dk",
            Phone = "+45 12 34 56 78",
            Role = "owner",
            RoleKey = "employees.roles.owner",
            Status = "active",
            StatusKey = "employees.status.active",
            BookingsThisYear = "312",
            RevenueThisYear = "245.800 kr",
            Rating = "4.9",
            EmployedSince = "2018",
            Address = "Hovedgaden 12",
            PostalCity = "2100 København Ø",
            EmploymentDate = "1. januar 2018",
            Position = "Ejer",
            EmploymentType = "Fuldtid",
            HoursPerWeek = "37",
            BirthDate = "12. maj 1985",
            EmergencyContact = "Peter Jensen (ægtefælle)",
            EmergencyPhone = "+45 98 76 54 32",
            BankAccount = "1234-5678901234",
            TaxCard = "Hovedkort",
            HourlyRate = "250 kr",
            MonthlyFixedSalary = "45.000 kr",
            Tags = new() { new("Master Stylist", "master"), new("Farvecertificeret", "cert") }
        },
        ["employee-2"] = new EmployeeDetailRecord
        {
            Key = "employee-2",
            Initials = "AS",
            Name = "Anna Sørensen",
            Email = "anna@salonbeauty.dk",
            Phone = "+45 23 45 67 89",
            Role = "admin",
            RoleKey = "employees.roles.admin",
            Status = "active",
            StatusKey = "employees.status.active",
            AvatarColor = "purple",
            BookingsThisYear = "248",
            RevenueThisYear = "186.450 kr",
            Rating = "4.9",
            EmployedSince = "2019",
            Address = "Vestergade 15, 3. tv",
            PostalCity = "8000 Aarhus C",
            EmploymentDate = "1. august 2019",
            Position = "Master Stylist",
            EmploymentType = "Fuldtid",
            HoursPerWeek = "37",
            BirthDate = "15. marts 1992",
            EmergencyContact = "Peter Sørensen (ægtefælle)",
            EmergencyPhone = "+45 87 65 43 21",
            BankAccount = "2345-6789012345",
            TaxCard = "Hovedkort",
            HourlyRate = "220 kr",
            MonthlyFixedSalary = "38.000 kr",
            Tags = new() { new("Master Stylist", "master"), new("Farvecertificeret", "cert"), new("Balayage", "cert") }
        },
        ["employee-3"] = new EmployeeDetailRecord
        {
            Key = "employee-3",
            Initials = "LP",
            Name = "Louise Pedersen",
            Email = "louise@salonbeauty.dk",
            Phone = "+45 34 56 78 90",
            Role = "leader",
            RoleKey = "employees.roles.leader",
            Status = "active",
            StatusKey = "employees.status.active",
            AvatarColor = "blue",
            BookingsThisYear = "198",
            RevenueThisYear = "156.200 kr",
            Rating = "4.7",
            EmployedSince = "2020",
            Address = "Nørrebrogade 45",
            PostalCity = "2200 København N",
            EmploymentDate = "15. marts 2020",
            Position = "Senior Stylist",
            EmploymentType = "Fuldtid",
            HoursPerWeek = "37",
            BirthDate = "22. november 1988",
            EmergencyContact = "Hans Pedersen (far)",
            EmergencyPhone = "+45 76 54 32 10",
            BankAccount = "3456-7890123456",
            TaxCard = "Hovedkort",
            HourlyRate = "200 kr",
            MonthlyFixedSalary = "35.000 kr",
            Tags = new() { new("Senior Stylist", "senior"), new("Farvecertificeret", "cert") }
        },
        ["employee-4"] = new EmployeeDetailRecord
        {
            Key = "employee-4",
            Initials = "KN",
            Name = "Katrine Nielsen",
            Email = "katrine@salonbeauty.dk",
            Phone = "+45 45 67 89 01",
            Role = "employee",
            RoleKey = "employees.roles.employee",
            Status = "active",
            StatusKey = "employees.status.active",
            AvatarColor = "amber",
            BookingsThisYear = "165",
            RevenueThisYear = "124.300 kr",
            Rating = "4.8",
            EmployedSince = "2021",
            Address = "Frederiksberggade 28",
            PostalCity = "1459 København K",
            EmploymentDate = "1. juni 2021",
            Position = "Stylist",
            EmploymentType = "Fuldtid",
            HoursPerWeek = "32",
            BirthDate = "8. august 1995",
            EmergencyContact = "Mette Nielsen (mor)",
            EmergencyPhone = "+45 65 43 21 09",
            BankAccount = "4567-8901234567",
            TaxCard = "Hovedkort",
            HourlyRate = "180 kr",
            MonthlyFixedSalary = "32.000 kr",
            Tags = new() { new("Stylist", "default") }
        },
        ["employee-5"] = new EmployeeDetailRecord
        {
            Key = "employee-5",
            Initials = "SH",
            Name = "Sofie Hansen",
            Email = "sofie@salonbeauty.dk",
            Phone = "+45 56 78 90 12",
            Role = "employee",
            RoleKey = "employees.roles.employee",
            Status = "invited",
            StatusKey = "employees.status.invited",
            AvatarColor = "purple",
            BookingsThisYear = "0",
            RevenueThisYear = "0 kr",
            Rating = "-",
            EmployedSince = "2025",
            Address = "-",
            PostalCity = "-",
            EmploymentDate = "1. januar 2025",
            Position = "Junior Stylist",
            EmploymentType = "Fuldtid",
            HoursPerWeek = "37",
            BirthDate = "-",
            EmergencyContact = "-",
            EmergencyPhone = "-",
            BankAccount = "-",
            TaxCard = "-",
            HourlyRate = "150 kr",
            MonthlyFixedSalary = "28.000 kr",
            Tags = new() { new("Junior Stylist", "junior") }
        }
    };

    public static EmployeeDetailRecord Get(string key)
    {
        if (!Employees.TryGetValue(key, out var employee))
            throw new KeyNotFoundException($"Employee with key '{key}' not found");
        return employee;
    }

    public static IEnumerable<string> AllKeys => Employees.Keys;
}

/// <summary>
/// Complete employee detail record used across all detail ViewComponents.
/// </summary>
public record EmployeeDetailRecord
{
    // Identity
    public required string Key { get; init; }
    public required string Initials { get; init; }
    public required string Name { get; init; }
    public string? AvatarColor { get; init; }

    // Contact
    public required string Email { get; init; }
    public required string Phone { get; init; }
    public required string Address { get; init; }
    public required string PostalCity { get; init; }

    // Role & Status
    public required string Role { get; init; }
    public required string RoleKey { get; init; }
    public required string Status { get; init; }
    public required string StatusKey { get; init; }

    // Stats
    public required string BookingsThisYear { get; init; }
    public required string RevenueThisYear { get; init; }
    public required string Rating { get; init; }
    public required string EmployedSince { get; init; }

    // Employment
    public required string EmploymentDate { get; init; }
    public required string Position { get; init; }
    public required string EmploymentType { get; init; }
    public required string HoursPerWeek { get; init; }

    // Personal
    public required string BirthDate { get; init; }
    public required string EmergencyContact { get; init; }
    public required string EmergencyPhone { get; init; }

    // Salary
    public required string BankAccount { get; init; }
    public required string TaxCard { get; init; }
    public required string HourlyRate { get; init; }
    public required string MonthlyFixedSalary { get; init; }

    // Salary - Rates
    public string NormalRate { get; init; } = "131,49 kr";
    public string OvertimeRate { get; init; } = "280,50 kr";
    public string VacationRate { get; init; } = "140,25 kr";

    // Salary - Commission
    public string MinimumPerHour { get; init; } = "220 kr";
    public string ServiceCommission { get; init; } = "15%";
    public string ProductCommission { get; init; } = "15%";

    // Salary - Supplements
    public string WeekdaySupplement { get; init; } = "28,03 kr";
    public string SaturdaySupplement { get; init; } = "56,02 kr";
    public string SundaySupplement { get; init; } = "112,07 kr";

    // Salary - Rate values (numeric only, for drawer inputs)
    public string NormalRateValue { get; init; } = "131,49";
    public string OvertimeRateValue { get; init; } = "280,50";
    public string CourseRateValue { get; init; } = "140,25";
    public string TimeOffRateValue { get; init; } = "140,25";
    public string PaidLeaveRateValue { get; init; } = "140,25";
    public string VacationRateValue { get; init; } = "140,25";
    public string OfficeRateValue { get; init; } = "140,25";
    public string ChildSickRateValue { get; init; } = "140,25";
    public string ChildHospitalRateValue { get; init; } = "140,25";
    public string MaternityRateValue { get; init; } = "140,25";
    public string WeekdaySupplementValue { get; init; } = "28,03";
    public string SaturdaySupplementValue { get; init; } = "56,02";
    public string SundaySupplementValue { get; init; } = "112,07";
    public string ProductCommissionValue { get; init; } = "15";
    public string ServiceCommissionValue { get; init; } = "15";

    // HR - Contract
    public string ContractType { get; init; } = "Fastansættelse";
    public string TerminationNotice { get; init; } = "1 måned";
    public string ContractExpiry { get; init; } = "— (ingen udløb)";

    // HR - Vacation
    public string VacationEarned { get; init; } = "25 dage";
    public string VacationUsed { get; init; } = "12 dage";
    public string VacationRemaining { get; init; } = "13 dage";

    // HR - Absence
    public string SickDays2025 { get; init; } = "3 dage";
    public string SickDays2024 { get; init; } = "7 dage";
    public string ChildSickDays2025 { get; init; } = "1 dag";
    public string MaternityLeave { get; init; } = "— (ingen planlagt)";

    // Tags (certifications, specialties)
    public List<EmployeeTag> Tags { get; init; } = new();
}

public record EmployeeTag(string Text, string CssClass);

// HR data records
public record CertificationRecord(string Name, string ExpiryDate, string Status, string StatusClass);
public record CourseRecord(string Name, string Provider, string Date, string? Status = null);
public record DocumentRecord(string Name, string UploadDate);
public record PlannedAbsenceRecord(string Dates, string Type, string TypeClass);
