<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    
    <title>Login - Accounting</title>
    <link rel="icon" href="<?= base_url('assets/img/accounting-color.png') ?>" type="image/png">

    <!-- Assets from Theme -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    
    <!-- Make sure the path is correct in a real scenario -->
    <link href="<?= base_url('assets/css/style-custom.css'); ?>" rel="stylesheet">

    <style>
        :root {
            --orange-main: #ff8c00;
            --orange-dark: #e67700;
            --orange-soft: rgba(255, 140, 0, 0.15);
        }

        body {
            background-color: #fff8f1;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
        }

        .login-card {
            width: 100%;
            max-width: 450px;
            border-radius: 16px;
            padding: 2.5rem;
        }

        .login-title {
            color: var(--orange-dark);
            font-weight: 700;
            font-size: 1.8rem;
            text-align: center;
            margin-bottom: 0.5rem;
        }
        
        .login-subtitle {
            text-align: center;
            color: #6c757d;
            margin-bottom: 2.5rem;
        }

        .form-control {
            border-radius: 12px;
            padding: 0.8rem 1rem;
            border: 1px solid #ced4da;
            transition: 0.2s ease-in-out;
        }

        .form-control:focus {
            border-color: var(--orange-main);
            box-shadow: 0 0 0 0.25rem var(--orange-soft);
        }

        .btn-login {
            width: 100%;
            padding: 0.8rem;
            font-size: 1rem;
            font-weight: 600;
            border-radius: 12px;
            background: var(--orange-main);
            border: none;
            color: #fff;
            transition: 0.2s ease;
        }

        .btn-login:hover {
            background: var(--orange-dark);
        }
    </style>
</head>
<body>

    <div class="card modern-card login-card shadow-lg">
        <div class="card-body">
            
            <center style="margin-bottom: 20px;">
                <img src="<?= base_url('assets/img/accounting-color.png'); ?>" width="150px">
            </center>
            <hr>
            <p class="login-subtitle">Silakan login untuk melanjutkan</p>

            <?php if (!empty($error)): ?>
                <div class="alert alert-danger" role="alert">
                    <?= $error; ?>
                </div>
            <?php endif; ?>

            <form action="<?= base_url('auth/process_login'); ?>" method="post">
                
                <div class="mb-3">
                    <label for="username" class="form-label fw-semibold">Username</label>
                    <div class="input-group">
                        <span class="input-group-text bg-light border-end-0"><i class="bi bi-person"></i></span>
                        <input type="text" class="form-control border-start-0" id="username" name="username" placeholder="Masukkan username Anda" required>
                    </div>
                </div>

                <div class="mb-4">
                    <label for="password" class="form-label fw-semibold">Password</label>
                    <div class="input-group">
                        <span class="input-group-text bg-light border-end-0"><i class="bi bi-lock"></i></span>
                        <input type="password" class="form-control border-start-0" id="password" name="password" placeholder="Masukkan password Anda" required>
                    </div>
                </div>

                <div class="d-grid">
                    <button type="submit" class="btn btn-premium btn-login">Login</button>
                </div>

            </form>

        </div>
    </div>

    <!-- Scripts from Theme -->
    <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>

</body>
</html>

<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>

<?php if($this->session->flashdata('error')): ?>
<script>
Swal.fire({
    icon: 'error',
    title: 'Login Gagal',
    text: '<?= $this->session->flashdata('error'); ?>',
    confirmButtonText: 'Coba Lagi'
});
</script>
<?php endif; ?>