<form class="{{cssClass}} flexcol" autocomplete="off">

    {{!-- Item Sheet Header --}}
    <header class="sheet-header flexrow">
        <img class="profile" src="{{item.img}}" data-tooltip="{{item.name}}" data-edit="img">

        <div class="header-details flexrow">
            <h1 class="charname">
                <input name="name" type="text" value="{{item.name}}" placeholder="{{ localize 'DND5E.SpellName' }}">
            </h1>

            <div class="item-subtitle">
                <h4 class="item-type">{{itemType}}</h4>
                <span class="item-status">{{itemStatus}}</span>
            </div>

            <ul class="summary flexrow">
                <li>
                    {{labels.level}}
                </li>
                <li>
                    {{labels.school}}
                </li>
                <li>
                    {{> "dnd5e.item-source"}}
                </li>
            </ul>
        </div>
    </header>

    {{!-- Item Sheet Navigation --}}
    <nav class="sheet-navigation tabs" data-group="primary">
        <a class="item active" data-tab="description">{{ localize "DND5E.Description" }}</a>
        <a class="item" data-tab="details">{{ localize "DND5E.Details" }}</a>
        <a class="item" data-tab="effects">{{ localize "DND5E.Effects" }}</a>
    </nav>

    {{!-- Item Sheet Body --}}
    <section class="sheet-body">

        {{!-- Description Tab --}}
        {{> "dnd5e.item-description"}}

        {{!-- Details Tab --}}
        <div class="tab details" data-group="primary" data-tab="details">
            <h3 class="form-header">{{ localize "DND5E.SpellDetails" }}</h3>

            {{!-- Spell Level --}}
            <div class="form-group">
                <label>{{ localize "DND5E.SpellLevel" }}</label>
                <select name="system.level" data-dtype="Number">
                    {{#select system.level}}
                    {{#each config.spellLevels as |name lvl|}}
                    <option value="{{lvl}}">{{name}}</option>
                    {{/each}}
                    {{/select}}
                </select>
            </div>

            {{!-- Spell School --}}
            <div class="form-group">
                <label>{{ localize "DND5E.SpellSchool" }}</label>
                <select name="system.school">
                    {{selectOptions config.spellSchools selected=system.school labelAttr="label" blank=""}}
                </select>
            </div>

            {{!-- Spell Components --}}
            <div class="spell-components form-group stacked">
                <label>{{ localize "DND5E.SpellComponents" }}</label>
                {{#each properties}}
                <label class="checkbox">
                    <input type="checkbox" name="system.properties.{{@key}}" {{checked selected}}> {{ label }}
                </label>
                {{/each}}
            </div>

            {{!-- Material Components --}}
            <div class="form-group stacked">
                <label>{{ localize "DND5E.SpellMaterials" }}</label>
                <input class="materials" type="text" name="system.materials.value" value="{{system.materials.value}}">
                {{#if system.materials.value}}
                <div class="spell-materials flexrow">
                    <label>{{ localize "DND5E.Supply" }}</label>
                    {{numberInput system.materials.supply name="system.materials.supply" placeholder="0"}}
                    <label>{{ localize "DND5E.CostGP" }}</label>
                    {{numberInput system.materials.cost name="system.materials.cost" placeholder="—"}}
                    <label>{{ localize "DND5E.Consumed" }}</label>
                    <input type="checkbox" name="system.materials.consumed" {{checked system.materials.consumed}}>
                </div>
                {{/if}}
            </div>

            {{!-- Preparation Mode --}}
            <div class="form-group input-select">
                <label>{{ localize "DND5E.SpellPreparationMode" }}</label>
                <div class="form-fields">
                    <label class="checkbox prepared">
                        {{ localize "DND5E.SpellPrepared" }}
                        <input type="checkbox" name="system.preparation.prepared" {{checked system.preparation.prepared}}>
                    </label>
                    <select name="system.preparation.mode">
                        {{ selectOptions config.spellPreparationModes selected=system.preparation.mode labelAttr="label" }}
                    </select>
                </div>
            </div>

            {{!-- Source Class --}}
            {{#if isEmbedded}}
            <div class="form-group input-select">
                <label>{{ localize "DND5E.SpellSourceClass" }}</label>
                <div class="form-fields">
                    <select name="system.sourceClass">
                        {{selectOptions document.parent.spellcastingClasses selected=system.sourceClass
                                        labelAttr="name" blank=""}}
                    </select>
                </div>
            </div>
            {{/if}}

            <h3 class="form-header">{{ localize "DND5E.SpellCastingHeader" }}</h3>

            {{!-- Item Activation Template --}}
            {{> "dnd5e.item-activation"}}

            <h3 class="form-header">{{ localize "DND5E.SpellEffects" }}</h3>

            {{!-- Item Action Template --}}
            {{> "dnd5e.item-action"}}

            {{!-- Spell Level Scaling --}}
            <div class="form-group">
                <label>{{ localize "DND5E.LevelScaling" }}</label>
                <div class="form-fields">
                    <select name="system.scaling.mode">
                        {{#select system.scaling.mode}}
                        {{#each config.spellScalingModes as |name key|}}
                        <option value="{{key}}">{{name}}</option>
                        {{/each}}
                        {{/select}}
                    </select>
                    <input type="text" name="system.scaling.formula" value="{{system.scaling.formula}}"
                           placeholder="{{ localize 'DND5E.ScalingFormula' }}" data-formula-editor>
                </div>
            </div>
        </div>

        {{!-- Effects Tab --}}
        <div class="tab effects flexcol" data-group="primary" data-tab="effects">
            {{> "dnd5e.active-effects"}}
        </div>
    </section>
</form>
