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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>GO-ACS - Auto Configuration Server</title>
    <meta name="description" content="Go-based Auto Configuration Server for ONU Management">
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            --primary: #6366f1;
            --primary-dark: #4f46e5;
            --primary-light: #818cf8;
            --secondary: #0ea5e9;
            --success: #10b981;
            --warning: #f59e0b;
            --danger: #ef4444;
            --dark: #1e1b4b;
            --darker: #0f0d24;
            --light: #f8fafc;
            --gray: #64748b;
            --card-bg: rgba(255, 255, 255, 0.05);
            --border: rgba(255, 255, 255, 0.1);
            --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            --gradient-2: linear-gradient(135deg, #6366f1 0%, #0ea5e9 100%);
            --gradient-3: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
            --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            background: var(--darker);
            color: var(--light);
            min-height: 100vh;
            overflow-x: hidden;
        }

        /* Animated Background */
        .bg-animation {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
            background: linear-gradient(45deg, var(--darker) 0%, var(--dark) 50%, #1a1a2e 100%);
        }

        .bg-animation::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background:
                radial-gradient(circle at 20% 80%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(14, 165, 233, 0.15) 0%, transparent 50%),
                radial-gradient(circle at 50% 50%, rgba(168, 85, 247, 0.1) 0%, transparent 50%);
            animation: pulse 8s ease-in-out infinite;
        }

        @keyframes pulse {

            0%,
            100% {
                opacity: 0.5;
            }

            50% {
                opacity: 1;
            }
        }

        /* Header */
        header {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            z-index: 100;
            padding: 1rem 2rem;
            background: rgba(15, 13, 36, 0.8);
            backdrop-filter: blur(20px);
            border-bottom: 1px solid var(--border);
        }

        .header-content {
            max-width: 1400px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 12px;
            font-size: 1.5rem;
            font-weight: 700;
            background: var(--gradient-2);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .logo-icon {
            width: 40px;
            height: 40px;
            background: var(--gradient-2);
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            -webkit-text-fill-color: white;
        }

        nav {
            display: flex;
            gap: 2rem;
        }

        nav a {
            color: var(--gray);
            text-decoration: none;
            font-weight: 500;
            transition: color 0.3s;
        }

        nav a:hover {
            color: var(--light);
        }

        /* Hero Section */
        .hero {
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
            padding: 2rem;
            padding-top: 6rem;
        }

        .hero-content {
            max-width: 800px;
        }

        .hero-badge {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 8px 16px;
            background: var(--card-bg);
            border: 1px solid var(--border);
            border-radius: 50px;
            font-size: 0.875rem;
            color: var(--primary-light);
            margin-bottom: 2rem;
            animation: fadeIn 0.5s ease-out;
        }

        .hero-badge i {
            font-size: 1rem;
        }

        h1 {
            font-size: clamp(2.5rem, 6vw, 4.5rem);
            font-weight: 800;
            line-height: 1.1;
            margin-bottom: 1.5rem;
            animation: fadeInUp 0.6s ease-out 0.1s backwards;
        }

        h1 .highlight {
            background: var(--gradient-2);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .hero-description {
            font-size: 1.25rem;
            color: var(--gray);
            line-height: 1.7;
            margin-bottom: 3rem;
            animation: fadeInUp 0.6s ease-out 0.2s backwards;
        }

        .hero-buttons {
            display: flex;
            gap: 1rem;
            justify-content: center;
            flex-wrap: wrap;
            animation: fadeInUp 0.6s ease-out 0.3s backwards;
        }

        .btn {
            display: inline-flex;
            align-items: center;
            gap: 10px;
            padding: 14px 28px;
            border-radius: 12px;
            font-size: 1rem;
            font-weight: 600;
            text-decoration: none;
            transition: all 0.3s ease;
            cursor: pointer;
            border: none;
        }

        .btn-primary {
            background: var(--gradient-2);
            color: white;
            box-shadow: 0 10px 40px rgba(99, 102, 241, 0.4);
        }

        .btn-primary:hover {
            transform: translateY(-3px);
            box-shadow: 0 15px 50px rgba(99, 102, 241, 0.5);
        }

        .btn-secondary {
            background: var(--card-bg);
            color: var(--light);
            border: 1px solid var(--border);
        }

        .btn-secondary:hover {
            background: rgba(255, 255, 255, 0.1);
            transform: translateY(-3px);
        }

        /* Features Section */
        .features {
            padding: 6rem 2rem;
            max-width: 1400px;
            margin: 0 auto;
        }

        .section-title {
            text-align: center;
            margin-bottom: 4rem;
        }

        .section-title h2 {
            font-size: 2.5rem;
            font-weight: 700;
            margin-bottom: 1rem;
        }

        .section-title p {
            color: var(--gray);
            font-size: 1.125rem;
        }

        .features-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 2rem;
        }

        .feature-card {
            background: var(--card-bg);
            border: 1px solid var(--border);
            border-radius: 20px;
            padding: 2rem;
            transition: all 0.3s ease;
        }

        .feature-card:hover {
            transform: translateY(-10px);
            border-color: var(--primary);
            box-shadow: 0 20px 40px rgba(99, 102, 241, 0.2);
        }

        .feature-icon {
            width: 60px;
            height: 60px;
            border-radius: 16px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
            margin-bottom: 1.5rem;
        }

        .feature-icon.purple {
            background: linear-gradient(135deg, #6366f1, #8b5cf6);
        }

        .feature-icon.blue {
            background: linear-gradient(135deg, #0ea5e9, #06b6d4);
        }

        .feature-icon.green {
            background: linear-gradient(135deg, #10b981, #34d399);
        }

        .feature-icon.orange {
            background: linear-gradient(135deg, #f59e0b, #fbbf24);
        }

        .feature-icon.pink {
            background: linear-gradient(135deg, #ec4899, #f472b6);
        }

        .feature-icon.red {
            background: linear-gradient(135deg, #ef4444, #f87171);
        }

        .feature-card h3 {
            font-size: 1.25rem;
            font-weight: 600;
            margin-bottom: 0.75rem;
        }

        .feature-card p {
            color: var(--gray);
            line-height: 1.6;
        }

        /* Stats Section */
        .stats {
            padding: 4rem 2rem;
            background: var(--card-bg);
            border-top: 1px solid var(--border);
            border-bottom: 1px solid var(--border);
        }

        .stats-grid {
            max-width: 1000px;
            margin: 0 auto;
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 2rem;
            text-align: center;
        }

        .stat-item h3 {
            font-size: 3rem;
            font-weight: 800;
            background: var(--gradient-2);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            margin-bottom: 0.5rem;
        }

        .stat-item p {
            color: var(--gray);
            font-size: 0.875rem;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        /* Login Modal */
        .modal-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.7);
            backdrop-filter: blur(10px);
            z-index: 1000;
            align-items: center;
            justify-content: center;
        }

        .modal-overlay.active {
            display: flex;
        }

        .modal {
            background: var(--dark);
            border: 1px solid var(--border);
            border-radius: 24px;
            padding: 3rem;
            width: 100%;
            max-width: 420px;
            animation: scaleIn 0.3s ease-out;
        }

        @keyframes scaleIn {
            from {
                opacity: 0;
                transform: scale(0.9);
            }

            to {
                opacity: 1;
                transform: scale(1);
            }
        }

        .modal h2 {
            font-size: 1.75rem;
            text-align: center;
            margin-bottom: 0.5rem;
        }

        .modal-subtitle {
            text-align: center;
            color: var(--gray);
            margin-bottom: 2rem;
        }

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

        .form-group label {
            display: block;
            margin-bottom: 0.5rem;
            font-weight: 500;
            font-size: 0.875rem;
        }

        .form-group input {
            width: 100%;
            padding: 14px 16px;
            background: var(--card-bg);
            border: 1px solid var(--border);
            border-radius: 12px;
            color: var(--light);
            font-size: 1rem;
            transition: all 0.3s;
        }

        .form-group input:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
        }

        .form-group input::placeholder {
            color: var(--gray);
        }

        .modal .btn {
            width: 100%;
            justify-content: center;
            margin-top: 1rem;
        }

        .modal-close {
            position: absolute;
            top: 1rem;
            right: 1rem;
            background: none;
            border: none;
            color: var(--gray);
            font-size: 1.5rem;
            cursor: pointer;
            transition: color 0.3s;
        }

        .modal-close:hover {
            color: var(--light);
        }

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

        footer a {
            color: var(--primary-light);
            text-decoration: none;
        }

        /* Animations */
        @keyframes fadeIn {
            from {
                opacity: 0;
            }

            to {
                opacity: 1;
            }
        }

        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        /* Responsive */
        @media (max-width: 768px) {
            nav {
                display: flex;
                position: fixed;
                top: 10px;
                right: 10px;
                z-index: 1000;
                background: rgba(30, 27, 75, 0.9);
                padding: 5px;
                border-radius: 50px;
                backdrop-filter: blur(10px);
                border: 1px solid var(--border);
            }
            
            nav a {
                font-size: 0.8rem;
                padding: 8px 12px;
                border-radius: 20px;
            }
            
            nav a:hover {
                background: var(--primary);
                color: white;
            }

            .stats-grid {
                grid-template-columns: repeat(2, 1fr);
            }

            .stat-item h3 {
                font-size: 2rem;
            }
        }

        /* Loading animation */
        .loading {
            display: inline-block;
            width: 20px;
            height: 20px;
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 50%;
            border-top-color: white;
            animation: spin 1s linear infinite;
        }

        @keyframes spin {
            to {
                transform: rotate(360deg);
            }
        }

        .error-message {
            color: var(--danger);
            font-size: 0.875rem;
            margin-top: 0.5rem;
            text-align: center;
        }
    </style>
</head>

<body>
    <div class="bg-animation"></div>

    <header>
        <div class="header-content">
            <div class="logo">
                <div class="logo-icon">
                    <i class="fas fa-network-wired"></i>
                </div>
                GO-ACS
            </div>
            <nav>
                <a href="#features">Features</a>
                <a href="https://github.com/alijayanet/Go-ACS" target="_blank">GitHub</a>
                <a href="#" onclick="showLogin()">Login</a>
            </nav>
        </div>
    </header>

    <section class="hero">
        <div class="hero-content">
            <div class="hero-badge">
                <i class="fas fa-bolt"></i>
                Built with Go for maximum performance
            </div>
            <h1>
                Powerful ONU Management<br>
                <span class="highlight">Made Simple</span>
            </h1>
            <p class="hero-description">
                GO-ACS is a modern, high-performance Auto Configuration Server built with Go.
                Manage your ONU devices, configure WiFi settings, and monitor your network
                infrastructure with ease.
            </p>
            <div class="hero-buttons">
                <a href="#" class="btn btn-primary" onclick="showLogin()">
                    <i class="fas fa-rocket"></i>
                    Get Started
                </a>
                <a href="#features" class="btn btn-secondary">
                    <i class="fas fa-info-circle"></i>
                    Learn More
                </a>
            </div>
        </div>
    </section>

    <section class="stats">
        <div class="stats-grid">
            <div class="stat-item">
                <h3 id="stat-devices">0</h3>
                <p>Devices Managed</p>
            </div>
            <div class="stat-item">
                <h3 id="stat-online">0</h3>
                <p>Online Now</p>
            </div>
            <div class="stat-item">
                <h3>TR-069</h3>
                <p>Protocol</p>
            </div>
            <div class="stat-item">
                <h3>Go</h3>
                <p>Built With</p>
            </div>
        </div>
    </section>

    <section class="features" id="features">
        <div class="section-title">
            <h2>Everything You Need</h2>
            <p>Comprehensive tools for managing your ONU devices</p>
        </div>
        <div class="features-grid">
            <div class="feature-card">
                <div class="feature-icon purple">
                    <i class="fas fa-satellite-dish"></i>
                </div>
                <h3>Multi-Vendor Support</h3>
                <p>Manage devices from ZTE, Huawei, Nokia, and other major ONU manufacturers with a unified interface.
                </p>
            </div>
            <div class="feature-card">
                <div class="feature-icon blue">
                    <i class="fas fa-wifi"></i>
                </div>
                <h3>WiFi Configuration</h3>
                <p>Easily change SSID and password settings remotely. Configure multiple WiFi networks and security
                    settings.</p>
            </div>
            <div class="feature-card">
                <div class="feature-icon green">
                    <i class="fas fa-chart-line"></i>
                </div>
                <h3>Real-time Monitoring</h3>
                <p>Monitor device status, signal strength, temperature, and uptime with live WebSocket updates.</p>
            </div>
            <div class="feature-card">
                <div class="feature-icon orange">
                    <i class="fas fa-cog"></i>
                </div>
                <h3>WAN Management</h3>
                <p>Configure PPPoE, DHCP, and static IP connections. Manage VLANs and other WAN settings.</p>
            </div>
            <div class="feature-card">
                <div class="feature-icon pink">
                    <i class="fas fa-tasks"></i>
                </div>
                <h3>Task Queue</h3>
                <p>Queue commands and configurations that will be executed when devices connect to the ACS.</p>
            </div>
            <div class="feature-card">
                <div class="feature-icon red">
                    <i class="fas fa-download"></i>
                </div>
                <h3>Firmware Updates</h3>
                <p>Manage and deploy firmware updates to your devices remotely and safely.</p>
            </div>
        </div>
    </section>

    <footer>
        <p>GO-ACS &copy; 2026 - Open Source ONU Management System</p>
    </footer>

    <!-- Login Modal -->
    <div class="modal-overlay" id="loginModal">
        <div class="modal">
            <h2>Welcome Back</h2>
            <p class="modal-subtitle">Sign in to manage your devices</p>
            <form id="loginForm">
                <div class="form-group">
                    <label for="username">Username</label>
                    <input type="text" id="username" name="username" placeholder="Enter username" required>
                </div>
                <div class="form-group">
                    <label for="password">Password</label>
                    <input type="password" id="password" name="password" placeholder="Enter password" required>
                </div>
                <div id="loginError" class="error-message" style="display: none;"></div>
                <button type="submit" class="btn btn-primary" id="loginBtn">
                    <i class="fas fa-sign-in-alt"></i>
                    Sign In
                </button>
            </form>
            <p style="text-align: center; margin-top: 1.5rem; color: var(--gray); font-size: 0.875rem;">
                Default: admin / admin123
            </p>
        </div>
    </div>

    <script>
        // Show/hide login modal
        function showLogin() {
            document.getElementById('loginModal').classList.add('active');
        }

        // Close modal on overlay click
        document.getElementById('loginModal').addEventListener('click', function (e) {
            if (e.target === this) {
                this.classList.remove('active');
            }
        });

        // Handle login form
        document.getElementById('loginForm').addEventListener('submit', async function (e) {
            e.preventDefault();

            const btn = document.getElementById('loginBtn');
            const error = document.getElementById('loginError');
            const originalContent = btn.innerHTML;

            btn.innerHTML = '<span class="loading"></span>';
            btn.disabled = true;
            error.style.display = 'none';

            const username = document.getElementById('username').value;
            const password = document.getElementById('password').value;

            try {
                const response = await fetch('/api/auth/login', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json'
                    },
                    body: JSON.stringify({ username, password })
                });

                const data = await response.json();

                if (data.success) {
                    localStorage.setItem('token', data.token);
                    localStorage.setItem('user', JSON.stringify(data.user));
                    window.location.href = '/dashboard';
                } else {
                    throw new Error(data.error || 'Login failed');
                }
            } catch (err) {
                error.textContent = err.message || 'Invalid credentials';
                error.style.display = 'block';
                btn.innerHTML = originalContent;
                btn.disabled = false;
            }
        });

        // Fetch and display stats
        async function loadStats() {
            try {
                const response = await fetch('/api/dashboard/stats');
                const stats = await response.json();

                document.getElementById('stat-devices').textContent = stats.totalDevices || 0;
                document.getElementById('stat-online').textContent = stats.onlineDevices || 0;
            } catch (err) {
                console.log('Could not load stats:', err);
            }
        }

        // Check if already logged in
        if (localStorage.getItem('token')) {
            // Verify token is still valid
            loadStats();
        } else {
            loadStats();
        }

        // Escape key closes modal
        document.addEventListener('keydown', function (e) {
            if (e.key === 'Escape') {
                document.getElementById('loginModal').classList.remove('active');
            }
        });
    </script>
</body>

</html>