<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Кейсы - CS2 Simulator</title>
    <link rel="stylesheet" href="/static/css/style.css">
    <style>
        .cases-sections {
            display: flex;
            flex-direction: column;
            gap: 2rem;
        }
        
        .cases-container h1 {
            font-size: 1.5rem;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            margin-bottom: 0.25rem;
        }
        
        .section-tab {
            font-size: 1.1rem;
            margin-bottom: 0.75rem;
            padding-bottom: 0.4rem;
            border-bottom: 2px solid var(--primary-color);
            display: inline-block;
            font-family: 'Russo One', sans-serif;
            text-transform: uppercase;
            letter-spacing: 0.04em;
        }
        
        .section-cases {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
            gap: 1.5rem;
        }
        
        .case-card-new {
            background: var(--bg-card);
            border-radius: 12px;
            overflow: hidden;
            transition: all 0.3s;
            text-decoration: none;
            color: inherit;
            display: block;
            border: 1px solid var(--border-color);
        }
        
        .case-card-new:hover {
            transform: translateY(-4px);
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
            border-color: var(--primary-color);
        }
        
        .case-image {
            width: 100%;
            height: 150px;
            background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
        }
        
        .case-image img {
            max-width: 80%;
            max-height: 120px;
            object-fit: contain;
        }
        
        .case-price-badge {
            position: absolute;
            top: 10px;
            right: 10px;
            background: var(--bg-dark);
            padding: 0.25rem 0.75rem;
            border-radius: 20px;
            font-size: 0.9rem;
            font-weight: bold;
            color: var(--success-color);
            border: 1px solid var(--success-color);
        }
        
        .case-info {
            padding: 1rem;
        }
        
        .case-title {
            font-size: 1.1rem;
            font-weight: 600;
            margin-bottom: 0.5rem;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        
        .case-description {
            font-size: 0.85rem;
            color: var(--text-secondary);
            margin-bottom: 0.75rem;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }
        
        .case-stats {
            display: flex;
            justify-content: space-between;
            font-size: 0.8rem;
            color: var(--text-secondary);
            margin-bottom: 0.75rem;
        }
        
        .case-rarities-mini {
            display: flex;
            gap: 0.25rem;
            flex-wrap: wrap;
        }
        
        .rarity-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
        }
        
        .case-footer {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding-top: 0.75rem;
            border-top: 1px solid var(--border-color);
        }
        
        .case-price {
            font-weight: bold;
            color: var(--success-color);
        }
        
        .btn-open {
            padding: 0.4rem 1rem;
            background: var(--primary-color);
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.85rem;
            transition: all 0.2s;
        }
        
        .btn-open:hover {
            background: var(--primary-hover);
        }
    </style>
</head>
<body>
    {% include "_nav.html" %}

    <main class="cases-container">
        <div class="container">
            <h1>📦 Кейсы</h1>
            <p class="page-subtitle">Выберите кейс для открытия</p>
            
            <div class="cases-sections">
                {% for section in sections %}
                <div class="section-block">
                    <h2 class="section-tab">{{ section.tab }}</h2>
                    <div class="section-cases">
                        {% for case in section.cases %}
                        <a href="/case/{{ case.name|urlencode }}" class="case-card-new">
                            <div class="case-image">
                                {% if case.image_url %}
                                <img src="{{ case.image_url }}" alt="{{ case.display_name }}" onerror="this.src='/static/placeholder.png'">
                                {% else %}
                                <span style="font-size: 3rem;">📦</span>
                                {% endif %}
                                <span class="case-price-badge">{{ case.price|money }} ₽</span>
                            </div>
                            <div class="case-info">
                                <div class="case-title">{{ case.display_name }}</div>
                                {% if case.description %}
                                <div class="case-description">{{ case.description }}</div>
                                {% endif %}
                                <div class="case-stats">
                                    <span>{{ case.items_count }} предметов</span>
                                    <div class="case-rarities-mini">
                                        {% for rarity in case.rarities[:4] %}
                                        <span class="rarity-dot" style="background: var(--rarity-{{ rarity|lower|replace(' ', '-')|replace(' grade', '') }});" title="{{ rarity }}"></span>
                                        {% endfor %}
                                        {% if case.rarities|length > 4 %}
                                        <span style="font-size: 0.7rem;">+{{ case.rarities|length - 4 }}</span>
                                        {% endif %}
                                    </div>
                                </div>
                                <div class="case-footer">
                                    <span class="case-price">{{ case.price|money }} ₽</span>
                                    <span class="btn-open">Открыть</span>
                                </div>
                            </div>
                        </a>
                        {% endfor %}
                    </div>
                </div>
                {% endfor %}
            </div>
        </div>
    </main>

    <script>
        async function logout() {
            await fetch('/web/api/auth/logout', { method: 'POST' });
            window.location.href = '/';
        }
    </script>
    <script src="/static/js/sounds.js"></script>
    <script src="/static/js/websocket.js"></script>
    <script src="/static/js/notifications.js"></script>
    <script src="/static/js/safemode.js"></script>
    <script>
        function toggleSound() {
            const enabled = SoundManager.toggle();
            document.getElementById('soundToggle').textContent = enabled ? '🔊' : '🔇';
        }
        document.addEventListener('DOMContentLoaded', () => {
            const btn = document.getElementById('soundToggle');
            if (btn) btn.textContent = localStorage.getItem('sound_enabled') !== 'false' ? '🔊' : '🔇';
        });
    </script>
{% if user %}{% include '_activity_sidebar.html' %}{% endif %}
</body>
</html>