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

namespace BettingPredictor.UI
{
    /// <summary>
    /// Tema grafico moderno scuro per l'applicazione
    /// </summary>
    internal static class ModernTheme
    {
        // Palette colori — DARK THEME
        public static readonly Color SidebarBackground = Color.FromArgb(24, 24, 37);
        public static readonly Color SidebarHover = Color.FromArgb(40, 40, 58);
        public static readonly Color SidebarActive = Color.FromArgb(137, 180, 250);
        public static readonly Color SidebarText = Color.FromArgb(186, 194, 222);
        public static readonly Color SidebarActiveText = Color.FromArgb(24, 24, 37);

        public static readonly Color ContentBackground = Color.FromArgb(30, 30, 46);
        public static readonly Color CardBackground = Color.FromArgb(40, 42, 58);
        public static readonly Color CardBorder = Color.FromArgb(55, 57, 78);
        public static readonly Color HeaderBackground = Color.FromArgb(24, 24, 37);

        public static readonly Color PrimaryColor = Color.FromArgb(137, 180, 250);
        public static readonly Color PrimaryDark = Color.FromArgb(116, 155, 220);
        public static readonly Color SuccessColor = Color.FromArgb(166, 218, 149);
        public static readonly Color WarningColor = Color.FromArgb(249, 226, 175);
        public static readonly Color DangerColor = Color.FromArgb(243, 139, 168);
        public static readonly Color TextPrimary = Color.FromArgb(205, 214, 244);
        public static readonly Color TextSecondary = Color.FromArgb(147, 153, 178);

        public static readonly Color InputBackground = Color.FromArgb(49, 50, 68);
        public static readonly Color InputBorder = Color.FromArgb(69, 71, 90);
        public static readonly Color InputText = Color.FromArgb(205, 214, 244);

        // Font
        public static readonly Font TitleFont = new Font("Segoe UI Semibold", 16F);
        public static readonly Font SubtitleFont = new Font("Segoe UI Semibold", 12F);
        public static readonly Font BodyFont = new Font("Segoe UI", 10F);
        public static readonly Font SmallFont = new Font("Segoe UI", 9F);
        public static readonly Font NavFont = new Font("Segoe UI Semibold", 11F);

        // Dimensioni
        public const int SidebarWidth = 200;
        public const int CardRadius = 8;
        public const int CardPadding = 16;

        /// <summary>
        /// Applica lo stile moderno scuro a un DataGridView
        /// </summary>
        public static void StyleDataGridView(DataGridView grid)
        {
            grid.BorderStyle = BorderStyle.None;
            grid.BackgroundColor = CardBackground;
            grid.GridColor = CardBorder;
            grid.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal;

            grid.EnableHeadersVisualStyles = false;
            grid.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None;
            grid.ColumnHeadersDefaultCellStyle = new DataGridViewCellStyle
            {
                BackColor = Color.FromArgb(35, 36, 52),
                ForeColor = PrimaryColor,
                Font = new Font("Segoe UI Semibold", 10F),
                Padding = new Padding(8, 4, 8, 4),
                Alignment = DataGridViewContentAlignment.MiddleLeft
            };
            grid.ColumnHeadersHeight = 40;

            grid.DefaultCellStyle = new DataGridViewCellStyle
            {
                BackColor = CardBackground,
                ForeColor = TextPrimary,
                Font = BodyFont,
                SelectionBackColor = Color.FromArgb(60, 63, 85),
                SelectionForeColor = PrimaryColor,
                Padding = new Padding(6, 3, 6, 3)
            };

            grid.AlternatingRowsDefaultCellStyle = new DataGridViewCellStyle
            {
                BackColor = Color.FromArgb(45, 47, 64),
                ForeColor = TextPrimary,
                Font = BodyFont,
                SelectionBackColor = Color.FromArgb(60, 63, 85),
                SelectionForeColor = PrimaryColor,
                Padding = new Padding(6, 3, 6, 3)
            };

            grid.RowHeadersVisible = false;
            grid.RowTemplate.Height = 36;
            grid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            grid.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            grid.ReadOnly = true;
            grid.AllowUserToAddRows = false;
            grid.AllowUserToDeleteRows = false;
            grid.AllowUserToResizeRows = false;
        }

        /// <summary>
        /// Disegna un rettangolo arrotondato
        /// </summary>
        public static GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)
        {
            var path = new GraphicsPath();
            int d = radius * 2;
            path.AddArc(rect.X, rect.Y, d, d, 180, 90);
            path.AddArc(rect.Right - d, rect.Y, d, d, 270, 90);
            path.AddArc(rect.Right - d, rect.Bottom - d, d, d, 0, 90);
            path.AddArc(rect.X, rect.Bottom - d, d, d, 90, 90);
            path.CloseFigure();
            return path;
        }
    }
}
