<!DOCTYPE html>
<html lang="<?= getLang() ?>" dir="<?= isRTL() ? 'rtl' : 'ltr' ?>">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= __('login') ?> | HelperLink Admin</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <?php if (isRTL()): ?>
    <link href="https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap" rel="stylesheet">
    <?php else: ?>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
    <?php endif; ?>
    
    <style>
        :root {
            --primary: #2F6BFF;
            --bg-main: #F5F7FB;
            --card-bg: #FFFFFF;
            --text-primary: #111827;
            --text-secondary: #6B7280;
            --radius-card: 20px;
            --radius-input: 12px;
            --radius-btn: 14px;
            --shadow-soft: 0 8px 24px rgba(0,0,0,0.05);
            --font-main: '<?= isRTL() ? 'Cairo' : 'Inter' ?>', sans-serif;
        }

        body {
            background-color: var(--bg-main);
            font-family: var(--font-main);
            color: var(--text-primary);
            height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .login-card {
            background: var(--card-bg);
            border-radius: var(--radius-card);
            box-shadow: var(--shadow-soft);
            padding: 40px;
            width: 100%;
            max-width: 420px;
            text-align: center;
        }

        .logo-placeholder {
            width: 64px;
            height: 64px;
            background: rgba(47,107,255,0.1);
            color: var(--primary);
            border-radius: 16px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 28px;
            margin: 0 auto 24px;
        }

        .form-control {
            height: 48px;
            border-radius: var(--radius-input);
            border: 1px solid #E5E7EB;
            padding: 0 16px;
            font-size: 14px;
        }

        .form-control:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 4px rgba(47,107,255,0.12);
        }

        .btn-primary {
            background-color: var(--primary);
            border: none;
            border-radius: var(--radius-btn);
            height: 48px;
            font-weight: 600;
            width: 100%;
            margin-top: 16px;
            transition: all 0.3s;
        }

        .btn-primary:hover {
            background-color: #2555CC;
            box-shadow: 0 12px 30px rgba(47,107,255,0.12);
            transform: translateY(-1px);
        }

        .lang-switch {
            position: absolute;
            top: 24px;
            right: 24px;
            text-decoration: none;
            color: var(--text-secondary);
            font-weight: 500;
        }

        html[dir="rtl"] .lang-switch {
            right: auto;
            left: 24px;
        }
    </style>
</head>
<body>

    <a href="?lang=<?= isRTL() ? 'en' : 'ar' ?>" class="lang-switch">
        <i class="fas fa-globe"></i> <?= isRTL() ? __('english') : __('arabic') ?>
    </a>

    <div class="login-card">
        <div class="logo-placeholder">
            <i class="fas fa-hand-holding-heart"></i>
        </div>
        <h3 class="mb-1 fw-bold"><?= __('welcome_back') ?></h3>
        <p class="text-secondary mb-4" style="font-size: 14px;"><?= __('sign_in_to_admin') ?></p>

        <?php if (!empty($error)): ?>
            <div class="alert alert-danger" style="border-radius: var(--radius-input); font-size: 14px;">
                <?= htmlspecialchars($error) ?>
            </div>
        <?php endif; ?>

        <form action="?page=login" method="POST">
            <div class="mb-3 text-start">
                <label class="form-label text-secondary fw-semibold" style="font-size: 12px;"><?= __('email') ?></label>
                <input type="email" name="email" class="form-control" required placeholder="admin@helperlink.com">
            </div>
            <div class="mb-4 text-start">
                <label class="form-label text-secondary fw-semibold" style="font-size: 12px;"><?= __('password') ?></label>
                <input type="password" name="password" class="form-control" required placeholder="••••••••">
            </div>
            <button type="submit" class="btn btn-primary"><?= __('sign_in') ?></button>
        </form>
    </div>

</body>
</html>
