<?php
/**
 * Dashboard Login Template
 *
 * @var string $error Error message code.
 * @var bool   $sent  Whether the magic link was sent.
 * @package Nemtly_Booking
 */

defined( 'ABSPATH' ) || exit;
?>
<div class="nemtly-dashboard-login">
    <?php if ( $sent ) : ?>
        <div class="nb-alert nb-alert-success">
            <?php esc_html_e( 'We have sent a magic link to your email. Please check your inbox.', 'nemtly-booking' ); ?>
        </div>
    <?php endif; ?>

    <?php if ( 'invalid' === $error ) : ?>
        <div class="nb-alert nb-alert-error">
            <?php esc_html_e( 'The link is invalid or expired. Please request a new one.', 'nemtly-booking' ); ?>
        </div>
    <?php endif; ?>

    <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="nb-form">
        <input type="hidden" name="action" value="nemtly_send_magic_link">
        <?php wp_nonce_field( 'nemtly_magic_link', 'nemtly_booking_dashboard_nonce' ); ?>

        <div class="nb-form-group">
            <label
                for="nb-email"><?php esc_html_e( 'Enter your email to view your bookings', 'nemtly-booking' ); ?></label>
            <input type="email" name="email" id="nb-email" required placeholder="you@example.com" class="nb-input">
        </div>

        <button type="submit" class="nb-btn nb-btn-primary">
            <?php esc_html_e( 'Send Access Link', 'nemtly-booking' ); ?>
        </button>
    </form>
</div>