@using SumaTube.Domain.Entities.Videos
@model List<VideoSummary>
@{
    ViewData["Title"] = "Meus Resumos";
}

<div class="container my-5">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h1>Meus Resumos</h1>
        <a href="@Url.Action("Extract", "Video")" class="btn btn-primary">
            <i class="bi bi-plus-circle"></i> Novo Resumo
        </a>
    </div>

    @if (Model == null || !Model.Any())
    {
        <div class="text-center py-5">
            <i class="bi bi-file-earmark-text" style="font-size: 3rem; color: var(--suma-red);"></i>
            <h3 class="mt-3">Você ainda não possui resumos</h3>
            <p class="text-muted">Clique em "Novo Resumo" para extrair o conteúdo de um vídeo do YouTube</p>
            <a href="@Url.Action("Extract", "Video")" class="btn btn-primary mt-3">
                <i class="bi bi-plus-circle"></i> Criar Meu Primeiro Resumo
            </a>
        </div>
    }
    else
    {
        <div class="row">
            @foreach (var summary in Model)
            {
                <div class="col-md-6 col-lg-4 mb-4">
                    <div class="card h-100 shadow-sm">
                        <div class="position-relative">
                            <img src="@summary.ThumbnailUrl" class="card-img-top" alt="@summary.Title">
                            @if (summary.Status == "PROCESSANDO")
                            {
                                <div class="position-absolute top-0 end-0 p-2 bg-warning text-dark rounded-bottom-left">
                                    <i class="bi bi-hourglass-split"></i> Processando
                                </div>
                            }
                            else if (summary.Status == "REALIZADO")
                            {
                                <div class="position-absolute top-0 end-0 p-2 bg-success text-white rounded-bottom-left">
                                    <i class="bi bi-check-circle"></i> Concluído
                                </div>
                            }
                            else if (summary.Status == "ERRO")
                            {
                                <div class="position-absolute top-0 end-0 p-2 bg-danger text-white rounded-bottom-left">
                                    <i class="bi bi-exclamation-triangle"></i> Erro
                                </div>
                            }
                        </div>
                        <div class="card-body">
                            <h5 class="card-title text-truncate" title="@summary.Title">@summary.Title</h5>
                            <p class="card-text text-muted small">
                                <i class="bi bi-calendar"></i> @summary.RequestDate.ToString("dd/MM/yyyy HH:mm")
                                <br>
                                <i class="bi bi-translate"></i> @summary.Language
                            </p>
                        </div>
                        <div class="card-footer bg-white border-top-0">
                            <a href="@Url.Action("Summary", "Video", new { id = summary.Id })" class="btn btn-sm btn-outline-primary w-100">
                                @if (summary.Status == "PROCESSANDO")
                                {
                                    <span>Ver Progresso</span>
                                }
                                else if (summary.Status == "REALIZADO")
                                {
                                    <span>Ver Resumo</span>
                                }
                                else
                                {
                                    <span>Ver Detalhes</span>
                                }
                            </a>
                        </div>
                    </div>
                </div>
            }
        </div>
    }
</div>