namespace ComputerSalesApp.UI;

internal static class AppTheme
{
    public static readonly Color Background = Color.FromArgb(232, 249, 249);
    public static readonly Color Surface = Color.FromArgb(247, 254, 254);
    public static readonly Color Header = Color.FromArgb(31, 139, 145);
    public static readonly Color HeaderDark = Color.FromArgb(20, 105, 112);
    public static readonly Color Accent = Color.FromArgb(39, 174, 181);
    public static readonly Color AccentDark = Color.FromArgb(20, 132, 140);
    public static readonly Color Border = Color.FromArgb(160, 222, 224);
    public static readonly Color GridHeader = Color.FromArgb(207, 244, 244);
    public static readonly Color GridAlt = Color.FromArgb(238, 252, 252);
    public static readonly Color Text = Color.FromArgb(22, 55, 58);

    public static Font Regular(float size = 10f) => new("Segoe UI", size, FontStyle.Regular);
    public static Font Bold(float size = 10f) => new("Segoe UI", size, FontStyle.Bold);

    public static void StylePrimaryButton(Button button)
    {
        button.BackColor = Accent;
        button.ForeColor = Color.White;
        button.FlatStyle = FlatStyle.Flat;
        button.FlatAppearance.BorderColor = AccentDark;
        button.FlatAppearance.BorderSize = 1;
        button.Font = Bold(10f);
        button.UseVisualStyleBackColor = false;
        button.Cursor = Cursors.Hand;
    }

    public static void StyleSecondaryButton(Button button)
    {
        button.BackColor = Color.FromArgb(224, 247, 247);
        button.ForeColor = Text;
        button.FlatStyle = FlatStyle.Flat;
        button.FlatAppearance.BorderColor = Border;
        button.FlatAppearance.BorderSize = 1;
        button.Font = Bold(10f);
        button.UseVisualStyleBackColor = false;
        button.Cursor = Cursors.Hand;
    }

    public static void StyleGrid(DataGridView grid)
    {
        grid.BackgroundColor = Surface;
        grid.BorderStyle = BorderStyle.FixedSingle;
        grid.GridColor = Border;
        grid.EnableHeadersVisualStyles = false;
        grid.ColumnHeadersDefaultCellStyle.BackColor = GridHeader;
        grid.ColumnHeadersDefaultCellStyle.ForeColor = Text;
        grid.ColumnHeadersDefaultCellStyle.Font = Bold(9.5f);
        grid.ColumnHeadersDefaultCellStyle.SelectionBackColor = GridHeader;
        grid.ColumnHeadersDefaultCellStyle.SelectionForeColor = Text;
        grid.DefaultCellStyle.BackColor = Color.White;
        grid.DefaultCellStyle.ForeColor = Text;
        grid.DefaultCellStyle.SelectionBackColor = Color.FromArgb(178, 235, 236);
        grid.DefaultCellStyle.SelectionForeColor = Text;
        grid.AlternatingRowsDefaultCellStyle.BackColor = GridAlt;
        grid.RowTemplate.Height = 28;
        grid.ColumnHeadersHeight = 32;
        grid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
        grid.RowHeadersVisible = false;
    }
}
