{{!-- Modern Viking-themed Chat Message --}}
<div class="ygg-chat-card">
  
  {{!-- Header with Actor Info --}}
  <div class="ygg-chat-header">
    <div class="header-decorative-border"></div>
    <img class="actor-portrait" src="{{actorImg}}" alt="{{alias}}" />
    <div class="header-content">
      <h3 class="actor-name">{{alias}}</h3>
      <div class="roll-type">
        {{#if (eq mode "attribut")}}
          <i class="fas fa-fist-raised"></i> Jet d'Attribut
        {{else if (eq mode "competence")}}
          <i class="fas fa-book"></i> Jet de Compétence
        {{else if (eq mode "armecc")}}
          <i class="fas fa-crossed-swords"></i> Combat Rapproché
        {{else if (or (eq mode "armedist") (eq mode "armetir"))}}
          <i class="fas fa-bow-arrow"></i> Combat à Distance
        {{else if (eq mode "sejdr")}}
          <i class="fas fa-hat-wizard"></i> Magie Sejdr
        {{else if (eq mode "galdr")}}
          <i class="fas fa-sparkles"></i> Magie Galdr
        {{else if (eq mode "rune")}}
          <i class="fas fa-scroll"></i> Gravure de Rune
        {{else}}
          <i class="fas fa-dice"></i> Jet de Caractéristique
        {{/if}}
      </div>
    </div>
    <div class="header-decorative-border"></div>
  </div>

  {{!-- Roll Description --}}
  <div class="ygg-roll-description">
    {{#if (eq mode "attribut")}}
      <strong>{{attr.label}}</strong> - {{subAttr.label}} <span class="dice-formula">(2d10+{{subAttr.value}})</span>
    {{else if (eq mode "competence")}}
      <strong>{{competence.name}}</strong> <span class="skill-level">(Niveau {{competence.system.niveau}})</span><br>
      <span class="carac-detail">{{selectedCarac.label}} ({{selectedCarac.value}}d10)</span>
    {{else if (eq mode "armecc")}}
      <strong>{{arme.name}}</strong> - {{attackDef.label}}<br>
      <span class="skill-detail">{{competence.name}} (Niveau {{competence.system.niveau}})</span>
    {{else if (or (eq mode "armedist") (eq mode "armetir"))}}
      <strong>{{arme.name}}</strong> - {{attackDef.label}}<br>
      <span class="skill-detail">{{competence.name}} (Niveau {{competence.system.niveau}})</span>
    {{else if (eq mode "sejdr")}}
      <strong>{{sort.name}}</strong><br>
      <span class="skill-detail">{{competence.name}} (Niveau {{competence.system.niveau}})</span>
    {{else if (eq mode "galdr")}}
      <strong>{{sort.name}}</strong><br>
      <span class="skill-detail">{{competence.name}} (Niveau {{competence.system.niveau}})</span>
    {{else if (eq mode "rune")}}
      <strong>{{sort.name}}</strong><br>
      <span class="skill-detail">{{competence.name}} (Niveau {{competence.system.niveau}})</span>
    {{else}}
      <strong>{{selectedCarac.label}}</strong> <span class="dice-formula">({{selectedCarac.value}}d10)</span>
    {{/if}}
  </div>

  {{!-- Dice Results --}}
  <div class="ygg-dice-section">
    <div class="dice-results">
      <label><i class="fas fa-dice-d10"></i> Résultats des dés :</label>
      <div class="dice-list">
        {{#each rawDices as |roll key|}}
          <span class="die-result {{#if (gte roll.result 9)}}high{{else if (lte roll.result 2)}}low{{/if}}">{{roll.result}}</span>
        {{/each}}
      </div>
    </div>
    
    {{#if furorUsage}}
    <div class="furor-results">
      <label><i class="fas fa-fire"></i> Furor ({{furorUsage}} dépensé) :</label>
      <div class="dice-list">
        {{#each furorRawDices as |roll key|}}
          <span class="die-result furor {{#if (gte roll.result 9)}}high{{/if}}">{{roll.result}}</span>
        {{/each}}
      </div>
    </div>
    {{/if}}
  </div>

  {{!-- Calculation Breakdown --}}
  <div class="ygg-calculation">
    <div class="calc-row">
      <span class="calc-label">Meilleurs dés :</span>
      <span class="calc-value">{{#if (eq sumDice 1)}}{{maxTab.0.value}}{{else}}{{maxTab.0.value}} + {{maxTab.1.value}}{{/if}}</span>
    </div>
    
    {{#if niveauCompetence}}
    <div class="calc-row">
      <span class="calc-label">{{#if (eq mode "carac")}}Caractéristique{{else}}Compétence{{/if}} :</span>
      <span class="calc-value">+{{niveauCompetence}}</span>
    </div>
    {{/if}}
    
    {{#if finalBM}}
    <div class="calc-row">
      <span class="calc-label">Bonus/Malus :</span>
      <span class="calc-value {{#if (lt finalBM 0)}}negative{{else}}positive{{/if}}">{{#if (gte finalBM 0)}}+{{/if}}{{finalBM}}</span>
    </div>
    {{/if}}
    
    {{#if furorResult}}
    <div class="calc-row furor-row">
      <span class="calc-label"><i class="fas fa-fire"></i> Furor :</span>
      <span class="calc-value">+{{furorResult}}</span>
    </div>
    {{/if}}
  </div>

  {{!-- Final Result --}}
  <div class="ygg-result {{#if isCritical}}critical-success{{else if isFailure}}critical-failure{{else if isSuccess}}success{{else}}failure{{/if}}">
    <div class="result-total">
      <span class="result-label">Total :</span>
      <span class="result-value">{{finalTotal}}</span>
    </div>
    
    {{#if sr}}
    <div class="result-vs">
      <span class="vs-label">Seuil de Réussite :</span>
      <span class="vs-value">{{srFinal}}</span>
    </div>
    
    <div class="result-status">
      {{#if isCritical}}
        <img src="systems/fvtt-yggdrasill/images/icons/icon_reussite_critique.png" class="status-icon" />
        <span class="status-text critical">Réussite Critique !</span>
      {{else if isFailure}}
        <img src="systems/fvtt-yggdrasill/images/icons/icon_echec_critique.png" class="status-icon" />
        <span class="status-text failure">Échec Critique !</span>
      {{else if isSuccess}}
        <i class="fas fa-check-circle status-icon"></i>
        <span class="status-text success">Réussite (Marge: {{marge}})</span>
      {{else}}
        <i class="fas fa-times-circle status-icon"></i>
        <span class="status-text failure">Échec (Marge: {{marge}})</span>
      {{/if}}
    </div>
    {{/if}}
  </div>

  {{!-- Damage Section (for combat) --}}
  {{#if degats}}
  <div class="ygg-damage">
    <div class="damage-header">
      <i class="fas fa-skull-crossbones"></i>
      <span class="damage-label">Dégâts Infligés</span>
    </div>
    <div class="damage-value">{{degats}}</div>
    <div class="damage-detail">{{degatsExplain}}</div>
    {{#if attackDef.protection}}
    <div class="damage-note">Annulation de Protection : {{attackDef.protection}}</div>
    {{/if}}
  </div>
  {{/if}}

  {{!-- Weapon Details (for combat) --}}
  {{#if (or (eq mode "armecc") (eq mode "armedist") (eq mode "armetir"))}}
  <div class="ygg-weapon-details">
    <div class="weapon-header collapsible" data-action="toggle-weapon-details">
      {{#if (eq mode "armecc")}}
        <i class="fas fa-sword"></i>
      {{else}}
        <i class="fas fa-bow-arrow"></i>
      {{/if}}
      <span>Détails de l'Arme</span>
      <i class="fas fa-chevron-down toggle-icon"></i>
    </div>
    
    <div class="weapon-content collapsed">
      <div class="weapon-properties">
        {{#if arme.system.categorie}}
        <div class="weapon-property">
          <span class="property-label">Catégorie :</span>
          <span class="property-value">{{arme.system.categorie}}</span>
        </div>
        {{/if}}
        
        {{#if arme.system.degat}}
        <div class="weapon-property">
          <span class="property-label">Dégâts de base :</span>
          <span class="property-value">{{arme.system.degat}}</span>
        </div>
        {{/if}}
        
        {{#if arme.system.portee}}
        <div class="weapon-property">
          <span class="property-label">Portée :</span>
          <span class="property-value">{{arme.system.portee}}</span>
        </div>
        {{/if}}
        
        {{#if arme.system.solidite}}
        <div class="weapon-property">
          <span class="property-label">Solidité :</span>
          <span class="property-value">{{arme.system.solidite}}</span>
        </div>
        {{/if}}
        
        {{#if arme.system.enc}}
        <div class="weapon-property">
          <span class="property-label">Encombrement :</span>
          <span class="property-value">{{arme.system.enc}}</span>
        </div>
        {{/if}}
      </div>
      
      {{#if arme.system.description}}
      <div class="weapon-description">
        {{{arme.system.description}}}
      </div>
      {{/if}}
    </div>
  </div>
  {{/if}}

  {{!-- Magic Details (for spells) --}}
  {{#if (and isSuccess isMagie)}}
  <div class="ygg-magic-details">
    <div class="magic-header collapsible" data-action="toggle-magic-details">
      <i class="fas fa-magic"></i>
      <span>Effets du Sort</span>
      <i class="fas fa-chevron-down toggle-icon"></i>
    </div>
    
    <div class="magic-content collapsed">
      {{#if dureeGaldrText}}
      <div class="magic-property">
        <span class="property-label">Durée :</span>
        <span class="property-value">{{dureeGaldrText}}</span>
      </div>
      {{/if}}
      
      {{#if zoneGaldrText}}
      <div class="magic-property">
        <span class="property-label">Zone :</span>
        <span class="property-value">{{zoneGaldrText}}</span>
      </div>
      {{/if}}
      
      {{#if ciblesGaldrText}}
      <div class="magic-property">
        <span class="property-label">Cibles :</span>
        <span class="property-value">{{ciblesGaldrText}}</span>
      </div>
      {{/if}}
      
      {{#if (eq mode "rune")}}
      <div class="rune-details">
        <div class="magic-property">
          <span class="property-label">Support :</span>
          <span class="property-value">{{supportRune}}</span>
        </div>
        <div class="magic-property">
          <span class="property-label">Durée de réalisation :</span>
          <span class="property-value">{{dureeRune}} {{echelleDuree}}</span>
        </div>
        <div class="magic-property">
          <span class="property-label">Durée de vie :</span>
          <span class="property-value">{{niveauCompetence}} {{echelleDureeVie}}</span>
        </div>
      </div>
      {{/if}}
      
      {{#if sort.system.description}}
      <div class="magic-description">
        {{{sort.system.description}}}
      </div>
      {{/if}}
    </div>
  </div>
  {{/if}}

</div>
