<?php
/**
 * Reset password LocalEdge — shortcode [avision_localedge_reset_password].
 *
 * Variables: $le_t, $le_lang, $le_login_url, $le_reset_page_url, $le_key, $le_login_param,
 *            $le_reset_error, $le_reset_success, $le_invalid_link, $le_brand_name, $le_brand_color.
 *
 * @package Avision
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$le_logo_svg = '<svg xmlns="http://www.w3.org/2000/svg"
    width="48" height="48" viewBox="0 0 20 20" fill="none">
    <circle cx="10" cy="10" r="9"
        stroke="#f97316" stroke-width="1.5"/>
    <circle cx="10" cy="10" r="6"
        stroke="#f97316" stroke-width="1.5"/>
    <circle cx="10" cy="10" r="3"
        stroke="#f97316" stroke-width="1.5"/>
    <circle cx="10" cy="10" r="1.5" fill="#f97316"/>
    </svg>';

$le_form_action = add_query_arg(
	array(
		'key'   => rawurlencode( $le_key ),
		'login' => rawurlencode( $le_login_param ),
		'lang'  => $le_lang,
	),
	$le_reset_page_url
);
?>
<div class="le-reset-wrap">
<style>
.le-reset-wrap{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
    display:flex;align-items:center;justify-content:center;
    min-height:60vh;padding:24px;}
.le-reset-wrap .le-card{background:#fff;border-radius:14px;
    border:1px solid #e5e7eb;padding:40px 36px;max-width:440px;
    width:100%;text-align:center;
    box-shadow:0 4px 24px rgba(0,0,0,.06);}
.le-reset-wrap .le-logo{margin-bottom:20px;}
.le-reset-wrap .le-brand{font-size:22px;font-weight:700;color:#111;margin-bottom:8px;}
.le-reset-wrap .le-title{font-size:16px;font-weight:600;color:#111;margin-bottom:24px;}
.le-reset-wrap .le-form{text-align:left;}
.le-reset-wrap .le-field{margin-bottom:16px;}
.le-reset-wrap .le-label{display:block;font-size:13px;font-weight:600;
    color:#374151;margin-bottom:6px;}
.le-reset-wrap .le-input{width:100%;padding:11px 14px;font-size:15px;
    border:1px solid #d1d5db;border-radius:8px;background:#fff;color:#111;}
.le-reset-wrap .le-input:focus{outline:none;border-color:<?php echo esc_attr( $le_brand_color ); ?>;
    box-shadow:0 0 0 3px rgba(249,115,22,.15);}
.le-reset-wrap .le-btn{display:inline-flex;align-items:center;gap:10px;
    background:<?php echo esc_attr( $le_brand_color ); ?>;color:#fff;border:none;
    border-radius:8px;padding:13px 28px;font-size:15px;font-weight:600;
    cursor:pointer;text-decoration:none;width:100%;justify-content:center;margin-top:8px;}
.le-reset-wrap .le-btn:hover{opacity:.92;}
.le-reset-wrap .le-error{color:#dc2626;font-size:14px;margin-bottom:16px;line-height:1.5;text-align:center;}
.le-reset-wrap .le-success{color:#059669;font-size:14px;margin-bottom:16px;line-height:1.5;text-align:center;}
.le-reset-wrap .le-back{display:inline-block;margin-bottom:16px;font-size:14px;color:#374151;text-decoration:none;}
.le-reset-wrap .le-back:hover{text-decoration:underline;}
</style>
<div class="le-card">
	<div class="le-logo"><?php echo $le_logo_svg; ?></div>
	<div class="le-brand"><?php echo esc_html( $le_brand_name ); ?></div>

	<?php if ( ! empty( $le_invalid_link ) ) : ?>
		<p class="le-title"><?php echo esc_html( $le_t['reset_title'] ); ?></p>
		<p class="le-error"><?php echo esc_html( $le_invalid_link ); ?></p>
		<a class="le-btn" href="<?php echo esc_url( $le_login_url ); ?>"><?php echo esc_html( $le_t['reset_back_login'] ); ?></a>
	<?php elseif ( ! empty( $le_reset_success ) ) : ?>
		<p class="le-title"><?php echo esc_html( $le_t['reset_title'] ); ?></p>
		<p class="le-success"><?php echo esc_html( $le_reset_success ); ?></p>
		<a class="le-btn" href="<?php echo esc_url( $le_login_url ); ?>"><?php echo esc_html( $le_t['reset_sign_in'] ); ?></a>
	<?php else : ?>
		<a class="le-back" href="<?php echo esc_url( $le_login_url ); ?>"><?php echo esc_html( $le_t['reset_back_login'] ); ?></a>
		<p class="le-title"><?php echo esc_html( $le_t['reset_title'] ); ?></p>
		<?php if ( ! empty( $le_reset_error ) ) : ?>
			<p class="le-error"><?php echo esc_html( $le_reset_error ); ?></p>
		<?php endif; ?>
		<form class="le-form" method="post" action="<?php echo esc_url( $le_form_action ); ?>">
			<?php wp_nonce_field( 'le_reset_password', 'le_reset_password_nonce' ); ?>
			<input type="hidden" name="key" value="<?php echo esc_attr( $le_key ); ?>">
			<input type="hidden" name="login" value="<?php echo esc_attr( $le_login_param ); ?>">
			<div class="le-field">
				<label class="le-label" for="le_pass1"><?php echo esc_html( $le_t['reset_pass1'] ); ?></label>
				<input class="le-input" type="password" name="le_pass1" id="le_pass1" required autocomplete="new-password" minlength="8">
			</div>
			<div class="le-field">
				<label class="le-label" for="le_pass2"><?php echo esc_html( $le_t['reset_pass2'] ); ?></label>
				<input class="le-input" type="password" name="le_pass2" id="le_pass2" required autocomplete="new-password" minlength="8">
			</div>
			<button type="submit" class="le-btn" name="le_do_reset_password" value="1"><?php echo esc_html( $le_t['reset_btn'] ); ?></button>
		</form>
	<?php endif; ?>
</div>
</div>
