@model PlanTempus.Application.Features.Customers.Components.CustomerDetailJournalViewModel

<!-- Mini Tabs for quick filter -->
<swp-journal-mini-tabs>
    <swp-journal-mini-tab class="active" data-filter="all">
        <span class="tab-dot blue"></span>
        Alle
        <span class="tab-count">@Model.AllCount</span>
    </swp-journal-mini-tab>
    <swp-journal-mini-tab data-filter="note">
        <span class="tab-dot blue"></span>
        Noter
        <span class="tab-count">@Model.NotesCount</span>
    </swp-journal-mini-tab>
    <swp-journal-mini-tab data-filter="colorFormula">
        <span class="tab-dot amber"></span>
        Farveformler
        <span class="tab-count">@Model.ColorFormulasCount</span>
    </swp-journal-mini-tab>
    <swp-journal-mini-tab data-filter="analysis">
        <span class="tab-dot purple"></span>
        Analyser
        <span class="tab-count">@Model.AnalysesCount</span>
    </swp-journal-mini-tab>
</swp-journal-mini-tabs>

<swp-detail-grid>
    <!-- Left Column -->
    <swp-card-column>
        <!-- Noter header card -->
        <swp-card data-journal-type="note">
            <swp-card-header>
                <swp-card-title>
                    <span class="col-dot blue"></span>
                    <span>@Model.NotesTitle</span>
                </swp-card-title>
                <swp-section-action>@Model.AddNoteText</swp-section-action>
            </swp-card-header>
            @foreach (var entry in Model.Notes)
            {
                <swp-journal-entry data-entry-id="@entry.Id">
                    <swp-journal-entry-header>
                        <swp-journal-entry-type class="@entry.TypeClass">@entry.Tag</swp-journal-entry-type>
                        @if (entry.Subtags.Any())
                        {
                            <swp-journal-entry-tags>
                                @foreach (var subtag in entry.Subtags)
                                {
                                    <swp-journal-tag class="@subtag.ToLowerInvariant()">@subtag</swp-journal-tag>
                                }
                            </swp-journal-entry-tags>
                        }
                        <swp-journal-entry-delete><i class="ph ph-trash"></i></swp-journal-entry-delete>
                    </swp-journal-entry-header>
                    <swp-journal-entry-body>@Html.Raw(entry.Text.Replace("\n", "<br>"))</swp-journal-entry-body>
                    <swp-journal-entry-footer>
                        <swp-journal-entry-date>@entry.FormattedDate</swp-journal-entry-date>
                        @if (entry.Tag == "Advarsel")
                        {
                            <swp-journal-entry-visibility class="warning">
                                <i class="ph ph-warning"></i>
                                <span>Advarsel</span>
                            </swp-journal-entry-visibility>
                        }
                        else
                        {
                            <swp-journal-entry-visibility>
                                <i class="ph ph-eye"></i>
                                <span>Alle</span>
                            </swp-journal-entry-visibility>
                        }
                    </swp-journal-entry-footer>
                </swp-journal-entry>
            }
        </swp-card>

        <!-- Farveformler card -->
        <swp-card data-journal-type="colorFormula">
            <swp-card-header>
                <swp-card-title>
                    <span class="col-dot amber"></span>
                    <span>@Model.ColorFormulasTitle</span>
                </swp-card-title>
                <swp-section-action>@Model.AddColorFormulaText</swp-section-action>
            </swp-card-header>
            @foreach (var entry in Model.ColorFormulas)
            {
                <swp-journal-entry data-entry-id="@entry.Id">
                    <swp-journal-entry-header>
                        <swp-journal-entry-type class="@entry.TypeClass">@entry.Tag</swp-journal-entry-type>
                        <swp-journal-entry-delete><i class="ph ph-trash"></i></swp-journal-entry-delete>
                    </swp-journal-entry-header>
                    <swp-journal-entry-body>
                        @{
                            var lines = entry.Text.Split('\n');
                            foreach (var line in lines)
                            {
                                if (line.Contains(':'))
                                {
                                    var parts = line.Split(':', 2);
                                    <text><span class="label">@parts[0]:</span> <span class="mono">@parts[1].Trim()</span><br></text>
                                }
                                else if (!string.IsNullOrWhiteSpace(line))
                                {
                                    @line<br>
                                }
                                else
                                {
                                    <br>
                                }
                            }
                        }
                    </swp-journal-entry-body>
                    <swp-journal-entry-footer>
                        <swp-journal-entry-date>@entry.FormattedDate</swp-journal-entry-date>
                    </swp-journal-entry-footer>
                </swp-journal-entry>
            }
        </swp-card>
    </swp-card-column>

    <!-- Right Column -->
    <swp-card-column>
        <!-- Analyser card -->
        <swp-card data-journal-type="analysis">
            <swp-card-header>
                <swp-card-title>
                    <span class="col-dot purple"></span>
                    <span>@Model.AnalysesTitle</span>
                </swp-card-title>
                <swp-section-action>@Model.AddAnalysisText</swp-section-action>
            </swp-card-header>
            @foreach (var entry in Model.Analyses)
            {
                <swp-journal-entry data-entry-id="@entry.Id">
                    <swp-journal-entry-header>
                        <swp-journal-entry-type class="@entry.TypeClass">@entry.Tag</swp-journal-entry-type>
                        <swp-journal-entry-delete><i class="ph ph-trash"></i></swp-journal-entry-delete>
                    </swp-journal-entry-header>
                    <swp-journal-entry-body>
                        @{
                            var analysisLines = entry.Text.Split('\n');
                            foreach (var line in analysisLines)
                            {
                                if (line.Contains(':'))
                                {
                                    var parts = line.Split(':', 2);
                                    <text><span class="label">@parts[0]:</span> @parts[1].Trim()<br></text>
                                }
                                else if (!string.IsNullOrWhiteSpace(line))
                                {
                                    @line<br>
                                }
                                else
                                {
                                    <br>
                                }
                            }
                        }
                    </swp-journal-entry-body>
                    <swp-journal-entry-footer>
                        <swp-journal-entry-date>@entry.FormattedDate</swp-journal-entry-date>
                    </swp-journal-entry-footer>
                </swp-journal-entry>
            }
        </swp-card>
    </swp-card-column>
</swp-detail-grid>
