{{!-- Stress Tab --}}
<div class="tab madness {{#if (eq activeSheetTab "stress")}}active{{/if}}" data-group="sheet" data-tab="stress">

  <p class="madness-intro">
    {{localize "UA2E.Stress.Intro"}}
  </p>

  <section class="stress-meters-grid">
    {{#each stressMeters as |meter|}}
    <article class="stress-meter-card" data-meter="{{meter.key}}">
      <div class="meter-header">
        <h4 class="meter-name">{{meter.label}}</h4>
        <button type="button" class="stat-roll-btn stress-roll-btn" data-action="rollStressCheck" data-meter="{{meter.key}}" data-tooltip="{{localize "UA2E.Stress.RollTooltip" meter=meter.label}}">
          <i class="fas fa-dice-d10"></i>
        </button>
      </div>

      <div class="meter-track">
        <div class="meter-track-label">{{localize "UA2E.Common.Hardened"}}</div>
        <div class="notch-row">
          {{#each meter.hardenedArr as |filled i|}}
            <span class="notch hardened {{#if filled}}filled{{/if}}" data-index="{{i}}">■</span>
          {{/each}}
        </div>
        <div class="notch-controls">
          <button type="button" class="notch-btn" data-action="addHardenedNotch" data-meter="{{meter.key}}" data-tooltip="{{localize "UA2E.Stress.AddHardened"}}">+</button>
          <button type="button" class="notch-btn" data-action="removeHardenedNotch" data-meter="{{meter.key}}" data-tooltip="{{localize "UA2E.Stress.RemoveHardened"}}">−</button>
          <span class="notch-count">{{meter.hardened}}</span>
        </div>
      </div>

      <div class="meter-track">
        <div class="meter-track-label">{{localize "UA2E.Common.Failed"}}</div>
        <div class="notch-row">
          {{#each meter.failedArr as |filled i|}}
            <span class="notch failed {{#if filled}}filled{{/if}}" data-index="{{i}}">□</span>
          {{/each}}
        </div>
        <div class="notch-controls">
          <button type="button" class="notch-btn" data-action="addFailedNotch" data-meter="{{meter.key}}" data-tooltip="{{localize "UA2E.Stress.AddFailed"}}">+</button>
          <button type="button" class="notch-btn" data-action="removeFailedNotch" data-meter="{{meter.key}}" data-tooltip="{{localize "UA2E.Stress.RemoveFailed"}}">−</button>
          <span class="notch-count">{{meter.failed}}</span>
        </div>
      </div>
    </article>
    {{/each}}
  </section>

  <section class="stress-afflictions-section">
    <div class="skills-controls">
      <h3>{{localize "UA2E.StressAffliction.Header"}}</h3>
      <button type="button" data-action="createStressAffliction" class="create-btn">
        <i class="fas fa-plus"></i> {{localize "UA2E.StressAffliction.New"}}
      </button>
    </div>

    {{#if stressAfflictions.length}}
    <table class="skill-table">
      <thead>
        <tr>
          <th>{{localize "UA2E.StressAffliction.Name"}}</th>
          <th>{{localize "UA2E.StressAffliction.Meter"}}</th>
          <th>{{localize "UA2E.StressAffliction.Severity"}}</th>
          <th>{{localize "UA2E.StressAffliction.Ongoing"}}</th>
          <th></th>
        </tr>
      </thead>
      <tbody>
        {{#each stressAfflictions as |affliction|}}
        <tr data-item-id="{{affliction.id}}" class="skill-row">
          <td>{{affliction.name}}</td>
          <td>{{affliction.meterLabel}}</td>
          <td>{{affliction.severity}}</td>
          <td>{{#if affliction.ongoing}}{{localize "UA2E.Common.Yes"}}{{else}}{{localize "UA2E.Common.No"}}{{/if}}</td>
          <td class="skill-controls-col">
            <button type="button" data-action="editStressAffliction" data-tooltip="{{localize "UA2E.Common.Edit"}}">
              <i class="fas fa-edit"></i>
            </button>
            <button type="button" data-action="deleteStressAffliction" data-tooltip="{{localize "UA2E.Common.Delete"}}">
              <i class="fas fa-trash"></i>
            </button>
          </td>
        </tr>
        {{/each}}
      </tbody>
    </table>
    {{else}}
      <p class="hint">{{localize "UA2E.StressAffliction.Empty"}}</p>
    {{/if}}
  </section>

</div>
