<div class="mournblade-chat-result">
  {{!-- Header --}}
  <div class="chat-result-header">
    {{#if actorImg}}
    <img class="actor-icon" src="{{actorImg}}" alt="{{alias}}" />
    {{/if}}
    <div class="header-info">
      <h4 class="actor-name">{{alias}}</h4>
      <div class="action-title">
        <i class="fas fa-star-of-david"></i> Sortilège
      </div>
    </div>
  </div>

  {{!-- Résultat principal --}}
  <div class="result-main">
    <div class="result-display">
      <div class="dice-result">
        <i class="fas fa-dice"></i>
        <span class="dice-value">{{diceResult}}</span>
      </div>
      <div class="total-result">
        <span class="total-label">Total</span>
        <span class="total-value">{{finalResult}}</span>
      </div>
      {{#if difficulte}}
      <div class="difficulty">
        <span class="difficulty-label">SD</span>
        <span class="difficulty-value">{{difficulte}}</span>
      </div>
      {{/if}}
    </div>

    {{#if difficulte}}
    <div class="result-badge-container">
      {{#if isHeroique}}
      <div class="result-badge heroique">
        <i class="fas fa-star"></i> HÉROÏQUE !
      </div>
      {{else if isDramatique}}
      <div class="result-badge dramatique">
        <i class="fas fa-skull"></i> DRAMATIQUE !
      </div>
      {{else if isSuccess}}
      <div class="result-badge success">
        <i class="fas fa-check"></i> Succès
      </div>
      {{else}}
      <div class="result-badge failure">
        <i class="fas fa-times"></i> Échec
      </div>
      {{/if}}
    </div>
    {{/if}}
  </div>

  {{#if isImpair}}
  <div class="result-warning">
    <i class="fas fa-circle-half-stroke"></i> {{localize "MNBL.oddresult"}}
  </div>
  {{/if}}

  {{!-- Détails du sortilège --}}
  <div class="result-details">
    <div class="details-section">
      <div class="detail-row">
        <span class="detail-label">Formule :</span>
        <span class="detail-value">{{diceFormula}}</span>
      </div>
      <div class="detail-row">
        <span class="detail-label">Mode :</span>
        <span class="detail-value">{{runemode}}</span>
      </div>
      <div class="detail-row">
        <span class="detail-label">Points d'âme totaux :</span>
        <span class="detail-value">{{runeame}}</span>
      </div>
      <div class="detail-row">
        <span class="detail-label">Actions complexes :</span>
        <span class="detail-value">{{runeActionsComplexes}}</span>
      </div>
    </div>

    {{!-- Liste des runes du sortilège --}}
    <div class="sortilege-runes-summary">
      <div class="details-section-title"><i class="fas fa-layer-group"></i> Runes assemblées</div>
      {{#each sortilegeRunes as |rune|}}
      <div class="sortilege-rune-detail flexrow">
        <img src="{{rune.img}}" class="rune-mini-img" />
        <span class="rune-name">{{rune.name}}</span>
        {{#if rune.formule}}<span class="rune-formule">«&nbsp;{{rune.formule}}&nbsp;»</span>{{/if}}
        <span class="rune-pts">{{rune.pts}} pts</span>
        <span class="rune-actions">{{rune.actionsComplexes}} ac.</span>
        <span class="rune-duree">{{rune.dureeLabel}}</span>
      </div>
      {{/each}}
    </div>
  </div>

  {{!-- Effets --}}
  {{#if isSuccess}}
  <div class="result-effects">
    {{#each sortilegeRunes as |rune|}}
    <div class="effect-item">
      <i class="fas fa-star-of-david"></i>
      <strong>{{rune.name}}</strong> activée pour {{rune.dureeLabel}}.
    </div>
    {{/each}}
    {{#if runeameCostReduit}}
    <div class="effect-item">
      <em><i class="fas fa-star"></i> Réussite héroïque : coût total réduit à {{runeameCostFinal}} points d'âme.</em>
    </div>
    {{/if}}
    <div class="damage-buttons">
      {{#each sortilegeRunes as |rune|}}
      <button class="chat-card-button rune-post-chat" data-actor-id="{{../actorId}}" data-item-id="{{rune.id}}">
        <i class="fas fa-scroll"></i> Effets : {{rune.name}}
      </button>
      {{/each}}
    </div>
  </div>
  {{else if isDramatique}}
  {{#if chaosDieResult}}
  <div class="result-chaos">
    <div class="chaos-header">
      <i class="fas fa-dice-d20"></i> <strong>Dé du Chaos : {{chaosDieResult}}</strong>
    </div>
    <div class="chaos-effect {{chaosEffet}}">
      {{#if (eq chaosEffet "desastre")}}
      <i class="fas fa-radiation"></i>
      {{else if (eq chaosEffet "echec_absolu")}}
      <i class="fas fa-skull-crossbones"></i>
      {{else}}
      <i class="fas fa-minus-circle"></i>
      {{/if}}
      {{chaosEffetTexte}}
    </div>
  </div>
  {{/if}}
  {{/if}}

  {{!-- Prédilections --}}
  {{#each predilections as |pred key|}}
    {{#if (not pred.used)}}
    <div class="predilection-section">
      <button class="chat-card-button predilection-reroll" data-predilection-index="{{key}}">
        <i class="fas fa-redo"></i> Prédilection : {{pred.name}}
      </button>
    </div>
    {{/if}}
  {{/each}}

</div>
