<?php
/* Template Name: Custom Login Page */
get_header(); ?>

<div class="container py-5">
  <div class="row justify-content-center">
    <div class="col-md-6">
      <h2 class="text-center mb-4"><?php _e('Login to Your Account', 'howcan'); ?></h2>

      <?php if ( is_user_logged_in() ) : ?>
        <div class="alert alert-success text-center">
          <?php _e('You are already logged in.', 'howcan'); ?>
        </div>
      <?php else : ?>

        <form method="post" action="<?php echo esc_url( wp_login_url() ); ?>" class="card p-4 shadow-sm">
          <div class="mb-3">
            <label for="user_login" class="form-label"><?php _e('Username or Email', 'howcan'); ?></label>
            <input type="text" name="log" id="user_login" class="form-control" required>
          </div>

          <div class="mb-3">
            <label for="user_pass" class="form-label"><?php _e('Password', 'howcan'); ?></label>
            <input type="password" name="pwd" id="user_pass" class="form-control" required>
          </div>

          <div class="mb-3 form-check">
            <input type="checkbox" name="rememberme" id="rememberme" class="form-check-input">
            <label for="rememberme" class="form-check-label"><?php _e('Remember Me', 'howcan'); ?></label>
          </div>

          <input type="hidden" name="redirect_to" value="<?php echo esc_url( admin_url() ); ?>">
          <button type="submit" class="btn btn-dark w-100"><?php _e('Login', 'howcan'); ?></button>
        </form>

      <?php endif; ?>
      
    </div>
  </div>
</div>

<?php get_footer(); ?>