<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Вход - Java Planet</title>
    <link rel="stylesheet" href="/css/navigation.css">
    <style>
        @import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: #ece6d8;
            color: #1a1a1a;
            min-height: 100vh;
            line-height: 1.6;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 120px 20px 40px;
        }
        
        .login-container {
            background: #f8f5ee;
            border: 1px solid #ddd3c4;
            border-radius: 16px;
            padding: 40px;
            width: 100%;
            max-width: 460px;
            margin: 0 auto;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        }
        
        .login-header {
            text-align: center;
            margin-bottom: 30px;
        }
        
        .login-title {
            font-size: 2.2em;
            color: #1a1a1a;
            margin-bottom: 8px;
            font-weight: 600;
            letter-spacing: -0.5px;
        }
        
        .login-subtitle {
            font-size: 1.05em;
            color: #666;
        }
        
        .form-group {
            margin-bottom: 20px;
        }
        
        .form-label {
            display: block;
            font-size: 1em;
            color: #1a1a1a;
            margin-bottom: 8px;
            font-weight: 600;
        }
        
        .form-input {
            width: 100%;
            padding: 12px 15px;
            border: 1px solid #ddd3c4;
            border-radius: 8px;
            background: #fbf9f4;
            color: #1a1a1a;
            font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            font-size: 1em;
            transition: border-color 0.3s ease, box-shadow 0.3s ease;
        }
        
        .form-input:focus {
            outline: none;
            border-color: #4a90e2;
            box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.12);
        }
        
        .form-input::placeholder {
            color: #999;
        }
        
        .login-btn {
            width: 100%;
            background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
            color: #fff;
            border: 1px solid #357abd;
            padding: 12px 16px;
            border-radius: 8px;
            font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            font-size: 1.05em;
            cursor: pointer;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
            font-weight: 600;
            box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
        }
        
        .login-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
            background: linear-gradient(135deg, #357abd 0%, #2a5f8f 100%);
        }
        
        .back-link {
            display: block;
            text-align: center;
            margin-top: 16px;
            color: #4a90e2;
            text-decoration: none;
            font-size: 1em;
            transition: color 0.3s ease;
            font-weight: 500;
        }
        
        .back-link:hover {
            color: #357abd;
            text-decoration: underline;
        }
        
        .error-message {
            background: #fdecea;
            color: #c62828;
            padding: 12px;
            border-radius: 6px;
            margin-bottom: 20px;
            text-align: left;
            border: 1px solid #f5b5b5;
        }
        
        @media (max-width: 480px) {
            .container {
                padding: 100px 12px 20px;
            }
            
            .login-container {
                padding: 30px 20px;
            }
            
            .login-title {
                font-size: 1.8em;
            }
        }
    </style>
</head>
<body>
    
    <nav class="nav-menu">
        <div class="nav-container">
            <a href="/" class="nav-logo">🌍 Java Planet</a>
            <div class="nav-links" id="navLinks">
                <a href="/ratings">🏆 Рейтинги</a>
                <a href="/schedule">📅 Расписание</a>
                <a href="/groups">🎓 Группы</a>
                <a href="/lectures">📚 Лекции</a>
                <a href="/resources">📁 Ресурсы</a>
                <a href="/contacts">📞 Контакты</a>
                <!-- Кнопки авторизации: слева имя пользователя, справа кнопки -->
                
                
                <div class="auth-section">
                    <a href="/register" class="register-btn">🚀 Регистрация</a>
                    <a href="/login" class="login-btn">🔑 Войти</a>
                </div>
            </div>
        </div>
    </nav>

    <!-- Cookie consent banner -->
    <style>
        .cookie-consent-banner {
            position: fixed;
            left: 50%;
            bottom: 20px;
            transform: translateX(-50%);
            width: min(760px, 92vw);
            background: rgba(20, 20, 30, 0.92);
            color: #ecf0f1;
            border: 1px solid rgba(255, 215, 0, 0.35);
            border-radius: 14px;
            padding: 16px 16px 14px;
            box-shadow: 0 12px 40px rgba(0,0,0,0.55);
            z-index: 9999;
            display: none;
            gap: 12px;
            align-items: center;
        }

        .cookie-consent-text {
            flex: 1;
            font-size: 0.95rem;
            line-height: 1.45;
        }

        .cookie-consent-actions {
            display: flex;
            gap: 10px;
            align-items: center;
            justify-content: flex-end;
            flex-wrap: wrap;
        }

        .cookie-consent-actions .cookie-btn {
            border: 1px solid transparent;
            border-radius: 10px;
            padding: 10px 14px;
            font-weight: 700;
            cursor: pointer;
            transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
        }

        .cookie-btn-accept {
            background: rgba(255, 215, 0, 0.22);
            border-color: rgba(255, 215, 0, 0.5);
            color: #FFD700;
        }

        .cookie-btn-accept:hover {
            transform: translateY(-1px);
            background: rgba(255, 215, 0, 0.28);
        }

        .cookie-btn-reject {
            background: rgba(255, 255, 255, 0.06);
            border-color: rgba(255, 255, 255, 0.18);
            color: #ecf0f1;
        }

        .cookie-btn-reject:hover {
            transform: translateY(-1px);
            background: rgba(255, 255, 255, 0.1);
        }

        .cookie-consent-banner a {
            color: #FFD700;
            text-decoration: none;
        }

        .cookie-consent-banner a:hover {
            text-decoration: underline;
        }
    </style>

    <div id="cookie-consent-banner" class="cookie-consent-banner" role="dialog" aria-live="polite">
        <div class="cookie-consent-text">
            Мы используем cookies для работы сайта и сбора обезличенной статистики посещений.
            Согласно законодательству РФ, мы просим ваше согласие.
            <a href="/privacy-policy" target="_blank">Подробнее</a>.
        </div>
        <div class="cookie-consent-actions">
            <button type="button" id="cookie-accept-btn" class="cookie-btn cookie-btn-accept">Принять</button>
            <button type="button" id="cookie-reject-btn" class="cookie-btn cookie-btn-reject">Отклонить</button>
        </div>
    </div>

    <script>
        (function () {
            const banner = document.getElementById('cookie-consent-banner');
            if (!banner) return;

            const COOKIE_CONSENT = 'cookie_consent';
            const consent = getCookie(COOKIE_CONSENT);

            const isHomePage = function () {
                return window.location.pathname === '/' || window.location.pathname === '/home';
            };

            const postTrackHomeVisit = function () {
                // В статистику попадёт только если пользователь согласился (это проверяется на сервере).
                fetch('/track/home-visit', {
                    method: 'POST',
                    headers: { 'Content-Type': 'application/json' }
                }).catch(function () {
                    // Трекинг не критичен для работы сайта
                });
            };

            if (consent === 'accepted') {
                banner.style.display = 'none';
                if (isHomePage()) postTrackHomeVisit();
                return;
            }

            if (consent === 'rejected') {
                banner.style.display = 'none';
                return;
            }

            // Нет решения — показываем баннер
            banner.style.display = 'flex';

            document.getElementById('cookie-accept-btn').addEventListener('click', function () {
                setCookie(COOKIE_CONSENT, 'accepted', 365);
                banner.style.display = 'none';
                if (isHomePage()) postTrackHomeVisit();
            });

            document.getElementById('cookie-reject-btn').addEventListener('click', function () {
                setCookie(COOKIE_CONSENT, 'rejected', 365);
                banner.style.display = 'none';
                // При отклонении трекинг не запускаем
            });

            function getCookie(name) {
                const encoded = encodeURIComponent(name);
                const pattern = new RegExp('(?:^|; )' + encoded + '=([^;]*)');
                const match = document.cookie.match(pattern);
                return match ? decodeURIComponent(match[1]) : null;
            }

            function setCookie(name, value, days) {
                const expires = new Date(Date.now() + days * 86400000).toUTCString();
                const securePart = (window.location.protocol === 'https:') ? '; Secure' : '';
                document.cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value) +
                    '; expires=' + expires +
                    '; path=/' +
                    '; SameSite=Lax' +
                    securePart;
            }
        })();
    </script>

    <div class="container">
        <div class="login-container">
            <div class="login-header">
                <h1 class="login-title">🌍 Java Planet</h1>
                <p class="login-subtitle">Вход в систему</p>
            </div>
            
            
            
            <form action="/login" method="post">
                <div class="form-group">
                    <label for="username" class="form-label">👤 Логин</label>
                    <input type="text" 
                           id="username" 
                           name="username" 
                           class="form-input" 
                           placeholder="Введите имя пользователя"
                           required>
                </div>
                
                <div class="form-group">
                    <label for="password" class="form-label">🔒 Пароль</label>
                    <input type="password" 
                           id="password" 
                           name="password" 
                           class="form-input" 
                           placeholder="Введите пароль"
                           required>
                </div>
                
                <button type="submit" class="login-btn">
                    🚀 Войти
                </button>
            </form>
            
            <a href="/" class="back-link">
                ← Вернуться на главную
            </a>
            
            <a href="/register" class="back-link" style="margin-top: 8px;">
                🚀 Зарегистрироваться
            </a>
            
            <a href="/forgot-password" class="back-link" style="margin-top: 8px;">
                🔑 Забыли пароль?
            </a>
        </div>
    </div>
    <div class="bs-bottom-menu">
    <style>@import url('/css/bottom-sheet-menu.css');</style>
    <a href="#" class="bs-bottom-trigger" aria-label="Открыть меню">
        Меню
        <span class="bs-bottom-trigger-icon">▲</span>
    </a>

    <div id="bsBottomOverlay" class="bs-bottom-overlay" aria-hidden="true"></div>

    <div id="bsBottomSheet" class="bs-bottom-sheet" aria-hidden="true">
        <div class="bs-bottom-sheet-handle"></div>
        <div class="bs-bottom-sheet-content">
            <a href="/ratings" class="bs-bottom-link">🏆 Рейтинги</a>
            <a href="/schedule" class="bs-bottom-link">📅 Расписание</a>
            <a href="/groups" class="bs-bottom-link">🎓 Группы</a>
            <a href="/lectures" class="bs-bottom-link">📚 Лекции</a>
            <a href="/resources" class="bs-bottom-link">📁 Ресурсы</a>
            <a href="/contacts" class="bs-bottom-link">Контакты</a>

            

            

            <div class="bs-bottom-auth">
                <a href="/register" class="bs-bottom-link">Регистрация</a>
                <a href="/login" class="bs-bottom-link">Войти</a>
            </div>
        </div>
    </div>

    <footer class="site-footer">
        <a href="/privacy-policy">Политика конфиденциальности</a>
        <span class="site-footer-sep">·</span>
        <a href="/terms">Пользовательское соглашение</a>
    </footer>
    <style>
        .site-footer { text-align: center; padding: 12px 8px 16px; font-size: 12px; color: #666; background: #f5f5f5; border-top: 1px solid #eee; }
        .site-footer a { color: #555; text-decoration: none; }
        .site-footer a:hover { color: #357abd; text-decoration: underline; }
        .site-footer-sep { margin: 0 8px; opacity: 0.8; }
    </style>
    <script src="/js/bottom-sheet-menu.js"></script>
</div>
</body>
</html> 