<div class="modal-header">
    <div class="modal-main-title">
        <h1 class="modal-title fs-5" id="lockBackupLabel">{{ lang.t("Lock Backup") }}</h1>
    </div>
    <button type="button" class="btn-close" ng-click="cancel()" aria-label="Close"></button>
</div>

<div class="modal-body">
    <!-- Message explaining the purpose -->
    <p ng-bind-html="lang.t('This action allows you to lock or unlock a backup for a selected destination. If locked, the backup cannot be modified or deleted.')"></p>

    <!-- Destination selection (shown only if there are multiple destinations) -->
    <div class="row mt-4" ng-if="backup.destinations.length > 1">
        <div class="col-md-12 mx-auto text-start fs-13">
            <label class="form-label">
                {{ lang.t("This backup exists on multiple destinations. Please select the destination you want to lock or unlock.") }}
            </label>
            <div>
                <label ng-repeat="dest in backup.destinations"
                       class="list-group-item"
                       ng-show="!selectedDestination || selectedDestination === dest.id">
                    <input type="radio"
                           name="destinationRadio"
                           ng-model="selectedDestination"
                           ng-value="dest.id"
                           ng-change="updateLockStatus(dest)">
                    {{ lang.t(dest.name || 'Unknown') }} -
                    <span class="badge" ng-class="dest.locked === 1 ? 'bg-danger' : 'bg-success'">
                        {{ dest.locked === 1 ? lang.t('Locked') : lang.t('Unlocked') }}
                    </span>
                </label>
            </div>
        </div>
    </div>

    <!-- Single destination message -->
    <div class="row mt-4" ng-if="backup.destinations.length === 1">
        <div class="col-md-12 text-start">
            <p>
                {{ lang.t("This backup has only one destination:") }}
                <strong>{{ backup.destinations[0].name }}</strong>
            </p>
        </div>
    </div>

    <!-- Display lock status after selecting a destination -->
    <div class="row mt-4" ng-if="selectedDestination">
        <div class="col-md-12 text-start">
            <p>
                {{ lang.t("Current Status:") }}
                <span class="badge" ng-class="currentLockStatus ? 'bg-danger' : 'bg-success'">
                {{ currentLockStatus ? lang.t('Locked') : lang.t('Unlocked') }}
                </span>
            </p>
        </div>
    </div>
</div>

<div class="modal-footer">
    <button class="btn btn-secondary cancel_btn" type="button" ng-click="cancel()">
        {{ lang.t("Cancel") }}
    </button>
    <button class="btn btn-primary" type="button"
            ng-click="ok()"
            ng-disabled="!selectedDestination">
        {{ currentLockStatus ? lang.t("Unlock") : lang.t("Lock") }}
    </button>
</div>