<!DOCTYPE html>
<html lang="ru">

<head>
    <meta charset="UTF-8">
    <title>Тренеры</title>
    <link rel="icon" href="/static/smith.ico" type="image/x-icon">

    <style>
        :root {
            --bg: #0f1115;
            --panel: #171a21;
            --panel-2: #1d222b;
            --border: #2b3240;
            --text: #e8ecf3;
            --muted: #9aa4b2;
            --accent: #4f8cff;
            --shadow: 0 10px 30px rgba(0, 0, 0, .35);
            --radius: 16px;
        }

        * {
            box-sizing: border-box;
        }

        body {
            margin: 0;
            background: var(--bg);
            color: var(--text);
            font-family: Arial, sans-serif;
        }

        .page {
            max-width: 1400px;
            margin: 0 auto;
            padding: 24px;
        }

        .panel {
            background: var(--panel);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            padding: 20px;
        }

        .topbar {
            display: flex;
            gap: 12px;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 18px;
            flex-wrap: wrap;
        }

        .title {
            font-size: 24px;
            font-weight: 700;
        }

        .search-form {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
        }

        input[type="text"] {
            min-width: 280px;
            min-height: 42px;
            padding: 0 12px;
            border-radius: 10px;
            border: 1px solid var(--border);
            background: var(--panel-2);
            color: var(--text);
        }

        .btn {
            min-height: 42px;
            padding: 0 14px;
            border: none;
            border-radius: 10px;
            cursor: pointer;
            font-weight: 600;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
        }

        .btn-primary {
            background: var(--accent);
            color: white;
        }

        .btn-secondary {
            background: transparent;
            color: var(--text);
            border: 1px solid var(--border);
        }

        table {
            width: 100%;
            border-collapse: collapse;
            background: var(--panel-2);
            border-radius: 12px;
            overflow: hidden;
        }

        th,
        td {
            padding: 10px 12px;
            border-bottom: 1px solid var(--border);
            text-align: left;
            font-size: 14px;
        }

        th {
            color: var(--muted);
            font-weight: 600;
        }

        tr:last-child td {
            border-bottom: none;
        }

        .id-col {
            width: 70px;
        }

        .action-col {
            width: 140px;
            text-align: right;
        }

        .empty-box {
            padding: 18px;
            border-radius: 12px;
            background: var(--panel-2);
            color: var(--muted);
            border: 1px dashed var(--border);
        }
    </style>
</head>

<body>
    <div class="page">
        <div class="panel">
            <div class="topbar">
                <div class="title">Тренеры</div>
                <form method="get" action="/admin/db/coaches" class="search-form">
                    <input type="text" name="q" value="{{ q }}" placeholder="Поиск по ФИО или external_id">
                    <button type="submit" class="btn btn-primary">Найти</button>
                    <a href="/admin/db" class="btn btn-secondary">Назад</a>
                </form>
            </div>

            {% if coaches %}
            <table>
                <thead>
                    {% for c in coaches %}
                    <tr>
                        <td>{{ c.id }}</td>
                        <td>{{ c.full_name }}</td>
                        <td>{{ c.team_name or "—" }}</td>
                        <td>{{ c.role or "—" }}</td>
                        <td>{{ c.external_id }}</td>
                        <td class="action-col">
                            <a href="/admin/db/coaches/{{ c.id }}/edit" class="btn btn-secondary">Редактировать</a>
                        </td>
                    </tr>
                    {% endfor %}
                </thead>
            </table>
            {% else %}
            <div class="empty-box">Тренеры не найдены.</div>
            {% endif %}
        </div>
    </div>
</body>

</html>