<?php
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Local template scope variables.
/**
 * Upload modal partial.
 *
 * @package NNAXFUF_Plugin
 */
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

$accept_attr = isset( $accept_attr ) ? (string) $accept_attr : '';
?>
<!-- UPLOAD-MODAL -->
<div id="nnaxfuf-upload-modal" class="nnaxfuf-modal uk-flex-top" uk-modal>
    <div class="uk-modal-dialog uk-modal-body uk-margin-auto-vertical uk-width-1-1 uk-width-1-2@m">

        <button class="uk-modal-close-default" type="button" uk-close></button>

        <h3 class="uk-modal-title"><?php esc_html_e( 'Upload File(s)', 'nnax-frontend-user-files' ); ?></h3>

        <form method="post" action="<?php echo esc_url( $frontend_form_action_url ); ?>" enctype="multipart/form-data" class="nnaxfuf-upload-form">
            <?php wp_nonce_field('nnaxfuf_upload', 'nnaxfuf_nonce'); ?>
            <input type="hidden" name="action" value="nnaxfuf_upload">
            <input type="hidden" name="nnaxfuf_folder_id" value="<?php echo isset($current_folder_id) ? (int) $current_folder_id : 0; ?>">
            <input type="hidden" name="nnaxfuf_redirect_to" value="<?php echo esc_url( $frontend_redirect_url ); ?>">
            <input type="hidden" name="nnaxfuf_notice_key" value="<?php echo esc_attr( $frontend_notice_key ); ?>">

            <div class="uk-margin">
                <div id="nnaxfuf-upload-drop-area"
                    class="uk-placeholder uk-text-center uk-background-muted uk-padding">
                    <span uk-icon="icon: cloud-upload"></span>
                    <span class="uk-display-block uk-margin-small-top">
                        <?php esc_html_e( 'Drag files here or click to select.', 'nnax-frontend-user-files' ); ?>
                    </span>

                    <div class="uk-margin-small-top" uk-form-custom>
                        <input
                            type="file"
                            name="nnaxfuf_files[]"
                            id="nnaxfuf_files"
                            multiple
                            <?php echo $accept_attr ? 'accept="' . esc_attr($accept_attr) . '"' : ''; ?>>
                        <button class="uk-button uk-button-default" type="button">
                            <?php esc_html_e( 'Select files', 'nnax-frontend-user-files' ); ?>
                        </button>
                    </div>
                </div>
                <small class="uk-text-muted">
                    <?php esc_html_e( 'You can select multiple files at once or drag and drop them into the area.', 'nnax-frontend-user-files' ); ?>
                </small>
            </div>

            <div class="uk-margin-small">
                <h5 class="uk-heading-bullet uk-margin-small"><?php esc_html_e( 'Selected files', 'nnax-frontend-user-files' ); ?></h5>
                <ul id="nnaxfuf-upload-file-list"
                    class="uk-list uk-list-striped uk-text-small uk-margin-remove">
                    <!-- JS füllt diese Liste -->
                </ul>
            </div>

            <div class="uk-margin-top uk-text-right">
                <button class="uk-button uk-button-default uk-modal-close" type="button">
                    <?php esc_html_e( 'Cancel', 'nnax-frontend-user-files' ); ?>
                </button>
                <button class="uk-button uk-button-primary" type="submit">
                    <?php esc_html_e( 'Upload', 'nnax-frontend-user-files' ); ?>
                </button>
            </div>
        </form>
    </div>
</div>
