<?php
/**
 * Reset password form template
 *
 * @link       https://yourwebsite.com
 * @since      1.0.0
 *
 * @package    Subscription_System
 * @subpackage Subscription_System/public/partials
 */

// Get the reset key and login from URL - these are legitimate password reset parameters
$key = '';
$login = '';
if (isset($_GET['key'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    $key = sanitize_text_field(wp_unslash($_GET['key'])); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
}
if (isset($_GET['login'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    $login = sanitize_text_field(wp_unslash($_GET['login'])); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
}
?>

<div class="subscription-system-form-container">
    <div class="subscription-system-form-header">
        <h2>Reset Your Password</h2>
        <p>Enter your new password below.</p>
    </div>
    
    <div class="subscription-system-message-container"></div>
    
    <form id="subscription-system-reset-password-form" class="subscription-system-form">
        <input type="hidden" name="rp_key" value="<?php echo esc_attr($key); ?>">
        <input type="hidden" name="rp_login" value="<?php echo esc_attr($login); ?>">
        
        <div class="form-row">
            <div class="form-group">
                <label for="pass1">New Password</label>
                <div class="password-field-container">
                    <input type="password" id="pass1" name="pass1" class="form-control" required>
                    <span class="password-toggle" data-target="pass1">👁️</span>
                </div>
            </div>
        </div>
        
        <div class="form-row">
            <div class="form-group">
                <label for="pass2">Confirm New Password</label>
                <div class="password-field-container">
                    <input type="password" id="pass2" name="pass2" class="form-control" required>
                    <span class="password-toggle" data-target="pass2">👁️</span>
                </div>
            </div>
        </div>
        
        <div class="form-row">
            <div class="form-group">
                <button type="submit" class="subscription-system-submit-btn">Reset Password</button>
            </div>
        </div>
        
        <div class="subscription-system-form-footer">
            <?php
            // Get login page
            $login_page_id = get_option('login_page', 0);
            $login_url = $login_page_id ? get_permalink($login_page_id) : wp_login_url();
            ?>
            <p>Remember your password? <a href="<?php echo esc_url($login_url); ?>">Back to Login</a></p>
        </div>
        
        <?php wp_nonce_field('subs_sys_reset_password_nonce', 'subs_sys_reset_password_nonce'); ?>
    </form>
</div> 