<?= $this->extend('layouts/main') ?>

<?= $this->section('content') ?>
<div class="auth-wrapper fade-in">
    <div class="auth-card rounded-4 shadow-lg">
        <div class="text-center mb-4">
            <h2 class="fw-bold text-primary">Welcome Back</h2>
            <p class="text-muted">Sign in to manage your bookings</p>
        </div>

        <?php if(session()->getFlashdata('error')): ?>
            <div class="alert alert-danger rounded-3">
                <i class="fa-solid fa-circle-exclamation me-2"></i><?= session()->getFlashdata('error') ?>
            </div>
        <?php endif; ?>

        <?php if(session()->getFlashdata('success')): ?>
            <div class="alert alert-success rounded-3">
                <i class="fa-solid fa-check-circle me-2"></i><?= session()->getFlashdata('success') ?>
            </div>
        <?php endif; ?>

        <form action="<?= base_url('auth/processLogin') ?>" method="POST">
            <?= csrf_field() ?>
            <div class="mb-3">
                <label class="form-label fw-semibold">Email Address</label>
                <div class="input-group">
                    <span class="input-group-text bg-white border-end-0 text-muted"><i class="fa-solid fa-envelope"></i></span>
                    <input type="email" name="email" class="form-control border-start-0 ps-0" placeholder="name@example.com" required>
                </div>
            </div>
            
            <div class="mb-4">
                <div class="d-flex justify-content-between">
                    <label class="form-label fw-semibold">Password</label>
                    <a href="#" class="text-decoration-none small text-primary">Forgot Password?</a>
                </div>
                <div class="input-group">
                    <span class="input-group-text bg-white border-end-0 text-muted"><i class="fa-solid fa-lock"></i></span>
                    <input type="password" name="password" class="form-control border-start-0 ps-0" placeholder="••••••••" required>
                </div>
            </div>

            <div class="mb-4 form-check">
                <input type="checkbox" class="form-check-input" id="rememberMe">
                <label class="form-check-label text-muted small" for="rememberMe">Remember me</label>
            </div>

            <button type="submit" class="btn btn-primary w-100 py-2 mb-3">Sign In <i class="fa-solid fa-arrow-right ms-2"></i></button>

            <div class="text-center mt-3">
                <span class="text-muted">New here?</span>
                <a href="<?= base_url('auth/register') ?>" class="text-primary fw-semibold text-decoration-none">Create an account</a>
            </div>
        </form>
    </div>
</div>
<?= $this->endSection() ?>
