<?php
require_once(dirname(__DIR__) . '/init.php');

// Zaten giriş yapmışsa yönlendir
if(m_admin_check()){
    m_redirect(ADMIN_URL);
}
?>
<!DOCTYPE html>
<html lang="tr">
<head>
    <title><?=PROJECT?> | <?= lang('title', [], 'Yönetim Paneli') ?></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta content="VebuSoft Yönetim Paneli" name="description" />
    <meta content="VebuSoft" name="author" />
    <meta name="csrf-token" content="<?= $_SESSION['csrf_token']['value'] ?? '' ?>">
    
    <!-- App favicon -->
    <link rel="shortcut icon" href="<?=ADMIN_THEME_URL?>/assets/images/vebuicon.svg">
    <link rel="stylesheet" href="<?=ADMIN_THEME_URL?>/assets/css/login.css">
    <link rel="stylesheet" href="<?=ADMIN_THEME_URL?>/assets/css/bootstrap.min.css">
    <link href="<?=ADMIN_THEME_URL?>/assets/css/app.min.css" rel="stylesheet" type="text/css">
    
    <style>
        .field-error {
            display: none;
            color: #dc3545;
            font-size: 0.875rem;
            margin-top: 0.25rem;
        }
        
        .is-invalid {
            border-color: #dc3545 !important;
        }
        
        .alert {
            border-radius: 0.375rem;
            padding: 0.75rem 1rem;
            margin-bottom: 1rem;
        }
        
        .alert-danger {
            background-color: #f8d7da;
            border: 1px solid #f5c6cb;
            color: #721c24;
        }
        
        .alert-success {
            background-color: #d4edda;
            border: 1px solid #c3e6cb;
            color: #155724;
        }
        
        .spinner-border-sm {
            width: 1rem;
            height: 1rem;
        }
    </style>
</head>

<body>
<div class="wrapper">
    <img class="login_logo" src="<?=ADMIN_THEME_URL?>/assets/images/vebusoft-logo-beyaz.svg">
    
    <div class="login-box">
        <form id="secure-login-form" method="POST">
            <h2><?=lang('login_welcome', [], 'Hoş Geldiniz')?></h2>
            
            <!-- CSRF Token -->
            <input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token']['value'] ?? '' ?>">
            
            <!-- Alert Messages -->
            <div id="login-error" class="alert alert-danger" style="display: none;"></div>
            <div id="login-success" class="alert alert-success" style="display: none;"></div>
            
            <div class="input-box">
                <span class="icon">
                    <ion-icon name="mail"></ion-icon>
                </span>
                <input type="email" id="email" name="email" required>
                <label><?=lang('login_email_adress', [], 'Email Adresi')?></label>
            </div>

            <div class="input-box">
                <span class="icon">
                    <ion-icon name="lock-closed"></ion-icon>
                </span>
                <input type="password" id="password" name="password" required>
                <label><?=lang('login_password', [], 'Şifre')?></label>
            </div>

            <div class="remember-forgot">
                <label>
                    <input type="checkbox" id="remember-me" name="remember_me">
                    <?=lang('login_remember_me', [], 'Beni Hatırla')?>
                </label>
                <a href="#" id="forgot-password"><?=lang('login_password_forget', [], 'Şifremi Unuttum')?></a>
            </div>

            <button type="submit" id="login-submit"><?=lang('login_login', [], 'Giriş Yap')?></button>
        </form>
    </div>
</div>

<script src="<?=ADMIN_THEME_URL?>/assets/js/plugins.js"></script>
<script src="<?=ADMIN_THEME_URL?>/assets/js/secure-login.js"></script>

<script type="module" src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.js"></script>
</body>
</html> 