<header class="combat-tracker-header">

    {{!-- Encounter Controls --}}
    {{#if user.isGM}}
    <nav class="encounters {{ css }}" aria-label="{{ localize "COMBAT.NavLabel" }}">

        {{!-- Cycle Display --}}
        {{#if displayCycle}}
        <button type="button" class="inline-control icon fa-solid fa-plus" data-action="createCombat"
                data-tooltip aria-label="{{ localize "COMBAT.Create" }}"></button>

        <div class="cycle-combats">
            <button type="button" class="inline-control icon fa-solid fa-caret-left" data-action="cycleCombat"
                    {{#if previousId}}data-combat-id="{{ previousId }}" {{else}}disabled{{/if}}
                    data-tooltip aria-label="{{ localize "COMBAT.EncounterPrevious" }}"></button>
            <div class="encounter-count">
                <span class="value">{{ currentIndex }}</span>
                <span class="separator">&sol;</span>
                <span class="max">{{ combats.length }}</span>
            </div>
            <button type="button" class="inline-control icon fa-solid fa-caret-right" data-action="cycleCombat"
                    {{#if nextId}}data-combat-id="{{ nextId }}" {{else}}disabled{{/if}}
                    data-tooltip aria-label="{{ localize "COMBAT.EncounterNext" }}"></button>
        </div>

        <button type="button" class="inline-control icon fa-solid fa-gear" data-action="trackerSettings"
                data-tooltip aria-label="{{ localize "COMBAT.Settings" }}"></button>

        {{!-- Tabbed Display --}}
        {{else if combats.length}}
        <button type="button" class="inline-control icon fa-solid fa-plus" data-action="createCombat"
                data-tooltip aria-label="{{ localize "COMBAT.Create" }}"></button>
        {{#each combats}}
        <button type="button" class="inline-control {{#if active}}active{{/if}}" data-action="cycleCombat"
                data-combat-id="{{ id }}">
            {{ label }}
        </button>
        {{/each}}
        <button type="button" class="inline-control icon fa-solid fa-gear" data-action="trackerSettings"
                data-tooltip aria-label="{{ localize "COMBAT.Settings" }}"></button>

        {{!-- No Combats --}}
        {{else}}
        <button type="button" class="combat-control-lg" data-action="createCombat">
            <i class="fa-solid fa-plus" inert></i>
            <span>{{ localize "COMBAT.Create" }}</span>
        </button>

        {{/if}}
    </nav>
    {{/if}}

    <div class="encounter-controls {{#if hasCombat}}combat{{/if}}">

        {{!-- Bulk Rolls --}}
        <div class="control-buttons left flexrow">
            {{#if user.isGM}}
            <button type="button" class="inline-control combat-control icon fa-solid fa-users" data-action="rollAll"
                    {{#unless combat.turns.length}}disabled{{/unless}} data-tooltip="COMBAT.RollAll"
                    aria-label="{{ localize "COMBAT.RollAll" }}"></button>
            <button type="button" class="inline-control combat-control icon fa-solid fa-users-cog" data-action="rollNPC"
                    {{#unless combat.turns.length}}disabled{{/unless}} data-tooltip="COMBAT.RollNPC"
                    aria-label="{{ localize "COMBAT.RollNPC" }}"></button>
            {{else}}
            <div class="spacer"></div>
            <div class="spacer"></div>
            {{/if}}
        </div>

        {{!-- Combat Status --}}
        <strong class="encounter-title">
            {{#if combats.length}}
            {{#if (or combat.round (eq combat.turn 0))}}
            {{ localize "COMBAT.Round" round=combat.round }}
            {{else}}
            {{ localize "COMBAT.NotStarted" }}
            {{/if}}
            {{else}}
            {{ localize "COMBAT.None" }}
            {{/if}}
        </strong>

        {{!-- Combat Controls --}}
        <div class="control-buttons right flexrow">
            <div class="spacer"></div>
            <button type="button" class="encounter-context-menu inline-control combat-control icon fa-solid fa-ellipsis-vertical"
                    {{#unless (and user.isGM hasCombat)}}disabled{{/unless}}></button>
        </div>

    </div>

</header>
