{{!-- Modern Roll Dialog Layout --}}
<div class="ygg-roll-dialog">
  
  {{!-- Header with Actor Info --}}
  <div class="roll-header">
    <img class="actor-portrait" src="{{img}}" alt="{{name}}" />
    <div class="roll-info">
      <h2 class="actor-name">{{name}}</h2>
      {{#if competence}}
        <div class="roll-subject">
          <i class="fas fa-book"></i>
          <span class="subject-name">{{competence.name}}</span>
          {{#if competence.system.isspecialisation}}
            <span class="specialisation">({{competence.system.specialisation}})</span>
          {{/if}}
        </div>
      {{/if}}
      {{#if arme}}
        <div class="roll-subject">
          <i class="fas fa-crossed-swords"></i>
          <span class="subject-name">{{arme.name}}</span>
        </div>
      {{/if}}
      {{#if sort}}
        <div class="roll-subject">
          <i class="fas fa-sparkles"></i>
          <span class="subject-name">{{sort.name}}</span>
        </div>
      {{/if}}
    </div>
  </div>

  {{!-- Main Content Area --}}
  <div class="roll-body">
    
    {{!-- Left Column: Stats & Info --}}
    <div class="roll-stats">
      
      {{!-- Mode Compétence --}}
      {{#if (eq mode "competence")}}
        <div class="stat-card">
          <label>Caractéristique</label>
          <select id="caracName" name="caracName">
            {{#each config.optionsCarac as |opt|}}
              <option value="{{opt.key}}" {{#if (eq ../caracName opt.key)}}selected{{/if}}>{{opt.label}}</option>
            {{/each}}
          </select>
        </div>
        
        <div class="stat-card">
          <label>Compétence</label>
          <div class="stat-value">{{competence.name}} (<strong>{{competence.system.niveau}}</strong>)</div>
        </div>
      {{/if}}

      {{!-- Mode Carac --}}
      {{#if (eq mode "carac")}}
        <div class="stat-card">
          <label>Caractéristique</label>
          <div class="stat-value">{{selectedCarac.label}}: <strong>{{selectedCarac.value}}</strong></div>
        </div>
      {{/if}}

      {{!-- Mode Arme CC --}}
      {{#if (eq mode "armecc")}}
        <div class="stat-card">
          <label>Type d'attaque</label>
          <select id="typeAttack" name="typeAttack">
            {{#each config.optionsAttaque as |opt|}}
              <option value="{{opt.key}}" {{#if (eq ../attackDef.typeAttack opt.key)}}selected{{/if}}>{{opt.label}}</option>
            {{/each}}
          </select>
        </div>

        <div class="stat-card highlight">
          <label>Effet</label>
          <div class="stat-value" id="attackDescr">{{attackData.description}}</div>
        </div>

        <div class="stat-grid">
          <div class="stat-card compact">
            <label>Caractéristique</label>
            <div class="stat-value" id="caracName">{{attackData.categName}} / {{attackData.caracName}}</div>
          </div>

          <div class="stat-card compact">
            <label>Compétence</label>
            <div class="stat-value">{{competence.name}} (<strong>{{competence.system.niveau}}</strong>)</div>
          </div>
        </div>

        <div class="stat-card">
          <label>Malus d'Attaque</label>
          <div class="stat-value danger" id="malus">{{attackData.malus}}</div>
        </div>

        <div class="stat-card">
          <label>Défense Physique du défenseur</label>
          <select id="bonusdefense" name="bonusdefense">
            {{#each optionsBD as |opt|}}
              <option value="{{opt.key}}" {{#if (eq ../bonusdefense opt.key)}}selected{{/if}}>{{opt.label}}</option>
            {{/each}}
          </select>
        </div>
      {{/if}}

      {{!-- Mode Arme Tir / Arme Dist --}}
      {{#if (or (eq mode "armetir") (eq mode "armedist"))}}
        <div class="stat-card">
          <label>Type d'attaque</label>
          <select id="typeAttack" name="typeAttack">
            {{#each config.optionsAttaque as |opt|}}
              <option value="{{opt.key}}" {{#if (eq ../attackDef.typeAttack opt.key)}}selected{{/if}}>{{opt.label}}</option>
            {{/each}}
          </select>
        </div>

        <div class="stat-card highlight">
          <label>Effet</label>
          <div class="stat-value" id="attackDescr">{{attackData.description}}</div>
        </div>

        <div class="stat-grid">
          <div class="stat-card compact">
            <label>Caractéristique</label>
            <div class="stat-value" id="caracName">{{attackData.categName}} / {{attackData.caracName}}</div>
          </div>

          <div class="stat-card compact">
            <label>Compétence</label>
            <div class="stat-value">{{competence.name}} (<strong>{{competence.system.niveau}}</strong>)</div>
          </div>
        </div>

        <div class="stat-grid">
          <div class="stat-card compact">
            <label>Malus</label>
            <div class="stat-value danger" id="malus">{{attackData.malus}}</div>
          </div>

          <div class="stat-card compact">
            <label>Portée</label>
            <div class="stat-value">{{arme.system.portee}}</div>
          </div>
        </div>

        <div class="stat-card">
          <label>Défense Physique du défenseur</label>
          <select id="bonusdefense" name="bonusdefense">
            {{#each optionsBD as |opt|}}
              <option value="{{opt.key}}" {{#if (eq ../bonusdefense opt.key)}}selected{{/if}}>{{opt.label}}</option>
            {{/each}}
          </select>
        </div>
      {{/if}}

      {{!-- Mode Galdr --}}
      {{#if (eq mode "galdr")}}
        <div class="stat-grid">
          <div class="stat-card compact">
            <label>Caractéristique</label>
            <div class="stat-value" id="caracName">{{selectedCarac.label}}: <strong>{{selectedCarac.value}}</strong></div>
          </div>

          <div class="stat-card compact">
            <label>Compétence</label>
            <div class="stat-value">{{competence.name}} (<strong>{{competence.system.niveau}}</strong>)</div>
          </div>
        </div>

        <div class="stat-grid">
          <div class="stat-card compact">
            <label>Voie</label>
            <div class="stat-value">{{sort.system.voie}}</div>
          </div>

          <div class="stat-card compact">
            <label>SD de base</label>
            <div class="stat-value"><strong>{{sort.system.sd}}</strong></div>
          </div>
        </div>

        <div class="stat-card">
          <label>Durée</label>
          <select id="dureeGaldr" name="dureeGaldr">
            <option value="1d5a" {{#if (eq dureeGaldr "1d5a")}}selected{{/if}}>1d5 actions (+3)</option>
            <option value="1d10t" {{#if (eq dureeGaldr "1d10t")}}selected{{/if}}>1d10 tours (+6)</option>
            <option value="1d10m" {{#if (eq dureeGaldr "1d10m")}}selected{{/if}}>1d10 minutes (+9)</option>
            <option value="1d10h" {{#if (eq dureeGaldr "1d10h")}}selected{{/if}}>1d10 heures (+12)</option>
            <option value="1d5j" {{#if (eq dureeGaldr "1d5j")}}selected{{/if}}>1d5 jours (+15)</option>
          </select>
        </div>

        {{#if (eq sort.system.voie "illusion")}}
          <div class="stat-card">
            <label>Zone affectée</label>
            <select id="zoneGaldr" name="zoneGaldr">
              <option value="INS10cm3" {{#if (eq zoneGaldr "INS10cm3")}}selected{{/if}}>10cm³ (+3)</option>
              <option value="INS50cm3" {{#if (eq zoneGaldr "INS50cm3")}}selected{{/if}}>50cm³ (+6)</option>
              <option value="INS1m3" {{#if (eq zoneGaldr "INS1m3")}}selected{{/if}}>1m³ (+9)</option>
              <option value="INS5m3" {{#if (eq zoneGaldr "INS5m3")}}selected{{/if}}>5m³ (+12)</option>
              <option value="INS10m3" {{#if (eq zoneGaldr "INS10m3")}}selected{{/if}}>10m³ (+15)</option>
            </select>
          </div>
        {{else}}
          <div class="stat-card">
            <label>Nombre de cibles</label>
            <select id="nbCibles" name="nbCibles">
              <option value="1" {{#if (eq nbCibles "1")}}selected{{/if}}>1 (+3)</option>
              <option value="2_4" {{#if (eq nbCibles "2_4")}}selected{{/if}}>2-4 (+6)</option>
              <option value="5_9" {{#if (eq nbCibles "5_9")}}selected{{/if}}>5-9 (+9)</option>
              <option value="10_49" {{#if (eq nbCibles "10_49")}}selected{{/if}}>10-49 (+12)</option>
              <option value="50plus" {{#if (eq nbCibles "50plus")}}selected{{/if}}>50+ (+15)</option>
            </select>
          </div>
        {{/if}}

        <div class="stat-card success">
          <label>Seuil de Réussite Total</label>
          <div class="stat-value large" id="srTotal">{{srTotal}}</div>
        </div>
      {{/if}}

      {{!-- Mode Sejdr --}}
      {{#if (eq mode "sejdr")}}
        <div class="stat-grid">
          <div class="stat-card compact">
            <label>Caractéristique</label>
            <div class="stat-value" id="caracName">{{selectedCarac.label}}: <strong>{{selectedCarac.value}}</strong></div>
          </div>

          <div class="stat-card compact">
            <label>Préparation</label>
            <div class="stat-value">{{sort.system.preparation}}</div>
          </div>
        </div>

        <div class="stat-card">
          <label>Compétence</label>
          <div class="stat-value">{{competence.name}} (<strong>{{competence.system.niveau}}</strong>)</div>
        </div>

        <div class="stat-grid three-col">
          <div class="stat-card compact">
            <label>Forme</label>
            <div class="stat-value">{{sort.system.forme}}</div>
          </div>

          <div class="stat-card compact">
            <label>Niveau</label>
            <div class="stat-value"><strong>{{sort.system.niveau}}</strong></div>
          </div>

          <div class="stat-card compact">
            <label>Malus</label>
            <div class="stat-value danger">{{sort.system.malus}}</div>
          </div>
        </div>

        <div class="stat-grid">
          <div class="stat-card compact">
            <label>Durée</label>
            <div class="stat-value">{{sort.system.duree}}</div>
          </div>

          <div class="stat-card compact">
            <label>Zone</label>
            <div class="stat-value">{{sort.system.zone}}</div>
          </div>
        </div>

        <div class="stat-card">
          <label>Défense Mentale du défenseur</label>
          <select id="bonusdefense" name="bonusdefense">
            {{#each optionsBD as |opt|}}
              <option value="{{opt.key}}" {{#if (eq ../bonusdefense opt.key)}}selected{{/if}}>{{opt.label}}</option>
            {{/each}}
          </select>
        </div>

        <div class="stat-card success">
          <label>Seuil de Réussite Total (14+DM éventuelle)</label>
          <div class="stat-value large" id="srTotal">{{srTotal}}</div>
        </div>
      {{/if}}

      {{!-- Mode Rune --}}
      {{#if (eq mode "rune")}}
        <div class="stat-grid">
          <div class="stat-card compact">
            <label>Caractéristique</label>
            <div class="stat-value" id="caracName">{{selectedCarac.label}}: <strong>{{selectedCarac.value}}</strong></div>
          </div>

          <div class="stat-card compact">
            <label>Compétence</label>
            <div class="stat-value">{{competence.name}} (<strong>{{competence.system.niveau}}</strong>)</div>
          </div>
        </div>

        <div class="stat-card">
          <label>Niveau</label>
          <div class="stat-value"><strong>{{sort.system.niveau}}</strong></div>
        </div>

        <div class="stat-card">
          <label>Graver la Rune</label>
          <select id="supportRune" name="supportRune">
            {{#each config.optionsSupportRunes as |opt|}}
              <option value="{{opt.key}}" {{#if (eq ../supportRune opt.key)}}selected{{/if}}>{{opt.label}}</option>
            {{/each}}
          </select>
        </div>

        <div class="stat-card">
          <label>Puissance de la Rune</label>
          <select id="puissanceRune" name="puissanceRune">
            {{#each optionsPuissanceRune as |opt|}}
              <option value="{{opt.key}}" {{#if (eq ../puissanceRune opt.key)}}selected{{/if}}>{{opt.label}}</option>
            {{/each}}
          </select>
        </div>

        <div class="stat-grid">
          <div class="stat-card compact">
            <label>Durée de réalisation</label>
            <div class="stat-value" id="runeDuree">{{runeDuree}}</div>
          </div>

          <div class="stat-card compact">
            <label>Durée de Vie</label>
            <div class="stat-value" id="runeDureeVie">{{runeDureeVie}}</div>
          </div>
        </div>

        <div class="stat-card success">
          <label>Seuil de Réussite Total</label>
          <div class="stat-value large" id="srTotal">{{srTotal}}</div>
        </div>
      {{/if}}

    </div>

    {{!-- Right Column: Modifiers & Status --}}
    <div class="roll-modifiers">
      
      {{!-- Modifiers Card --}}
      <div class="modifier-card">
        <h3><i class="fas fa-sliders"></i> Modificateurs</h3>
        
        <div class="stat-grid">
          <div class="stat-card compact">
            <label>Bonus/Malus</label>
            <select id="bonusMalus" name="bonusMalus">
              {{#each optionsBonusMalus as |opt|}}
                <option value="{{opt.key}}" {{#if (eq ../bonusMalus opt.key)}}selected{{/if}}>{{opt.label}}</option>
              {{/each}}
            </select>
          </div>

          <div class="stat-card compact">
            <label>Furor à utiliser</label>
            <select id="furorUsage" name="furorUsage">
              {{#each optionsFuror as |opt|}}
                <option value="{{opt.key}}" {{#if (eq ../furorUsage opt.key)}}selected{{/if}}>{{opt.label}}</option>
              {{/each}}
            </select>
          </div>
        </div>

        {{#unless (or (eq mode "galdr") (eq mode "sejdr") (eq mode "rune"))}}
        <div class="stat-card">
          <label>Seuil de Réussite</label>
          <select id="sr" name="sr">
            {{#each config.optionsSR as |opt|}}
              <option value="{{opt.key}}" {{#if (eq ../sr opt.key)}}selected{{/if}}>{{opt.label}}</option>
            {{/each}}
          </select>
        </div>
        {{/unless}}
      </div>

      {{!-- Status Effects Card --}}
      <div class="status-card">
        <h3><i class="fas fa-heart-broken"></i> État</h3>
        
        <div class="status-list">
          <label class="status-item epuise">
            <input type="checkbox" id="isEpuise" name="isEpuise" {{checked isEpuise}} disabled />
            <span class="status-icon">💀</span>
            <span class="status-text">Épuisé</span>
            <span class="status-effect">1d</span>
          </label>

          <label class="status-item blesse">
            <input type="checkbox" id="isBlesse" name="isBlesse" {{checked isBlesse}} disabled />
            <span class="status-icon">🩸</span>
            <span class="status-text">Blessé</span>
            <span class="status-effect">-3</span>
          </label>

          <label class="status-item meurtri">
            <input type="checkbox" id="isMeurtri" name="isMeurtri" {{checked isMeurtri}} disabled />
            <span class="status-icon">💢</span>
            <span class="status-text">Meurtri</span>
            <span class="status-effect">1d</span>
          </label>
        </div>
      </div>

    </div>

  </div>

</div>
