<?php 
    if (!isset($_GET['token'])) {
        header("location: /admin");
        exit;
    }

    $user_email = isset($_GET['token']) ? $utils->getUserByResetToken($_GET['token']) : '';

    if($user_email == ''){
        header("location: /admin");
        exit;
    }
?>
<!DOCTYPE html>
<html lang="tr">
    <head>
        <title><?php echo $meta_title; ?> | <?php echo $App->title; ?></title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <meta name="description" content="" />
        <meta name="csrf_token" content="<?php echo $csrf_token; ?>" />
        <link rel="apple-touch-icon" sizes="180x180" href="<?php echo $App->url; ?>/public/admin/assets/images/favicons/apple-touch-icon.png">
        <link rel="icon" type="image/png" sizes="32x32" href="<?php echo $App->url; ?>/public/admin/assets/images/favicons/favicon-32x32.png">
        <link rel="icon" type="image/png" sizes="16x16" href="<?php echo $App->url; ?>/public/admin/assets/images/favicons/favicon-16x16.png">
        <link rel="manifest" href="<?php echo $App->url; ?>/public/admin/assets/images/favicons/site.webmanifest">
        <link rel="mask-icon" href="<?php echo $App->url; ?>/public/admin/assets/images/favicons/safari-pinned-tab.svg" color="#5bbad5">
        <link rel="shortcut icon" href="<?php echo $App->url; ?>/public/admin/assets/images/favicons/favicon.ico">
        <meta name="msapplication-TileColor" content="#da532c">
        <meta name="msapplication-config" content="<?php echo $App->url; ?>/public/admin/assets/images/favicons/browserconfig.xml">
        <meta name="theme-color" content="#ffffff">
        <link rel="preconnect" href="https://fonts.googleapis.com">
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
        <link href="https://fonts.googleapis.com/css2?family=Fira+Sans:wght@300;400;500&display=swap" rel="stylesheet">
        <link href="<?php echo $App->url; ?>/public/admin/assets/css/bootstrap/bootstrap.min.css" rel="stylesheet">
        <link href="<?php echo $App->url; ?>/public/admin/assets/css/public.css" rel="stylesheet">
        <link href="<?php echo $App->url; ?>/public/admin/assets/css/login.css" rel="stylesheet">
    </head>
    <body>
        <div class="row g-0 vh-100">
            <div class="col-12 d-flex align-items-center justify-content-center">
                <form action="" method="POST" id="password-reset-form" class="my-3">
                    <div class="return-login">
                        <a href="/login"><svg class="me-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M7.707 14.707a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l2.293 2.293a1 1 0 010 1.414z" clip-rule="evenodd"></path></svg> Girişe dön</a>
                    </div>
                    <div class="login-wrapper">
                        <h3 class="title">Parola Sıfırlama</h3>
                        <p class="mb-3">Yeni bir güvenli parola oluşturun.</p>
                        <input type="text" name="email" autocomplete="username" value="<?php echo $user_email; ?>" class="d-none"/>
                        <div class="row">
                            <div class="col-12">
                                <div class="form-label-group">
                                    <label for="password" class="form-label">Yeni Parola <span class="text-danger">*</span></label>
                                    <input type="password" class="form-control" id="password" name="password" placeholder="" autocomplete="new-password" data-check="password" autofocus required/>
                                    <span class="password-visibility-toggler" data-password="password">
                                        <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16">
                                            <path d="M16 8s-3-5.5-8-5.5S0 8 0 8s3 5.5 8 5.5S16 8 16 8zM1.173 8a13.133 13.133 0 0 1 1.66-2.043C4.12 4.668 5.88 3.5 8 3.5c2.12 0 3.879 1.168 5.168 2.457A13.133 13.133 0 0 1 14.828 8c-.058.087-.122.183-.195.288-.335.48-.83 1.12-1.465 1.755C11.879 11.332 10.119 12.5 8 12.5c-2.12 0-3.879-1.168-5.168-2.457A13.134 13.134 0 0 1 1.172 8z"/>
                                            <path d="M8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5zM4.5 8a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0z"/>
                                        </svg>
                                    </span>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-12">
                                <div class="form-label-group">
                                    <label for="confirm-password" class="form-label">Yeni Parola (tekrar) <span class="text-danger">*</span></label>
                                    <input type="password" class="form-control" id="confirm-password" name="confirm-password" data-check="compare" data-target="password" placeholder="" autocomplete="new-password" required/>
                                    <span class="password-visibility-toggler" data-password="confirm-password">
                                        <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16">
                                            <path d="M16 8s-3-5.5-8-5.5S0 8 0 8s3 5.5 8 5.5S16 8 16 8zM1.173 8a13.133 13.133 0 0 1 1.66-2.043C4.12 4.668 5.88 3.5 8 3.5c2.12 0 3.879 1.168 5.168 2.457A13.133 13.133 0 0 1 14.828 8c-.058.087-.122.183-.195.288-.335.48-.83 1.12-1.465 1.755C11.879 11.332 10.119 12.5 8 12.5c-2.12 0-3.879-1.168-5.168-2.457A13.134 13.134 0 0 1 1.172 8z"/>
                                            <path d="M8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5zM4.5 8a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0z"/>
                                        </svg>
                                    </span>
                                </div>
                            </div>
                        </div>
                        <div id="login-errors">
                        </div>
                        <input type="hidden" name="csrf_token" value="<?php echo $csrf_token; ?>"/>
                        <input type="hidden" name="token" value="<?php echo $_GET['token']; ?>"/>
                        <button type="submit" class="btn btn-primary" data-form="password-reset-form">Onayla</button>
                        
                    </div>
                </form>
            </div>
        </div>
        <script src="<?php echo $App->url; ?>/public/admin/assets/js/bootstrap/bootstrap.bundle.min.js"></script>
        <script src="<?php echo $App->url; ?>/public/admin/assets/js/public.js?v=<?php echo $App->version; ?>"></script>
        <script src="<?php echo $App->url; ?>/public/admin/assets/js/pages/auth/password-reset.js?v=<?php echo $App->version; ?>"></script>
    </body>
</html>
