{{!-- Modificação do mh-chat-roll.hbs --}}

<div class="roll-container">
  <div class="mhr-roll-title mh-dropshadow-{{themeCategory}}">{{localize moveName}}</div>
  {{#if subtitle}}
  <div class="mhr-roll-subtitle">{{subtitle}}</div>
  {{/if}}
  {{#if subtitleImg}}
    <div class="mhr-subtitleImg mh-dropshadow-{{themeCategory}}" style="display: block;"><img src="{{subtitleImg}}"></div>
  {{/if}}
  
  {{!-- Dice rolls - escondida no sistema Legends in the Mist --}}
  {{#if rollResults}}
  {{#unless (eq activeSystem "legend")}}
  <div class="mh-dice-rolls">
      {{#each rollResults}}
        <div class="{{this.mainDiceClass}}">{{this.value}}</div>
      {{/each}}
  </div>
  <div class="{{diceClass}}"></div>
  {{/unless}}
  {{/if}}

  {{!-- Tags and modifiers section --}}
  {{!-- <div class="accordion-container">
    <div class="mhr-roll-mdf accordion-header clickable">
      {{#if themeCount}}
      <span class="mhr-icon {{themeCategory}}"></span><span> {{themeCount}}</span>
      {{/if}}
      {{#if calculatedPower}}
        <span><i class="fa-light fa-bolt"></i> {{calculatedPower}}</span>
      {{/if}}
      {{#if totalCrewPowerTags}}
        <span><i class="fa-solid fa-users"></i> {{totalCrewPowerTags}}</span>
      {{/if}}
      {{#if totalLoadoutTags}}
        <span><i class="fa-regular fa-gear"></i> {{totalLoadoutTags}}</span>
      {{/if}}
      {{#if totalWeakness}}
        <span><i class="fa-light fa-angles-down mhr-mls"></i> {{totalWeakness}}</span>
      {{/if}}
      {{#if totalCrewWeaknessTags}}
        <span><i class="fa-solid fa-users-slash"></i> {{totalCrewWeaknessTags}}</span>
      {{/if}}
      {{#if totalStoryTags}}
        <span><i class="fa-light fa-tag mhr-mls" style="transform: scaleX(-1);"></i> {{totalStoryTags}}</span>
      {{/if}}
      {{#if totalCharStatuses}}
        <span><i class="fa-light fa-suitcase-medical"></i> {{totalCharStatuses}}</span>
      {{/if}}
      {{#if totalScnTags}}
        <span><i class="fa-solid fa-tag mhr-mls"></i> {{totalScnTags}}</span>
      {{/if}}
      {{#if totalSceneStatuses}}
        <span><i class="fa-solid fa-suitcase-medical"></i> {{totalSceneStatuses}}</span>
      {{/if}}
      {{#if totalBonus}}
        <span><i class="fa-solid fa-life-ring"></i> {{totalBonus}}</span>
      {{/if}}
      {{#if (neq this.totalNpcInfluence 0)}}
        <span class="npc-influence"><i class="fa-solid fa-skull"></i> {{totalNpcInfluence}}</span>
      {{/if}}
      {{#if modifier}}
        <span><i class="fa-regular fa-hexagon-plus"></i> {{modifier}}</span>
      {{/if}}
    </div> --}}

    <div class="tags-section accordion-content">
      <span class="tag-row">
        {{#each tagsData.powerTags}}
          <span class="mhr-power-tag {{stateClass}}">{{tagName}}</span>
        {{/each}}
        {{#each tagsData.loadoutTags}}
          <span class="mhr-power-tag {{stateClass}}">{{tagName}}</span>
        {{/each}}
        {{#each tagsData.weaknessTags}}
          <span class="mhr-weakness-tag {{stateClass}}">{{tagName}}</span>
        {{/each}}
        {{#each tagsData.storyTags}}
          <span class="mhr-story-tag {{stateClass}} {{#if temporary}}mhr-temporary-tag{{/if}}">
            <i class="fa-light fa-tag" style="transform: scaleX(-1);"></i> {{tagName}} 
            {{#if temporary}}<i class="fa-regular fa-hourglass-half"></i>{{/if}}
            {{#if permanent}}<i class="fa-solid fa-gem"></i>{{/if}}
          </span>
        {{/each}}
        {{#each tagsData.statuses}}
          <span class="mhr-status-tag {{typeClass}} {{#if temporary}}mhr-temporary-status{{/if}} {{#if permanent}}mhr-permanent-status{{/if}}">
            <i class="fa-light fa-suitcase-medical"></i> {{name}}-{{tier}}
            {{#if temporary}}<i class="fa-regular fa-hourglass-half"></i>{{/if}}
            {{#if permanent}}<i class="fa-solid fa-gem"></i>{{/if}}
          </span>
        {{/each}}
        {{#each tagsData.scnTags}}   
        <span class="scene-tag-item {{#if (eq this.type "positive")}}scene-positive{{else}}scene-negative{{/if}}">
          <i class="fa-solid fa-tag"></i> {{this.name}}
          {{#if this.temporary}}<i class="fa-regular fa-hourglass-half"></i>{{/if}}
          {{#if this.permanent}}<i class="fa-solid fa-gem"></i>{{/if}}
        </span>
        {{/each}}
        {{#each tagsData.sceneStatuses}}
          <span class="mhr-scene-status-tag {{typeClass}}">
            <i class="fa-solid fa-suitcase-medical"></i> {{name}}-{{tier}}
            {{#if temporary}}<i class="fa-regular fa-hourglass-half"></i>{{/if}}
            {{#if permanent}}<i class="fa-solid fa-gem"></i>{{/if}}
          </span>
        {{/each}}
        {{#if (neq modifier 0)}}
          <span class="mhr-modifier {{#if (gt modifier 0)}}positive{{else}}negative{{/if}}">
            <i class="fa-regular fa-hexagon-plus"></i> {{#if (gt totalNpcInfluence 0)}}+{{modifier}}{{else}}-{{modifier}}{{/if}}
          </span>
        {{/if}}
        {{#if (neq this.totalNpcInfluence 0)}}
          <span class="mhr-npc-influence-tag {{#if (gt totalNpcInfluence 0)}}positive{{else}}negative{{/if}}">
            <i class="fa-solid fa-skull"></i> 
            {{#if (gt totalNpcInfluence 0)}}+{{totalNpcInfluence}}{{else}}{{totalNpcInfluence}}{{/if}}
          </span>
        {{/if}}
        {{#each helpHurtMessages}}
          <span class="mhr-help-hurt-tag {{#if (eq this.type "help")}}positive{{else}}negative{{/if}}">
            {{#if (eq this.type "help")}}
            <i class="fa-solid fa-life-ring"></i> {{this.giverName}} +{{this.amount}}
            {{else}}
            <i class="fa-solid fa-life-ring"></i> {{this.giverName}} -{{this.amount}}
            {{/if}}
          </span>
        {{/each}}
      </span>
    </div>
  </div>

  {{#if rollTotal}}
  <hr class="mhr-roll-divider">
  {{/if}}

  {{!-- Dice rolls - hidden only for systems that don't need them in top --}}
  {{#if rollResults}}
  <div class="mh-dice-rolls">
      {{#each rollResults}}
        <div class="{{this.mainDiceClass}}">{{this.value}}</div>
      {{/each}}
  </div>
  <div class="{{diceClass}}"></div>
  {{/if}}

  {{!-- Tags and modifiers section --}}
  <div class="accordion-container">
    <div class="mhr-roll-mdf accordion-header clickable">
      {{#if themeCount}}
      <span class="mhr-icon {{themeCategory}}"></span><span> {{themeCount}}</span>
      {{/if}}
      {{#if calculatedPower}}
        <span><i class="fa-light fa-bolt"></i> {{calculatedPower}}</span>
      {{/if}}
      {{#if totalCrewPowerTags}}
        <span><i class="fa-solid fa-users"></i> {{totalCrewPowerTags}}</span>
      {{/if}}
      {{#if totalLoadoutTags}}
        <span><i class="fa-regular fa-gear"></i> {{totalLoadoutTags}}</span>
      {{/if}}
      {{#if totalWeakness}}
        <span><i class="fa-light fa-angles-down mhr-mls"></i> {{totalWeakness}}</span>
      {{/if}}
      {{#if totalCrewWeaknessTags}}
        <span><i class="fa-solid fa-users-slash"></i> {{totalCrewWeaknessTags}}</span>
      {{/if}}
      {{#if totalStoryTags}}
        <span><i class="fa-light fa-tag mhr-mls" style="transform: scaleX(-1);"></i> {{totalStoryTags}}</span>
      {{/if}}
      {{#if totalCharStatuses}}
        <span><i class="fa-light fa-suitcase-medical"></i> {{totalCharStatuses}}</span>
      {{/if}}
      {{#if totalScnTags}}
        <span><i class="fa-solid fa-tag mhr-mls"></i> {{totalScnTags}}</span>
      {{/if}}
      {{#if totalSceneStatuses}}
        <span><i class="fa-solid fa-suitcase-medical"></i> {{totalSceneStatuses}}</span>
      {{/if}}
      {{#if totalBonus}}
        <span><i class="fa-solid fa-life-ring"></i> {{totalBonus}}</span>
      {{/if}}
      {{#if (neq this.totalNpcInfluence 0)}}
        <span class="npc-influence"><i class="fa-solid fa-skull"></i> {{totalNpcInfluence}}</span>
      {{/if}}
      {{#if modifier}}
        <span><i class="fa-regular fa-hexagon-plus"></i> {{modifier}}</span>
      {{/if}}
    </div>

    <div class="tags-section accordion-content">
      <span class="tag-row">
        {{#each tagsData.powerTags}}
          <span class="mhr-power-tag {{stateClass}}">{{tagName}}</span>
        {{/each}}
        {{#each tagsData.loadoutTags}}
          <span class="mhr-power-tag {{stateClass}}">{{tagName}}</span>
        {{/each}}
        {{#each tagsData.weaknessTags}}
          <span class="mhr-weakness-tag {{stateClass}}">{{tagName}}</span>
        {{/each}}
        {{#each tagsData.storyTags}}
          <span class="mhr-story-tag {{stateClass}} {{#if temporary}}mhr-temporary-tag{{/if}}">
            <i class="fa-light fa-tag" style="transform: scaleX(-1);"></i> {{tagName}} 
            {{#if temporary}}<i class="fa-regular fa-hourglass-half"></i>{{/if}}
            {{#if permanent}}<i class="fa-solid fa-gem"></i>{{/if}}
          </span>
        {{/each}}
        {{#each tagsData.statuses}}
          <span class="mhr-status-tag {{typeClass}} {{#if temporary}}mhr-temporary-status{{/if}} {{#if permanent}}mhr-permanent-status{{/if}}">
            <i class="fa-light fa-suitcase-medical"></i> {{name}}-{{tier}}
            {{#if temporary}}<i class="fa-regular fa-hourglass-half"></i>{{/if}}
            {{#if permanent}}<i class="fa-solid fa-gem"></i>{{/if}}
          </span>
        {{/each}}
        {{#each tagsData.scnTags}}   
        <span class="scene-tag-item {{#if (eq this.type "positive")}}scene-positive{{else}}scene-negative{{/if}}">
          <i class="fa-solid fa-tag"></i> {{this.name}}
          {{#if this.temporary}}<i class="fa-regular fa-hourglass-half"></i>{{/if}}
          {{#if this.permanent}}<i class="fa-solid fa-gem"></i>{{/if}}
        </span>
        {{/each}}
        {{#each tagsData.sceneStatuses}}
          <span class="mhr-scene-status-tag {{typeClass}}">
            <i class="fa-solid fa-suitcase-medical"></i> {{name}}-{{tier}}
            {{#if temporary}}<i class="fa-regular fa-hourglass-half"></i>{{/if}}
            {{#if permanent}}<i class="fa-solid fa-gem"></i>{{/if}}
          </span>
        {{/each}}
        {{#if (neq modifier 0)}}
          <span class="mhr-modifier {{#if (gt modifier 0)}}positive{{else}}negative{{/if}}">
            <i class="fa-regular fa-hexagon-plus"></i> {{#if (gt totalNpcInfluence 0)}}+{{modifier}}{{else}}-{{modifier}}{{/if}}
          </span>
        {{/if}}
        {{#if (neq this.totalNpcInfluence 0)}}
          <span class="mhr-npc-influence-tag {{#if (gt totalNpcInfluence 0)}}positive{{else}}negative{{/if}}">
            <i class="fa-solid fa-skull"></i> 
            {{#if (gt totalNpcInfluence 0)}}+{{totalNpcInfluence}}{{else}}{{totalNpcInfluence}}{{/if}}
          </span>
        {{/if}}
        {{#each helpHurtMessages}}
          <span class="mhr-help-hurt-tag {{#if (eq this.type "help")}}positive{{else}}negative{{/if}}">
            {{#if (eq this.type "help")}}
            <i class="fa-solid fa-life-ring"></i> {{this.giverName}} +{{this.amount}}
            {{else}}
            <i class="fa-solid fa-life-ring"></i> {{this.giverName}} -{{this.amount}}
            {{/if}}
          </span>
        {{/each}}
      </span>
    </div>
  </div>

  {{!-- Roll result - ONLY for systems that are NOT "legend" --}}
  {{#unless (eq activeSystem "legend")}}
  {{#if rollTotal}}
  <hr class="mhr-roll-divider">
  <div class="mhr-roll-result {{outcomeClass}}">
    {{{rollTotal}}}
  </div>
  {{/if}}
  {{/unless}}

  {{#if rollTotal}}
  <hr class="mhr-roll-divider">
  {{/if}}

  {{!-- Outcome section --}}
  <div class="mhr-outcome {{outcomeClass}}">
    {{#if (eq activeSystem "legend")}}
      {{!-- For Legends: number + icon inside the outcome box --}}
      <div class="roll-total-with-icon">
        <div class="roll-number">{{{rollTotal}}}</div>
        <div class="outcome-icon {{outcomeClass}}"></div>
      </div>
    {{/if}}
    {{localize outcomeMessage}}
  </div>

  <!-- Move Effects List -->
  {{#if localizedMoveEffects.length}}
    <ul class="mhr-move-list">
      {{#each localizedMoveEffects}}
      <hr class="mhr-divider">
        <li>{{this}}</li>
      {{/each}}
    </ul>
  {{/if}}
</div>

{{#if trackedEffects.length}}
<div class="mh-trackedfx-container accordion-container">
    {{#each trackedEffects}}
    <div class="mh-trackedfx-item">
        <div class="accordion-header clickable"><span class="mh-trackedfx-name">{{name}}: </span><span class="mh-trackedfx-description">{{description}}</span></div>
        <div class="mh-trackedfx-tags accordion-content">
        {{#each tags}}<span class="mh-trackedfx-tag">{{this}}</span>{{#unless @last}}, {{/unless}}{{/each}}
        </div>
        <div class="mh-trackedfx-cost">{{{cost}}}</div>
    </div>
    {{/each}}
</div>
{{/if}}