<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="AlgoMania es un juez en línea de programación competitiva en español que permite evaluar automáticamente tus soluciones a problemas de programación.">
    <title>AlgoMania</title>

    <link rel="icon" type="image/x-png" href="/images/algomaniaLogo.png">

    <script src="/vendor/tailwindcss.js"></script>

    <script>
        tailwind.config = {
            darkMode: 'class',
            theme: {
                extend: {}
            }
        }
    </script>

    <script>
        if (localStorage.getItem('color-theme') === 'dark' || (!('color-theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
            document.documentElement.classList.add('dark');
        } else {
            document.documentElement.classList.remove('dark');
        }
    </script>

    <script>
        window.algomaniaUserCache = window.algomaniaUserCache || {};

        window.buildUserMentionNode = function(username, info) {
            if (info && info.userId && info.formattedUsernameHtml) {
                const a = document.createElement('a');
                a.href = `/account/${encodeURIComponent(info.userId)}`;
                a.className = 'algomania-user-link font-bold !no-underline hover:!underline';
                a.innerHTML = info.formattedUsernameHtml;
                return a;
            }
            const span = document.createElement('span');
            span.className = 'font-bold';
            span.textContent = username;
            return span;
        };

        window.resolveUserMentions = async function(rootElement) {
            const root = rootElement || document.body;
            if (!root) return;

            const SKIP_TAGS = new Set(['CODE', 'PRE', 'SCRIPT', 'STYLE', 'TEXTAREA', 'MJX-CONTAINER', 'A']);
            const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, {
                acceptNode(node) {
                    if (!node.nodeValue || !node.nodeValue.includes('[user:')) {
                        return NodeFilter.FILTER_SKIP;
                    }
                    let parent = node.parentElement;
                    while (parent && parent !== root) {
                        if (SKIP_TAGS.has(parent.tagName.toUpperCase()) || parent.classList.contains('CodeMirror')) {
                            return NodeFilter.FILTER_REJECT;
                        }
                        parent = parent.parentElement;
                    }
                    if (node.parentElement && SKIP_TAGS.has(node.parentElement.tagName.toUpperCase())) {
                        return NodeFilter.FILTER_REJECT;
                    }
                    return NodeFilter.FILTER_ACCEPT;
                }
            });

            const textNodes = [];
            let currentNode;
            while ((currentNode = walker.nextNode())) {
                textNodes.push(currentNode);
            }

            const regex = /\[user:([^\[\]\s<>]{1,32})\]/g;
            const pendingSpans = [];
            const missingUsernames = new Set();

            for (const textNode of textNodes) {
                const text = textNode.nodeValue;
                regex.lastIndex = 0;
                if (!regex.test(text)) continue;

                regex.lastIndex = 0;
                const frag = document.createDocumentFragment();
                let lastIndex = 0;
                let match;

                while ((match = regex.exec(text)) !== null) {
                    if (match.index > lastIndex) {
                        frag.appendChild(document.createTextNode(text.slice(lastIndex, match.index)));
                    }
                    const uname = match[1];
                    if (Object.prototype.hasOwnProperty.call(window.algomaniaUserCache, uname)) {
                        frag.appendChild(window.buildUserMentionNode(uname, window.algomaniaUserCache[uname]));
                    } else {
                        const placeholder = document.createElement('span');
                        placeholder.className = 'algomania-user-mention font-bold';
                        placeholder.dataset.username = uname;
                        placeholder.textContent = uname;
                        frag.appendChild(placeholder);
                        pendingSpans.push(placeholder);
                        missingUsernames.add(uname);
                    }
                    lastIndex = regex.lastIndex;
                }

                if (lastIndex < text.length) {
                    frag.appendChild(document.createTextNode(text.slice(lastIndex)));
                }

                textNode.replaceWith(frag);
            }

            root.querySelectorAll('span.algomania-user-mention[data-username]').forEach(span => {
                const uname = span.dataset.username;
                if (!uname) return;
                if (Object.prototype.hasOwnProperty.call(window.algomaniaUserCache, uname)) {
                    span.replaceWith(window.buildUserMentionNode(uname, window.algomaniaUserCache[uname]));
                } else {
                    pendingSpans.push(span);
                    missingUsernames.add(uname);
                }
            });

            if (missingUsernames.size === 0) return;

            try {
                const params = new URLSearchParams();
                missingUsernames.forEach(u => params.append('usernames', u));
                const res = await fetch(`/api/account/mentions?${params.toString()}`);
                if (res.ok) {
                    const json = await res.json();
                    const data = (json && json.successful && json.data) ? json.data : {};
                    missingUsernames.forEach(u => {
                        window.algomaniaUserCache[u] = data[u] || null;
                    });
                }
            } catch (e) {
                console.error('Error resolving user mentions:', e);
            }

            for (const span of pendingSpans) {
                if (!span.isConnected) continue;
                const uname = span.dataset.username;
                if (Object.prototype.hasOwnProperty.call(window.algomaniaUserCache, uname)) {
                    span.replaceWith(window.buildUserMentionNode(uname, window.algomaniaUserCache[uname]));
                }
            }
        };

        document.addEventListener('DOMContentLoaded', () => {
            window.resolveUserMentions(document.body);
        });
    </script>
</head>

<body class="bg-gray-100 dark:bg-gray-900 text-gray-900 dark:text-gray-100 transition-colors duration-200 min-h-screen flex flex-col">

<nav class="bg-white dark:bg-gray-900 shadow-sm border-b border-gray-100 dark:border-gray-800 sticky top-0 z-50 transition-colors duration-200">
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        <div class="flex justify-between h-16">

            <a href="/" class="flex items-center">
                <div class="flex-shrink-0 text-2xl sm:text-3xl font-extrabold tracking-tight">
                    <span class="text-blue-600 dark:text-blue-500">Algo</span><span class="text-red-500 dark:text-red-400">Mania</span>
                </div>
            </a>

            <div class="hidden md:flex space-x-8 items-center">
                <a href="/" class="text-gray-600 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 font-medium transition-colors duration-200">Inicio</a>
                <a href="/problems" class="text-gray-600 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 font-medium transition-colors duration-200">Problemas</a>
                <a href="/contests" class="text-gray-600 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 font-medium transition-colors duration-200">Concursos</a>
                <a href="/forum" class="text-gray-600 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 font-medium transition-colors duration-200">Foro</a>
                <a href="/statistics" class="text-gray-600 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 font-medium transition-colors duration-200">Estadísticas</a>
                <a href="/contact" class="text-gray-600 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 font-medium transition-colors duration-200">Contacto</a>
            </div>

            <div class="flex items-center space-x-2 sm:space-x-4">
                <!--
                <a href="/donate" class="hidden sm:flex items-center px-3 py-1.5 text-sm font-semibold text-gray-800 bg-gradient-to-r from-yellow-300 to-yellow-400 hover:from-yellow-400 hover:to-yellow-500 dark:text-gray-900 dark:from-yellow-400 dark:to-yellow-500 rounded-full shadow-sm hover:shadow-md transition-all duration-200">
                    <svg class="w-4 h-4 mr-1.5 text-red-500" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
                        <path fill-rule="evenodd" d="M3.172 5.172a4 4 0 015.656 0L10 6.343l1.172-1.171a4 4 0 115.656 5.656L10 17.657l-6.828-6.829a4 4 0 010-5.656z" clip-rule="evenodd"></path>
                    </svg>
                    <span>Dona</span>
                </a>
                -->

                <button id="theme-toggle" type="button" class="text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 focus:outline-none rounded-lg text-sm p-2 transition-colors duration-200">
                    <svg id="theme-toggle-dark-icon" class="hidden w-5 h-5 sm:w-6 sm:h-6" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
                        <path d="M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z"></path>
                    </svg>
                    <svg id="theme-toggle-light-icon" class="hidden w-5 h-5 sm:w-6 sm:h-6" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
                        <path d="M10 2a1 1 0 011 1v1a1 1 0 11-2 0V3a1 1 0 011-1zm4 8a4 4 0 11-8 0 4 4 0 018 0zm-.464 4.95l.707.707a1 1 0 001.414-1.414l-.707-.707a1 1 0 00-1.414 1.414zm2.12-10.607a1 1 0 010 1.414l-.706.707a1 1 0 11-1.414-1.414l.707-.707a1 1 0 011.414 0zM17 11a1 1 0 100-2h-1a1 1 0 100 2h1zm-7 4a1 1 0 011 1v1a1 1 0 11-2 0v-1a1 1 0 011-1zM5.05 6.464A1 1 0 106.465 5.05l-.708-.707a1 1 0 00-1.414 1.414l.707.707zm1.414 8.486l-.707.707a1 1 0 01-1.414-1.414l.707-.707a1 1 0 011.414 1.414zM4 11a1 1 0 100-2H3a1 1 0 000 2h1z" fill-rule="evenodd" clip-rule="evenodd"></path>
                    </svg>
                </button>

                

                <a href="/account/login" class="flex items-center group pl-1">
                    <img src="/images/default-avatar.png"
                         alt="Iniciar sesión"
                         title="Iniciar sesión"
                         class="h-9 w-9 sm:h-10 sm:w-10 rounded-full border border-gray-200 dark:border-gray-700 ring-2 ring-transparent group-hover:ring-blue-600 dark:group-hover:ring-blue-500 transition-all duration-200 object-cover">
                </a>

                <button id="mobile-menu-button" class="md:hidden p-2 text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 focus:outline-none rounded-md transition-colors">
                    <svg class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"/>
                    </svg>
                </button>
            </div>
        </div>
    </div>

    <div id="mobile-menu" class="hidden md:hidden border-t border-gray-100 dark:border-gray-800 bg-gray-50 dark:bg-gray-900">
        <div class="px-4 pt-2 pb-4 space-y-1">
            <a href="/" class="block px-3 py-2 rounded-md text-base font-medium text-gray-700 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-blue-50 dark:hover:bg-gray-800 transition-colors">Inicio</a>
            <a href="/problems" class="block px-3 py-2 rounded-md text-base font-medium text-gray-700 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-blue-50 dark:hover:bg-gray-800 transition-colors">Problemas</a>
            <a href="/contests" class="block px-3 py-2 rounded-md text-base font-medium text-gray-700 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-blue-50 dark:hover:bg-gray-800 transition-colors">Concursos</a>
            <a href="/forum" class="block px-3 py-2 rounded-md text-base font-medium text-gray-700 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-blue-50 dark:hover:bg-gray-800 transition-colors">Foro</a>
            <a href="/statistics" class="block px-3 py-2 rounded-md text-base font-medium text-gray-700 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-blue-50 dark:hover:bg-gray-800 transition-colors">Estadísticas</a>
            <a href="/contact" class="block px-3 py-2 rounded-md text-base font-medium text-gray-700 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-blue-50 dark:hover:bg-gray-800 transition-colors">Contacto</a>

            <!--
            <a href="/donate" class="flex items-center px-3 py-2 mt-1 rounded-md text-base font-medium text-yellow-700 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-900/20 hover:bg-yellow-100 dark:hover:bg-yellow-900/40 transition-colors">
                <svg class="w-5 h-5 mr-2 text-red-500" fill="currentColor" viewBox="0 0 20 20">
                    <path fill-rule="evenodd" d="M3.172 5.172a4 4 0 015.656 0L10 6.343l1.172-1.171a4 4 0 115.656 5.656L10 17.657l-6.828-6.829a4 4 0 010-5.656z" clip-rule="evenodd"></path>
                </svg>
                Apoya a AlgoMania
            </a>
            -->

            <div class="border-t border-gray-200 dark:border-gray-700 my-2"></div>

            
            <a href="/account/login" class="block px-3 py-2 rounded-md text-base font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-gray-800 transition-colors">Iniciar sesión</a>
        </div>
    </div>

    <script>
        document.getElementById('mobile-menu-button').addEventListener('click', function() {
            const menu = document.getElementById('mobile-menu');
            menu.classList.toggle('hidden');
        });

        const themeToggleDarkIcon = document.getElementById('theme-toggle-dark-icon');
        const themeToggleLightIcon = document.getElementById('theme-toggle-light-icon');
        const themeToggleBtn = document.getElementById('theme-toggle');

        if (localStorage.getItem('color-theme') === 'dark' || (!('color-theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
            themeToggleLightIcon.classList.remove('hidden');
            document.documentElement.classList.add('dark');
        } else {
            themeToggleDarkIcon.classList.remove('hidden');
            document.documentElement.classList.remove('dark');
        }

        themeToggleBtn.addEventListener('click', function() {
            themeToggleDarkIcon.classList.toggle('hidden');
            themeToggleLightIcon.classList.toggle('hidden');

            if (document.documentElement.classList.contains('dark')) {
                document.documentElement.classList.remove('dark');
                localStorage.setItem('color-theme', 'light');
            } else {
                document.documentElement.classList.add('dark');
                localStorage.setItem('color-theme', 'dark');
            }
        });
    </script>
</nav>

<main class="flex-grow">
    <div>
    <div class="flex flex-col w-full lg:w-1/2 px-4 sm:px-6 lg:px-0 mx-auto mt-10 sm:mt-20 transition-colors duration-200">
        <div class="p-8 sm:p-12 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-700 rounded-md shadow-sm text-center transition-colors duration-200">

            <div class="text-7xl sm:text-8xl font-extrabold text-red-600 dark:text-red-500 tracking-tight mb-6">
                404
            </div>

            <h1 class="text-3xl sm:text-4xl font-bold text-gray-900 dark:text-white tracking-tight mb-4">
                Recurso no encontrado
            </h1>

            <p class="text-base sm:text-lg leading-relaxed text-gray-600 dark:text-gray-300 mb-8">
                Lo sentimos, la página que buscas no existe o ha sido eliminada.
            </p>

            <a href="/" class="inline-flex items-center justify-center gap-3 bg-blue-600 dark:bg-blue-500 text-white font-semibold py-3 px-6 rounded-md hover:bg-blue-700 dark:hover:bg-blue-600 shadow-sm transition-colors duration-200">
                <img src="/images/home-icon.png" alt="Inicio" class="w-5 h-5 flex-shrink-0 filter invert brightness-0">
                <span>Volver a inicio</span>
            </a>

        </div>
    </div>
</div>
</main>

<footer class="bg-white dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 transition-colors duration-200 mt-auto">
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6 flex flex-col md:flex-row items-center justify-between">

        <div class="flex items-center justify-center md:justify-start mb-4 md:mb-0">
            <a href="/" class="text-lg font-extrabold tracking-tight hover:opacity-80 transition-opacity">
                <span class="text-blue-600 dark:text-blue-500">Algo</span><span class="text-red-500 dark:text-red-400">Mania</span>
            </a>
        </div>

        <div class="flex flex-col sm:flex-row items-center gap-4 sm:gap-6">
            <div class="text-sm text-gray-500 dark:text-gray-400 text-center sm:text-left flex flex-wrap items-center justify-center sm:justify-start gap-x-3 gap-y-1">
                <span>&copy; <span>2026</span> AlgoMania.</span>
                <span>Creado por <a href="https://danimania.dev" target="_blank" rel="noopener noreferrer" class="font-semibold text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white hover:underline transition-colors">Daniel Villena Lillo</a>.</span>
                <span class="hidden sm:inline text-gray-400 dark:text-gray-600">·</span>
                <a href="/contests/policy" class="hover:text-blue-600 dark:hover:text-blue-400 hover:underline transition-colors">Normas de concursos</a>
                <span class="text-gray-400 dark:text-gray-600">·</span>
                <a href="/privacy-policy" class="hover:text-blue-600 dark:hover:text-blue-400 hover:underline transition-colors">Política de privacidad</a>
            </div>

            <div class="flex items-center space-x-4">
                <a href="https://www.instagram.com/danimania.dev/" target="_blank" rel="noopener noreferrer"
                   class="text-gray-400 dark:text-gray-500 hover:text-pink-600 dark:hover:text-pink-500 transition-colors" aria-label="Instagram">
                    <svg class="w-5 h-5" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
                        <path fill-rule="evenodd" d="M12.315 2c2.43 0 2.784.013 3.808.06 1.064.049 1.791.218 2.427.465a4.902 4.902 0 011.772 1.153 4.902 4.902 0 011.153 1.772c.247.636.416 1.363.465 2.427.048 1.067.06 1.407.06 4.123v.08c0 2.643-.012 2.987-.06 4.043-.049 1.064-.218 1.791-.465 2.427a4.902 4.902 0 01-1.153 1.772 4.902 4.902 0 01-1.772 1.153c-.636.247-1.363.416-2.427.465-1.067.048-1.407.06-4.123.06h-.08c-2.643 0-2.987-.012-4.043-.06-1.064-.049-1.791-.218-2.427-.465a4.902 4.902 0 01-1.772-1.153 4.902 4.902 0 01-1.153-1.772c-.247-.636-.416-1.363-.465-2.427-.047-1.024-.06-1.379-.06-3.808v-.63c0-2.43.013-2.784.06-3.808.049-1.064.218-1.791.465-2.427a4.902 4.902 0 011.153-1.772A4.902 4.902 0 015.45 2.525c.636-.247 1.363-.416 2.427-.465C8.901 2.013 9.256 2 11.685 2h.63zm-.081 1.802h-.468c-2.456 0-2.784.011-3.807.058-.975.045-1.504.207-1.857.344-.467.182-.8.398-1.15.748-.35.35-.566.683-.748 1.15-.137.353-.3.882-.344 1.857-.047 1.023-.058 1.351-.058 3.807v.468c0 2.456.011 2.784.058 3.807.045.975.207 1.504.344 1.857.182.466.399.8.748 1.15.35.35.683.566 1.15.748.353.137.882.3 1.857.344 1.054.048 1.37.058 4.041.058h.08c2.597 0 2.917-.01 3.96-.058.976-.045 1.505-.207 1.858-.344.466-.182.8-.398 1.15-.748.35-.35.566-.683.748-1.15.137-.353.3-.882.344-1.857.048-1.055.058-1.37.058-4.041v-.08c0-2.597-.01-2.917-.058-3.96-.045-.976-.207-1.505-.344-1.858a3.097 3.097 0 00-.748-1.15 3.098 3.098 0 00-1.15-.748c-.353-.137-.882-.3-1.857-.344-1.023-.047-1.351-.058-3.807-.058zM12 6.865a5.135 5.135 0 110 10.27 5.135 5.135 0 010-10.27zm0 1.802a3.333 3.333 0 100 6.666 3.333 3.333 0 000-6.666zm5.338-3.205a1.2 1.2 0 110 2.4 1.2 1.2 0 010-2.4z" clip-rule="evenodd" />
                    </svg>
                </a>

                <a href="https://www.youtube.com/@danimania_dev" target="_blank" rel="noopener noreferrer"
                   class="text-gray-400 dark:text-gray-500 hover:text-red-600 dark:hover:text-red-500 transition-colors" aria-label="YouTube">
                    <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
                        <path fill-rule="evenodd" d="M19.812 5.418c.861.23 1.538.907 1.768 1.768C21.998 8.746 22 12 22 12s0 3.255-.418 4.814a2.504 2.504 0 0 1-1.768 1.768c-1.56.419-7.814.419-7.814.419s-6.255 0-7.814-.419a2.505 2.505 0 0 1-1.768-1.768C2 15.255 2 12 2 12s0-3.255.417-4.814a2.507 2.507 0 0 1 1.768-1.768C5.744 5 11.998 5 11.998 5s6.255 0 7.814.418ZM15.194 12 10 15V9l5.194 3Z" clip-rule="evenodd" />
                    </svg>
                </a>
            </div>

        </div>

    </div>
</footer>

</body>
</html>