<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login - Malawi Secondary School LMS</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <style>
        :root {
            --primary: #1a56db;
            --primary-hover: #1e40af;
            --secondary: #10b981;
            --text-main: #111827;
            --text-muted: #6b7280;
            --bg-main: #f3f4f6;
            --bg-card: #ffffff;
            --border-color: #e5e7eb;
            --error: #ef4444;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Inter', sans-serif;
        }

        body {
            background-color: var(--bg-main);
            color: var(--text-main);
            display: flex;
            min-height: 100vh;
        }

        .split-layout {
            display: flex;
            width: 100%;
        }

        .left-pane {
            flex: 1;
            background: linear-gradient(135deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.8)), url('https://images.unsplash.com/photo-1577896851231-70ef18881754?q=80&w=2070&auto=format&fit=crop') no-repeat center center;
            background-size: cover;
            display: flex;
            flex-direction: column;
            justify-content: center;
            padding: 4rem;
            color: white;
            position: relative;
        }

        .left-pane::before {
            content: '';
            position: absolute;
            top: 0; left: 0; right: 0; bottom: 0;
            background: linear-gradient(to bottom, transparent, rgba(0,0,0,0.7));
            z-index: 1;
        }

        .left-content {
            position: relative;
            z-index: 2;
            max-width: 600px;
        }

        .brand-badge {
            display: inline-block;
            padding: 0.5rem 1rem;
            background: rgba(255, 255, 255, 0.2);
            backdrop-filter: blur(10px);
            border-radius: 9999px;
            font-weight: 500;
            font-size: 0.875rem;
            margin-bottom: 1.5rem;
            border: 1px solid rgba(255, 255, 255, 0.3);
        }

        .left-pane h1 {
            font-size: 3.5rem;
            font-weight: 700;
            line-height: 1.2;
            margin-bottom: 1.5rem;
            text-shadow: 0 4px 6px rgba(0,0,0,0.1);
        }

        .left-pane p {
            font-size: 1.25rem;
            color: #e5e7eb;
            line-height: 1.6;
        }

        .right-pane {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: var(--bg-card);
            padding: 2rem;
        }

        .login-container {
            width: 100%;
            max-width: 440px;
        }

        .login-header {
            margin-bottom: 2.5rem;
        }

        .login-header h2 {
            font-size: 2rem;
            font-weight: 700;
            margin-bottom: 0.5rem;
        }

        .login-header p {
            color: var(--text-muted);
            font-size: 1rem;
        }

        .form-group {
            margin-bottom: 1.5rem;
            position: relative;
        }

        .form-label {
            display: block;
            font-size: 0.875rem;
            font-weight: 500;
            margin-bottom: 0.5rem;
            color: var(--text-main);
        }

        .form-control {
            width: 100%;
            padding: 0.875rem 1rem;
            font-size: 1rem;
            border: 1px solid var(--border-color);
            border-radius: 0.5rem;
            transition: all 0.2s ease;
            outline: none;
            background-color: #f9fafb;
        }

        .form-control:focus {
            border-color: var(--primary);
            background-color: #fff;
            box-shadow: 0 0 0 4px rgba(26, 86, 219, 0.1);
        }

        .btn-submit {
            width: 100%;
            padding: 1rem;
            background-color: var(--primary);
            color: white;
            border: none;
            border-radius: 0.5rem;
            font-size: 1rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 0.5rem;
            margin-top: 1rem;
        }

        .btn-submit:hover {
            background-color: var(--primary-hover);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(26, 86, 219, 0.2);
        }

        .btn-submit:active {
            transform: translateY(0);
        }

        .alert-error {
            background-color: #fef2f2;
            border: 1px solid #f87171;
            color: var(--error);
            padding: 1rem;
            border-radius: 0.5rem;
            margin-bottom: 1.5rem;
            font-size: 0.875rem;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .meta-links {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 1.5rem;
            font-size: 0.875rem;
        }

        .meta-links a {
            color: var(--primary);
            text-decoration: none;
            font-weight: 500;
            transition: color 0.2s;
        }

        .meta-links a:hover {
            color: var(--primary-hover);
            text-decoration: underline;
        }

        @media (max-width: 900px) {
            .split-layout {
                flex-direction: column;
            }
            .left-pane {
                padding: 3rem 2rem;
                min-height: 40vh;
            }
            .left-pane h1 {
                font-size: 2.5rem;
            }
            .right-pane {
                padding: 3rem 2rem;
            }
        }
    </style>
</head>
<body>
    <div class="split-layout">
        <div class="left-pane">
            <div class="left-content">
                <div style="margin-bottom: 1.5rem;">
                    <img src="<?= base_url('assets/images/logo.png') ?>" alt="Civil Society Organisation" style="height: 80px; width: auto; border-radius: 8px; background: white; padding: 4px;">
                </div>
                <h1>Empowering the Future of Malawi.</h1>
                <p>Welcome to the official Learning Management System for Malawi Secondary Schools. Access your courses, grades, and resources all in one place.</p>
            </div>
        </div>
        <div class="right-pane">
            <div class="login-container">
                <div class="login-header">
                    <h2>Welcome back</h2>
                    <p>Please enter your credentials to sign in.</p>
                </div>

                <?php if (isset($error) && !empty($error)): ?>
                    <div class="alert-error">
                        <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></svg>
                        <?= htmlspecialchars($error) ?>
                    </div>
                <?php endif; ?>

                <form action="<?= site_url('auth/do_login') ?>" method="POST">
                    <div class="form-group">
                        <label for="username" class="form-label">Username</label>
                        <input type="text" id="username" name="username" class="form-control" placeholder="Enter your username" required autocomplete="username">
                    </div>
                    <div class="form-group">
                        <label for="password" class="form-label">Password</label>
                        <input type="password" id="password" name="password" class="form-control" placeholder="••••••••" required autocomplete="current-password">
                    </div>
                    <button type="submit" class="btn-submit">
                        Sign In
                        <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>
                    </button>
                </form>

                <div class="meta-links">
                    <label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer; color: var(--text-muted);">
                        <input type="checkbox" style="accent-color: var(--primary);"> Remember me
                    </label>
                    <a href="#">Forgot password?</a>
                </div>

                <div style="margin-top: 2rem; text-align: center; font-size: 0.875rem; color: var(--text-muted);">
                    Don't have an account? <a href="<?= site_url('auth/register') ?>" style="color: var(--primary); text-decoration: none; font-weight: 600;">Register as Student</a>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
