@page "/"
@attribute [Authorize]
@inject IOllamaService OllamaService
@inject IProjectService ProjectService
@inject ILocalizationService Loc

<PageTitle>@Loc["page.title.home"]</PageTitle>

<div class="tab-bar">
    <div class="tab @GetTabClass("rag")" @onclick='() => activeTab = "rag"'>@Loc["home.tab.rag_facts"]</div>
    <div class="tab @GetTabClass("style")" @onclick='() => activeTab = "style"'>@Loc["home.tab.style_analysis"]</div>
</div>

<div class="tab-content">
    @if (activeTab == "rag")
    {
        @if (foundFacts.Count == 0)
        {
            <p style="color: var(--border-color);">@Loc["home.rag.empty"]</p>
        }
        else
        {
            @foreach (var fact in foundFacts)
            {
                <div class="fact-card">@fact</div>
            }
        }
    }
    else if (activeTab == "style")
    {
        <textarea style="width: 100%; min-height: 300px; background: var(--editor-bg); color: var(--text-color); border: 1px solid var(--border-color); padding: 8px; font-family: Consolas;" readonly>@styleSuggestions</textarea>
    }
</div>

@code {
    private string activeTab = "rag";
    private List<string> foundFacts = new();
    private string styleSuggestions = string.Empty;

    private string GetTabClass(string tab)
    {
        return activeTab == tab ? "active" : "";
    }
}
