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

namespace BettingPredictor.UI
{
    /// <summary>
    /// Pannello con angoli arrotondati e ombra simulata per stile card moderno
    /// </summary>
    internal class CardPanel : Panel
    {
        public int Radius { get; set; } = ModernTheme.CardRadius;

        public CardPanel()
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw, true);
            BackColor = Color.Transparent;
            Padding = new Padding(ModernTheme.CardPadding);
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            var g = e.Graphics;
            g.SmoothingMode = SmoothingMode.AntiAlias;

            // Pulisci sfondo
            using (var bgBrush = new SolidBrush(Parent?.BackColor ?? ModernTheme.ContentBackground))
                g.FillRectangle(bgBrush, ClientRectangle);

            var cardRect = new Rectangle(0, 0, Width - 2, Height - 2);
            using (var path = ModernTheme.GetRoundedRectPath(cardRect, Radius))
            {
                using (var brush = new SolidBrush(ModernTheme.CardBackground))
                    g.FillPath(brush, path);
                using (var pen = new Pen(ModernTheme.CardBorder, 1))
                    g.DrawPath(pen, path);
            }
        }
    }
}
