<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>KIWI.store</title>
    <link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@700&family=Exo+2:wght@400;600&display=swap" rel="stylesheet">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Exo 2', sans-serif;
            background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
            color: #fff;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            font-size: 1.1rem;
        }

        header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: linear-gradient(90deg, #a4ff33 0%, #8dd82b 100%);
            padding: 1.2rem 5%;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
            position: sticky;
            top: 0;
            z-index: 1000;
        }

        .logo {
            font-family: 'Orbitron', sans-serif;
            font-size: 2.2rem;
            color: #000;
            letter-spacing: 1.5px;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
        }

        input[type="text"] {
            flex-grow: 1;
            margin: 0 2rem;
            padding: 0.8rem 1.5rem;
            background: rgba(0, 0, 0, 0.3);
            border: 2px solid #a4ff33;
            color: #fff;
            border-radius: 30px;
            transition: all 0.3s ease;
            font-size: 1rem;
        }

        input[type="text"]:focus {
            outline: none;
            box-shadow: 0 0 15px rgba(164, 255, 51, 0.4);
        }

        .auth-buttons {
            display: flex;
            gap: 15px;
            align-items: center;
        }

        .login-btn {
            background: #000;
            color: #a4ff33;
            padding: 0.8rem 1.5rem;
            border: 2px solid #000;
            border-radius: 8px;
            cursor: pointer;
            font-size: 1.1rem;
            font-weight: bold;
            text-decoration: none;
            transition: all 0.3s ease;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
            position: relative;
            overflow: hidden;
            display: flex;
            align-items: center;
        }

        .login-btn::after {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(
                90deg,
                transparent,
                rgba(164, 255, 51, 0.2),
                transparent
            );
            transition: 0.5s;
        }

        .login-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(164, 255, 51, 0.5);
            border-color: #a4ff33;
        }

        .login-btn:hover::after {
            left: 100%;
        }

        .login-btn::before {
            content: '';
            display: inline-block;
            width: 20px;
            height: 20px;
            margin-right: 8px;
            background-size: contain;
        }

        .auth-buttons a:first-child::before {
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23a4ff33"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>');
        }

        .auth-buttons a:last-child::before {
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23a4ff33"><path d="M11 7L9.6 8.4l2.6 2.6H2v2h10.2l-2.6 2.6L11 17l5-5-5-5zm9 12h-8v2h8c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2h-8v2h8v14z"/></svg>');
        }

        .user-profile {
            display: none;
            align-items: center;
            gap: 1rem;
            background: rgba(0, 0, 0, 0.95);
            padding: 0.8rem 1.5rem;
            border-radius: 12px;
            border: 2px solid #a4ff33;
            box-shadow: 0 0 20px rgba(164, 255, 51, 0.2);
            animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            backdrop-filter: blur(5px);
        }

        .username {
            color: #a4ff33;
            font-weight: 600;
            font-size: 1.1rem;
            text-shadow: 0 0 8px rgba(164, 255, 51, 0.4);
            letter-spacing: 0.5px;
        }

        .logout-btn {
            background: none;
            border: 2px solid #ff4444;
            color: #ff4444;
            padding: 0.5rem 1rem;
            border-radius: 8px;
            font-weight: 600;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .logout-btn:hover {
            background: rgba(255, 68, 68, 0.1);
            transform: translateY(-2px);
            box-shadow: 0 2px 8px rgba(255, 68, 68, 0.2);
        }

        .logout-btn::before {
            content: '';
            display: block;
            width: 18px;
            height: 18px;
            background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23ff4444"><path d="M17 7l-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5zM4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4V5z"/></svg>');
        }

        main {
            display: grid;
            gap: 2rem;
            padding: 2rem 5%;
            flex-grow: 1;
        }

        .main-content {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 15px;
            box-shadow: 0 8px 32px rgba(164, 255, 51, 0.1);
            border: 1px solid rgba(164, 255, 51, 0.2);
            min-height: 500px;
        }

        .side-content {
            display: grid;
            gap: 2rem;
        }

        .top-box, .bottom-box {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 15px;
            box-shadow: 0 8px 32px rgba(164, 255, 51, 0.1);
            border: 1px solid rgba(164, 255, 51, 0.2);
            min-height: 200px;
        }

        .brands-container {
            background: rgba(0, 0, 0, 0.7);
            border: 1px solid #a4ff33;
            margin: 2rem auto;
            padding: 2rem;
            border-radius: 15px;
            max-width: 1200px;
            position: relative;
        }

        .brands-container::before {
            content: "Популярные бренды";
            position: absolute;
            top: -20px;
            left: 50%;
            transform: translateX(-50%);
            background: #a4ff33;
            color: #000;
            padding: 8px 25px;
            border-radius: 20px;
            font-weight: 700;
            font-size: 1.1rem;
        }

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

        .brands img {
            height: 60px;
            filter: grayscale(0.8);
            transition: all 0.3s ease;
            cursor: pointer;
            padding: 8px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 8px;
        }

        .brands img:hover {
            filter: grayscale(0);
            transform: translateY(-5px) scale(1.1);
            background: rgba(164, 255, 51, 0.1);
        }

        footer {
            background: linear-gradient(90deg, #a4ff33 0%, #8dd82b 100%);
            color: #000;
            padding: 1.5rem 5%;
            margin-top: auto;
        }

        .contact {
            display: flex;
            justify-content: center;
            gap: 3rem;
            font-weight: 600;
        }

        .contact > span {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 0.5rem 1rem;
            border-radius: 8px;
            transition: all 0.3s ease;
        }

        .contact > span:hover {
            background: rgba(0, 0, 0, 0.1);
        }

        .contact > span::before {
            content: "";
            width: 24px;
            height: 24px;
            background-size: contain;
            background-repeat: no-repeat;
            display: inline-block;
            vertical-align: middle;
        }

        .contact > span:first-child::before {
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23000"><path d="M20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4V8l8 5 8-5v10zm-8-7L4 6h16l-8 5z"/></svg>');
        }

        .contact > span:last-child::before {
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23000"><path d="M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z"/></svg>');
        }

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

        @media (max-width: 1200px) {
            main {
                grid-template-columns: 1fr;
            }
            
            .side-content {
                grid-template-columns: 1fr 1fr;
                gap: 1rem;
            }
        }

        @media (max-width: 768px) {
            header {
                flex-direction: column;
                gap: 1rem;
            }
            
            input[type="text"] {
                margin: 0;
                width: 100%;
            }
            
            .brands img {
                height: 40px;
            }

            .contact {
                flex-direction: column;
                align-items: center;
                gap: 1rem;
            }
        }
        .products-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 2rem;
            padding: 2rem;
        }

        .product-card {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 15px;
            padding: 1.5rem;
            box-shadow: 0 8px 25px rgba(164, 255, 51, 0.1);
            transition: transform 0.3s ease;
        }

        .product-card:hover {
            transform: translateY(-5px);
        }

        .product-image {
            width: 100%;
            height: 250px;
            object-fit: contain;
            margin-bottom: 1rem;
        }

        .product-title {
            font-family: 'Orbitron', sans-serif;
            color: #1a1a1a;
            font-size: 1.4rem;
            margin-bottom: 0.5rem;
        }

        .product-description {
            color: #666;
            font-size: 0.9rem;
            margin-bottom: 1rem;
        }

        .product-price {
            font-size: 1.8rem;
            color: #1a1a1a;
            font-weight: 700;
            margin: 1rem 0;
        }

        .buy-button {
            display: block;
            width: 100%;
            padding: 1rem;
            background: #000;
            color: #a4ff33;
            border: 2px solid #a4ff33;
            border-radius: 10px;
            cursor: pointer;
            font-weight: bold;
            transition: all 0.3s ease;
        }

        .buy-button:hover {
            background: #a4ff33;
            color: #000;
            box-shadow: 0 0 15px rgba(164, 255, 51, 0.4);
        }

        /* Адаптивность */
        @media (max-width: 768px) {
            .products-grid {
                grid-template-columns: 1fr;
                padding: 1rem;
            }
            
            .product-image {
                height: 200px;
            }
        }
    </style>
</head>
<body>
    <header>
        <div class="logo">KIWI.store</div>
        <input type="text" placeholder="Поиск...">
        <div class="auth-section">
            <div class="user-profile" id="userProfile">
                <span class="username" id="username"></span>
                <button class="logout-btn" id="logoutBtn">Выход</button>
            </div>
            <div class="auth-buttons" id="authButtons">
                <a href="register.html" class="login-btn">Регистрация</a>
                <a href="login.html" class="login-btn">Вход</a>
            </div>
        </div>
    </header>

    <main>
        <div class="main-content">
            <div class="products-grid">
                <!-- Карточка RTX 4090 -->
                <div class="product-card">
                    <img src="https://avatars.mds.yandex.net/get-goods_pic/6439275/hatfa8a18c3b1a5d3793e0a9bf84d3b6b84/600x600" alt="RTX 4090" class="product-image">
                    <h2 class="product-title">NVIDIA GeForce RTX 4090</h2>
                    <p class="product-description">24 ГБ GDDR6X, архитектура Ada Lovelace, 16384 ядер CUDA, DLSS 3</p>
                    <div class="product-price">199 990 ₽</div>
                    <button class="buy-button">Купить сейчас</button>
                </div>

                <!-- Карточка RX 7900 XT -->
                <div class="product-card">
                    <img src="https://avatars.mds.yandex.net/get-goods_pic/9362007/hat3b510fcccde606266d7ecb129c04f697/600x600" alt="RX 7900 XT" class="product-image">
                    <h2 class="product-title">AMD Radeon RX 7900 XT</h2>
                    <p class="product-description">20 ГБ GDDR6, архитектура RDNA 3, 5376 потоковых процессоров, FSR 3</p>
                    <div class="product-price">149 990 ₽</div>
                    <button class="buy-button">Купить сейчас</button>
                </div>
            </div>
        </div>
        
        <!-- Боковая панель остается без изменений -->
    </main>

    <div class="brands-container">
        <div class="brands">
            <img src="/static/images/amd.png" alt="AMD">
            <img src="/static/images/ardor.png" alt="ARDOR">
            <img src="/static/images/apple.png" alt="Apple">
            <img src="/static/images/samsung.png" alt="SAMSUNG">
            <img src="/static/images/nvidia.png" alt="NVIDIA">
            <img src="/static/images/msi.png" alt="msi">
        </div>
    </div>

    <footer>
        <div class="contact">
            <span>kiwi@store.com</span>
            <span>+7900806050</span>
        </div>
    </footer>

    <script>
        document.addEventListener('DOMContentLoaded', () => {
            const authButtons = document.getElementById('authButtons');
            const userProfile = document.getElementById('userProfile');
            const usernameSpan = document.getElementById('username');
            const logoutBtn = document.getElementById('logoutBtn');
    
            // Проверка авторизации
            const checkAuth = () => {
                const currentUser = JSON.parse(localStorage.getItem('currentUser'));
                const currentUrl = window.location.pathname;

                if (currentUser && currentUser.username) {
                    authButtons.style.display = 'none';
                    userProfile.style.display = 'flex';
                    usernameSpan.textContent = currentUser.username;
                } else if (currentUrl !== '/login.html' && currentUrl !== '/register.html') {
                    // Если пользователь не авторизован и не находится на странице входа или регистрации
                    authButtons.style.display = 'flex';
                    userProfile.style.display = 'none';
                    // Перенаправляем на страницу входа только если текущий URL не login.html и не register.html
                    // window.location.href = 'login.html'; // Убираем безусловный редирект
                } else {
                    // Если пользователь не авторизован, но находится на странице входа или регистрации
                    authButtons.style.display = 'flex';
                    userProfile.style.display = 'none';
                }
            };
    
            // Выход из системы
            logoutBtn.addEventListener('click', () => {
                localStorage.removeItem('currentUser');
                checkAuth();
                window.location.reload();
            });
    
            // Первоначальная проверка
            checkAuth();
    
            // Обработчик для кнопок покупки
            document.querySelectorAll('.buy-button').forEach(button => {
                button.addEventListener('click', () => {
                    const currentUser = JSON.parse(localStorage.getItem('currentUser'));
                    if(!currentUser) {
                        alert('Для совершения покупки необходимо авторизоваться!');
                        window.location.href = 'login.html';
                    } else {
                        // Логика покупки
                        alert(`Покупка совершена, ${currentUser.username}!`);
                    }
                });
            });
    
            // Поисковая строка (заглушка)
            document.querySelector('input[type="text"]').addEventListener('keypress', (e) => {
                if(e.key === 'Enter') {
                    alert('Поиск временно недоступен');
                }
            });
        });
    </script>
</body>
</html>