<section class="schedule-view-shell">
    <div class="card schedule-view-control-card">
        <div class="schedule-view-control-header">
            <div>
                <h2>Расписания</h2>
                <span class="muted" id="schedule-view-period-label">Период не выбран</span>
            </div>
            <button type="button" class="btn btn-md btn-secondary" id="schedule-view-load">Показать</button>
        </div>

        <div class="schedule-view-control-grid">
            <div class="form-group">
                <label for="schedule-view-target">Что смотреть</label>
                <select id="schedule-view-target">
                    <option value="groups">Группа</option>
                    <option value="teachers">Преподаватель</option>
                    <option value="classrooms">Аудитория</option>
                    <option value="departments">Кафедра</option>
                </select>
            </div>

            <div class="form-group schedule-view-entity-field" data-schedule-view-target-field="groups">
                <label for="schedule-view-group">Группа</label>
                <select id="schedule-view-group">
                    <option value="">Все группы</option>
                </select>
            </div>

            <div class="form-group schedule-view-entity-field" data-schedule-view-target-field="teachers" hidden>
                <label for="schedule-view-teacher">Преподаватель</label>
                <select id="schedule-view-teacher">
                    <option value="">Все преподаватели</option>
                </select>
            </div>

            <div class="form-group schedule-view-entity-field" data-schedule-view-target-field="classrooms" hidden>
                <label for="schedule-view-classroom">Аудитория</label>
                <select id="schedule-view-classroom">
                    <option value="">Все аудитории</option>
                </select>
            </div>

            <div class="form-group schedule-view-entity-field" data-schedule-view-target-field="departments" hidden>
                <label for="schedule-view-department">Кафедра</label>
                <select id="schedule-view-department">
                    <option value="">Все кафедры</option>
                </select>
            </div>

            <input type="date" id="schedule-view-date" hidden>
        </div>

        <details class="schedule-view-extra-filters">
            <summary>Дополнительные фильтры</summary>
            <div class="schedule-view-extra-grid">
                <div class="form-group">
                    <label for="schedule-view-semester">Семестр</label>
                    <select id="schedule-view-semester">
                        <option value="">По текущей дате</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="schedule-view-subject">Дисциплина</label>
                    <select id="schedule-view-subject">
                        <option value="">Все дисциплины</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="schedule-view-lesson-type">Тип занятия</label>
                    <select id="schedule-view-lesson-type">
                        <option value="">Все типы</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="schedule-view-parity">Неделя</label>
                    <select id="schedule-view-parity">
                        <option value="">Любая</option>
                        <option value="BOTH">Каждая</option>
                        <option value="ODD">Нечётная</option>
                        <option value="EVEN">Чётная</option>
                    </select>
                </div>
            </div>
        </details>

        <div class="form-alert" id="schedule-view-alert" role="alert"></div>
    </div>

    <div class="card schedule-view-results-card">
        <div class="schedule-view-results-header">
            <div>
                <h2>Найденные расписания</h2>
                <span class="muted" id="schedule-view-count">0 занятий</span>
            </div>
            <div class="schedule-view-result-actions">
                <button type="button" class="btn btn-md btn-secondary" id="schedule-view-overrides-open" hidden>
                    Изменения за период
                    <span class="schedule-override-count" id="schedule-view-overrides-count">0</span>
                </button>
                <button type="button" class="btn btn-icon-md btn-secondary" id="schedule-view-result-prev" aria-label="Предыдущее расписание">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
                        <polyline points="15 18 9 12 15 6"></polyline>
                    </svg>
                </button>
                <span id="schedule-view-active-label">Нет выбранного расписания</span>
                <button type="button" class="btn btn-icon-md btn-secondary" id="schedule-view-result-next" aria-label="Следующее расписание">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
                        <polyline points="9 18 15 12 9 6"></polyline>
                    </svg>
                </button>
            </div>
        </div>
        <div class="schedule-view-result-tabs" id="schedule-view-result-tabs"></div>
    </div>

    <div class="card schedule-view-table-card">
        <div class="schedule-view-table-header">
            <div>
                <h2 id="schedule-view-table-title">Расписание</h2>
                <span class="muted" id="schedule-view-table-caption">Выберите параметры и нажмите «Показать»</span>
            </div>
            <div class="schedule-view-day-tabs" id="schedule-view-day-tabs" hidden></div>
        </div>
        <div class="schedule-view-table-stage" id="schedule-view-tables">
            <div class="loading-row schedule-view-state">Загрузка...</div>
        </div>
    </div>
</section>

<div class="schedule-override-drawer" id="schedule-override-drawer" hidden aria-hidden="true">
    <button type="button" class="schedule-override-backdrop" data-override-close aria-label="Закрыть панель"></button>
    <aside class="schedule-override-panel" role="dialog" aria-modal="true" aria-labelledby="schedule-override-title">
        <header class="schedule-override-header">
            <div>
                <span class="schedule-override-eyebrow">Точечное изменение</span>
                <h2 id="schedule-override-title">Конкретное занятие</h2>
            </div>
            <button type="button" class="btn btn-icon-md btn-secondary" data-override-close aria-label="Закрыть">
                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
                    <path d="M6 6l12 12M18 6L6 18"></path>
                </svg>
            </button>
        </header>

        <nav class="schedule-override-tabs" aria-label="Разовые изменения">
            <button type="button" class="schedule-override-tab active" data-override-tab="edit">Редактирование</button>
            <button type="button" class="schedule-override-tab" data-override-tab="registry">Изменения за период</button>
        </nav>

        <div class="schedule-override-body">
            <section data-override-section="edit">
                <div class="schedule-override-empty" id="schedule-override-empty">
                    Выберите занятие в расписании или откройте его из реестра изменений.
                </div>

                <form id="schedule-override-form" hidden>
                    <div class="schedule-override-comparison">
                        <article>
                            <span>Было по правилу</span>
                            <strong id="schedule-override-before-title">—</strong>
                            <p id="schedule-override-before-meta">—</p>
                        </article>
                        <article class="schedule-override-after">
                            <span>Станет</span>
                            <strong id="schedule-override-after-title">—</strong>
                            <p id="schedule-override-after-meta">—</p>
                        </article>
                    </div>

                    <fieldset class="schedule-override-fieldset">
                        <legend>Дата занятия</legend>
                        <div class="schedule-override-week" id="schedule-override-week"></div>
                        <button type="button" class="btn btn-md btn-secondary schedule-override-calendar-toggle" id="schedule-override-calendar-toggle">
                            Выбрать другую дату
                        </button>
                        <div class="schedule-override-calendar" id="schedule-override-calendar" hidden></div>
                    </fieldset>

                    <div class="schedule-override-fields">
                        <div class="form-group">
                            <label for="schedule-override-time">Время</label>
                            <select id="schedule-override-time" data-native-select="true" required></select>
                        </div>
                        <div class="form-group">
                            <label for="schedule-override-teacher">Преподаватель</label>
                            <select id="schedule-override-teacher" data-native-select="true"></select>
                        </div>
                        <div class="form-group">
                            <label for="schedule-override-classroom">Аудитория</label>
                            <select id="schedule-override-classroom" data-native-select="true"></select>
                        </div>
                        <div class="form-group">
                            <label for="schedule-override-format">Формат</label>
                            <select id="schedule-override-format" data-native-select="true">
                                <option value="Очно">Очно</option>
                                <option value="Онлайн">Онлайн</option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="schedule-override-comment">Комментарий</label>
                        <textarea id="schedule-override-comment" rows="3" maxlength="1000" placeholder="Например, замена аудитории из-за мероприятия"></textarea>
                    </div>

                    <div class="form-alert" id="schedule-override-alert" role="alert"></div>

                    <footer class="schedule-override-actions">
                        <button type="submit" class="btn btn-md btn-primary" id="schedule-override-save">Сохранить</button>
                        <button type="button" class="btn btn-md btn-danger-subtle" id="schedule-override-cancel">Отменить занятие</button>
                        <button type="button" class="btn btn-md btn-secondary" id="schedule-override-restore" hidden>Вернуть по правилу</button>
                    </footer>
                </form>
            </section>

            <section data-override-section="registry" hidden>
                <div class="schedule-override-registry-heading">
                    <div>
                        <h3>Изменения за выбранный период</h3>
                        <span class="muted" id="schedule-override-registry-period">—</span>
                    </div>
                </div>
                <div class="schedule-override-registry" id="schedule-override-registry"></div>
            </section>
        </div>
    </aside>
</div>
