<?php
// No tenant context on admin/* routes (see Filters.php) — branding here
// is the platform's own fixed indigo, not any hotel's primary_color.
$primaryColor   = '#4f46e5';
$secondaryColor = '#f59e0b';
$heroImage      = 'https://images.unsplash.com/photo-1551288049-bebda4e38f71?auto=format&fit=crop&w=1400&q=80';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Platform Login · MaxYields</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/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=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
    <?php include APPPATH . 'Views/auth/_auth_shared_styles.php'; ?>
</head>
<body>
<div class="login-shell d-flex">
    <div class="form-col col-lg-5 col-12 d-flex flex-column justify-content-center px-4 px-md-5 py-5 mx-auto">
        <div style="max-width: 380px; width: 100%; margin: 0 auto;">

            <div class="d-flex align-items-center gap-2 mb-4">
                <div class="brand-mark"><i class="bi bi-hexagon-fill"></i></div>
                <div>
                    <div class="brand-name">MaxYields Platform</div>
                    <div class="text-muted small">Super Admin Console</div>
                </div>
            </div>

            <h1 class="h3 fw-bold mb-1">Platform sign in</h1>
            <p class="text-muted mb-4">Manage hotels, plans, billing and platform health.</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('admin/login') ?>" method="post">
                <?= csrf_field() ?>
                <div class="mb-3">
                    <label class="form-label small fw-semibold" for="email">Email</label>
                    <div class="input-icon">
                        <i class="bi bi-envelope"></i>
                        <input type="email" class="form-control form-control-lg" id="email" name="email"
                               value="<?= esc(old('email')) ?>" placeholder="you@maxyields.com" required autofocus>
                    </div>
                </div>
                <div class="mb-3">
                    <label class="form-label small fw-semibold" for="password">Password</label>
                    <div class="input-icon">
                        <i class="bi bi-lock"></i>
                        <input type="password" class="form-control form-control-lg" id="password" name="password" placeholder="Enter your password" required>
                        <i class="bi bi-eye toggle-eye" id="togglePassword" role="button" aria-label="Show password"></i>
                    </div>
                </div>

                <button type="submit" class="btn btn-brand btn-lg w-100 mt-2">
                    <i class="bi bi-box-arrow-in-right me-1"></i> Sign In
                </button>
            </form>

            <p class="text-muted small mt-3 mb-0 text-center">
                Platform staff only. Hotel staff should use their hotel's own login page.
            </p>

            <p class="text-center text-muted small mt-5 mb-0">&copy; <?= date('Y') ?> MaxYields PMS</p>
        </div>
    </div>

    <div class="hero-col col-lg-7 d-none d-lg-block">
        <div class="hero-overlay">
            <div class="mb-4">
                <div class="hero-headline mb-2">Run the whole platform<br>from one console.</div>
                <div class="hero-sub">Hotels, subscriptions, billing and platform health — everything a SaaS operator needs, in one place.</div>
            </div>

            <div class="row row-cols-4 g-2 mb-4">
                <div class="col">
                    <div class="feature-card h-100">
                        <i class="bi bi-buildings"></i>
                        <p class="title">Hotels</p>
                        <p class="desc">Onboard &amp; manage</p>
                    </div>
                </div>
                <div class="col">
                    <div class="feature-card h-100">
                        <i class="bi bi-credit-card"></i>
                        <p class="title">Billing</p>
                        <p class="desc">Plans &amp; invoices</p>
                    </div>
                </div>
                <div class="col">
                    <div class="feature-card h-100">
                        <i class="bi bi-graph-up"></i>
                        <p class="title">Analytics</p>
                        <p class="desc">Platform usage</p>
                    </div>
                </div>
                <div class="col">
                    <div class="feature-card h-100">
                        <i class="bi bi-heart-pulse"></i>
                        <p class="title">Health</p>
                        <p class="desc">System status</p>
                    </div>
                </div>
            </div>

            <div class="trust-badge d-flex align-items-center gap-2">
                <i class="bi bi-shield-check fs-5"></i>
                <span>Access restricted to authorized MaxYields platform staff.</span>
            </div>
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script>
document.getElementById('togglePassword').addEventListener('click', function () {
    const pw = document.getElementById('password');
    const showing = pw.type === 'text';
    pw.type = showing ? 'password' : 'text';
    this.classList.toggle('bi-eye', showing);
    this.classList.toggle('bi-eye-slash', !showing);
});
</script>
</body>
</html>
