<div class="prismrpg-roll-dialog">
  <fieldSet>
    <legend>{{actorName}}</legend>

    {{#if rollTarget.weapon}}
      <div class="dialog-save">
        <strong>{{rollTarget.weapon.name}}</strong>
      </div>
    {{/if}}
  </fieldSet>

  {{#if rollTarget.weapon}}
    {{! Weapon-specific options }}
    <fieldSet class="dialog-weapon-options">
      <legend>Weapon Options</legend>

      {{! Display weapon ranges if set }}
      {{#if (or (gt rollTarget.weapon.system.shortRange 0) (gt rollTarget.weapon.system.longRange 0))}}
        <div class="dialog-save" style="font-size: 0.9em; color: #666; margin-bottom: 0.5em;">
          {{#if (gt rollTarget.weapon.system.shortRange 0)}}
            <span>Short Range: {{rollTarget.weapon.system.shortRange}} ft</span>
          {{/if}}
          {{#if (gt rollTarget.weapon.system.longRange 0)}}
            {{#if (gt rollTarget.weapon.system.shortRange 0)}} • {{/if}}
            <span>Long Range: {{rollTarget.weapon.system.longRange}} ft</span>
          {{/if}}
        </div>
      {{/if}}

      {{! Choose STR or DEX for attack/damage rolls }}
      {{#if (or (eq rollType "weapon-attack") (eq rollType "weapon-damage-small") (eq rollType "weapon-damage-medium"))}}
        <div class="dialog-save">
          <label>Attack with:</label>
          <select name="attackAttribute" data-tooltip-direction="UP">
            <option value="str" {{#if (eq rollTarget.weapon.system.weaponType "melee")}}selected{{/if}}>Strength (+{{rollTarget.strMod}})</option>
            <option value="dex" {{#if (eq rollTarget.weapon.system.weaponType "ranged")}}selected{{/if}}>Dexterity (+{{rollTarget.dexMod}})</option>
          </select>
        </div>
      {{/if}}

      {{! Ranged weapon specific options }}
      {{#if (eq rollTarget.weapon.system.weaponType "ranged")}}
        {{#if
          (or (eq rollType "weapon-attack") (eq rollType "monster-attack"))
        }}
          <div class="dialog-save">
            <label>
              <input
                type="checkbox"
                name="pointBlank"
                data-action="selectPointBlank"
              />
              Point Blank Range Attack
            </label>
          </div>
          <div class="dialog-save">
            <label>
              <input
                type="checkbox"
                name="beyondSkill"
                data-action="selectBeyondSkill"
              />
              Beyond Skill Range Attack
            </label>
          </div>
          <div class="dialog-save">
            <label>
              <input
                type="checkbox"
                name="letItFly"
                data-action="selectLetItFly"
              />
              Let it Fly (Pure D20E)
            </label>
          </div>
          <div class="dialog-save">
            <label>Aiming:</label>
            <select name="attackerAim" data-tooltip-direction="UP">
              {{selectOptions attackerAimChoices selected="simple"}}
            </select>
          </div>
        {{/if}}
      {{/if}}
    </fieldSet>
  {{/if}}

  {{#if rollTarget.type}}
    {{#if (eq rollTarget.type "spell")}}
      {{! Spell-specific options }}
      <fieldSet class="dialog-spell-options">
        <legend>Spell Options</legend>

        <div class="dialog-save" style="font-size: 0.9em; color: #666; margin-bottom: 0.5em;">
          <span>Casting with: {{rollTarget.mentalCharacteristic}} ({{rollTarget.mentalCharValue}}, +{{rollTarget.value}})</span>
          <br><span>Base Cost: {{rollTarget.system.manaCost}} Mana, {{rollTarget.system.apc}} APC</span>
          {{#if (gt rollTarget.system.manaUpkeep 0)}}
            <br><span>Upkeep: {{rollTarget.system.manaUpkeep}} Mana/round</span>
          {{/if}}
        </div>

        {{#if rollTarget.system.canAscend}}
          <div class="dialog-save">
            <label>Upcast Level:</label>
            <select name="upcastLevel" data-tooltip-direction="UP">
              <option value="0">Base Level ({{rollTarget.system.level}})</option>
              <option value="1">+1 Level (+1 Mana, +1 APC)</option>
              <option value="2">+2 Levels (+2 Mana, +2 APC)</option>
              <option value="3">+3 Levels (+3 Mana, +3 APC)</option>
              <option value="4">+4 Levels (+4 Mana, +4 APC)</option>
              <option value="5">+5 Levels (+5 Mana, +5 APC)</option>
              <option value="6">+6 Levels (+6 Mana, +6 APC)</option>
              <option value="7">+7 Levels (+7 Mana, +7 APC)</option>
            </select>
          </div>
        {{/if}}
      </fieldSet>
    {{/if}}
  {{/if}}

  {{! Skill Options }}
  {{#if (eq rollType "skill")}}
    <fieldSet class="dialog-skill-options">
      <legend>Skill Options</legend>

      {{! Choose which sub-attribute to use }}
      <div class="dialog-save">
        <label>Use Sub-Attribute:</label>
        <select name="skillSubAttribute" data-tooltip-direction="UP">
          <option value="{{rollTarget.subAttribute1}}" selected>
            {{rollTarget.subAttribute1Label}} (+{{rollTarget.subAttribute1Value}})
          </option>
          <option value="{{rollTarget.subAttribute2}}">
            {{rollTarget.subAttribute2Label}} (+{{rollTarget.subAttribute2Value}})
          </option>
        </select>
      </div>
    </fieldSet>
  {{/if}}

  {{#if hasAdvantage}}
    <fieldSet class="dialog-advantage">
      <legend>{{localize "PRISMRPG.Roll.advantageDisadvantage"}}</legend>
      <select
        name="advantage"
        class="advantage-choice"
        data-tooltip-direction="UP"
      >
        {{selectOptions choiceAdvantage selected=advantage}}
      </select>
    </fieldSet>
  {{/if}}

  {{#if hasModifier}}
    <fieldSet class="dialog-modifier">
      <legend>{{localize "PRISMRPG.Roll.modifierBonusMalus"}}</legend>
      <select name="modifier" data-tooltip-direction="UP">
        {{selectOptions choiceModifier selected=modifier}}
      </select>
    </fieldSet>
  {{/if}}

  <fieldSet>
    <legend>{{localize "PRISMRPG.Roll.visibility"}}</legend>
    <select name="visibility">
      {{selectOptions rollModes selected=visibility localize=true}}
    </select>
  </fieldSet>
</div>