<?php
require_once 'config.php';
require_once 'includes/db.php';
require_once 'includes/functions.php';

// Try to get site settings for branding
$site_settings = get_site_settings($pdo);
$site_name = $site_settings['site_name'] ?? 'SonicPesa';
$logo = $site_settings['site_logo'] ?? 'assets/images/logo.png';
$favicon = $site_settings['site_favicon'] ?? 'assets/images/favicon.png';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>404 - Page Not Found | <?= htmlspecialchars($site_name) ?></title>
    <link rel="icon" type="image/png" href="<?= SITE_URL ?>/<?= htmlspecialchars($favicon) ?>">
    <link href="https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;800&display=swap" rel="stylesheet">
    <style>
        :root {
            --primary: #5d66e5;
            --secondary: #a78bfa;
            --dark: #0f172a;
            --light: #f8fafc;
        }
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body {
            font-family: 'Outfit', sans-serif;
            background: var(--dark);
            height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            overflow: hidden;
            text-align: center;
        }
        .container {
            position: relative;
            z-index: 10;
            padding: 20px;
        }
        .bg-glow {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 500px;
            height: 500px;
            background: radial-gradient(circle, rgba(93, 102, 229, 0.2) 0%, rgba(15, 23, 42, 0) 70%);
            z-index: 1;
        }
        h1 {
            font-size: 10rem;
            font-weight: 800;
            margin: 0;
            line-height: 1;
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            letter-spacing: -5px;
            animation: floating 3s ease-in-out infinite;
        }
        h2 {
            font-size: 2rem;
            font-weight: 600;
            margin-bottom: 1rem;
            color: var(--light);
        }
        p {
            color: #94a3b8;
            max-width: 450px;
            margin: 0 auto 2.5rem;
            line-height: 1.6;
            font-size: 1.1rem;
        }
        .btn {
            display: inline-flex;
            align-items: center;
            padding: 14px 34px;
            background: var(--primary);
            color: white;
            text-decoration: none;
            border-radius: 50px;
            font-weight: 600;
            transition: 0.3s;
            box-shadow: 0 10px 30px rgba(93, 102, 229, 0.4);
        }
        .btn:hover {
            transform: translateY(-3px);
            box-shadow: 0 15px 40px rgba(93, 102, 229, 0.6);
            background: #4f58d6;
        }
        @keyframes floating {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-20px); }
        }
        .icon {
            font-size: 5rem;
            margin-bottom: -1.5rem;
            display: block;
        }
        /* Geometric shapes background */
        .shape {
            position: absolute;
            opacity: 0.1;
            z-index: 0;
        }
        .shape-1 { top: 10%; left: 10%; width: 100px; height: 100px; border: 2px solid white; border-radius: 20%; transform: rotate(45deg); }
        .shape-2 { bottom: 15%; right: 12%; width: 150px; height: 150px; border: 2px solid white; border-radius: 50%; }
        .shape-3 { top: 20%; right: 15%; width: 50px; height: 50px; background: white; border-radius: 10%; transform: rotate(15deg); }
    </style>
</head>
<body>
    <div class="bg-glow"></div>
    <div class="shape shape-1"></div>
    <div class="shape shape-2"></div>
    <div class="shape shape-3"></div>

    <div class="container">
        <img src="<?= SITE_URL ?>/<?= htmlspecialchars($logo) ?>" alt="Logo" style="max-width: 180px; margin-bottom: 2rem;">
        
        <span class="icon">🚀</span>
        <h1>404</h1>
        <h2>Lost in Space?</h2>
        <p>The page you are looking for has either drifted into another galaxy or was never there in the first place.</p>
        
        <a href="<?= SITE_URL ?>/dashboard" class="btn">Back to Dashboard</a>
    </div>
</body>
</html>

