/* ==========================================================================
   schedule.css — страница «Расписание / Horaires» (schedule.php)
   Все классы с префиксом sch-, чтобы не пересекаться со стилями шапки, подвала и кабинета.
   Фирменный цвет школы — #134fa9 (как в шапке и подвале).
   ========================================================================== */

html, body { margin: 0; }

.sch-page {
    --sch-blue: #134fa9;
    --sch-blue-dark: #0f3f87;
    --sch-blue-soft: #eef3fc;
    --sch-text: #1f212c;
    --sch-muted: #6b7280;
    --sch-border: #e2e6ee;
    --sch-bg: #f6f8fb;
    --sch-green: #15803d;
    --sch-green-soft: #f1faf4;
    --sch-red: #b91c1c;
    --sch-shadow: 0 6px 18px rgba(20, 35, 70, .08);

    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--sch-bg);
    color: var(--sch-text);
    font-family: 'Gilroy', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.4;
}
.sch-page *, .sch-page *::before, .sch-page *::after { box-sizing: border-box; }
.sch-page [hidden] { display: none !important; }
.sch-page > footer { flex: none; margin-top: auto; }   /* подвал «прибит к полу», как в кабинете */
.sch-main { flex: 1 0 auto; }
.sch-container { max-width: 1200px; margin: 0 auto; padding: 32px 24px 56px; }

.sch-page :focus-visible { outline: 2px solid var(--sch-blue); outline-offset: 2px; }

/* ---------- Заголовок и переключатель вида ---------- */
.sch-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px 24px; margin-bottom: 20px; }
.sch-title { margin: 0; font-size: 32px; font-weight: 700; line-height: 1.15; color: var(--sch-text); }

/* Сегментированный переключатель (вид, режим даты) */
.sch-seg { display: inline-flex; gap: 2px; padding: 3px; background: #e8edf6; border-radius: 12px; }
.sch-seg-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 18px; border: 0; border-radius: 9px; background: transparent; color: #4b5563; font: inherit; font-size: 15px; font-weight: 600; line-height: 1.2; cursor: pointer; transition: background .15s ease, color .15s ease, box-shadow .15s ease; }
.sch-seg-btn:hover { color: var(--sch-blue); }
.sch-seg-btn.is-active { background: #fff; color: var(--sch-blue); box-shadow: 0 1px 3px rgba(20, 35, 70, .16); }
.sch-seg-btn svg { flex: none; }
.sch-field--mode .sch-seg-btn { min-height: 38px; padding: 6px 18px; }   /* вместе с рамкой 3+3 = 44px — как поля ввода рядом */

/* ---------- Фильтры ---------- */
.sch-filters { margin-bottom: 14px; padding: 16px 18px; background: #fff; border: 1px solid var(--sch-border); border-radius: 16px; }
.sch-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 16px; min-width: 0; margin: 0; padding: 0; border: 0; transition: opacity .2s ease; }
.sch-fields:disabled { opacity: .55; }
.sch-field { flex: 0 0 auto; min-width: 0; }
.sch-field--date { width: 168px; }
.sch-field--course { flex: 1 1 220px; min-width: 200px; }
.sch-label { display: block; margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--sch-muted); }

.sch-input { display: block; width: 100%; height: 44px; padding: 0 12px; border: 1px solid #d3dae6; border-radius: 10px; background: #fff; color: var(--sch-text); font: inherit; font-size: 15px; line-height: 1.2; transition: border-color .15s ease, box-shadow .15s ease; }
.sch-input:hover { border-color: #aebbd2; }
.sch-input:focus { outline: none; border-color: var(--sch-blue); box-shadow: 0 0 0 3px rgba(19, 79, 169, .18); }
.sch-input[type="date"] { -webkit-appearance: none; appearance: none; min-height: 44px; }
.sch-input[type="date"]::-webkit-date-and-time-value { text-align: left; }
.sch-select { -webkit-appearance: none; appearance: none; padding-right: 38px; cursor: pointer; text-overflow: ellipsis; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }

.sch-meta { display: flex; align-items: center; min-height: 22px; margin: 0 2px 14px; font-size: 14px; font-weight: 600; color: var(--sch-muted); }

/* ---------- Кнопки ---------- */
.sch-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 22px; border: 1px solid transparent; border-radius: 50px; background: transparent; color: inherit; font: inherit; font-size: 15px; font-weight: 600; line-height: 1.2; white-space: nowrap; cursor: pointer; transition: background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .1s ease; }
.sch-btn:active:not(:disabled) { transform: translateY(1px); }
.sch-btn:disabled { opacity: .5; cursor: default; }
.sch-btn--sm { min-height: 38px; padding: 6px 16px; font-size: 14px; }
.sch-btn--primary { background: var(--sch-blue); border-color: var(--sch-blue); color: #fff; }
.sch-btn--primary:hover:not(:disabled) { background: var(--sch-blue-dark); border-color: var(--sch-blue-dark); box-shadow: 0 6px 16px rgba(19, 79, 169, .28); }
.sch-btn--outline { background: #fff; border-color: var(--sch-blue); color: var(--sch-blue); }
.sch-btn--outline:hover:not(:disabled) { background: var(--sch-blue-soft); }
.sch-btn--ghost { background: #fff; border-color: #cdd5e2; color: #4b5563; }
.sch-btn--ghost:hover:not(:disabled) { background: #fff6f6; border-color: #e3aaaa; color: var(--sch-red); }
.sch-btn--link { min-height: 44px; padding: 0 6px; border-radius: 10px; color: var(--sch-blue); }
.sch-btn--link:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 3px; }
.sch-btn.is-loading { color: transparent !important; pointer-events: none; }
.sch-btn.is-loading::after { content: ""; position: absolute; top: 50%; left: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border: 2px solid rgba(128, 128, 128, .35); border-top-color: var(--sch-blue); border-radius: 50%; animation: sch-spin .7s linear infinite; }
.sch-btn--primary.is-loading::after { border-color: rgba(255, 255, 255, .45); border-top-color: #fff; }
/* «Купить и записаться» — это ссылка на страницу курса (<a>), выглядит как обычная кнопка */
a.sch-btn, a.sch-btn:hover, a.sch-btn:focus { text-decoration: none; }
a.sch-btn--primary, a.sch-btn--primary:hover, a.sch-btn--primary:focus { color: #fff; }

.sch-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border: 1px solid #d3dae6; border-radius: 50%; background: #fff; color: var(--sch-blue); cursor: pointer; transition: background .15s ease, border-color .15s ease; }
.sch-icon-btn:hover { background: var(--sch-blue-soft); border-color: var(--sch-blue); }

/* ---------- Загрузка / пустое состояние / ошибка ---------- */
.sch-loading, .sch-empty { text-align: center; color: var(--sch-muted); }
.sch-loading { padding: 48px 16px; }
.sch-loading p { margin: 0; font-size: 15px; }
.sch-spinner { width: 30px; height: 30px; margin: 0 auto 12px; border: 3px solid #dfe6f2; border-top-color: var(--sch-blue); border-radius: 50%; animation: sch-spin .8s linear infinite; }
.sch-empty { padding: 44px 20px; background: #fff; border: 1px dashed #cdd5e2; border-radius: 16px; }
.sch-empty p { margin: 0 0 6px; font-size: 17px; font-weight: 600; color: var(--sch-text); }
.sch-empty p.sch-empty-hint { margin-bottom: 0; font-size: 14.5px; font-weight: 400; color: var(--sch-muted); }
.sch-empty .sch-btn { margin-top: 16px; }
.sch-empty--error p { color: var(--sch-red); }

/* ---------- Вид «Список» ---------- */
.sch-day { margin: 0 0 26px; }
.sch-day-title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 10px; font-size: 18px; font-weight: 700; line-height: 1.25; }
.sch-rel { padding: 3px 10px; border-radius: 50px; background: var(--sch-blue); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .05em; line-height: 1.4; text-transform: uppercase; }

.sch-lessons { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.sch-lesson { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; grid-template-areas: "time body action"; align-items: center; gap: 6px 18px; padding: 14px 18px 14px 16px; background: #fff; border: 1px solid var(--sch-border); border-left: 4px solid var(--c, var(--sch-blue)); border-radius: 14px; box-shadow: 0 1px 2px rgba(20, 35, 70, .04); transition: box-shadow .2s ease, border-color .2s ease; }
.sch-lesson:hover { box-shadow: var(--sch-shadow); }
.sch-lesson.is-registered { background: var(--sch-green-soft); border-color: #cfe9d8; border-left-color: var(--c, var(--sch-blue)); }
.sch-lesson-time { grid-area: time; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; min-width: 0; }
.sch-time { font-size: 21px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sch-hour { max-width: 100%; padding: 2px 8px; border-radius: 6px; background: #eef1f6; color: var(--sch-muted); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.sch-lesson.is-registered .sch-hour { background: #e1f1e7; }
.sch-lesson-body { grid-area: body; min-width: 0; }
.sch-lesson-course { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 3px; color: var(--c, var(--sch-blue)); font-size: 13px; font-weight: 700; letter-spacing: .03em; line-height: 1.3; text-transform: uppercase; }
.sch-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 50px; background: #dff1e6; color: var(--sch-green); font-size: 12px; font-weight: 700; letter-spacing: 0; line-height: 1.4; text-transform: none; }
.sch-lesson-title { font-size: 17px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.sch-lesson-desc { margin-top: 4px; color: #4b5563; font-size: 14px; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.sch-lesson-desc.is-expanded { display: block; -webkit-line-clamp: unset; line-clamp: unset; overflow: visible; }
.sch-desc-toggle { margin: 2px 0 0; padding: 2px 0; border: 0; background: none; color: var(--sch-blue); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.sch-desc-toggle:hover { text-decoration: underline; text-underline-offset: 3px; }
.sch-lesson-action { grid-area: action; display: flex; align-items: center; justify-content: flex-end; }

/* Узкая карточка: в боковой панели календаря и на телефоне — время и кнопка в первой строке, текст ниже */
.sch-lesson--compact { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "time action" "body body"; gap: 8px 12px; padding: 12px 14px 12px 14px; }
.sch-lesson--compact .sch-lesson-time { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.sch-lesson--compact .sch-time { font-size: 19px; }
.sch-lesson--compact .sch-btn { min-height: 38px; padding: 6px 16px; font-size: 14px; }

/* ---------- Вид «Календарь» ---------- */
.sch-cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.sch-cal { min-width: 0; padding: 16px; background: #fff; border: 1px solid var(--sch-border); border-radius: 16px; }
.sch-cal-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 12px; margin-bottom: 14px; }
.sch-cal-title { margin: 0; font-size: 21px; font-weight: 700; line-height: 1.2; }
.sch-cal-nav { display: flex; align-items: center; gap: 8px; }
.sch-cal-weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); padding-bottom: 8px; color: var(--sch-muted); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-align: center; text-transform: uppercase; }
.sch-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; overflow: hidden; background: var(--sch-border); border: 1px solid var(--sch-border); border-radius: 12px; }

.sch-cell { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 4px; min-width: 0; min-height: 112px; margin: 0; padding: 6px 6px 8px; border: 0; border-radius: 0; background: #fff; color: inherit; font: inherit; text-align: left; }
button.sch-cell { cursor: pointer; transition: background .15s ease; }
button.sch-cell:hover { background: #f3f7ff; }
.sch-cell.is-other { background: #fafbfd; color: #b6bdc9; }
.sch-cell-num { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 26px; height: 26px; border-radius: 50%; font-size: 13px; font-weight: 600; line-height: 1; }
.sch-cell.is-today .sch-cell-num { background: var(--sch-blue); color: #fff; }
.sch-cell.is-selected { z-index: 1; outline: 2px solid var(--sch-blue); outline-offset: -2px; background: var(--sch-blue-soft); }
.sch-page .sch-cell:focus-visible { z-index: 2; outline-offset: -2px; }

.sch-chips { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sch-chip { display: flex; align-items: center; gap: 5px; min-width: 0; padding: 3px 6px; border-left: 3px solid var(--c, var(--sch-blue)); border-radius: 6px; background: rgba(var(--c-rgb, 19, 79, 169), .11); color: var(--sch-text); font-size: 11.5px; line-height: 1.25; }
.sch-chip-time { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; }
.sch-chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sch-chip.is-booked::after { content: "\2713"; flex: none; margin-left: auto; color: var(--sch-green); font-weight: 800; }
/* В узкой ячейке название курса превращается в «Ак…» и ничего не говорит — оставляем время и цвет (название — во всплывающей подсказке, в легенде и в панели дня) */
.sch-cell { container-type: inline-size; }
@container (max-width: 110px) { .sch-chip-name { display: none; } }
.sch-more { padding-left: 4px; color: var(--sch-muted); font-size: 11.5px; font-weight: 700; }

.sch-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; font-size: 13.5px; color: #4b5563; }
.sch-legend-item { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.sch-legend-item i { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }

.sch-day-panel { position: sticky; top: 16px; padding: 16px; background: #fff; border: 1px solid var(--sch-border); border-radius: 16px; scroll-margin-top: 12px; }
.sch-panel-title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 12px; font-size: 17px; font-weight: 700; line-height: 1.25; }
.sch-panel-hint { margin: 0; padding: 26px 8px; color: var(--sch-muted); font-size: 14.5px; text-align: center; }
.sch-panel-hint svg { display: block; width: 34px; height: 34px; margin: 0 auto 10px; color: #b4bfd3; }

/* ---------- Уведомления ---------- */
.sch-toasts { position: fixed; left: 50%; bottom: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); transform: translateX(-50%); pointer-events: none; }
.sch-toast { padding: 12px 16px; border-radius: 12px; color: #fff; font-family: 'Gilroy', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; font-size: 14.5px; font-weight: 500; line-height: 1.35; box-shadow: 0 8px 24px rgba(0, 0, 0, .22); pointer-events: auto; animation: sch-toast-in .22s ease-out; }
.sch-toast--success { background: var(--sch-green, #15803d); }
.sch-toast--error { background: var(--sch-red, #b91c1c); }
.sch-toast.is-leaving { opacity: 0; transform: translateY(8px); transition: opacity .25s ease, transform .25s ease; }

@keyframes sch-spin { to { transform: rotate(360deg); } }
@keyframes sch-toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Планшет ---------- */
@media (max-width: 1000px) {
    .sch-cal-layout { grid-template-columns: minmax(0, 1fr); }
    .sch-day-panel { position: static; }
}

/* ---------- Телефон ---------- */
@media (max-width: 720px) {
    /* Календарь: вместо подписей — цветные точки, подробности — в панели под сеткой */
    .sch-cal { padding: 12px 10px; }
    .sch-cell { align-items: center; min-height: 60px; padding: 5px 2px 6px; }
    .sch-chips { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px; max-width: 100%; }
    .sch-chip { width: 8px; height: 8px; padding: 0; border: 0; border-radius: 50%; background: var(--c, var(--sch-blue)); }
    .sch-chip > * { display: none; }
    .sch-chip.is-booked::after { display: none; }
    .sch-more { padding: 0; font-size: 10px; line-height: 8px; }
    .sch-cell.has-booked .sch-cell-num { box-shadow: 0 0 0 2px var(--sch-green); }
}

@media (max-width: 640px) {
    .sch-container { padding: 20px 16px 40px; }
    .sch-title { font-size: 26px; }
    .sch-head { margin-bottom: 14px; }
    .sch-seg--view { width: 100%; }
    .sch-seg--view .sch-seg-btn { flex: 1 1 0; }

    .sch-filters { padding: 14px; }
    .sch-fields { gap: 12px; }
    .sch-field { flex: 1 1 100%; }
    .sch-field--range { flex: 1 1 calc(50% - 6px); width: auto; }
    .sch-field--day { width: auto; min-width: 0; }
    .sch-field--mode .sch-seg { display: flex; width: 100%; }
    .sch-field--mode .sch-seg-btn { flex: 1 1 0; }
    /* Подпись «Дата» над переключателем убираем с экрана (для скринридеров остаётся) — экономим высоту */
    .sch-field--mode .sch-label { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
    .sch-input { font-size: 16px; }   /* 16px — иначе iOS приближает страницу при вводе */
    /* «Сбросить» — в одной строке с выбором курса */
    .sch-field--course { flex: 1 1 0; width: auto; min-width: 0; }
    .sch-field--reset { flex: 0 0 auto; }
    .sch-field--reset .sch-btn { min-height: 44px; padding: 0 4px; }

    .sch-day-title { font-size: 17px; }
    .sch-lesson { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "time action" "body body"; gap: 8px 12px; padding: 12px 14px; }
    .sch-lesson-time { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
    .sch-time { font-size: 19px; }
    .sch-lesson .sch-btn { min-height: 38px; padding: 6px 16px; font-size: 14px; }

    .sch-cal-title { font-size: 19px; }
    .sch-toasts { bottom: 16px; }
}

@media (max-width: 380px) {
    .sch-lesson-action .sch-btn { white-space: normal; text-align: center; padding: 6px 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .sch-page *, .sch-page *::before, .sch-page *::after, .sch-toast { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
