<section class="tab proficiencies major" data-group="primary" data-tab="proficiencies" data-tooltip-class="pf2e">
    <header>{{localize "PF2E.CoreSkillsHeader"}}</header>
    <ul class="proficiencies-list">
        <!-- Core Skills -->
        {{#each data.skills as |skill key|}}
            {{#unless skill.lore}}
                <li>
                    <a class="skill-name" data-action="roll-check" data-statistic="{{skill.slug}}" data-tooltip="{{skill.breakdown}}">
                        <span class="modifier">{{numberFormat skill.value decimals=0 sign=true}}</span>
                        <h4>{{localize skill.label}}</h4>
                    </a>
                    <div class="skill-prof button-group">
                        <select
                            class="skill-proficiency pf-rank"
                            data-property="system.skills.{{key}}.rank"
                            data-rank="{{skill.rank}}"
                            data-dtype="Number"
                        >
                            {{> "systems/pf2e/templates/actors/character/partials/proficiencylevels-dropdown.hbs" proflevel=skill.rank}}
                        </select>
                        <div class="hover-container">
                            <h6 class="hover" data-tooltip-content="#{{@root.options.id}}-{{skill.slug}}-modifiers">{{localize "PF2E.ModifiersTitle"}}</h6>
                        </div>
                    </div>
                    {{#with skill}}
                        {{> "systems/pf2e/templates/actors/partials/modifiers-tooltip.hbs" abpEnabled=@root.abpEnabled title=label}}
                    {{/with}}
                </li>
            {{/unless}}
        {{/each}}
    </ul>

    <!-- Lore Header -->
    <header>
        {{localize "PF2E.LoreSkillsHeader"}}
        <div class="controls">
            <button type="button" class="item-control item-create" data-tooltip="PF2E.CreateSkillTitle" data-type="lore">
                <i class="fa-solid fa-fw fa-plus"></i>{{localize "PF2E.AddShortLabel"}}
            </button>
        </div>
    </header>

    <ul class="proficiencies-list lores-list">
        <!-- Lore Skills -->
        {{#each data.skills as |skill idx|}}
            {{#if skill.lore}}
                <li class="item" data-item-id="{{skill.itemID}}" data-item-type="lore">
                    <a
                        class="modifier"
                        data-action="roll-check"
                        data-statistic="{{skill.slug}}"
                        data-tooltip="{{skill.breakdown}}"
                    >{{numberFormat skill.value decimals=0 sign=true}}</a>
                    <div class="skill-name lore-name-input item-name-input">
                        <input data-item-id="{{skill.itemID}}" data-item-property="name" type="text" value="{{skill.label}}" />
                    </div>
                    <div class="skill-prof button-group skill-container">
                        <select class="skill-proficiency pf-rank adjust-item-stat-select" data-item-property="system.proficient.value" data-tooltip="{{skill.breakdown}}" data-rank="{{skill.rank}}">
                            {{> "systems/pf2e/templates/actors/character/partials/proficiencylevels-dropdown.hbs" proflevel=skill.rank}}
                        </select>
                        {{#if ../editable}}
                            <div class="item-controls">
                                <a class="item-control item-delete skill-armor" data-tooltip="PF2E.DeleteItemTitle"><i class="fa-solid fa-fw fa-trash"></i></a>
                            </div>
                        {{/if}}
                    </div>
                </li>
            {{/if}}
        {{/each}}
    </ul>

    <!-- Attacks -->
    <header class="attacks-defenses">
        {{localize "PF2E.Actor.Character.Proficiency.Attack.Title"}}
        {{#if editable}}
            <div class="controls">
                <button type="button" class="item-control" data-action="add-attack-proficiency" data-tooltip="PF2E.AddCombatProficiency.Title">
                    <i class="fa-solid fa-fw fa-plus"></i>{{localize "PF2E.AddShortLabel"}}
                </button>
            </div>
        {{/if}}
    </header>

    <ul class="proficiencies-list combat-list">
        {{#each martialProficiencies.attacks as |proficiency key|}}
            <li{{#if proficiency.custom}} class="custom"{{/if}} data-slug="{{key}}">
                {{#if (and proficiency.custom @root.editable)}}
                    <a class="delete" data-action="remove-attack-proficiency"><i class="fa-solid fa-fw fa-trash"></i></a>
                {{/if}}
                <span class="modifier" data-tooltip="{{proficiency.breakdown}}">{{numberFormat proficiency.value decimals=0 sign=true}}</span>
                <h4 class="skill-name lore-name-input">{{localize proficiency.label}}</h4>
                <div class="skill-prof button-group skill-container">
                    <select
                        class="skill-proficiency pf-rank{{#if proficiency.immutable}} readonly{{/if}}"
                        data-property="system.proficiencies.attacks.{{key}}.rank"
                        data-rank="{{proficiency.rank}}"
                        data-dtype="Number"
                    >
                        {{> "systems/pf2e/templates/actors/character/partials/proficiencylevels-dropdown.hbs" proflevel=proficiency.rank}}
                    </select>
                </div>
            </li>
        {{/each}}
    </ul>

    <!-- Defenses -->
    <header class="attacks-defenses">
        {{localize "PF2E.Actor.Character.Proficiency.Defense.Title"}}
    </header>
    <ul class="proficiencies-list combat-list">
        {{#each martialProficiencies.defenses as |proficiency key|}}
            <li{{#if proficiency.custom}} class="custom"{{/if}} data-slug="{{key}}">
                {{#if (and proficiency.custom @root.editable)}}
                    <a class="delete" data-action="remove-attack-proficiency"><i class="fa-solid fa-fw fa-trash"></i></a>
                {{/if}}
                <span class="modifier" data-tooltip="{{proficiency.breakdown}}">{{numberFormat proficiency.value decimals=0 sign=true}}</span>
                <h4 class="skill-name">{{localize proficiency.label}}</h4>
                <div class="skill-prof button-group skill-container">
                    <select
                        class="skill-proficiency pf-rank{{#if proficiency.immutable}} readonly{{/if}}"
                        data-property="system.proficiencies.defenses.{{key}}.rank"
                        data-rank="{{proficiency.rank}}"
                        data-dtype="Number"
                    >
                        {{> "systems/pf2e/templates/actors/character/partials/proficiencylevels-dropdown.hbs" proflevel=proficiency.rank}}
                    </select>
                </div>
            </li>
        {{/each}}
    </ul>

    <!-- Spellcasting -->
    {{#if hasNormalSpellcasting}}
        <header>{{localize "PF2E.Item.Spell.Plural"}}</header>
        <ul class="proficiencies-list">
            {{#with document.spellcasting.base as |spellcasting|}}
                <li data-slug="spellcasting">
                    <span class="modifier" data-tooltip="{{spellcasting.breakdown}}">{{numberFormat spellcasting.mod decimals=0 sign=true}}</span>
                    <h4 class="skill-name lore-name-input">{{localize spellcasting.label}}</h4>
                    <div class="skill-prof button-group skill-container">
                        {{#if (gt actor.itemTypes.spellcastingEntry.length 0)}}
                            <select
                                class="skill-proficiency pf-rank"
                                data-action="update-spellcasting-rank"
                                data-rank="{{spellcasting.rank}}"
                            >
                                {{> "systems/pf2e/templates/actors/character/partials/proficiencylevels-dropdown.hbs" proflevel=spellcasting.rank excludeUntrained=true}}
                            </select>
                        {{else}}
                            <div class="button-group">
                                <span class="pf-rank" data-rank="{{spellcasting.rank}}">{{lookup @root.numberToRank spellcasting.rank}}</span>
                            </div>
                        {{/if}}
                    </div>
                </li>
            {{/with}}
        </ul>
    {{/if}}
</section>
