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

<head>

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Login | Sistem Informasi Perpustakaan</title>

<!-- Google Fonts -->
<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=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap" rel="stylesheet">

<!-- Bootstrap -->
<link rel="stylesheet" href="<?= base_url('plugins/bootstrap/css/bootstrap.min.css'); ?>">
<!-- FontAwesome -->
<link rel="stylesheet" href="<?= base_url('plugins/fontawesome-free/css/all.min.css'); ?>">

<style>
:root {
    --green: #198754;
    --green-dark: #0f5c3d;
    --green-light: #20c997;
    --teal-soft: #e6f7f0;
}

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

body {
    min-height: 100vh;
    font-family: 'Plus Jakarta Sans', 'Segoe UI', sans-serif;
    background: #f4f8f6;
}

/* ===== WRAPPER SPLIT ===== */
.auth-wrapper {
    display: flex;
    min-height: 100vh;
    background: #fff;
}

/* ===== PANEL KIRI (BRANDING) ===== */
.auth-brand {
    flex: 1.1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 50px;
    overflow: hidden;
    background:
        linear-gradient(160deg, rgba(15,92,61,.92), rgba(25,135,84,.82)),
        url('<?= base_url('assets/img/mas.jpg') ?>');
    background-size: cover;
    background-position: center;
    color: #fff;
}

/* dekorasi blob */
.auth-brand::before,
.auth-brand::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(10px);
    opacity: .35;
}
.auth-brand::before {
    width: 340px;
    height: 340px;
    background: radial-gradient(circle, #20c997, transparent 70%);
    top: -100px;
    right: -100px;
}
.auth-brand::after {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, #6fffd0, transparent 70%);
    bottom: -120px;
    left: -80px;
}

.brand-content {
    position: relative;
    z-index: 2;
    max-width: 460px;
    animation: slideUp 1s ease;
}

.brand-logo {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid rgba(255,255,255,.9);
    box-shadow: 0 0 0 10px rgba(255,255,255,.12), 0 12px 35px rgba(0,0,0,.35);
    margin-bottom: 32px;
}

.brand-content h1 {
    font-size: 36px;
    font-weight: 800;
    line-height: 1.25;
    text-shadow: 0 3px 12px rgba(0,0,0,.25);
}

.brand-content p {
    font-size: 15px;
    opacity: .95;
    line-height: 1.75;
    margin-top: 18px;
    max-width: 400px;
}

/* quote dekoratif */
.brand-quote {
    margin-top: 40px;
    padding: 22px 24px;
    background: rgba(255,255,255,.12);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,.22);
    border-left: 4px solid #6fffd0;
    border-radius: 18px;
    font-size: 15px;
    font-weight: 500;
    font-style: italic;
    line-height: 1.7;
}
.brand-quote .author {
    display: block;
    margin-top: 10px;
    font-size: 12px;
    font-weight: 700;
    font-style: normal;
    letter-spacing: 1px;
    text-transform: uppercase;
    opacity: .8;
}

/* angka dekoratif mengambang */
.float-num {
    position: absolute;
    font-size: 130px;
    font-weight: 800;
    color: rgba(255,255,255,.06);
    user-select: none;
    z-index: 1;
    line-height: 1;
}
.fn-1 { top: 8%; right: 6%; transform: rotate(12deg); }
.fn-2 { bottom: 10%; left: 4%; transform: rotate(-10deg); font-size: 90px; }

/* ===== PANEL KANAN (FORM) ===== */
.auth-form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 30px;
    background: #fff;
}

.form-wrap {
    width: 100%;
    max-width: 400px;
    animation: slideUp .9s ease;
}

.badge-login {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--teal-soft);
    color: var(--green);
    font-size: 12px;
    font-weight: 700;
    padding: 7px 14px;
    border-radius: 30px;
    letter-spacing: .3px;
    margin-bottom: 20px;
}

.form-wrap h2 {
    font-size: 28px;
    font-weight: 800;
    color: #1f2937;
    margin-bottom: 6px;
}

.form-wrap .sub {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 30px;
}

/* Flash error */
.alert-custom {
    border-radius: 14px;
    font-size: 14px;
    border: none;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: shake .4s ease;
}
.alert-danger {
    background: #fdecec;
    color: #b3261e;
}
@keyframes shake {
    0%,100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #374151;
}

.input-box {
    position: relative;
    width: 100%;
}
.input-box i.prefix {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--green);
    font-size: 15px;
    z-index: 2;
}
.input-box .toggle-pass {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 15px;
    z-index: 2;
    padding: 6px;
}
.input-box .toggle-pass:hover { color: var(--green); }

.form-control {
    width: 100%;
    height: 50px;
    padding-left: 46px;
    padding-right: 46px;
    border-radius: 14px;
    border: 1.5px solid #e5e7eb;
    background: #f9fafb;
    font-size: 14px;
    transition: .3s;
    color: #1f2937;
}
.form-control:focus {
    background: #fff;
    border-color: var(--green);
    box-shadow: 0 0 0 .18rem rgba(25,135,84,.18);
}

.btn-login {
    width: 100%;
    height: 52px;
    border-radius: 14px;
    border: none;
    background: linear-gradient(135deg, var(--green), var(--green-light));
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .3px;
    transition: .3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-login:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(25,135,84,.40);
}
.btn-login:active { transform: translateY(0); }

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0 18px;
    color: #9ca3af;
    font-size: 12px;
}
.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}

.register-link {
    text-align: center;
    font-size: 14px;
    color: #6b7280;
}
.register-link a {
    color: var(--green);
    font-weight: 700;
    text-decoration: none;
}
.register-link a:hover { text-decoration: underline; }

.footer-copy {
    margin-top: 30px;
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 992px) {
    .auth-brand { display: none; }
    .auth-form-side {
        background:
            linear-gradient(160deg, rgba(15,92,61,.92), rgba(25,135,84,.82)),
            url('<?= base_url('assets/img/mas.jpg') ?>');
        background-size: cover;
        background-position: center;
    }
    .form-wrap {
        background: rgba(255,255,255,.96);
        padding: 40px 34px;
        border-radius: 28px;
        box-shadow: 0 20px 50px rgba(0,0,0,.3);
    }
}
</style>
</head>

<body>

<div class="auth-wrapper">

<!-- PANEL KIRI -->
    <div class="auth-brand">
        <span class="float-num fn-1">1</span>
        <span class="float-num fn-2">قرأ</span>
        <div class="brand-content">
            <img src="<?= base_url('assets/img/logo.jpg') ?>" class="brand-logo" alt="Logo">
            <h1>Selamat Datang di<br>Perpustakaan<br>MAS Asy Syarif</h1>
            <p>Tempat menimba ilmu dan menumbuhkan kecintaan terhadap membaca untuk generasi yang cerdas dan berakhlak mulia.</p>

            <div class="brand-quote">
                <i class="fas fa-quote-left me-2"></i>
                Bacalah dengan nama Tuhanmu yang menciptakan.
                <span class="author">— Q.S. Al-'Alaq 1</span>
            </div>
        </div>
    </div>

    <!-- PANEL KANAN -->
    <div class="auth-form-side">
        <div class="form-wrap">

            <span class="badge-login">
                <i class="fas fa-lock"></i> Akses Terbatas
            </span>

            <h2>Login ke Akun</h2>
            <p class="sub">Masukkan username dan password untuk melanjutkan.</p>

            <!-- FLASH ERROR -->
            <?php if (session()->getFlashdata('error')) : ?>
                <div class="alert alert-danger alert-dismissible fade show alert-custom" role="alert">
                    <i class="fas fa-exclamation-circle"></i>
                    <span><?= session()->getFlashdata('error') ?></span>
                    <button type="button" class="close ml-auto" data-dismiss="alert" aria-label="Close">
                        <span>&times;</span>
                    </button>
                </div>
            <?php endif; ?>

            <!-- FORM -->
            <form action="<?= base_url('login') ?>" method="post">
                <?= csrf_field() ?>

                <div class="form-group text-start mb-3">
                    <label class="form-label">Username</label>
                    <div class="input-box">
                        <i class="fas fa-user prefix"></i>
                        <input type="text" name="username" class="form-control"
                               placeholder="Masukkan username" required autofocus>
                    </div>
                </div>

                <div class="form-group text-start mb-4">
                    <label class="form-label">Password</label>
                    <div class="input-box">
                        <i class="fas fa-lock prefix"></i>
                        <input type="password" name="password" id="password"
                               class="form-control" placeholder="Masukkan password" required>
                        <button type="button" class="toggle-pass" onclick="togglePass()">
                            <i class="fas fa-eye" id="eyeIcon"></i>
                        </button>
                    </div>
                </div>

                <button type="submit" class="btn btn-login">
                    <i class="fas fa-sign-in-alt"></i> Login
                </button>
            </form>

            <div class="divider">atau</div>

            <div class="register-link">
                Belum punya akun?
                <a href="<?= base_url('register') ?>">Daftar di sini</a>
            </div>

            <div class="footer-copy">
                &copy; <?= date('Y') ?> MAS Asy Syarif Sidang Koto Laweh
            </div>

        </div>
    </div>

</div>

<script src="<?= base_url('plugins/bootstrap/js/bootstrap.bundle.min.js'); ?>"></script>
<script>
function togglePass() {
    var pw = document.getElementById('password');
    var icon = document.getElementById('eyeIcon');
    if (pw.type === 'password') {
        pw.type = 'text';
        icon.classList.remove('fa-eye');
        icon.classList.add('fa-eye-slash');
    } else {
        pw.type = 'password';
        icon.classList.remove('fa-eye-slash');
        icon.classList.add('fa-eye');
    }
}
</script>

</body>
</html>
