<?php
$tenant = service('tenantContext')->hasTenant() ? service('tenantContext')->getTenant() : null;
$primaryColor   = safe_hex_color($tenant->primary_color ?? null, '#4f46e5');
$secondaryColor = safe_hex_color($tenant->secondary_color ?? null, '#f59e0b');
$hotelName      = $tenant->hotel_name ?? 'MaxYields PMS';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <?php include APPPATH . 'Views/public/_shell_head.php'; ?>
</head>
<body>
<div class="public-shell">
    <div class="d-flex align-items-center gap-2 mb-4">
        <div class="brand-mark"><i class="bi bi-buildings-fill"></i></div>
        <div>
            <div class="brand-name"><?= esc($hotelName) ?></div>
            <div class="text-muted small">Event Organizer Portal</div>
        </div>
    </div>

    <div class="public-card">
        <h1 class="h5 mb-1">Organizer Log In</h1>
        <p class="text-muted small mb-3">Manage the events you've been invited to.</p>

        <?php if (session()->getFlashdata('error')): ?>
            <div class="alert alert-danger py-2 small"><?= esc(session()->getFlashdata('error')) ?></div>
        <?php endif; ?>
        <?php if (session()->getFlashdata('success')): ?>
            <div class="alert alert-success py-2 small"><?= esc(session()->getFlashdata('success')) ?></div>
        <?php endif; ?>
        <?php if (isset($validation)): ?>
            <div class="alert alert-danger py-2 small"><?= $validation->listErrors() ?></div>
        <?php endif; ?>

        <form action="<?= site_url('organizer/login') ?>" method="post">
            <?= csrf_field() ?>
            <div class="mb-3">
                <label class="form-label small fw-semibold">Email</label>
                <input type="email" class="form-control" name="email" value="<?= esc(old('email')) ?>" required autofocus>
            </div>
            <div class="mb-3">
                <label class="form-label small fw-semibold">Password</label>
                <input type="password" class="form-control" name="password" required>
            </div>
            <button type="submit" class="btn btn-brand w-100"><i class="bi bi-box-arrow-in-right me-1"></i>Sign In</button>
        </form>
        <p class="text-muted small text-center mt-3 mb-0">
            <a href="<?= site_url('organizer/forgot-password') ?>" class="text-decoration-none fw-semibold" style="color: var(--brand);">Forgot your password?</a>
        </p>
    </div>

    <p class="text-center text-muted small mt-4 mb-0">&copy; <?= date('Y') ?> <?= esc($hotelName) ?> · Powered by MaxYields PMS</p>
</div>
</body>
</html>
