<!-- Nextcloud Upload Modal -->
<div class="modal-dialog modal-dialog-centered">
    <div class="modal-content border-0 shadow">
        <form class="js-modal-submit" action="{{ url_for('data.modal_nextcloud', projectname=projectname) }}"
            method="POST" id="nextcloudUploadForm">
            <div class="modal-header border-0 pb-0">
                <div class="d-flex align-items-center">
                    <div class="rounded-circle bg-info bg-opacity-10 me-3 d-flex align-items-center justify-content-center"
                        style="width: 56px; height: 56px; min-width: 56px;">
                        <i class="bi bi-cloud text-info" style="font-size: 1.5rem;"></i>
                    </div>
                    <div>
                        <h5 class="modal-title fw-bold mb-0">Connect to Nextcloud</h5>
                        <small class="text-muted">Import files from your cloud storage</small>
                    </div>
                </div>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <div class="modal-body pt-4">
                {% if message %}
                <div class="alert alert-warning d-flex align-items-center mb-4" role="alert">
                    <i class="bi bi-exclamation-triangle me-2"></i>
                    {{ message }}
                </div>
                {% endif %}

                <div class="mb-3">
                    <label for="nextcloudUrl" class="form-label fw-semibold">
                        <i class="bi bi-link-45deg me-1"></i> Server URL <span class="text-danger">*</span>
                    </label>
                    <input type="url" class="form-control" id="nextcloudUrl" name="nextcloud_url"
                        placeholder="https://cloud.example.com" required>
                </div>

                <div class="row g-3 mb-3">
                    <div class="col-md-6">
                        <label for="nextcloudUser" class="form-label fw-semibold">
                            <i class="bi bi-person me-1"></i> Username <span class="text-danger">*</span>
                        </label>
                        <input type="text" class="form-control" id="nextcloudUser" name="nextcloud_user" required>
                    </div>
                    <div class="col-md-6">
                        <label for="nextcloudPassword" class="form-label fw-semibold">
                            <i class="bi bi-key me-1"></i> Password <span class="text-danger">*</span>
                        </label>
                        <input type="password" class="form-control" id="nextcloudPassword" name="nextcloud_password"
                            required>
                    </div>
                </div>

                <div class="mb-3">
                    <label for="nextcloudFolder" class="form-label fw-semibold">
                        <i class="bi bi-folder me-1"></i> Folder <span class="text-muted fw-normal">(optional)</span>
                    </label>
                    <input type="text" class="form-control" id="nextcloudFolder" name="nextcloud_folder"
                        placeholder="/Documents/TEI-Files">
                    <div class="form-text">
                        <i class="bi bi-info-circle me-1"></i>
                        Leave empty to browse from root folder
                    </div>
                </div>
            </div>
            <div class="modal-footer border-0 pt-0">
                <button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">
                    Cancel
                </button>
                <button type="submit" class="btn btn-info text-white">
                    <span class="spinner-border spinner-border-sm me-2 d-none" role="status" aria-hidden="true"></span>
                    <i class="bi bi-box-arrow-in-right me-1"></i>
                    <span>Connect</span>
                </button>
            </div>
        </form>
    </div>
</div>