<form class="{{cssClass}}" autocomplete="off">

  {{!-- Sheet Header --}}
  <header class="sheet-header-simple">
    <div style="display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem;">
      <img class="profile-img-small" src="{{actor.img}}" data-action="editImage" title="{{actor.name}}" style="width: 48px; height: 48px; border-radius: 4px; border: 1px solid #8b0000; object-fit: cover; flex-shrink: 0;" />
      <h1 class="charname" style="flex: 1; margin: 0; min-width: 0;"><input name="name" type="text" value="{{actor.name}}" placeholder="Name" {{#if isPlayMode}}disabled{{/if}} /></h1>
      <button type="button" class="sheet-mode-toggle" data-action="toggleSheet" data-tooltip="{{#if isEditMode}}Mode Visualisation{{else}}Mode Édition{{/if}}">
        <i class="{{#if isEditMode}}fas fa-eye{{else}}fas fa-edit{{/if}}"></i>
      </button>
    </div>
  </header>

  {{!-- Sheet Tab Navigation --}}
  <nav class="sheet-tabs tabs" data-group="primary">
    <a class="item" data-tab="principal">{{localize "MNBL.attributes"}}</a>
    <a class="item" data-tab="competences">{{localize "MNBL.skills"}}</a>
    <a class="item" data-tab="equipement">{{localize "MNBL.attacks"}}</a>
    <a class="item" data-tab="biodata">{{localize "MNBL.bio"}}</a>
  </nav>

  {{!-- Sheet Body --}}
  <section class="sheet-body">

    {{!-- Main Tab --}}
    <div class="tab principal" data-group="primary" data-tab="principal">

      <div class="grid grid-2col">

        <div class="sheet-box color-bg-archetype">
          <ul class="item-list alternate-list">
            {{#each data.attributs as |attr key|}}
            <li class="item flexrow " data-attr-key="{{key}}">
              <img class="item-name-img" src="systems/fvtt-mournblade/assets/icons/{{attr.labelnorm}}.webp">
              <span class="item-name-label competence-name item-field-label-medium"><a
                  data-action="rollAttribut" data-attr-key="{{key}}">{{localize attr.label}}</a></span>
              <select class="status-small-label color-class-common item-field-label-short" type="text"
                name="system.attributs.{{key}}.value" value="{{attr.value}}" data-dtype="Number" {{#if @root.isPlayMode}}disabled{{/if}}>
                {{selectOptions @root.config.listeNiveauCreature selected=attr.value}}
              </select>
            </li>
            {{/each}}
          </ul>

          <h4 class="item-name-label competence-name">{{localize "MNBL.health"}}</h4>
          <ul class="item-list alternate-list">
            <li class="item flexrow">
              <label class="label-name">Total</label>
              <input type="text" class="input-numeric-short" name="system.sante.base" value="{{data.sante.base}}"
                  data-dtype="Number" />
            </li>
            <li class="item  flexrow">
              <label class="label-name">{{localize "MNBL.nonlethal"}}</label>
              <a data-action="modifySante" data-type="nonletaux" data-value="-1" class="plus-minus-button">-</a>
              <input type="text" class="input-numeric-short" name="system.sante.nonletaux"
                value="{{data.sante.nonletaux}}" data-dtype="Number" />
              <a data-action="modifySante" data-type="nonletaux" data-value="+1" class="plus-minus-button">+</a>
            </li>
            <li class="item  flexrow">
              <label class="label-name">{{localize "MNBL.lethal"}}</label>
              <a data-action="modifySante" data-type="letaux" data-value="-1" class="plus-minus-button">-</a>
              <input type="text" class="input-numeric-short" name="system.sante.letaux" value="{{data.sante.letaux}}"
                data-dtype="Number" />
              <a data-action="modifySante" data-type="letaux" data-value="+1" class="plus-minus-button">+</a>
            </li>
            <li class="item flexrow">
              <label class="label-name">Malus</label>
              <input type="text" class="input-numeric-short" name="system.sante.malusmanuel"
                value="{{data.sante.malusmanuel}}" data-dtype="Number" />
              <label class="label-name">{{localize "MNBL.automalus"}}</label>
              <label class="label-name">{{santeMalus}}</label>
            </li>
          </ul>

        </div>

        <div class="sheet-box color-bg-archetype">

          <h4 class="item-name-label competence-name">{{localize "MNBL.soul"}}</h4>
          <ul class="item-list alternate-list">
            <li class="item flexrow">
              <label class="label-name">Max</label>
              <input type="text" class="input-numeric-short" name="system.ame.fullmax" {{#if isPlayMode}}disabled{{/if}} value="{{data.ame.fullmax}}"
                data-dtype="Number" />
              <label class="label-name">{{localize "MNBL.currentmax"}}</label>
              <input type="text" class="input-numeric-short" name="system.ame.currentmax" {{#if isPlayMode}}disabled{{/if}}
                value="{{data.ame.currentmax}}" data-dtype="Number" />
            <li class="item flexrow">
              <label class="label-name">{{localize "MNBL.consumed"}}</label>
              <a class="ame-modify plus-minus-button" data-value="-1">-</a>
              <input type="text" class="input-numeric-short" name="system.ame.value" {{#if isPlayMode}}disabled{{/if}} value="{{data.ame.value}}"
                data-dtype="Number" />
              <a class="ame-modify plus-minus-button" data-value="+1">+</a>
            </li>

            <li class="item flexrow">
              <label class="label-name">{{localize "MNBL.automalus"}}</label>
              <label class="label-name">{{ameMalus}}</label>

            </li>
          </ul>

          <h4 class="item-name-label competence-name">Combat</h4>
          <ul class="item-list alternate-list">
            <li class="item flexrow">
              <label class="competence-name">Initiative</label>
              <label class="competence-name">{{combat.initBase}}</label>
              <input type="text" class="input-numeric-short" name="system.combat.initbonus"
                value="{{data.combat.initbonus}}" data-dtype="Number" />
              <label class="competence-name">{{combat.initTotal}}</label>
            </li>
            <li class="item  flexrow">
              <label class="competence-name">{{localize "MNBL.speed"}}</label>
              <label class="competence-name">{{combat.vitesseBase}}</label>
              <input type="text" class="input-numeric-short" name="system.combat.vitessebonus"
                value="{{data.combat.vitessebonus}}" data-dtype="Number" />
              <label class="competence-name">{{combat.vitesseTotal}}</label>
            </li>
            <li class="item  flexrow">
              <label class="competence-name">{{localize "MNBL.defense"}}</label>
              <label class="competence-name">{{combat.defenseBase}}</label>
              <input type="text" class="input-numeric-short" name="system.combat.defensebonus"
                value="{{data.combat.defensebonus}}" data-dtype="Number" />
              <label class="competence-name">{{combat.defenseTotal}}</label>
            </li>
            <li class="item  flexrow">
              <label class="competence-name">{{localize "MNBL.totalprotection"}}</label>
              <label class="competence-name">{{protectionTotal}}</label>
            </li>
            <li class="item  flexrow">
              <label class="competence-name">{{localize "MNBL.ressources"}}</label>
              <input type="text" class="input-numeric-short" name="system.ressources.value"
                value="{{data.ressources.value}}" data-dtype="Number" />
            </li>
          </ul>
        </div>

      </div>

      <div>
        <ul class="item-list alternate-list">
          <li class="item flexrow list-item items-title-bg">
            <span class="item-name-label-header">
              <h3><label class="items-title-text">{{localize "MNBL.modifier"}}</label></h3>
            </span>
            <span class="item-field-label-short">
              <label class="short-label">{{localize "MNBL.type"}}</label>
            </span>
            <span class="item-field-label-short">
              <label class="short-label">{{localize "MNBL.value"}}</label>
            </span>
            <div class="item-filler">&nbsp;</div>
            <div class="item-controls item-controls-fixed">
            </div>
          </li>
          {{#each modifiers as |modifier key|}}
          <li class="item flexrow " data-item-id="{{modifier._id}}" data-item-type="modifier">
            <img class="item-name-img" src="{{modifier.img}}" />
            <span class="item-name-label competence-name">{{modifier.name}}</span>
            <span class="item-field-label-short">{{upperFirst modifier.system.modifiertype}}</span>
            <span class="item-field-label-short">{{modifier.system.value}}</span>
            <div class="item-filler">&nbsp;</div>
            <div class="item-controls item-controls-fixed">
              <a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
              <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
            </div>
          </li>
          {{/each}}
        </ul>
      </div>

    </div>

    {{!-- Competence Tab --}}
    <div class="tab competences" data-group="primary" data-tab="competences">

      <div class="flexrow">

        <div class="sheet-box color-bg-archetype">
          <ul class="item-list alternate-list">
            <li class="item flexrow">
              <span class="item-name-label-header">
                <h3><label class="items-title-text">{{localize "MNBL.skills"}}</label></h3>
              </span>
              <span class="item-field-label-short">
                <label class="short-label">{{localize "MNBL.level"}}</label>
              </span>
              <div class="item-filler">&nbsp;</div>
            </li>
            {{#each skills as |skill key|}}
            <li class="item flexrow " data-item-id="{{skill._id}}" data-item-type="competence">
              <img class="item-name-img" src="{{skill.img}}" />
              <div class="flexcol item-name-label">

                <span class="item-name-label competence-name"><a data-action="rollCompetence"
                    data-attr-key="tochoose">{{skill.name}}</a></span>

                <span class="predilection-text">
                  {{#each skill.system.predilections as |pred key|}}
                  {{pred.name}},
                  {{/each}}
                </span>
              </div>
              <select class="status-small-label color-class-common edit-item-data competence-niveau" type="text"
                data-item-field="niveau" value="{{skill.system.niveau}}" data-dtype="Number">
                {{selectOptions @root.config.listeNiveauSkill selected=skill.system.niveau}}
              </select>

              {{#if (ne skill.system.attribut1 "none")}}
              <span class="item-field-label-short">
                <button class="button-sheet-roll" data-action="rollCompetence" data-attr-key="{{skill.system.attribut1}}">{{upper
                  skill.system.attribut1}} : {{skill.system.attribut1total}}</button>
              </span>
              {{/if}}
              {{#if (ne skill.system.attribut2 "none")}}
              <span class="item-field-label-short">
                <button class="button-sheet-roll" data-action="rollCompetence" data-attr-key="{{skill.system.attribut2}}">{{upper
                  skill.system.attribut2}} : {{skill.system.attribut2total}}</button>
              </span>
              {{/if}}
              {{#if (ne skill.system.attribut3 "none")}}
              <span class="item-field-label-short">
                <button class="button-sheet-roll" data-action="rollCompetence" data-attr-key="{{skill.system.attribut3}}">{{upper
                  skill.system.attribut3}} : {{skill.system.attribut3total}}</button>
              </span>
              {{/if}}

              <div class="item-filler">&nbsp;</div>
              <div class="item-controls item-controls-fixed">
                <a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
                <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
              </div>
            </li>
            {{/each}}
          </ul>
        </div>

      </div>

    </div>

    {{!-- Equipement Tab --}}
    <div class="tab equipement" data-group="primary" data-tab="equipement">

      <div class="flexcol">
        <div class="sheet-box color-bg-archetype">
          <ul class="item-list alternate-list">
            <li class="item flexrow list-item items-title-bg">
              <span class="item-name-label-header">
                <h3><label class="items-title-text">{{localize "MNBL.weaponscapacities"}}</label></h3>
              </span>
              <span class="item-field-label-short">
                <label class="short-label">{{localize "MNBL.attack"}}</label>
              </span>
              <span class="item-field-label-short">
                <label class="short-label">{{localize "MNBL.defense"}}</label>
              </span>
              <span class="item-field-label-short">
                <label class="short-label">{{localize "MNBL.damage"}}</label>
              </span>
              <div class="item-filler">&nbsp;</div>
              <div class="item-controls item-controls-fixed">
                <a class="item-control item-add" data-type="arme" title="Ajouter une arme"><i
                    class="fas fa-plus"></i></a>
              </div>
            </li>
            {{#each armes as |arme key|}}
            <li class="item flexrow " data-item-id="{{arme._id}}" data-item-type="arme">
              <img class="item-name-img" src="{{arme.img}}" />
              <span class="item-name-label competence-name">{{arme.name}}</span>

              <span class="item-field-label-short">
                {{#if (eq arme.system.typearme "special")}}
                <button class="button-sheet-roll" data-action="rollArmeSpecial" data-arme-id="{{arme._id}}">{{localize "MNBL.use"}}</button>
                {{else}}
                  {{#if arme.system.equipped}}
                  <button class="button-sheet-roll" data-action="rollArmeOffensif" data-arme-id="{{arme._id}}">{{arme.system.totalOffensif}}</button>
                  {{else}}
                  <button disabled class="button-sheet-roll">{{arme.system.totalOffensif}}</button>
                  {{/if}}
                {{/if}}
              </span>

              {{#if arme.system.isdefense}}
              <span class="item-field-label-short arme-defensif"><label
                  class="arme-defensif">{{arme.system.totalDefensif}}</label></span>
              {{else}}
              <span class="item-field-label-short arme-defensif"><label class="arme-defensif">-</label></span>
              {{/if}}

              {{#if (eq arme.system.typearme "special")}}
              <span class="item-field-label-short arme-defensif"><label class="arme-defensif">-</label></span>
            {{else}}
              <span class="item-field-label-short">
                  {{#if arme.system.equipped}}
                  <button class="button-sheet-roll" data-action="rollArmeDegats" data-arme-id="{{arme._id}}">{{arme.system.totalDegats}}</button>
                  {{else}}
                  <button disabled class="button-sheet-roll">{{arme.system.totalDegats}}</button>
                  {{/if}}
              </span>
            {{/if}}
    
              <div class="item-filler">&nbsp;</div>
              <div class="item-controls item-controls-fixed">
                <a class="item-control item-equip" title="Worn">{{#if arme.system.equipped}}<i
                    class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
                <a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
                <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
              </div>
            </li>
            {{/each}}
          </ul>
        </div>

        <div class="sheet-box color-bg-archetype">
          <ul class="item-list alternate-list">
            <li class="item flexrow list-item items-title-bg">
              <span class="item-name-label-header">
                <h3><label class="items-title-text">Protections</label></h3>
              </span>
              <span class="item-field-label-short">
                <label class="short-label">Protection</label>
              </span>
              <div class="item-filler">&nbsp;</div>
              <div class="item-controls item-controls-fixed">
                <a class="item-control item-add" data-type="protection" title="Ajouter une protection"><i
                    class="fas fa-plus"></i></a>
              </div>
            </li>
            {{#each protections as |protection key|}}
            <li class="item flexrow " data-item-id="{{protection._id}}" data-item-type="protection">
              <img class="item-name-img" src="{{protection.img}}" />
              <span class="item-name-label competence-name">{{protection.name}}</span>
              <span class="item-field-label-short arme-defensif"><label
                  class="arme-defensif">{{protection.system.protection}}</label>
              </span>
              <div class="item-filler">&nbsp;</div>
              <div class="item-controls item-controls-fixed">
                <a class="item-control item-equip" title="Worn">{{#if protection.system.equipped}}<i
                    class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
                <a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
                <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
              </div>
            </li>
            {{/each}}
          </ul>
        </div>

        <div class="sheet-box color-bg-archetype">
          <ul class="item-list alternate-list">
            <li class="item flexrow list-item items-title-bg">
              <span class="item-name-label-header">
                <h3><label class="items-title-text">{{localize "MNBL.speciestrait"}}</label></h3>
              </span>
              <div class="item-filler">&nbsp;</div>
              <div class="item-controls item-controls-fixed">
                <a class="item-control item-add" data-type="traitespece" title="Ajouter un trait d'espèce"><i
                    class="fas fa-plus"></i></a>
              </div>
            </li>
            {{#each traitsEspeces as |trait key|}}
            <li class="item flexrow " data-item-id="{{trait._id}}" data-item-type="traitespece">
              <img class="item-name-img" src="{{trait.img}}" />
              <span class="item-name-label competence-name">{{trait.name}}</span>
              <div class="item-filler">&nbsp;</div>
              <div class="item-controls item-controls-fixed">
                <a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
                <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
              </div>
            </li>
            {{/each}}
          </ul>
        </div>
        
        {{#if (count runes)}}
        <div class="sheet-box color-bg-archetype">
          <ul class="item-list alternate-list">
            <li class="item flexrow list-item items-title-bg">
              <span class="item-name-label-header">
                <h3><label class="items-title-text">Runes</label></h3>
              </span>
              <span class="item-field-label-long">
                <label class="short-label">{{localize "MNBL.highlanguage"}}</label>
              </span>
              <span class="item-field-label-short">
                <label class="short-label">{{localize "MNBL.difficulty"}}</label>
              </span>
              <div class="item-filler">&nbsp;</div>
              <div class="item-controls item-controls-fixed">
              </div>
            </li>
            {{#each runes as |rune key|}}
            <li class="item flexrow " data-item-id="{{rune._id}}" data-item-type="rune">
              <img class="item-name-img" src="{{rune.img}}" />
              <span class="item-name-label competence-name"><a data-action="rollRune">{{rune.name}}</a></span>
              <span class="item-field-label-long">{{rune.system.formule}}</span>
              <span class="item-field-label-short">{{rune.system.seuil}}</span>
              <div class="item-filler">&nbsp;</div>
              <div class="item-controls item-controls-fixed">
                <a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
                <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
              </div>
            </li>
            {{/each}}
          </ul>
        </div>
        {{/if}}

        {{#if (count equipements)}}
        <div class="sheet-box color-bg-archetype">
          <ul class="item-list alternate-list">
            <li class="item flexrow list-item items-title-bg">
              <span class="item-name-label-header">
                <h3><label class="items-title-text">{{localize "MNBL.equipments"}}</label></h3>
              </span>
              <div class="item-filler">&nbsp;</div>
              <div class="item-controls item-controls-fixed">
                <a class="item-control item-add" data-type="equipement" title="Ajouter un équipement"><i
                    class="fas fa-plus"></i></a>
              </div>
            </li>
            {{#each equipements as |equipement key|}}
            <li class="item flexrow " data-item-id="{{equipement._id}}" data-item-type="equipement">
              <img class="item-name-img" src="{{equipement.img}}" />
              <span class="item-name-label competence-name">{{equipement.name}}</span>
              <div class="item-filler">&nbsp;</div>
              <div class="item-controls item-controls-fixed">
                <a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
                <a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
              </div>
            </li>
            {{/each}}
          </ul>
        </div>
        {{/if}}

      </div>

    </div>


    {{!-- Biography Tab --}}
    <div class="tab biodata" data-group="primary" data-tab="biodata">

      {{#if isGM}}
      <div class="grid grid-2col">
        <div>
          <ul class="item-list alternate-list">
            <li class="flexrow item">
              <label class="generic-label">{{localize "MNBL.soulmultiplier"}}</label>
              <input type="text" class="input-numeric-short" name="system.biodata.amemultiplier"
                value="{{data.biodata.amemultiplier}}" data-dtype="Number" />
            </li>
          </ul>
        </div>
        <div>
          <ul class="item-list alternate-list">
            <li class="flexrow item">
              <label class="generic-label">{{localize "MNBL.ignorehealthmalus"}} ?</label>
              <input type="checkbox" name="system.biodata.ignoresantemalus" {{checked data.biodata.ignoresantemalus}} />
            </li>
            <li class="flexrow item">
              <label class="generic-label">{{localize "MNBL.ignoresoulmalus"}} ?</label>
              <input type="checkbox" name="system.biodata.ignoreamemalus" {{checked data.biodata.ignoreamemalus}} />
            </li>
          </ul>
        </div>
      </div>
      {{/if}}

      <span>
        <h3>Description</h3>
      </span>
      <div class="medium-editor item-text-long-line">
        {{editor description target="system.biodata.description" button=true owner=owner editable=editable}}
      </div>

    </div>

  </section>
</form>