<div class="les-oublies-chat-card {{#if result}}{{#if result.success}}is-success{{else}}is-failure{{/if}}{{/if}}">
  <header class="chat-card-header">
    <div class="chat-card-banner">
      <img class="chat-card-portrait" src="{{actor.img}}" alt="{{actor.name}}" />
      <div class="chat-card-heading">
        <p class="chat-card-kicker">{{#if result}}Action{{else}}Résolution{{/if}}</p>
        <h3>{{#if action}}{{action.title}}{{else}}{{result.label}}{{/if}}</h3>
        <p class="chat-card-subtitle"><strong>{{actor.name}}</strong>{{#if action.subtitle}} · {{action.subtitle}}{{/if}}</p>
      </div>
      {{#if result}}
        <div class="chat-card-badge {{#if result.success}}success{{else}}failure{{/if}}">{{result.successLabel}}</div>
      {{/if}}
    </div>
  </header>

  <section class="chat-card-body">
    {{#if result}}
      <div class="roll-summary-grid">
        <div><span>{{localize "LESOUBLIES.rolls.score"}}</span><strong>{{result.score}}</strong></div>
        <div><span>{{localize "LESOUBLIES.rolls.difficulty"}}</span><strong>{{numberFormat result.difficulty sign=true}}</strong></div>
        <div><span>{{localize "LESOUBLIES.rolls.natural"}}</span><strong>{{result.natural}}</strong></div>
        <div><span>{{localize "LESOUBLIES.rolls.final"}}</span><strong>{{result.final}}</strong></div>
        <div><span>{{localize "LESOUBLIES.rolls.threshold"}}</span><strong>{{result.threshold}}+</strong></div>
        <div><span>{{localize "LESOUBLIES.rolls.margin"}}</span><strong>{{numberFormat result.margin sign=true}}</strong></div>
      </div>

      <p class="roll-formula"><strong>{{localize "LESOUBLIES.rolls.resolution"}}</strong> : {{result.natural}} + {{result.score}} {{numberFormat result.difficulty sign=true}}{{#if result.finalModifier}} {{numberFormat result.finalModifier sign=true}}{{/if}} = {{result.final}}</p>

      <div class="dice-strip">
        {{#each result.dice as |die|}}
          <div class="die-chip {{#if (eq die.index @root.result.selectedDie.index)}}selected{{/if}}">
            <strong>{{die.typeLabel}}</strong>
            <span>{{die.breakdown}}</span>
            {{#if die.exploded}}<em>{{localize "LESOUBLIES.rolls.exploded"}}</em>{{/if}}
            {{#if die.sourceLabel}}<em>{{die.sourceLabel}}</em>{{/if}}
          </div>
        {{/each}}
      </div>
    {{/if}}

    {{#if action.hint}}
      <p class="roll-formula"><strong>Rappel</strong> : {{action.hint}}</p>
    {{/if}}

    {{#if action.modifiers.labels.length}}
      <div class="chat-callouts">
        <div class="chat-callout">
          <span>Modificateurs</span>
          <strong>{{join action.modifiers.labels}}</strong>
        </div>
      </div>
    {{/if}}

    {{#if action.outcome}}
      {{#if result}}
        {{#if result.success}}
          <div class="chat-callouts">
            <div class="chat-callout">
              <span>{{action.outcome.label}}</span>
              <strong>{{action.outcome.description}}</strong>
            </div>
          </div>
        {{/if}}
      {{else}}
        <div class="chat-callouts">
          <div class="chat-callout">
            <span>{{action.outcome.label}}</span>
            <strong>{{action.outcome.description}}</strong>
          </div>
        </div>
      {{/if}}
    {{/if}}

    {{#if action.damage}}
      <div class="chat-callouts">
        <div class="chat-callout">
          <span>Dégâts de base</span>
          <strong>{{action.damage.baseLabel}}</strong>
        </div>
        <div class="chat-callout">
          <span>Protection</span>
          <strong>{{action.damage.effectiveProtection}}</strong>
          <em>{{action.damage.targetLabel}}</em>
        </div>
        <div class="chat-callout">
          <span>Dégâts finaux</span>
          <strong>{{action.damage.finalDamage}}</strong>
          {{#if action.damage.nonLethal}}<em>Non létal</em>{{/if}}
        </div>
      </div>
    {{/if}}

    {{#if action.harvest}}
      <div class="chat-callouts">
        <div class="chat-callout">
          <span>Récolte</span>
          <strong>{{action.harvest.threadCount}} fil{{#unless (eq action.harvest.threadCount 1)}}s{{/unless}} de {{action.harvest.threadType}}</strong>
          <em>{{action.harvest.sleeperLabel}}</em>
        </div>
        <div class="chat-callout">
          <span>Stockage</span>
          <strong>{{action.harvest.destinationLabel}}</strong>
          <em>{{#if action.harvest.stored}}Réserve créditée{{else}}Aucun fil stocké{{/if}}</em>
        </div>
        <div class="chat-callout">
          <span>Dégâts subis</span>
          <strong>{{action.harvest.damageTaken}}</strong>
        </div>
        <div class="chat-callout">
          <span>Après le Néphertine</span>
          <strong>{{action.harvest.durationHours}} h</strong>
          <em>{{action.harvest.sideEffectText}}</em>
        </div>
      </div>
    {{/if}}

    {{#if action.notes}}
      <p class="roll-formula"><strong>Notes</strong> : {{action.notes}}</p>
    {{/if}}
  </section>
</div>
