<?php
require_once('source/session.php');
require_once('source/error.php');
require_once('source/dbconfig.php');
require_once('source/function.php');

if($SESS_FULLNAME_USER){
    $msg = "Welcome, $SESS_FULLNAME_USER!";
}
else if($_SESSION['msg'] == "activated"){
    $msg = "Email Verification is Successful!<br>Sign in to Your Dashboard";
}
else if($_GET['msg'] == "inactive"){
    $msg = "Are you a new member? Check your email to activate your account Now! For a blocked participant, write to support.";
}

if($_SESSION['msg'] == "duplicate") {
    $msg = "Email already registered, please try another.";
}            
else if($_SESSION['msg'] == "signup") {
    $msg = "Account Registered successfully.";
}            
else if($_SESSION['msg'] == "captcha") {
    $msg = "Incorrect Captcha.";
}            
else if($_SESSION['msg'] == "samp") {
    $msg = "Samp request found, please try again.";
}            
else if($_SESSION['msg'] == "failed") {
    $msg = "Invalid Email Password Combination.";
}            
else if($_SESSION['msg'] == "forget") {
    $msg = "New password has been sent to your verified email.";
}            
unset($_SESSION['msg']);
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Admin Login | Henzy Royal International School - Powered by DataSwift Coders</title>
    <link rel="icon" type="image/png" href="https://portal.hris.com.ng/coll_admin/coll_logo.jpg">
    
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    
    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    
    <style>
        :root {
            --primary-blue: #1a4b8c;    /* Royal Blue */
            --dark-blue: #0f2b4f;        /* Dark Blue */
            --light-blue: #4a7db5;        /* Medium Blue */
            --accent-gold: #FFD700;        /* Gold */
            --light-gold: #FFF1B8;         /* Light Gold */
            --bg-gradient-start: #1a4b8c;
            --bg-gradient-end: #0f2b4f;
        }
        
        body {
            font-family: 'Poppins', sans-serif;
            background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            justify-content: center;
            color: #333;
        }
        
        .login-container {
            max-width: 500px;
            margin: 0 auto;
            animation: fadeIn 0.5s ease-in-out;
        }
        
        .login-card {
            border: none;
            border-radius: 12px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            overflow: hidden;
            transition: transform 0.3s ease;
            border: 2px solid var(--accent-gold);
        }
        
        .login-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 40px rgba(255, 215, 0, 0.15);
        }
        
        .card-header {
            background: linear-gradient(135deg, var(--primary-blue), var(--dark-blue));
            color: white;
            padding: 1.5rem;
            text-align: center;
            font-weight: 600;
            font-size: 1.25rem;
            border-bottom: 3px solid var(--accent-gold);
        }
        
        .card-body {
            padding: 2rem;
            background-color: white;
        }
        
        .school-info {
            text-align: center;
            margin-bottom: 1.5rem;
            padding-bottom: 1rem;
            border-bottom: 2px dashed var(--accent-gold);
        }
        
        .school-name {
            font-weight: 700;
            color: var(--primary-blue);
            font-size: 1.2rem;
            margin-bottom: 5px;
        }
        
        .school-address {
            font-size: 0.85rem;
            color: #666;
            font-style: italic;
        }
        
        .form-control {
            height: 50px;
            border-radius: 8px;
            border: 1px solid #ddd;
            padding-left: 45px;
            transition: all 0.3s;
        }
        
        .form-control:focus {
            border-color: var(--accent-gold);
            box-shadow: 0 0 0 0.2rem rgba(255, 215, 0, 0.25);
        }
        
        .input-icon {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--primary-blue);
            z-index: 10;
        }
        
        .btn-login {
            background: linear-gradient(135deg, var(--primary-blue), var(--dark-blue));
            border: none;
            color: white;
            padding: 12px 0;
            font-weight: 600;
            border-radius: 8px;
            transition: all 0.3s;
            width: 100%;
            border: 1px solid var(--accent-gold);
        }
        
        .btn-login:hover {
            background: linear-gradient(135deg, var(--accent-gold), #e6b800);
            color: var(--dark-blue);
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(255, 215, 0, 0.3);
        }
        
        .school-logo {
            width: 100px;
            height: 100px;
            object-fit: cover;
            border-radius: 50%;
            margin-bottom: 1rem;
            border: 3px solid var(--accent-gold);
            box-shadow: 0 5px 15px rgba(0,0,0,0.2);
        }
        
        .logo-text {
            font-size: 2rem;
            font-weight: 900;
            color: white;
            letter-spacing: 3px;
            line-height: 1.2;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
            margin-bottom: 5px;
        }
        
        .logo-text span {
            color: var(--accent-gold);
        }
        
        .tagline {
            color: var(--accent-gold);
            font-size: 0.9rem;
            font-style: italic;
            letter-spacing: 2px;
            margin-top: 5px;
        }
        
        .powered-by {
            color: white;
            text-align: center;
            margin-top: 2rem;
            font-size: 0.9rem;
        }
        
        .powered-by a {
            color: var(--accent-gold);
            text-decoration: none;
            transition: color 0.3s;
            display: inline-flex;
            align-items: center;
            gap: 8px;
        }
        
        .powered-by a:hover {
            color: white;
            transform: translateY(-2px);
        }
        
        .powered-by img {
            height: 30px;
            filter: brightness(0) invert(1);
            transition: transform 0.3s;
        }
        
        .powered-by a:hover img {
            transform: scale(1.1);
        }
        
        .message-alert {
            margin-bottom: 1.5rem;
            border-radius: 8px;
            text-align: center;
            background-color: var(--light-gold);
            color: var(--dark-blue);
            border: 1px solid var(--accent-gold);
            padding: 12px;
        }
        
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        .form-group {
            position: relative;
            margin-bottom: 1.5rem;
        }
        
        .support-info {
            background: rgba(255,255,255,0.1);
            padding: 10px;
            border-radius: 8px;
            margin-top: 15px;
            color: white;
            font-size: 0.85rem;
        }
        
        .support-info i {
            color: var(--accent-gold);
            margin-right: 5px;
        }
        
        .campus-badge {
            background: var(--accent-gold);
            color: var(--dark-blue);
            padding: 5px 10px;
            border-radius: 20px;
            font-size: 0.75rem;
            font-weight: 600;
            display: inline-block;
            margin-bottom: 10px;
        }
    </style>
</head>

<body>
    <div class="container login-container">
        <div class="text-center mb-4">
            <!-- School Logo/Text -->
            <div class="logo-text">
                H.R.<span>I.S</span>
            </div>
            <div class="tagline">
                THE PRIDE OF EXCELLENCE
            </div>
            <div class="campus-badge mt-2">
                <i class="fas fa-map-marker-alt me-1"></i> Main Campus
            </div>
        </div>
        
        <div class="login-card">
            <div class="card-header">
                <i class="fas fa-user-shield me-2"></i> ADMIN PORTAL
            </div>
            
            <div class="card-body">
                <!-- School Information -->
                <div class="school-info">
                    <div class="school-name">
                        <i class="fas fa-school me-2" style="color: var(--accent-gold);"></i>
                        Henzy Royal International School
                    </div>
                    <div class="school-address">
                        <i class="fas fa-map-pin me-1" style="color: var(--primary-blue);"></i>
                        No 17 Amadi Street, Amakohia, Uratta Owerri Imo State Nigeria
                    </div>
                </div>
                
                <?php if(!empty($msg)): ?>
                    <div class="message-alert">
                        <i class="fas fa-info-circle me-2"></i>
                        <?php echo $msg; ?>
                    </div>
                <?php endif; ?>
                
                <form method="post" action="exe_signin.php">
                    <div class="form-group">
                        <i class="fas fa-user input-icon"></i>
                        <input type="text" class="form-control" name="username" placeholder="Enter Username" required autofocus>
                    </div>
                    
                    <div class="form-group">
                        <i class="fas fa-lock input-icon"></i>
                        <input type="password" class="form-control" name="password" placeholder="Enter Password" required>
                    </div>
                    
                    <div class="d-grid gap-2">
                        <button type="submit" name="signin" class="btn btn-login">
                            <i class="fas fa-sign-in-alt me-2"></i> SIGN IN
                        </button>
                    </div>
                </form>
                
                <div class="text-center mt-3">
                    <small class="text-muted">
                        <i class="fas fa-shield-alt me-1" style="color: var(--primary-blue);"></i>
                        Secure Admin Access Only
                    </small>
                </div>
            </div>
        </div>
        
        <div class="powered-by">
            <div class="support-info">
                <i class="fas fa-phone-alt"></i> Support: +234 803 292 9756
                <span class="mx-2">|</span>
                <i class="fas fa-envelope"></i> support@hris.com.ng
            </div>
            
            <div class="mt-3">
                <a href="https://dataswift.com.ng" target="_blank">
                    <span>Proudly powered by</span>
                    <img src="datalogo.png" alt="DataSwift Coders" onerror="this.style.display='none'; this.nextElementSibling.style.display='inline';">
                    <span style="display:none;">DataSwift Coders</span>
                </a>
            </div>
            
            <div class="mt-2 small" style="opacity: 0.8;">
                <i class="fas fa-copyright me-1"></i> <?php echo date("Y"); ?> Henzy Royal International School. 
                <br class="d-sm-none">All Rights Reserved.
            </div>
            
            <div class="mt-2" style="font-size: 0.7rem; opacity: 0.6;">
                No 17 Amadi Street, Amakohia, Uratta Owerri Imo State Nigeria
            </div>
        </div>
    </div>

    <!-- Bootstrap 5 JS Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <!-- Font Awesome -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/js/all.min.js"></script>
    
    <script>
    document.addEventListener('DOMContentLoaded', function() {
        // Auto-hide alerts after 5 seconds
        const alert = document.querySelector('.message-alert');
        if (alert) {
            setTimeout(() => {
                alert.style.transition = 'opacity 0.5s ease';
                alert.style.opacity = '0';
                setTimeout(() => {
                    alert.style.display = 'none';
                }, 500);
            }, 5000);
        }
        
        // Add animation to form inputs
        const inputs = document.querySelectorAll('.form-control');
        inputs.forEach(input => {
            input.addEventListener('focus', function() {
                this.parentElement.querySelector('.input-icon').style.color = 'var(--accent-gold)';
            });
            input.addEventListener('blur', function() {
                this.parentElement.querySelector('.input-icon').style.color = 'var(--primary-blue)';
            });
        });
    });
    </script>
</body>
</html>