<?php
/**
 * Dark Theme Landing Page & Dashboard Router
 * BoostWithKagujje SMM Platform
 */

session_start();

// Check if user is logged in
$isLoggedIn = isset($_SESSION['user_id']);
$userName = $_SESSION['user_name'] ?? 'Guest';
$userBalance = $_SESSION['user_balance'] ?? 0;
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $isLoggedIn ? 'Dashboard' : 'BoostWithKagujje'; ?> - SMM Social Media Growth</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@400;500;600;700;800&display=swap" rel="stylesheet">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        :root {
            --primary: #ffffff;
            --primary-hover: #f0f0f0;
            --secondary: #000000;
            --accent: #cccccc;
            --dark-bg: #000000;
            --dark-card: #111111;
            --dark-border: #222222;
            --light-text: #ffffff;
            --text: #e0e0e0;
            --text-light: #999999;
            --glow-white: rgba(255, 255, 255, 0.2);
            --glow-gray: rgba(200, 200, 200, 0.15);
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'San Francisco', 'Helvetica Neue', sans-serif;
            line-height: 1.6;
            color: var(--text);
            background: var(--dark-bg);
            overflow-x: hidden;
        }

        /* Navigation */
        nav {
            background: var(--dark-card);
            border-bottom: 1px solid var(--dark-border);
            position: sticky;
            top: 0;
            z-index: 100;
            box-shadow: 0 8px 32px rgba(255, 255, 255, 0.05);
        }

        nav .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 1rem 2rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .logo {
            font-size: 1.5rem;
            font-weight: 700;
            color: var(--light-text);
            display: flex;
            gap: 0.5rem;
            align-items: center;
            letter-spacing: -0.5px;
        }

        .logo span:first-child {
            font-size: 1.8rem;
        }

        nav .nav-right {
            display: flex;
            gap: 2rem;
            align-items: center;
        }

        .nav-right a {
            text-decoration: none;
            color: var(--text);
            font-weight: 500;
            transition: all 0.3s ease;
            position: relative;
        }

        .nav-right a:before {
            content: '';
            position: absolute;
            bottom: -4px;
            left: 0;
            width: 0;
            height: 2px;
            background: var(--primary);
            transition: width 0.3s ease;
        }

        .nav-right a:hover {
            color: var(--primary);
        }

        .nav-right a:hover:before {
            width: 100%;
        }

        .btn {
            padding: 0.65rem 1.75rem;
            border: none;
            border-radius: 12px;
            cursor: pointer;
            font-weight: 600;
            transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
            text-decoration: none;
            display: inline-block;
            position: relative;
            overflow: hidden;
            font-size: 0.95rem;
            letter-spacing: 0.3px;
            user-select: none;
            -webkit-user-select: none;
        }

        .btn::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: rgba(255, 255, 255, 0.15);
            transition: left 0.5s ease;
            z-index: -1;
        }

        .btn:active::before {
            left: 100%;
        }

        .btn:active {
            transform: scale(0.98);
        }

        .btn-primary {
            background: linear-gradient(135deg, #ffffff, #f0f0f0);
            color: #000000;
            box-shadow: 0 0 20px rgba(255, 255, 255, 0.2), inset 0 0 20px rgba(255,255,255,0.1);
            position: relative;
        }

        .btn-primary::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 0;
            height: 0;
            background: rgba(255, 255, 255, 0.3);
            border-radius: 50%;
            pointer-events: none;
            transform: translate(-50%, -50%);
        }

        .btn-primary:hover {
            transform: translateY(-3px) scale(1.02);
            box-shadow: 0 8px 32px rgba(255, 255, 255, 0.3), 0 0 40px rgba(255, 255, 255, 0.2), inset 0 0 20px rgba(255,255,255,0.2);
        }

        .btn-primary:focus {
            outline: 2px solid #ffffff;
            outline-offset: 2px;
        }

        .btn-secondary {
            background: rgba(255, 255, 255, 0.1);
            color: #ffffff;
            border: 1.5px solid #ffffff;
            box-shadow: 0 0 15px rgba(255, 255, 255, 0.15);
            transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
        }

        .btn-secondary:hover {
            background: linear-gradient(135deg, #ffffff, #f0f0f0);
            color: #000000;
            box-shadow: 0 0 40px rgba(255, 255, 255, 0.3), 0 8px 32px rgba(255, 255, 255, 0.2), inset 0 0 20px rgba(255,255,255,0.1);
            transform: translateY(-3px);
            border-color: transparent;
        }

        .btn-secondary:focus {
            outline: 2px solid #ffffff;
            outline-offset: 2px;
        }

        /* Hero Section */
        .hero {
            background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(200, 200, 200, 0.03) 100%),
                        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
            color: white;
            padding: 8rem 2rem;
            text-align: center;
            position: relative;
            overflow: hidden;
        }

        .hero::before {
            content: '';
            position: absolute;
            top: -50%;
            right: -50%;
            width: 100%;
            height: 100%;
            background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
            animation: float 6s ease-in-out infinite;
        }

        @keyframes float {
            0%, 100% { transform: translate(0, 0); }
            50% { transform: translate(30px, -30px); }
        }

        .hero .container {
            max-width: 900px;
            margin: 0 auto;
            position: relative;
            z-index: 2;
        }

        .hero h1 {
            font-size: 3.8rem;
            margin-bottom: 1rem;
            font-weight: 800;
            line-height: 1.15;
            background: linear-gradient(135deg, var(--light-text) 0%, var(--text) 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            letter-spacing: -1px;
        }

        .hero p {
            font-size: 1.3rem;
            margin-bottom: 2.5rem;
            color: var(--text);
            opacity: 0.95;
            letter-spacing: 0.3px;
        }

        .hero-cta {
            display: flex;
            gap: 1.5rem;
            justify-content: center;
            flex-wrap: wrap;
        }

        /* Stats Section */
        .stats {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 2rem;
            margin: 4rem auto;
            max-width: 1200px;
            padding: 0 2rem;
        }

        .stat-card {
            background: var(--dark-card);
            padding: 2.5rem 2rem;
            border-radius: 16px;
            text-align: center;
            border: 1px solid var(--dark-border);
            transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
            position: relative;
            overflow: hidden;
        }

        .stat-card::before {
            content: '';
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
            opacity: 0;
            transition: opacity 0.4s;
        }

        .stat-card:hover {
            border-color: #ffffff;
            transform: translateY(-8px);
            box-shadow: 0 20px 40px rgba(255, 255, 255, 0.1), 0 0 30px rgba(255, 255, 255, 0.15);
        }

        .stat-card:hover::before {
            opacity: 1;
        }

        .stat-number {
            font-size: 2.8rem;
            font-weight: 800;
            background: linear-gradient(135deg, #ffffff, #cccccc);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            margin-bottom: 0.5rem;
            letter-spacing: -1px;
        }

        .stat-label {
            color: var(--text-light);
            font-size: 0.95rem;
            font-weight: 500;
            letter-spacing: 0.5px;
        }

        /* Features Section */
        .features {
            padding: 5rem 2rem;
            background: var(--dark-bg);
        }

        .section-title {
            text-align: center;
            font-size: 2.8rem;
            margin-bottom: 4rem;
            color: var(--light-text);
            font-weight: 700;
            letter-spacing: -1px;
        }

        .features-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
            gap: 2.5rem;
            max-width: 1200px;
            margin: 0 auto;
        }

        .feature-card {
            padding: 2.5rem;
            border-radius: 16px;
            border: 1px solid var(--dark-border);
            background: var(--dark-card);
            transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
            position: relative;
        }

        .feature-card::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(200, 200, 200, 0.02) 100%);
            opacity: 0;
            border-radius: 16px;
            transition: opacity 0.4s;
            pointer-events: none;
        }

        .feature-card:hover {
            border-color: #ffffff;
            transform: translateY(-8px);
            box-shadow: 0 20px 50px rgba(255, 255, 255, 0.1), 0 0 30px rgba(255, 255, 255, 0.15);
        }

        .feature-card:hover::after {
            opacity: 1;
        }

        .feature-icon {
            font-size: 2.8rem;
            margin-bottom: 1.2rem;
            display: inline-block;
        }

        .feature-card h3 {
            margin-bottom: 0.8rem;
            color: var(--light-text);
            font-size: 1.2rem;
            font-weight: 600;
        }

        .feature-card p {
            color: var(--text-light);
            font-size: 0.95rem;
            line-height: 1.6;
        }

        /* Dashboard Section */
        .dashboard {
            display: none;
        }

        .dashboard.active {
            display: block;
        }

        .dashboard-header {
            background: linear-gradient(135deg, var(--dark-card) 0%, rgba(99, 102, 241, 0.1) 100%);
            padding: 3rem 2rem;
            border-bottom: 1px solid var(--dark-border);
            margin-bottom: 3rem;
            border-radius: 16px;
        }

        .dashboard-header h1 {
            color: var(--light-text);
            font-size: 2.2rem;
            font-weight: 700;
            margin-bottom: 0.5rem;
        }

        .dashboard-header p {
            color: var(--text-light);
            font-weight: 500;
        }

        .dashboard-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 2rem;
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 2rem 3rem;
        }

        .dashboard-card {
            background: var(--dark-card);
            padding: 2rem;
            border-radius: 16px;
            border: 1px solid var(--dark-border);
            transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
            position: relative;
            overflow: hidden;
        }

        .dashboard-card::before {
            content: '';
            position: absolute;
            top: -50%;
            right: -50%;
            width: 100%;
            height: 100%;
            background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
            opacity: 0;
            transition: opacity 0.4s;
        }

        .dashboard-card:hover {
            border-color: #ffffff;
            box-shadow: 0 15px 40px rgba(255, 255, 255, 0.1), 0 0 25px rgba(255, 255, 255, 0.15);
            transform: translateY(-5px);
        }

        .dashboard-card:hover::before {
            opacity: 0.5;
        }

        .dashboard-card h3 {
            font-size: 0.85rem;
            color: var(--text-light);
            margin-bottom: 1rem;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            font-weight: 600;
        }

        .dashboard-card .value {
            font-size: 2.2rem;
            font-weight: 800;
            background: linear-gradient(135deg, #ffffff, #cccccc);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            position: relative;
            z-index: 1;
        }

        /* Pricing Section */
        .pricing {
            padding: 5rem 2rem;
            background: var(--dark-bg);
        }

        .pricing-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 2.5rem;
            max-width: 1200px;
            margin: 0 auto;
        }

        .pricing-card {
            background: var(--dark-card);
            padding: 2.5rem;
            border-radius: 16px;
            border: 1px solid var(--dark-border);
            text-align: center;
            transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
            position: relative;
            overflow: hidden;
        }

        .pricing-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(200, 200, 200, 0.02) 100%);
            opacity: 0;
            transition: opacity 0.4s;
        }

        .pricing-card.featured {
            border: 2px solid #ffffff;
            box-shadow: 0 0 40px rgba(255, 255, 255, 0.2), inset 0 0 30px rgba(255, 255, 255, 0.05);
            transform: scale(1.08);
        }

        .pricing-card:hover {
            box-shadow: 0 20px 50px rgba(255, 255, 255, 0.15), 0 0 30px rgba(255, 255, 255, 0.2);
            border-color: #ffffff;
            transform: translateY(-8px);
        }

        .pricing-card.featured:hover {
            transform: scale(1.08) translateY(-8px);
        }

        .pricing-card:hover::before {
            opacity: 1;
        }

        .pricing-card h3 {
            font-size: 1.5rem;
            margin-bottom: 1rem;
            color: var(--light-text);
            font-weight: 700;
            position: relative;
            z-index: 1;
        }

        .price {
            font-size: 2.8rem;
            font-weight: 800;
            background: linear-gradient(135deg, #ffffff, #cccccc);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            margin-bottom: 1.5rem;
            position: relative;
            z-index: 1;
        }

        .price span {
            font-size: 0.9rem;
            color: var(--text-light);
            display: block;
            margin-top: 0.3rem;
        }

        .pricing-features {
            text-align: left;
            margin: 2rem 0;
            padding: 2rem 0;
            border-top: 1px solid var(--dark-border);
            border-bottom: 1px solid var(--dark-border);
            position: relative;
            z-index: 1;
        }

        .pricing-features li {
            list-style: none;
            padding: 0.7rem 0;
            color: var(--text-light);
            font-weight: 500;
            letter-spacing: 0.3px;
        }

        .pricing-features li:before {
            content: "✓ ";
            color: #ffffff;
            font-weight: bold;
            margin-right: 0.8rem;
        }

        /* CTA Section */
        .cta {
            background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(200, 200, 200, 0.05) 100%),
                        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.08) 0%, transparent 50%);
            color: white;
            padding: 5rem 2rem;
            text-align: center;
            position: relative;
            overflow: hidden;
            border-top: 1px solid var(--dark-border);
            border-bottom: 1px solid var(--dark-border);
        }

        .cta h2 {
            font-size: 2.8rem;
            margin-bottom: 1rem;
            font-weight: 800;
            letter-spacing: -1px;
        }

        .cta p {
            font-size: 1.15rem;
            margin-bottom: 2.5rem;
            opacity: 0.9;
            color: var(--text);
            max-width: 600px;
            margin-left: auto;
            margin-right: auto;
        }

        /* Footer */
        footer {
            background: var(--dark-card);
            color: white;
            padding: 3rem 2rem;
            text-align: center;
            border-top: 1px solid var(--dark-border);
        }

        footer p {
            opacity: 0.8;
            margin-bottom: 1rem;
            letter-spacing: 0.3px;
        }

        .footer-links {
            display: flex;
            justify-content: center;
            gap: 2rem;
            flex-wrap: wrap;
            margin-top: 1.5rem;
        }

        .footer-links a {
            color: var(--text);
            text-decoration: none;
            opacity: 0.8;
            transition: all 0.3s;
            font-weight: 500;
        }

        .footer-links a:hover {
            color: #ffffff;
            opacity: 1;
        }

        /* User Menu */
        .user-menu {
            display: flex;
            gap: 1rem;
            align-items: center;
        }

        .user-badge {
            background: linear-gradient(135deg, #ffffff, #f0f0f0);
            color: #000000;
            padding: 0.65rem 1.25rem;
            border-radius: 12px;
            font-size: 0.9rem;
            font-weight: 600;
            box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
        }

        /* Responsive */
        @media (max-width: 768px) {
            .hero h1 {
                font-size: 2rem;
            }

            .section-title {
                font-size: 2rem;
            }

            nav .nav-right {
                gap: 1rem;
                flex-wrap: wrap;
            }

            .pricing-card.featured {
                transform: scale(1);
            }

            .pricing-card.featured:hover {
                transform: translateY(-8px);
            }

            .hero-cta {
                flex-direction: column;
            }

            .hero-cta .btn {
                width: 100%;
            }

            .pricing-grid .pricing-card:nth-child(2) {
                grid-column: 1 / -1;
                max-width: 100%;
            }
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 2rem;
        }

        /* Modal Styles */
        .modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.7);
            backdrop-filter: blur(5px);
        }

        .modal.active {
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .modal-content {
            background: var(--dark-card);
            padding: 3rem;
            border-radius: 16px;
            border: 1px solid var(--dark-border);
            max-width: 500px;
            width: 90%;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(255, 255, 255, 0.1);
            animation: slideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
        }

        @keyframes slideIn {
            from {
                transform: translateY(-50px);
                opacity: 0;
            }
            to {
                transform: translateY(0);
                opacity: 1;
            }
        }

        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.5rem;
        }

        .modal-header h2 {
            color: var(--light-text);
            font-size: 1.8rem;
            font-weight: 700;
        }

        .close-btn {
            background: none;
            border: none;
            color: var(--text-light);
            font-size: 1.8rem;
            cursor: pointer;
            transition: color 0.3s;
        }

        .close-btn:hover {
            color: #ffffff;
        }

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

        .form-group label {
            display: block;
            margin-bottom: 0.5rem;
            color: var(--light-text);
            font-weight: 600;
            letter-spacing: 0.3px;
        }

        .form-group input,
        .form-group textarea {
            width: 100%;
            padding: 0.75rem 1rem;
            border: 1px solid var(--dark-border);
            border-radius: 10px;
            background: rgba(255, 255, 255, 0.05);
            color: var(--light-text);
            font-family: inherit;
            transition: all 0.3s;
            font-size: 0.95rem;
        }

        .form-group input:focus,
        .form-group textarea:focus {
            outline: none;
            border-color: #ffffff;
            background: rgba(255, 255, 255, 0.05);
            box-shadow: 0 0 15px rgba(255, 255, 255, 0.15);
        }

        .form-group input::placeholder,
        .form-group textarea::placeholder {
            color: var(--text-light);
        }

        .form-submit {
            width: 100%;
            padding: 0.9rem 1.5rem;
            background: linear-gradient(135deg, #ffffff, #f0f0f0);
            color: #000000;
            border: none;
            border-radius: 10px;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.3s;
            font-size: 1rem;
            box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
        }

        .form-submit:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(255, 255, 255, 0.3), 0 0 30px rgba(255, 255, 255, 0.2);
        }
    </style>
</head>
<body>
    <!-- Navigation -->
    <nav>
        <div class="container" style="display: flex; justify-content: space-between; align-items: center;">
            <div class="logo">
                <span>🚀</span>
                <span>BoostWithKagujje</span>
            </div>
            <div class="nav-right">
                <?php if ($isLoggedIn): ?>
                    <a href="/dashboard">Dashboard</a>
                    <div class="user-badge">💰 UGX <?php echo number_format($userBalance); ?></div>
                    <a href="/logout" class="btn btn-secondary" style="padding: 0.65rem 1.5rem; font-size: 0.95rem;">Logout</a>
                <?php else: ?>
                    <a href="#pricing">Pricing</a>
                    <a href="#" onclick="openLoginModal(); return false;" class="btn btn-secondary">Login</a>
                    <a href="#" onclick="openRegisterModal(); return false;" class="btn btn-primary">Register</a>
                <?php endif; ?>
            </div>
        </div>
    </nav>

    <!-- Register Modal -->
    <div id="registerModal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <h2>Create Account</h2>
                <button class="close-btn" onclick="closeRegisterModal()">&times;</button>
            </div>
            <form id="registerForm" method="POST" action="/api/v1/auth/register">
                <div class="form-group">
                    <label for="fullname">Full Name</label>
                    <input type="text" id="fullname" name="full_name" placeholder="Your Full Name" required>
                </div>
                <div class="form-group">
                    <label for="email">Email</label>
                    <input type="email" id="email" name="email" placeholder="your@email.com" required>
                </div>
                <div class="form-group">
                    <label for="username">Username</label>
                    <input type="text" id="username" name="username" placeholder="Choose a username" required>
                </div>
                <div class="form-group">
                    <label for="password">Password</label>
                    <input type="password" id="password" name="password" placeholder="Min 8 characters" required>
                </div>
                <button type="submit" class="form-submit">Create Account Now</button>
                <p style="text-align: center; margin-top: 1rem; color: var(--text-light); font-size: 0.9rem;">
                    Already have an account? <a href="#" onclick="closeRegisterModal(); openLoginModal(); return false;" style="color: var(--primary); font-weight: 600;">Login here</a>
                </p>
            </form>
        </div>
    </div>

    <!-- Login Modal -->
    <div id="loginModal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <h2>Login</h2>
                <button class="close-btn" onclick="closeLoginModal()">&times;</button>
            </div>
            <form id="loginForm" method="POST" action="/api/v1/auth/login">
                <div class="form-group">
                    <label for="login-username">Email or Username</label>
                    <input type="text" id="login-username" name="username" placeholder="your@email.com or username" required>
                </div>
                <div class="form-group">
                    <label for="login-password">Password</label>
                    <input type="password" id="login-password" name="password" placeholder="Your password" required>
                </div>
                <button type="submit" class="form-submit">Login</button>
                <p style="text-align: center; margin-top: 1rem; color: var(--text-light); font-size: 0.9rem;">
                    No account? <a href="#" onclick="closeLoginModal(); openRegisterModal(); return false;" style="color: var(--primary); font-weight: 600;">Create one</a>
                </p>
            </form>
        </div>
    </div>

    <!-- Admin Access Modal -->
    <div id="adminModal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <h2>Admin Panel Access</h2>
                <button class="close-btn" onclick="closeAdminModal()">&times;</button>
            </div>
            <form id="adminForm" method="POST" action="/admin/login">
                <div class="form-group">
                    <label for="admin-email">Admin Email</label>
                    <input type="email" id="admin-email" name="email" placeholder="admin@boost.kagujje.com" required>
                </div>
                <div class="form-group">
                    <label for="admin-password">Admin Password</label>
                    <input type="password" id="admin-password" name="password" placeholder="Your admin password" required>
                </div>
                <button type="submit" class="form-submit">Access Admin Panel</button>
            </form>
        </div>
    </div>

    <!-- Main Content -->
    <?php if ($isLoggedIn): ?>
        <!-- Dashboard -->
        <div class="dashboard active">
            <div class="dashboard-header">
                <h1>Welcome back, <?php echo htmlspecialchars($userName); ?>! 👋</h1>
                <p>Manage your social media growth from here</p>
            </div>

            <div class="dashboard-grid">
                <div class="dashboard-card">
                    <h3>Account Balance</h3>
                    <div class="value">UGX <?php echo number_format($userBalance); ?></div>
                </div>
                <div class="dashboard-card">
                    <h3>Active Orders</h3>
                    <div class="value">0</div>
                </div>
                <div class="dashboard-card">
                    <h3>Followers Added</h3>
                    <div class="value">0</div>
                </div>
                <div class="dashboard-card">
                    <h3>Account Created</h3>
                    <div class="value"><?php echo date('M d, Y'); ?></div>
                </div>
            </div>

            <div style="text-align: center; margin-top: 4rem; padding-bottom: 2rem;">
                <a href="/api/v1/services" class="btn btn-primary" style="padding: 0.75rem 2rem; font-size: 1.1rem;">Browse Services</a>
            </div>
        </div>
    <?php else: ?>
        <!-- Landing Page -->
        <section class="hero">
            <div class="container">
                <h1>Boost Your Social Media Presence</h1>
                <p>Real social media growth with instant delivery and 24/7 support</p>
                <div class="hero-cta">
                    <a href="#" onclick="openRegisterModal(); return false;" class="btn btn-primary" style="color: white; padding: 1rem 2.5rem; font-size: 1.1rem;">🚀 Get Started</a>
                    <a href="#pricing" class="btn btn-secondary" style="background: rgba(99, 102, 241, 0.15); color: var(--primary); padding: 1rem 2.5rem; font-size: 1.1rem;">View Pricing</a>
                </div>
            </div>
        </section>

        <!-- Stats -->
        <div class="stats">
            <div class="stat-card">
                <div class="stat-number">50k+</div>
                <div class="stat-label">Happy Customers</div>
            </div>
            <div class="stat-card">
                <div class="stat-number">100%</div>
                <div class="stat-label">Real Growth</div>
            </div>
            <div class="stat-card">
                <div class="stat-number">24/7</div>
                <div class="stat-label">Support Team</div>
            </div>
            <div class="stat-card">
                <div class="stat-number">⚡</div>
                <div class="stat-label">Instant Delivery</div>
            </div>
        </div>

        <!-- Features -->
        <section class="features">
            <h2 class="section-title">Why Choose BoostWithKagujje?</h2>
            <div class="features-grid">
                <div class="feature-card">
                    <div class="feature-icon">⚡</div>
                    <h3>Instant Delivery</h3>
                    <p>Your orders are processed instantly. See results in minutes, not days.</p>
                </div>
                <div class="feature-card">
                    <div class="feature-icon">🔒</div>
                    <h3>100% Safe</h3>
                    <p>Secure payment processing with industry-leading encryption and protection.</p>
                </div>
                <div class="feature-card">
                    <div class="feature-icon">💰</div>
                    <h3>Cheapest Rates</h3>
                    <p>Lowest prices in the market with zero hidden fees. Pure value.</p>
                </div>
                <div class="feature-card">
                    <div class="feature-icon">🎯</div>
                    <h3>Targeted Growth</h3>
                    <p>Real, targeted followers and engagement from your ideal audience.</p>
                </div>
                <div class="feature-card">
                    <div class="feature-icon">📊</div>
                    <h3>Real Analytics</h3>
                    <p>Track your growth in real-time with detailed analytics and reports.</p>
                </div>
                <div class="feature-card">
                    <div class="feature-icon">🤝</div>
                    <h3>Expert Support</h3>
                    <p>24/7 customer support team ready to help with any questions.</p>
                </div>
            </div>
        </section>

        <!-- Pricing -->
        <section class="pricing" id="pricing">
            <h2 class="section-title">Simple, Transparent Pricing</h2>
            <div class="pricing-grid">
                <div class="pricing-card">
                    <h3>Starter</h3>
                    <div class="price">UGX <span>50k</span></div>
                    <ul class="pricing-features">
                        <li>100 Followers</li>
                        <li>10 Likes per post</li>
                        <li>Email Support</li>
                        <li>24-hour delivery</li>
                    </ul>
                    <a href="#" onclick="openRegisterModal(); return false;" class="btn btn-secondary" style="width: 100%; border: 1.5px solid var(--primary); display: block; text-align: center;">Get Started</a>
                </div>
                <div class="pricing-card featured">
                    <h3>Professional</h3>
                    <div class="price">UGX <span>250k</span></div>
                    <ul class="pricing-features">
                        <li>1000 Followers</li>
                        <li>100 Likes per post</li>
                        <li>Priority Support</li>
                        <li>Instant delivery</li>
                    </ul>
                    <a href="#" onclick="openRegisterModal(); return false;" class="btn btn-primary" style="width: 100%; display: block; text-align: center;">🌟 Most Popular</a>
                </div>
                <div class="pricing-card">
                    <h3>Enterprise</h3>
                    <div class="price">UGX <span>1M+</span></div>
                    <ul class="pricing-features">
                        <li>10k+ Followers</li>
                        <li>Custom packages</li>
                        <li>Dedicated Manager</li>
                        <li>Priority everything</li>
                    </ul>
                    <a href="mailto:dicksonkagujje@gmail.com" class="btn btn-secondary" style="width: 100%; border: 1.5px solid var(--primary); display: block; text-align: center;">Contact Sales</a>
                </div>
            </div>
        </section>

        <!-- CTA -->
        <section class="cta">
            <h2>Ready to Grow Your Account?</h2>
            <p>Join thousands of satisfied customers growing their social media presence</p>
            <a href="#" onclick="openRegisterModal(); return false;" class="btn btn-primary" style="padding: 1rem 2.5rem; font-size: 1.1rem;">Start Growing Now</a>
        </section>
    <?php endif; ?>
    <!-- Footer -->
    <footer>
        <p>&copy; 2026 BoostWithKagujje. All rights reserved.</p>
        <p style="font-size: 0.9rem;">Powered by MrGoViral & Marzpay</p>
        <div class="footer-links">
            <a href="/terms">Terms of Service</a>
            <a href="/privacy">Privacy Policy</a>
            <a href="#" onclick="openAdminModal(); return false;">Admin Access</a>
            <a href="https://support.kagujje.com">Support</a>
        </div>
    </footer>

    <script>
        // Prevent double-clicks
        let isProcessing = false;

        // Modal Functions
        function openRegisterModal() {
            if (isProcessing) return;
            document.getElementById('registerModal').classList.add('active');
            document.body.style.overflow = 'hidden';
            document.getElementById('registerForm').reset();
        }

        function closeRegisterModal() {
            document.getElementById('registerModal').classList.remove('active');
            document.body.style.overflow = 'auto';
        }

        function openLoginModal() {
            if (isProcessing) return;
            document.getElementById('loginModal').classList.add('active');
            document.body.style.overflow = 'hidden';
            document.getElementById('loginForm').reset();
        }

        function closeLoginModal() {
            document.getElementById('loginModal').classList.remove('active');
            document.body.style.overflow = 'auto';
        }

        function openAdminModal() {
            if (isProcessing) return;
            document.getElementById('adminModal').classList.add('active');
            document.body.style.overflow = 'hidden';
            document.getElementById('adminForm').reset();
        }

        function closeAdminModal() {
            document.getElementById('adminModal').classList.remove('active');
            document.body.style.overflow = 'auto';
        }

        // Close modal when clicking outside
        window.addEventListener('click', function(event) {
            let registerModal = document.getElementById('registerModal');
            let loginModal = document.getElementById('loginModal');
            let adminModal = document.getElementById('adminModal');
            
            if (event.target === registerModal) {
                closeRegisterModal();
            }
            if (event.target === loginModal) {
                closeLoginModal();
            }
            if (event.target === adminModal) {
                closeAdminModal();
            }
        });

        // Close modals with Escape key
        document.addEventListener('keydown', function(event) {
            if (event.key === 'Escape') {
                closeRegisterModal();
                closeLoginModal();
                closeAdminModal();
            }
        });

        // Handle form submissions
        document.getElementById('registerForm')?.addEventListener('submit', async (e) => {
            e.preventDefault();
            if (isProcessing) return;
            
            isProcessing = true;
            const btn = e.target.querySelector('.form-submit');
            const originalText = btn.textContent;
            btn.textContent = '⏳ Creating Account...';
            btn.disabled = true;

            const formData = new FormData(e.target);
            try {
                const response = await fetch('/api/v1/auth/register', {
                    method: 'POST',
                    body: formData
                });
                const data = await response.json();
                if (response.ok) {
                    alert('✅ Account created! Please login.');
                    closeRegisterModal();
                    openLoginModal();
                } else {
                    alert('❌ ' + (data.message || 'Registration failed'));
                }
            } catch (error) {
                console.error('Error:', error);
                alert('❌ Registration failed. Please try again.');
            } finally {
                btn.textContent = originalText;
                btn.disabled = false;
                isProcessing = false;
            }
        });

        document.getElementById('loginForm')?.addEventListener('submit', async (e) => {
            e.preventDefault();
            if (isProcessing) return;
            
            isProcessing = true;
            const btn = e.target.querySelector('.form-submit');
            const originalText = btn.textContent;
            btn.textContent = '⏳ Logging in...';
            btn.disabled = true;

            const formData = new FormData(e.target);
            try {
                const response = await fetch('/api/v1/auth/login', {
                    method: 'POST',
                    body: formData
                });
                const data = await response.json();
                if (response.ok) {
                    window.location.href = data.redirect || '/';
                } else {
                    alert('❌ ' + (data.message || 'Login failed'));
                }
            } catch (error) {
                console.error('Error:', error);
                alert('❌ Login failed. Please try again.');
            } finally {
                btn.textContent = originalText;
                btn.disabled = false;
                isProcessing = false;
            }
        });

        document.getElementById('adminForm')?.addEventListener('submit', async (e) => {
            e.preventDefault();
            if (isProcessing) return;
            
            isProcessing = true;
            const btn = e.target.querySelector('.form-submit');
            const originalText = btn.textContent;
            btn.textContent = '⏳ Accessing...';
            btn.disabled = true;

            const formData = new FormData(e.target);
            try {
                const response = await fetch('/admin/login', {
                    method: 'POST',
                    body: formData
                });
                if (response.ok) {
                    window.location.href = '/admin/dashboard';
                } else {
                    alert('❌ Invalid admin credentials');
                }
            } catch (error) {
                console.error('Error:', error);
                alert('❌ Admin login failed. Please try again.');
            } finally {
                btn.textContent = originalText;
                btn.disabled = false;
                isProcessing = false;
            }
        });

        // Smooth scroll for anchor links
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                const href = this.getAttribute('href');
                if (href !== '#') {
                    e.preventDefault();
                    const target = document.querySelector(href);
                    if (target) {
                        target.scrollIntoView({
                            behavior: 'smooth',
                            block: 'start'
                        });
                    }
                }
            });
        });

        // Add loading animation to all buttons
        document.querySelectorAll('.btn').forEach(btn => {
            btn.addEventListener('click', function(e) {
                if (!this.classList.contains('no-ripple')) {
                    const ripple = document.createElement('span');
                    const rect = this.getBoundingClientRect();
                    const size = Math.max(rect.width, rect.height);
                    const x = e.clientX - rect.left - size / 2;
                    const y = e.clientY - rect.top - size / 2;
                    
                    ripple.style.width = ripple.style.height = size + 'px';
                    ripple.style.left = x + 'px';
                    ripple.style.top = y + 'px';
                }
            });
        });
    </script>
</body>
</html>
