<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Reset Password - KidGo</title>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
    @import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap');

    :root {
        --primary: #FF3B62;
        --primary-light: #FFD6E0;
        --primary-dark: #E31A49;
        --error: #F44336;
        --error-light: #FFEBEE;
        --text: #333333;
        --text-light: #666666;
        --background: #f9f9f9;
        --input-border: #E0E0E0;
        --input-focus: #FF3B62;
    }

    * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
    }

    body {
        font-family: 'Nunito', Arial, sans-serif;
        background-color: var(--background);
        color: var(--text);
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        background-image:
            radial-gradient(circle at 10% 20%, rgba(255, 59, 98, 0.1) 0%, transparent 20%),
            radial-gradient(circle at 90% 30%, rgba(33, 150, 243, 0.1) 0%, transparent 20%),
            radial-gradient(circle at 50% 80%, rgba(255, 193, 7, 0.1) 0%, transparent 20%);
    }

    .container {
        background-color: white;
        border-radius: 20px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
        width: 90%;
        max-width: 450px;
        padding: 0;
        overflow: hidden;
        position: relative;
        animation: fadeIn 0.8s ease-out;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
            transform: translateY(20px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .header {
        background-color: var(--primary);
        position: relative;
        padding: 25px 20px;
        text-align: center;
        overflow: hidden;
    }

    .header::before {
        content: "";
        position: absolute;
        top: -10px;
        left: -10px;
        right: -10px;
        bottom: -10px;
        background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23ffffff' fill-opacity='0.1' fill-rule='evenodd'/%3E%3C/svg%3E") center center;
        z-index: 0;
        opacity: 0.5;
    }

    .logo {
        width: 60px;
        height: 60px;
        background-color: white;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 auto 10px;
        position: relative;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    }

    .logo i {
        font-size: 30px;
        color: var(--primary);
    }

    h1 {
        color: white;
        font-size: 22px;
        font-weight: 700;
        position: relative;
        z-index: 1;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .content {
        padding: 30px;
    }

    .alert {
        background-color: var(--error-light);
        color: var(--error);
        padding: 12px 15px;
        border-radius: 12px;
        margin-bottom: 20px;
        display: flex;
        align-items: flex-start;
        font-size: 14px;
        line-height: 1.5;
        border-left: 4px solid var(--error);
    }

    .alert i {
        margin-right: 10px;
        font-size: 16px;
        margin-top: 2px;
    }

    .alert ul {
        margin: 5px 0 0 0;
        padding-left: 25px;
    }

    .form-group {
        margin-bottom: 20px;
        position: relative;
    }

    label {
        display: block;
        margin-bottom: 8px;
        font-weight: 600;
        font-size: 14px;
        color: var(--text);
        transition: color 0.3s ease;
    }

    .input-wrapper {
        position: relative;
    }

    input[type="email"],
    input[type="password"],
    input[type="text"] {
        width: 100%;
        padding: 12px 15px;
        padding-left: 40px;
        border: 2px solid var(--input-border);
        border-radius: 12px;
        font-family: 'Nunito', sans-serif;
        font-size: 15px;
        transition: all 0.3s ease;
        color: var(--text);
        background-color: white;
        height: 48px;
        /* Fixed height for all input types */
    }

    input[type="email"]:focus,
    input[type="password"]:focus,
    input[type="text"]:focus {
        border-color: var(--input-focus);
        box-shadow: 0 0 0 3px rgba(255, 59, 98, 0.1);
        outline: none;
    }

    .input-icon {
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-light);
        transition: color 0.3s ease;
    }

    input:focus+.input-icon {
        color: var(--primary);
    }

    .password-toggle {
        position: absolute;
        right: 12px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-light);
        cursor: pointer;
        transition: color 0.3s ease;
        background: none;
        border: none;
        padding: 0;
        font-size: 16px;
    }

    .password-toggle:hover {
        color: var(--primary);
    }

    .error-message {
        color: var(--error);
        font-size: 13px;
        margin-top: 6px;
        display: flex;
        align-items: center;
    }

    .error-message i {
        margin-right: 5px;
        font-size: 12px;
    }

    .button {
        background-color: var(--primary);
        color: white;
        border: none;
        padding: 14px 20px;
        border-radius: 12px;
        cursor: pointer;
        width: 100%;
        font-size: 16px;
        font-weight: 700;
        font-family: 'Nunito', sans-serif;
        text-align: center;
        transition: all 0.3s ease;
        position: relative;
        overflow: hidden;
        margin-top: 10px;
    }

    .button:hover {
        background-color: var(--primary-dark);
        transform: translateY(-2px);
        box-shadow: 0 5px 15px rgba(255, 59, 98, 0.3);
    }

    .button:active {
        transform: translateY(0);
        box-shadow: 0 2px 5px rgba(255, 59, 98, 0.3);
    }

    .button::after {
        content: '';
        position: absolute;
        width: 30px;
        height: 200px;
        background: rgba(255, 255, 255, 0.3);
        top: -50px;
        left: -100px;
        transform: rotate(45deg);
        transition: all 0.5s ease;
    }

    .button:hover::after {
        left: 120%;
    }

    .password-hint {
        font-size: 12px;
        color: var(--text-light);
        margin-top: 8px;
        line-height: 1.4;
    }

    /* Animated elements */
    .decorative-element {
        position: absolute;
        border-radius: 50%;
        opacity: 0.5;
        z-index: -1;
    }

    .decorative-1 {
        width: 80px;
        height: 80px;
        background-color: rgba(255, 59, 98, 0.1);
        bottom: 40px;
        left: -20px;
        animation: float 8s ease-in-out infinite;
    }

    .decorative-2 {
        width: 40px;
        height: 40px;
        background-color: rgba(33, 150, 243, 0.1);
        top: 80px;
        right: -10px;
        animation: float 6s ease-in-out infinite 1s;
    }

    @keyframes float {
        0% {
            transform: translateY(0);
        }

        50% {
            transform: translateY(-15px);
        }

        100% {
            transform: translateY(0);
        }
    }

    /* Extra styling for readonly email field */
    input[readonly] {
        background-color: rgba(0, 0, 0, 0.02);
        cursor: not-allowed;
    }

    /* Password strength indicator */
    .password-strength {
        height: 4px;
        width: 100%;
        background-color: #E0E0E0;
        border-radius: 4px;
        margin-top: 8px;
        overflow: hidden;
        position: relative;
    }

    .password-strength-bar {
        height: 100%;
        width: 0;
        border-radius: 4px;
        transition: width 0.3s ease, background-color 0.3s ease;
    }

    .password-match-indicator {
        font-size: 12px;
        margin-top: 6px;
        transition: all 0.3s ease;
        display: flex;
        align-items: center;
    }

    .password-match-indicator i {
        margin-right: 5px;
        font-size: 12px;
    }
    </style>
</head>

<body>
    <div class="container">
        <!-- Decorative elements -->
        <div class="decorative-element decorative-1"></div>
        <div class="decorative-element decorative-2"></div>

        <div class="header">
            <div class="logo">
                <i class="fas fa-lock"></i>
            </div>
            <h1>Buat Password Baru</h1>
        </div>

        <div class="content">
            @if(isset($error))
            <div class="alert">
                <i class="fas fa-exclamation-circle"></i>
                <div>{{ $error }}</div>
            </div>
            @endif

            @if($errors->any())
            <div class="alert">
                <i class="fas fa-exclamation-circle"></i>
                <div>
                    <span>Terdapat kesalahan:</span>
                    <ul>
                        @foreach($errors->all() as $error)
                        <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
            </div>
            @endif

            <form method="POST" action="{{ route('password.update') }}" id="resetForm">
                @csrf

                <input type="hidden" name="token" value="{{ $token }}">

                <div class="form-group">
                    <label for="email">Email</label>
                    <div class="input-wrapper">
                        <input type="email" id="email" name="email" value="{{ $email ?? old('email') }}" readonly>
                        <i class="fas fa-envelope input-icon"></i>
                    </div>
                </div>

                <div class="form-group">
                    <label for="password">Password Baru</label>
                    <div class="input-wrapper">
                        <input type="password" id="password" name="password" required>
                        <i class="fas fa-lock input-icon"></i>
                        <button type="button" class="password-toggle" id="togglePassword">
                            <i class="fas fa-eye"></i>
                        </button>
                    </div>
                    @error('password')
                    <div class="error-message">
                        <i class="fas fa-exclamation-circle"></i>
                        {{ $message }}
                    </div>
                    @enderror
                    <div class="password-strength">
                        <div class="password-strength-bar" id="passwordStrengthBar"></div>
                    </div>
                    <div class="password-hint">
                        Password harus terdiri dari minimal 8 karakter, huruf besar, huruf kecil, dan angka.
                    </div>
                </div>

                <div class="form-group">
                    <label for="password_confirmation">Konfirmasi Password</label>
                    <div class="input-wrapper">
                        <input type="password" id="password_confirmation" name="password_confirmation" required>
                        <i class="fas fa-lock input-icon"></i>
                        <button type="button" class="password-toggle" id="toggleConfirmPassword">
                            <i class="fas fa-eye"></i>
                        </button>
                    </div>
                    <div class="password-match-indicator" id="passwordMatch">

                    </div>
                </div>

                <button type="submit" class="button">Reset Password</button>
            </form>
        </div>
    </div>

    <script>
    // Toggle password visibility - improved function
    document.getElementById('togglePassword').addEventListener('click', function() {
        const passwordInput = document.getElementById('password');
        const icon = this.querySelector('i');

        if (passwordInput.type === 'password') {
            // Instead of changing the input type, use a custom attribute to track state
            passwordInput.setAttribute('type', 'text');
            icon.classList.remove('fa-eye');
            icon.classList.add('fa-eye-slash');
        } else {
            passwordInput.setAttribute('type', 'password');
            icon.classList.remove('fa-eye-slash');
            icon.classList.add('fa-eye');
        }
    });

    document.getElementById('toggleConfirmPassword').addEventListener('click', function() {
        const confirmInput = document.getElementById('password_confirmation');
        const icon = this.querySelector('i');

        if (confirmInput.type === 'password') {
            confirmInput.setAttribute('type', 'text');
            icon.classList.remove('fa-eye');
            icon.classList.add('fa-eye-slash');
        } else {
            confirmInput.setAttribute('type', 'password');
            icon.classList.remove('fa-eye-slash');
            icon.classList.add('fa-eye');
        }
    });

    // Password strength indicator
    const passwordInput = document.getElementById('password');
    const strengthBar = document.getElementById('passwordStrengthBar');

    passwordInput.addEventListener('input', function() {
        const password = this.value;
        let strength = 0;

        if (password.length >= 8) strength += 25;
        if (password.match(/[A-Z]/)) strength += 25;
        if (password.match(/[a-z]/)) strength += 25;
        if (password.match(/[0-9]/)) strength += 25;

        strengthBar.style.width = strength + '%';

        if (strength <= 25) {
            strengthBar.style.backgroundColor = '#F44336'; // Red
        } else if (strength <= 50) {
            strengthBar.style.backgroundColor = '#FF9800'; // Orange
        } else if (strength <= 75) {
            strengthBar.style.backgroundColor = '#2196F3'; // Blue
        } else {
            strengthBar.style.backgroundColor = '#4CAF50'; // Green
        }
    });

    // Password match indicator
    const confirmInput = document.getElementById('password_confirmation');
    const matchIndicator = document.getElementById('passwordMatch');

    function checkPasswordMatch() {
        const password = passwordInput.value;
        const confirmPassword = confirmInput.value;

        if (confirmPassword.length === 0) {
            matchIndicator.innerHTML = '';
            return;
        }

        if (password === confirmPassword) {
            matchIndicator.innerHTML =
                '<i class="fas fa-check-circle" style="color: #4CAF50;"></i><span style="color: #4CAF50;">Password cocok</span>';
        } else {
            matchIndicator.innerHTML =
                '<i class="fas fa-times-circle" style="color: #F44336;"></i><span style="color: #F44336;">Password tidak cocok</span>';
        }
    }

    confirmInput.addEventListener('input', checkPasswordMatch);
    passwordInput.addEventListener('input', function() {
        if (confirmInput.value.length > 0) {
            checkPasswordMatch();
        }
    });
    </script>
</body>

</html>