<!DOCTYPE html>
<html lang="ru">
<!-- НЕ ЛЕЗЬ СЮДА -->
<head>
    <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
    new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
    j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
    'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
    })(window,document,'script','dataLayer','GTM-5CSFWZX5');</script>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title data-i18n="title">workshop</title>
    <link rel="icon" href="https://csgoworkshop.ru/favicon.ico" type="image/x-icon">
    <link rel="canonical" href="https://csgoworkshop.ru/">
    <link rel="stylesheet" href="{{ url_for('static', filename='workshop.css') }}">
    <script src="{{ url_for('static', filename='workshop.js') }}" defer></script>

    <script async src="https://www.googletagmanager.com/gtag/js?id=G-PGN3XJFDFF"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
      gtag('config', 'G-PGN3XJFDFF');
    </script>
</head>
<body>
    <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5CSFWZX5"
    height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>

    <div class="top-bar">
        <div class="left-text">
            <p data-i18n="made_by">Сделал: ©️𝙎𝙃∆𝙈∆𝙉©️</p>
            <p data-i18n="description">Неофициальный сайт<br>с картами для CS:GO<br>из мастерской Steam</p>
        </div>
        <h1 class="center-text" data-i18n="header">CS:GO Workshop</h1>
        <a href="https://cloud.shsr.ru/apps/forms/s/xr8NyqdpsodwcNnRBSrMzJ4N" class="contact-button" target="_blank" data-i18n="contact">Связаться</a>
    </div>

    <div class="main-container">
        <div class="cards-container">
            {% for map in maps_data %}
            <div class="card">
                <a href="/main?image_url={{ get_image_path(map[0]) }}&map_title={{ map[1] }}&{{ filters }}">
                    <img src="{{ get_image_path(map[0]) }}" alt="Map Image" width="200" height="110">
                </a>
                <img src="{{ get_star_image(map[2]) }}" alt="{{ map[2] }} stars" class="stars" width="81" height="14">
                <div class="card-title">{{ map[1] }}</div>
                <div class="description-popup">
                    <strong>{{ map[1] }}</strong>
                    <p>{{ map[3] }}</p>
                </div>
            </div>
            {% endfor %}
        </div>

        <div class="right-rectangle">
            <div class="sort-button-container">
                <button class="sort-button" data-i18n="sort_by_date">Сортировать по дате</button>
            </div>
            <div class="game-modes">
                <div class="show-products-title" data-i18n="show_products">Показать продукты, попадающие в каждую из выбранных категорий:</div>
                <div class="game-modes-title" data-i18n="game_modes">РЕЖИМ ИГРЫ</div>

                {% for mode, label in {
                    "Classic": "Классический",
                    "Deathmatch": "Бой насмерть",
                    "Demolition": "Уничтожение объекта",
                    "Armsrace": "Гонка вооружений",
                    "Custom": "Пользовательский",
                    "Training": "Обучение",
                    "Co-op Strike": "Совместный налёт",
                    "Wingman": "Напарники",
                    "Flying_Scoutsman": "Перелётные снайперы"
                }.items() %}
                <label class="game-mode">
                    <input type="checkbox" class="game-mode-checkbox" value="{{ mode }}" {% if mode in filters %}checked{% endif %}>
                    <span data-i18n="game_mode_{{ mode }}">{{ label }}</span>
                </label>
                {% endfor %}
            </div>
            <div class="search-container">
                <form method="get" action="/">
                    <div class="search-input-container">
                        <input type="text" id="search" class="search-input" name="search_title" data-i18n-placeholder="search_placeholder" placeholder="Поиск по названию" value="{{ request.args.get('search_title', '') }}">
                        <button class="search-button" type="submit">
                            <img src="/images/search-icon.png" alt="Поиск">
                        </button>
                    </div>
                </form>
            </div>
        </div>

        <div id="sortModal" class="modal">
            <div class="modal-content">
                <span class="close-btn">×</span>
                <h2 data-i18n="sort_by_date">Сортировать по дате</h2>
                <div class="modal-rectangle">
                    <span class="text-left" data-i18n="from">С</span>
                    <div class="first-rectangle">
                        <input type="date" class="date-input" />
                    </div>
                    <span class="text-center" data-i18n="to">ПО</span>
                    <div class="second-rectangle">
                        <input type="date" class="date-input" />
                    </div>
                </div>
                <button class="ok-button" data-i18n="ok">ОК</button>
                <button class="cancel-button" data-i18n="cancel">Отмена</button>
            </div>
        </div>

        <div class="filter-stars">
            <div class="filter-title">
                <label data-i18n="filter_by_stars">Фильтр по количеству звезд:</label>
            </div>
            <div class="stars-filter">
                <label><input type="checkbox" name="stars" value="1" {% if 'stars' in request.args and '1' in request.args.getlist('stars') %}checked{% endif %}> 1</label>
                <label><input type="checkbox" name="stars" value="2" {% if 'stars' in request.args and '2' in request.args.getlist('stars') %}checked{% endif %}> 2</label>
                <label><input type="checkbox" name="stars" value="3" {% if 'stars' in request.args and '3' in request.args.getlist('stars') %}checked{% endif %}> 3</label>
                <label><input type="checkbox" name="stars" value="4" {% if 'stars' in request.args and '4' in request.args.getlist('stars') %}checked{% endif %}> 4</label>
                <label><input type="checkbox" name="stars" value="5" {% if 'stars' in request.args and '5' in request.args.getlist('stars') %}checked{% endif %}> 5</label>
            </div>
        </div>

        <div class="pagination">
            {% if page > 1 %}
            <a class="pagebtn" href="/?page={{ page - 1 }}&{{ filters }}"><</a>
            {% endif %}

            {% if page > 3 %}
            <a class="pagelink" href="/?page=1&{{ filters }}">1</a>
            <span class="pagination_space">...</span>
            {% endif %}

            {% for p in range(1, total_pages + 1) %}
            {% if p >= page - 1 and p <= page + 2 %}
            {% if p == page %}
            <span class="pagelink" style="color: #417A9B;">{{ p }}</span>
            {% else %}
            <a class="pagelink" href="/?page={{ p }}&{{ filters }}">{{ p }}</a>
            {% endif %}
            {% endif %}
            {% endfor %}

            {% if total_pages > 3 and page < total_pages - 2 %}
            <span class="pagination_space">...</span>
            <a class="pagelink" href="/?page={{ total_pages }}&{{ filters }}">{{ total_pages }}</a>
            {% endif %}

            {% if page < total_pages %}
            <a class="pagebtn" href="/?page={{ page + 1 }}&{{ filters }}">></a>
            {% endif %}
        </div>
    </div>
</body>
</html>