<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="layout" content="width=device-width, initial-scale=1.0">
    <title><?= $title ?? 'تسجيل الدخول' ?></title>
    <!-- Google Fonts: Tajawal -->
    <link href="https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap" rel="stylesheet">
    <!-- Bootstrap 5 RTL -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.rtl.min.css">
    <!-- FontAwesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        body {
            font-family: 'Tajawal', sans-serif;
            background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 0;
        }
        .login-card {
            background: #ffffff;
            border-radius: 24px;
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
            width: 100%;
            max-width: 420px;
            padding: 3rem 2.5rem;
            position: relative;
            overflow: hidden;
        }
        .login-card::before {
            content: '';
            position: absolute;
            top: 0; left: 0; width: 100%; height: 6px;
            background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
        }
        .form-control {
            border-radius: 12px;
            padding: 0.8rem 1rem;
            border: 2px solid #e2e8f0;
            font-weight: 500;
            transition: all 0.3s ease;
        }
        .form-control:focus {
            border-color: #3b82f6;
            box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
        }
        .btn-login {
            border-radius: 12px;
            padding: 0.85rem;
            font-weight: 700;
            font-size: 1.1rem;
            letter-spacing: 0.5px;
            background: #0f172a;
            border: none;
            transition: all 0.3s ease;
        }
        .btn-login:hover {
            background: #1e293b;
            transform: translateY(-2px);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        }
    </style>
</head>
<body>

<div class="login-card animate-slide-up">
    <div class="text-center mb-5">
        <h2 class="fw-bold mb-1" style="color: #0f172a; letter-spacing: -1px;"><i class="fa-solid fa-infinity text-primary me-2"></i> OTIS</h2>
        <p class="text-muted fw-semibold">نظام الإدارة الحياتية المتكامل</p>
    </div>

    <?= display_flash_message('auth_error') ?>
    <?= display_flash_message('system') ?>

    <form action="<?= BASE_URL ?>/auth/authenticate" method="POST">
        <?= csrf_field() ?>
        <div class="mb-4">
            <label class="form-label text-secondary fw-bold small">اسم المستخدم</label>
            <div class="input-group">
                <span class="input-group-text bg-light border-end-0 text-muted px-3"><i class="fa-solid fa-user"></i></span>
                <input type="text" name="username" class="form-control border-start-0 ps-0" placeholder="أدخل اسم الحساب" required autofocus>
            </div>
        </div>
        
        <div class="mb-5">
            <label class="form-label text-secondary fw-bold small">كلمة المرور</label>
            <div class="input-group">
                <span class="input-group-text bg-light border-end-0 text-muted px-3"><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>

        <button type="submit" class="btn btn-primary w-100 btn-login text-white">تسجيل الدخول <i class="fa-solid fa-arrow-left ms-2"></i></button>
    </form>
    
    <div class="text-center mt-4">
        <small class="text-muted fw-semibold">مرحلة التأمين والحماية الجاهزة للإنتاج</small>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
