<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.w3.org/1999/xhtml"
      layout:decorate="~{layouts/main-layout}">
<head>
    <title>Бронирования</title>
    <link rel="stylesheet" href="/css/catalog.css"/>
    <link rel="stylesheet" href="/css/bookings.css"/>
</head>
<body>
<th:block layout:fragment="content">
    <div id="bookings-page" class="catalog-page bookings-page py-3">
        <div class="d-flex justify-content-between align-items-start flex-wrap gap-3 mb-3">
            <div>
                <h2 class="mb-1">Бронирования</h2>
                <div class="catalog-helper">Табличный просмотр забронированных слотов с фильтрацией по времени, заявке и спутникам.</div>
            </div>
            <div class="d-flex gap-2 flex-wrap">
                <button id="bookings-reset" type="button" class="btn btn-outline-secondary">Сбросить</button>
                <button id="bookings-refresh" type="button" class="btn btn-primary">Обновить</button>
            </div>
        </div>

        <div id="bookings-alert"></div>

        <div class="card catalog-card bookings-filter-card mb-3">
            <div class="card-body">
                <div class="row g-3 align-items-end">
                    <div class="col-12 col-md-3">
                        <label for="bookings-time-start" class="form-label">Начало интервала</label>
                        <input id="bookings-time-start" type="datetime-local" class="form-control form-control-sm">
                    </div>
                    <div class="col-12 col-md-3">
                        <label for="bookings-time-stop" class="form-label">Конец интервала</label>
                        <input id="bookings-time-stop" type="datetime-local" class="form-control form-control-sm">
                    </div>
                    <div class="col-12 col-md-3">
                        <label for="bookings-request" class="form-label">Заявка</label>
                        <select id="bookings-request" class="form-select form-select-sm">
                            <option value="">Все заявки</option>
                        </select>
                    </div>
                    <div class="col-12 col-md-3">
                        <label for="bookings-satellite-search" class="form-label">Фильтр спутников</label>
                        <input id="bookings-satellite-search"
                               type="search"
                               class="form-control form-control-sm"
                               autocomplete="off"
                               placeholder="ID, NORAD, код, имя, тип">
                    </div>
                </div>
            </div>
        </div>

        <div class="row g-3 bookings-layout">
            <div class="col-12 col-xl-3">
                <div class="card catalog-card bookings-satellites-card h-100">
                    <div class="card-header d-flex justify-content-between align-items-center gap-2">
                        <div>
                            <div class="catalog-section-title">Спутники</div>
                            <div class="catalog-helper mt-1">Выберите один или несколько КА.</div>
                        </div>
                        <button id="bookings-satellites-clear" type="button" class="btn btn-outline-secondary btn-sm">Выбрать все</button>
                    </div>
                    <div class="card-body p-0 bookings-satellites-wrap">
                        <table class="table table-hover mb-0 bookings-satellites-table">
                            <thead class="table-light">
                            <tr>
                                <th class="bookings-check-col"></th>
                                <th>ID</th>
                                <th>Спутник</th>
                            </tr>
                            </thead>
                            <tbody id="bookings-satellites-body"></tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="col-12 col-xl-9">
                <div class="card catalog-card bookings-table-card h-100">
                    <div class="card-header d-flex justify-content-between align-items-start gap-3 flex-wrap">
                        <div>
                            <div class="catalog-section-title">Забронированные слоты</div>
                            <div id="bookings-summary" class="catalog-helper mt-1">Загрузка данных...</div>
                        </div>
                    </div>
                    <div class="card-body p-0">
                        <div id="bookings-empty" class="catalog-empty d-none">Забронированные слоты не найдены.</div>
                        <div id="bookings-table-wrap" class="table-responsive bookings-table-wrap">
                            <table class="table table-hover mb-0 bookings-table">
                                <thead class="table-light">
                                <tr>
                                    <th>Бронь</th>
                                    <th>КА</th>
                                    <th>Слот / цикл</th>
                                    <th>Время</th>
                                    <th>Виток</th>
                                    <th>Крен</th>
                                    <th>Статус</th>
                                    <th>Заявки</th>
                                </tr>
                                </thead>
                                <tbody id="bookings-body"></tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="/bookings_scripts.js"></script>
</th:block>
</body>
</html>
