using System.Drawing;
using System.Windows.Forms;

namespace Elfisa.ButtonSkillDemo;

internal sealed class ButtonSkillDemoForm : Form
{
    public ButtonSkillDemoForm()
    {
        Text = "Skill ModernButton — демо стилей";
        Size = new Size(920, 620);
        MinimumSize = new Size(820, 520);
        StartPosition = FormStartPosition.CenterScreen;
        BackColor = Color.FromArgb(18, 18, 22);
        Font = new Font("Segoe UI", 10f);

        var header = new Label
        {
            Text = "Custom Modern Button (skill) — варианты стилей",
            ForeColor = Color.White,
            AutoSize = false,
            Height = 48,
            Dock = DockStyle.Top,
            Padding = new Padding(24, 14, 24, 0),
            Font = new Font("Segoe UI Semibold", 14f, FontStyle.Bold)
        };

        var scroll = new Panel
        {
            Dock = DockStyle.Fill,
            AutoScroll = true,
            Padding = new Padding(24)
        };

        var layout = new TableLayoutPanel
        {
            Dock = DockStyle.Top,
            AutoSize = true,
            ColumnCount = 2,
            Padding = new Padding(0, 8, 0, 24)
        };
        layout.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 220));
        layout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));

        AddSection(layout, "Default (тёмная)", CreateDefaultButton());
        AddSection(layout, "Светлая тема", CreateLightButton());
        AddSection(layout, "Неоновый стиль", CreateNeonButton());
        AddSection(layout, "Glass (полупрозрачный)", CreateGlassButton());
        AddSection(layout, "Pharma Trust — синяя", CreatePharmaPrimaryButton());
        AddSection(layout, "Pharma Trust — красный ×", CreatePharmaClearButton());
        AddSection(layout, "Большая CTA", CreateLargeCtaButton());

        var note = new Label
        {
            AutoSize = true,
            MaximumSize = new Size(820, 0),
            ForeColor = Color.FromArgb(180, 180, 190),
            Text =
                "Это отдельный класс SkillModernButton для демо. Основное приложение использует Elfisa.UI.Controls.ModernButton + ThemeManager.\n" +
                "Наведите курсор и нажмите кнопки — видны hover и pressed.",
            Margin = new Padding(0, 8, 0, 0)
        };

        layout.Controls.Add(note, 0, layout.RowCount);
        layout.SetColumnSpan(note, 2);

        scroll.Controls.Add(layout);
        Controls.Add(scroll);
        Controls.Add(header);
    }

    private static void AddSection(TableLayoutPanel layout, string title, Control content)
    {
        var row = layout.RowCount;
        layout.RowStyles.Add(new RowStyle(SizeType.AutoSize));

        var label = new Label
        {
            Text = title,
            ForeColor = Color.FromArgb(200, 200, 210),
            AutoSize = true,
            Margin = new Padding(0, 16, 12, 8),
            Font = new Font("Segoe UI Semibold", 10.5f, FontStyle.Bold)
        };

        content.Margin = new Padding(0, 12, 0, 8);
        layout.Controls.Add(label, 0, row);
        layout.Controls.Add(content, 1, row);
        layout.RowCount++;
    }

    private static FlowLayoutPanel Row(params Control[] buttons)
    {
        var panel = new FlowLayoutPanel
        {
            AutoSize = true,
            WrapContents = true,
            FlowDirection = FlowDirection.LeftToRight
        };
        foreach (var btn in buttons)
        {
            panel.Controls.Add(btn);
        }
        return panel;
    }

    private static SkillModernButton CreateDefaultButton()
    {
        return new SkillModernButton
        {
            Text = "Красивая кнопка",
            Size = new Size(200, 48),
            Margin = new Padding(0, 0, 12, 0)
        };
    }

    private static SkillModernButton CreateLightButton()
    {
        return new SkillModernButton
        {
            Text = "Светлая кнопка",
            Size = new Size(200, 48),
            BackColor = Color.White,
            ForeColor = Color.FromArgb(30, 30, 30),
            BorderColor = Color.FromArgb(0, 122, 204),
            HoverColor = Color.FromArgb(245, 249, 255),
            PressedColor = Color.FromArgb(230, 240, 250),
            BorderRadius = 12
        };
    }

    private static SkillModernButton CreateNeonButton()
    {
        return new SkillModernButton
        {
            Text = "Неон",
            Size = new Size(180, 48),
            BackColor = Color.FromArgb(20, 24, 28),
            ForeColor = Color.FromArgb(220, 255, 250),
            BorderRadius = 8,
            BorderColor = Color.FromArgb(0, 255, 200),
            HoverColor = Color.FromArgb(50, 255, 220),
            PressedColor = Color.FromArgb(0, 180, 140),
            BorderSize = 2
        };
    }

    private static SkillModernButton CreateGlassButton()
    {
        return new SkillModernButton
        {
            Text = "Glass",
            Size = new Size(180, 48),
            BackColor = Color.FromArgb(80, 80, 80),
            ForeColor = Color.White,
            BorderColor = Color.FromArgb(160, 160, 170),
            HoverColor = Color.FromArgb(110, 110, 120),
            PressedColor = Color.FromArgb(60, 60, 68),
            BorderRadius = 16,
            BorderSize = 1
        };
    }

    private static SkillModernButton CreatePharmaPrimaryButton()
    {
        return new SkillModernButton
        {
            Text = "Сохранить заказ",
            Size = new Size(200, 40),
            BackColor = Color.FromArgb(3, 105, 161),
            ForeColor = Color.White,
            BorderColor = Color.FromArgb(3, 105, 161),
            HoverColor = Color.FromArgb(7, 89, 133),
            PressedColor = Color.FromArgb(12, 74, 110),
            BorderRadius = 6,
            BorderSize = 0,
            Font = new Font("Segoe UI Semibold", 10f, FontStyle.Bold)
        };
    }

    private static SkillModernButton CreatePharmaClearButton()
    {
        return new SkillModernButton
        {
            Text = "×",
            Size = new Size(32, 32),
            BackColor = Color.FromArgb(220, 38, 38),
            ForeColor = Color.White,
            BorderColor = Color.FromArgb(220, 38, 38),
            HoverColor = Color.FromArgb(239, 68, 68),
            PressedColor = Color.FromArgb(185, 28, 28),
            BorderRadius = 6,
            BorderSize = 0,
            Font = new Font("Segoe UI Semibold", 13f, FontStyle.Bold)
        };
    }

    private static Control CreateLargeCtaButton()
    {
        return Row(
            new SkillModernButton
            {
                Text = "Загрузить на сервер",
                Size = new Size(220, 52),
                BorderRadius = 20,
                BorderColor = Color.FromArgb(64, 158, 255),
                BackColor = Color.FromArgb(30, 30, 30),
                HoverColor = Color.FromArgb(0, 140, 230),
                PressedColor = Color.FromArgb(0, 100, 180)
            },
            new SkillModernButton
            {
                Text = "Отмена",
                Size = new Size(140, 52),
                BackColor = Color.White,
                ForeColor = Color.FromArgb(30, 30, 30),
                BorderColor = Color.FromArgb(200, 200, 210),
                HoverColor = Color.FromArgb(245, 245, 248),
                PressedColor = Color.FromArgb(230, 230, 235),
                BorderRadius = 20
            });
    }
}
