{{!-- Chat Card for Roll Results --}}
<div class="heritiers-chat-card">
  
  {{!-- Header --}}
  <div class="chat-card-header">
    {{#if actorImg}}
    <img class="chat-actor-avatar" src="{{actorImg}}" alt="{{alias}}" />
    {{/if}}
    <div class="chat-actor-info">
      <h4 class="chat-actor-name">{{alias}}</h4>
      {{#if competence}}
        <div class="chat-action-name">{{competence.name}}{{#if arme}} - {{arme.name}}{{/if}}</div>
      {{else if pouvoir}}
        <div class="chat-action-name">{{pouvoir.name}}</div>
      {{else if sort}}
        <div class="chat-action-name">{{sort.name}}</div>
      {{else if rang}}
        <div class="chat-action-name">{{rang.label}}</div>
      {{else}}
        <div class="chat-action-name">{{carac.label}}</div>
      {{/if}}
    </div>
    {{#if actionImg}}
    <img class="chat-action-icon" src="{{actionImg}}" alt="{{name}}" />
    {{/if}}
  </div>

  {{!-- Attack Type Badge --}}
  {{#if attackType}}
  <div class="chat-attack-badge">{{attackType}}</div>
  {{/if}}

  {{!-- Roll Calculation Grid --}}
  {{#unless noRoll}}
  <div class="chat-roll-grid">
    <div class="chat-roll-item">
      <span class="chat-roll-label">Carac</span>
      <span class="chat-roll-value">{{carac.label}} {{carac.value}}</span>
    </div>
    
    {{#if rang}}
    <div class="chat-roll-item">
      <span class="chat-roll-label">Rang</span>
      <span class="chat-roll-value">{{rang.value}}</span>
    </div>
    {{/if}}
    
    {{#if competence}}
    <div class="chat-roll-item">
      <span class="chat-roll-label">Compétence</span>
      <span class="chat-roll-value">{{competence.name}} {{competence.system.niveau}}</span>
    </div>
    {{/if}}
    
    {{#if useSpecialite}}
    <div class="chat-roll-item">
      <span class="chat-roll-label">Spécialité</span>
      <span class="chat-roll-value">+1</span>
    </div>
    {{/if}}
    
    <div class="chat-roll-item">
      <span class="chat-roll-label">Formule</span>
      <span class="chat-roll-value">{{diceFormula}}</span>
    </div>
    
    <div class="chat-roll-item">
      <span class="chat-roll-label">Dé</span>
      <span class="chat-roll-value chat-dice-result">{{mainDice}} ({{diceValue}})</span>
    </div>
    
    {{#if forcedValue}}
    <div class="chat-roll-item chat-tricherie-used">
      <span class="chat-roll-label">Tricherie</span>
      <span class="chat-roll-value">Face {{forcedValue}} utilisée (2 pts)</span>
    </div>
    {{/if}}
  </div>
  {{/unless}}

  {{!-- Result Display --}}
  {{#unless noRoll}}
  <div class="chat-result-box {{#if isSuccess}}success{{else}}{{#if isCriticalFailure}}critical-failure{{else}}failure{{/if}}{{/if}}">
    <div class="chat-result-total">
      <span class="chat-result-label">Total</span>
      <span class="chat-result-number">{{finalResult}}</span>
    </div>
    
    {{#if (gt sdValue "-1")}}
    <div class="chat-result-details">
      <span>SD: {{sdValue}}</span>
      <span>Marge: {{marge}}</span>
    </div>
    <div class="chat-result-status">
      {{#if isCriticalSuccess}}
        <i class="fas fa-star"></i> RÉUSSITE CRITIQUE !
      {{else if isCriticalFailure}}
        <i class="fas fa-skull"></i> ÉCHEC CRITIQUE !
      {{else if isSuccess}}
        <i class="fas fa-check"></i> Succès
      {{else}}
        <i class="fas fa-times"></i> Échec
      {{/if}}
    </div>
    {{/if}}
    
    {{#if isBrelan}}
    <div class="chat-special-result"><i class="fas fa-dice"></i> Brelan !</div>
    {{/if}}
    {{#if isSuite}}
    <div class="chat-special-result"><i class="fas fa-dice"></i> Suite !</div>
    {{/if}}
    
    {{!-- Damage display for successful weapon attacks --}}
    {{#if (and arme isSuccess degatsArme)}}
    <div class="chat-damage-display">
      <i class="fas fa-heart-broken"></i> <strong>Dégâts : {{degatsArme}}</strong>
    </div>
    {{/if}}
  </div>
  {{/unless}}

  {{!-- Tricherie Adjacent Faces --}}
  {{#if (and adjacentFaces (not forcedValue))}}
  <div class="chat-tricherie-box">
    <span class="chat-tricherie-label">Faces adjacentes (2 pts Tricherie) :</span>
    <div class="chat-tricherie-faces">
      {{#each adjacentFaces as |value key|}}
      <a class="roll-tricherie-2 chat-tricherie-face" data-dice-value="{{value}}">{{value}}</a>
      {{/each}}
    </div>
  </div>
  {{/if}}

  {{!-- Details Section (Collapsible) --}}
  {{#if pouvoir}}
  <details class="chat-details-section">
    <summary class="chat-details-summary"><i class="fas fa-magic"></i> Détails du pouvoir</summary>
    <div class="chat-details-content">
      <div><strong>Effet :</strong> {{pouvoir.system.effet}}</div>
      {{#if (ne pouvoir.system.duree "")}}
      <div><strong>Durée :</strong> {{pouvoir.system.duree}}</div>
      {{/if}}
      {{#if (ne pouvoir.system.portee "")}}
      <div><strong>Portée :</strong> {{pouvoir.system.portee}}</div>
      {{/if}}
      {{#if (ne pouvoir.system.resistance "")}}
      <div><strong>Résistance :</strong> {{pouvoir.system.resistance}}</div>
      {{/if}}
      {{#if (ne pouvoir.system.zoneeffet "")}}
      <div><strong>Zone d'effet :</strong> {{pouvoir.system.zoneeffet}}</div>
      {{/if}}
      {{#if (ne pouvoir.system.cibles "")}}
      <div><strong>Cibles :</strong> {{pouvoir.system.cibles}}</div>
      {{/if}}
      <div><strong>Points d'usage :</strong> {{pouvoirPointsUsage}}</div>
    </div>
  </details>
  {{/if}}

  {{#if sort}}
  <details class="chat-details-section">
    <summary class="chat-details-summary"><i class="fas fa-hat-wizard"></i> Détails du sort</summary>
    <div class="chat-details-content">
      {{#if (ne sort.system.duree "")}}
      <div><strong>Durée :</strong> {{sort.system.duree}}</div>
      {{/if}}
      {{#if (ne sort.system.portee "")}}
      <div><strong>Portée :</strong> {{sort.system.portee}}</div>
      {{/if}}
      {{#if (ne sort.system.ingredients "")}}
      <div><strong>Ingrédients :</strong> {{sort.system.ingredients}}</div>
      {{/if}}
      {{#if (ne sort.system.resistance "")}}
      <div><strong>Résistance :</strong> {{sort.system.resistance}}</div>
      {{/if}}
      {{#if spendEsprit}}
      <div><strong>Points d'Esprit :</strong> 1</div>
      {{else}}
      <div><strong>Points d'Âme :</strong> {{sortPointsAme}}</div>
      {{#if (eq sort.system.competence "Magie du Clan")}}
      <div><strong>Souffle :</strong> {{sort.system.souffle}}</div>
      <div><strong>Coût PV :</strong> 2</div>
      {{/if}}
      {{/if}}
    </div>
  </details>
  {{/if}}

</div>
