<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Connexion - FerryOps</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">
    <style>
        body {
            background: linear-gradient(135deg, #1b2a4a 0%, #0d6efd 100%);
            min-height: 100vh; display: flex; align-items: center; justify-content: center;
        }
        .login-card {
            background: #fff; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
            max-width: 420px; width: 100%; padding: 2.5rem;
        }
        .login-brand {
            text-align: center; margin-bottom: 2rem;
        }
        .login-brand i { font-size: 2.5rem; color: #0d6efd; }
        .login-brand h2 { font-weight: 700; margin: .5rem 0 0; color: #1b2a4a; }
        .login-brand small { color: #6c757d; }
    </style>
</head>
<body>
    <div class="login-card">
        <div class="login-brand">
            <i class="bi bi-tsunami"></i>
            <h2>FerryOps</h2>
            <small>Wassim Service — Gestion des Opérations</small>
        </div>

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

        <?php if ($msg = $this->session->flashdata('success')): ?>
            <div class="alert alert-success"><?= $msg; ?></div>
        <?php endif; ?>

        <?php if ($msg = $this->session->flashdata('error')): ?>
            <div class="alert alert-danger"><?= $msg; ?></div>
        <?php endif; ?>

        <?= form_open('auth/login'); ?>

            <div class="mb-3">
                <label class="form-label">Identifiant</label>
                <div class="input-group">
                    <span class="input-group-text"><i class="bi bi-person"></i></span>
                    <input type="text" name="identity" class="form-control" 
                           placeholder="Nom d'utilisateur ou email"
                           value="<?= set_value('identity'); ?>" required autofocus>
                </div>
            </div>

            <div class="mb-4">
                <label class="form-label">Mot de passe</label>
                <div class="input-group">
                    <span class="input-group-text"><i class="bi bi-lock"></i></span>
                    <input type="password" name="password" class="form-control" 
                           placeholder="••••••••" required>
                </div>
            </div>

            <button type="submit" class="btn btn-primary w-100 py-2">
                <i class="bi bi-box-arrow-in-right"></i> Se connecter
            </button>

        <?= form_close(); ?>

        <div class="text-center mt-3">
            <small class="text-muted">Ligne Moroni — Mutsamudu</small>
        </div>
    </div>
</body>
</html>
