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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Login - SIDAKDesa</title>
    <meta name="description"
        content="Halaman login SIDAKDesa untuk mengakses sistem informasi dan layanan digital Desa Pelem secara aman dan mudah.">
    <meta name="keywords" content="login SIDAKDesa, SIDAKDesa, login desa, sistem informasi desa, Desa Pelem">
    <meta name="author" content="Desa Pelem">
    <meta name="robots" content="noindex, nofollow">
    <meta name="theme-color" content="#ffffff">

    <link rel="canonical" href="{{ url()->current() }}">

    <meta property="og:type" content="website">
    <meta property="og:title" content="Login - SIDAKDesa">
    <meta property="og:description"
        content="Akses halaman login SIDAKDesa untuk masuk ke sistem informasi dan layanan digital Desa Pelem.">
    <meta property="og:url" content="{{ url()->current() }}">
    <meta property="og:image" content="{{ asset('assets/images/njk-logo.png') }}">
    <meta property="og:site_name" content="SIDAKDesa">

    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:title" content="Login - SIDAKDesa">
    <meta name="twitter:description"
        content="Akses halaman login SIDAKDesa untuk masuk ke sistem informasi dan layanan digital Desa Pelem.">
    <meta name="twitter:image" content="{{ asset('assets/images/njk-logo.png') }}">

    <link rel="icon" type="image/png" href="{{ asset('assets/images/njk-logo.png') }}">
    <link rel="shortcut icon" href="{{ asset('assets/images/njk-logo.png') }}">
    <link rel="apple-touch-icon" href="{{ asset('assets/images/njk-logo.png') }}">

    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">

    @vite(['resources/css/app.css', 'resources/js/app.js'])

    <style>
        body {
            background: #ffffff;
            font-family: 'Inter', sans-serif;
        }

        .login-wrapper {
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }

        .logo-col {
            background: #ffffff;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 2rem;
        }

        .logo-card {
            background: #f4f6f8;
            border-radius: 20px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
            padding: 2rem;
            text-align: center;
            max-width: 480px;
            width: 100%;
            overflow: hidden;
        }

        .logo-card img {
            display: block max-width: 100%;
            height: auto;
        }

        /* Skala nyaman, tapi tetap dibatasi kontainer */
        .brand-img {
            width: clamp(220px, 70%, 360px);
        }

        .illu-img {
            width: clamp(280px, 85%, 440px);
        }

        /* Kolom kiri agak lega di layar besar */
        @media (min-width:1200px) {
            .logo-col {
                padding: 3rem;
            }

            .logo-card {
                max-width: 520px;
            }
        }

        /* Di layar kecil, kasih jarak bawah */
        @media (max-width:991.98px) {
            .logo-col {
                padding: 1.25rem;
            }

            .logo-card img {
                display: block;
                max-width: 100%;
                height: auto;
            }

        }

        .form-col {
            background: #ffffff;
            padding: 3rem 2rem;
            display: flex;
            align-items: center;
        }

        .btn-teal {
            background-color: #168a85;
            border: none;
            color: #fff;
        }

        .btn-teal:hover {
            background-color: #11716c;
            color: #fff;
        }

        .btn-orange {
            background-color: #f27d32;
            border: none;
            color: #fff;
        }

        .btn-orange:hover {
            background-color: #d86b28;
            color: #fff;
        }

        .text-forgot-password {
            color: #168a85;
            text-decoration: none;
            font-weight: 500;
        }

        /* Tombol ikon transparan, tanpa border, tidak mengubah tinggi field */
        .password-toggle {
            background: transparent;
            border: 0;
            padding: 0;
            width: 40px;
            /* area klik nyaman */
            height: 40px;
            /* tidak wajib, hanya agar target sentuh enak */
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
        }

        .password-toggle:focus {
            outline: none;
        }
    </style>
</head>

<body>
    <div class="login-wrapper">
        <div class="row g-0 w-100" style="max-width: 1100px; background: transparent;">
            {{-- Kolom kiri: card logo & ilustrasi --}}
            <div class="col-lg-6 logo-col">
                <div class="logo-card">
                    {{-- Logo --}}
                    <img src="{{ asset('assets/images/sidak-desa.jpg') }}" alt="Logo SIDAKDesa"
                        class="img-fluid mb-4 brand-img">
                    {{-- Ilustrasi --}}
                    <img src="{{ asset('assets/images/login.png') }}" alt="Ilustrasi Login" class="img-fluid illu-img">
                </div>
            </div>

            {{-- Kolom kanan: form login --}}
            <div class="col-lg-6 form-col">
                <div class="w-100" style="max-width: 500px;">
                    {{-- Tombol kembali --}}
                    <div class="d-flex gap-2 mb-4">
                        {{-- Tombol kembali --}}
                        <a href="{{ url('/') }}"
                            class="btn btn-light flex-fill d-flex justify-content-center align-items-center"
                            style="border-radius:8px; border:1px solid #ddd;">
                            ← Halaman Utama
                        </a>

                        <a href="{{ route('attendance.session.show', ['sessionId' => 1]) }}"
                            class="btn btn-light flex-fill d-flex justify-content-center align-items-center gap-1"
                            style="border-radius:8px; border:1px solid #ddd;" target="_blank" rel="noopener noreferrer">
                            <i class="ti ti-qrcode"></i>
                            <span>QR Absensi</span>
                        </a>
                    </div>
                    <h3 class="fw-bold mb-2">Selamat Datang di Absensi Digital Perangkat Desa Pelem!</h3>
                    <p class="text-muted mb-4">Silahkan masukkan email dan Kata Sandi anda untuk masuk ke halaman
                        utama!</p>
                    @if ($errors->has('email'))
                        <div class="alert alert-danger mt-4">
                            <ul class="mb-0">
                                @foreach ($errors->get('email') as $error)
                                    <li>{{ $error }}</li>
                                @endforeach
                            </ul>
                        </div>
                    @endif
                    @if (session('status'))
                        <div class="alert alert-success mt-4">
                            {{ session('status') }}
                        </div>
                    @endif
                    <form action="{{ route('login') }}" method="POST">
                        @csrf
                        <div class="mb-3">
                            <label class="form-label">Email</label>
                            <input type="email" value="{{ old('email') }}" name="email"
                                class="form-control form-control-lg" placeholder="Masukkan Email" required>
                        </div>
                        <div class="mb-4">
                            <label class="form-label">Kata Sandi</label>
                            <div class="position-relative">
                                <input type="password" name="password" id="password"
                                    class="form-control form-control-lg pe-5" placeholder="••••••••" required>

                                <button type="button"
                                    class="password-toggle js-toggle-password position-absolute top-50 end-0 translate-middle-y me-3"
                                    data-target="#password" aria-label="Tampilkan kata sandi" aria-pressed="false">
                                    <i class="bi bi-eye"></i>
                                </button>
                            </div>
                            <div class="mt-2">
                                <a href="{{ route('forget.password') }}" class="text-forgot-password">Lupa Kata
                                    Sandi?</a>
                            </div>
                        </div>
                        <div class="d-grid gap-3">
                            <button type="submit" class="btn btn-teal btn-lg">Masuk</button>
                            {{-- <a href="{{ route('register') }}" class="btn btn-orange btn-lg">Daftar Akun Sebagai Perangkat Desa</a> --}}
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
    <script>
        // Toggle show/hide password (delegated, bisa dipakai banyak field)
        document.addEventListener('click', (e) => {
            const btn = e.target.closest('.js-toggle-password');
            if (!btn) return;

            const target = btn.getAttribute('data-target');
            const input = document.querySelector(target);
            if (!input) return;

            const isVisible = input.type === 'text';
            input.type = isVisible ? 'password' : 'text';

            // Update icon & ARIA
            const icon = btn.querySelector('i');
            if (icon) {
                icon.classList.toggle('bi-eye', isVisible);
                icon.classList.toggle('bi-eye-slash', !isVisible);
            }
            btn.setAttribute('aria-pressed', String(!isVisible));
            btn.setAttribute('aria-label', isVisible ? 'Tampilkan kata sandi' : 'Sembunyikan kata sandi');
        });
    </script>
</body>

</html>
