@using System.Collections.Generic
@inject NavigationManager Navigation

<div class="panel-body">
@*     <div class="row">
        @foreach (var item in Items)
        {
            <div class=@DashboardClass>
                <div class="circle-tile">
                    <p>
                        <div class="circle-tile-heading @item.MainColor">
                            <br />
                            <i class="@item.Icon"></i>
                        </div>
                    </p>
                    <div class="circle-tile-content @item.MainColor">
                        <div class="circle-tile-description text-faded" style="color: @item.ValueColor;">
                            <h5 style="text-transform: uppercase">@item.Title</h5>
                            @item.Description
                        </div>
                        <div class="circle-tile-number text-faded" style="color: @item.ValueColor;">
                            @item.Value
                        </div>
                        @if (item.OnClickAction is not null)
                        {
                            <a class="circle-tile-footer" @onclick="async () => await item.OnClickAction(item.OnClickParam)">More Info <i class="fa fa-chevron-circle-right"></i></a>
                        }
                        else
                        {
                            <a class="circle-tile-footer" @onclick="() => NavigateToUrl(item.Url)">More Info <i class="fa fa-chevron-circle-right"></i></a>
                        }
                    </div>
                </div>
            </div>
        }
    </div>
 *@
    <!-- MAPA DE EJEMPLO -->
    <div class="row mt-4">
        <div class="col-12">
            <div class="card shadow rounded-3">
                <div class="card-header bg-light">
                    <strong>Ubicación de ejemplo</strong>
                </div>
                <div class="card-body">
                    <PhMap Latitude="-34.618998"
                           Longitude="-58.501015"  />
                </div>
            </div>
        </div>
    </div>
    </div>

@code {
    [Parameter] public List<DashboardItem> Items { get; set; } = new List<DashboardItem>();
    [Parameter] public string DashboardClass { get; set; } = string.Empty;

    public class DashboardItem
    {
        public string Title { get; set; } = string.Empty;
        public string Description { get; set; } = string.Empty;
        public string Value { get; set; } = string.Empty;
        public string Icon { get; set; } = string.Empty;
        public string MainColor { get; set; } = string.Empty;
        public string ValueColor { get; set; } = string.Empty;
        public string Url { get; set; } = string.Empty;
        public Func<string?, Task>? OnClickAction { get; set; }
        public string? OnClickParam { get; set; }
    }

    private void NavigateToUrl(string url) => Navigation.NavigateTo(url);

    private void OnMapChanged((double Lat, double Lng) loc)
    {
        Console.WriteLine($"Nueva ubicación desde el mapa: {loc.Lat}, {loc.Lng}");
        // Aquí podrías guardar en una variable, mostrar en UI, o integrarlo con lógica posterior
    }
}
