/* ==========================================================================
   Админка: шапка, расписание, карточки учеников.
   ========================================================================== */

/* --- Шапка --------------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(10, 8, 12, .86);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
}

.brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.brand:hover { color: var(--text); }

.brand-mark {
    display: grid; place-items: center;
    width: 38px; height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--wine-2), var(--wine));
    box-shadow: 0 4px 14px rgba(143, 28, 66, .4), inset 0 1px 0 rgba(255, 255, 255, .18);
    font: 600 18px/1 var(--font-display);
    color: #fff;
    flex: none;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-name { font-weight: 600; font-size: 15px; white-space: nowrap; }
.brand-sub  { font-size: 11.5px; color: var(--faint); letter-spacing: .06em; text-transform: uppercase; }

.inline-form { display: inline; }

.page { padding: 26px 0 60px; }
.footer { padding: 24px 0 32px; border-top: 1px solid var(--line); }

/* --- Заголовок страницы -------------------------------------------------- */
.page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
    margin-bottom: 22px;
}

.page-title { font-size: 26px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.page-sub { color: var(--muted); font-size: 14.5px; margin: 4px 0 0; }

/* --- Сетка недели -------------------------------------------------------- */
.week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
}

.day {
    display: flex;
    flex-direction: column;
    min-height: 200px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--ink-2), rgba(18, 14, 21, .55));
    overflow: hidden;
}

.day-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
}

.day-name { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.day-body { padding: 8px; display: flex; flex-direction: column; gap: 6px; flex: 1; }

.day-empty { padding: 14px 8px; text-align: center; color: var(--faint); font-size: 12.5px; }

/* --- Окно / занятие ------------------------------------------------------ */
.slot {
    display: block;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, .28);
    color: var(--text-2);
    font-size: 13px;
    transition: border-color .15s, background .15s, transform .1s;
}

.slot:hover { border-color: var(--line-2); background: rgba(255, 255, 255, .04); color: var(--text); }
.slot:active { transform: translateY(1px); }

.slot-time { font-weight: 600; font-size: 13px; color: var(--text); letter-spacing: .01em; }
.slot-name { display: block; margin-top: 2px; font-size: 13px; }
.slot-meta { display: block; margin-top: 3px; font-size: 11.5px; color: var(--faint); }

/* Свободное окно — пунктир, приглушённое */
.slot.is-free {
    border-style: dashed;
    border-color: rgba(255, 255, 255, .18);
    background: transparent;
    color: var(--faint);
}
.slot.is-free:hover { border-color: var(--pink); color: var(--pink-2); background: var(--pink-soft); }

/* Занятое окно — винная полоса слева */
.slot.is-busy { border-left: 3px solid var(--wine-2); }

.slot.is-done      { border-left-color: var(--ok);   background: rgba(86, 211, 160, .08); }
.slot.is-cancelled { border-left-color: var(--danger); opacity: .6; }
.slot.is-cancelled .slot-name { text-decoration: line-through; }
.slot.is-moved     { border-left-color: var(--warn); }

@media (max-width: 1000px) {
    .week { grid-template-columns: 1fr; }
    .day { min-height: 0; }
    .day-head { padding: 12px 14px; }
    .day-name { font-size: 13px; }
}

/* --- Список (ученики, заявки) -------------------------------------------- */
.list { display: grid; gap: 10px; }

.list-item {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--ink-3), var(--ink-2));
    color: var(--text);
    transition: border-color .15s, transform .1s;
}

.list-item:hover { border-color: var(--pink-soft); color: var(--text); }
.list-item:active { transform: translateY(1px); }
.list-item.is-archived { opacity: .5; }

.avatar {
    display: grid; place-items: center;
    width: 42px; height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--wine-2), var(--wine));
    color: #fff;
    font-weight: 600;
    font-size: 16px;
    flex: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2);
}

.list-name { font-weight: 600; font-size: 15.5px; }
.list-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* --- Формы в две колонки ------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

.form-actions {
    display: flex; gap: 10px; flex-wrap: wrap;
    margin-top: 20px; padding-top: 18px;
    border-top: 1px solid var(--line);
}

/* Архив и удаление — справа, подальше от «Сохранить» */
.form-actions-end { display: flex; gap: 10px; flex-wrap: wrap; margin-left: auto; }

/* --- Модальное окно ------------------------------------------------------ */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 60;
    background: rgba(4, 3, 6, .78);
    backdrop-filter: blur(6px);
    display: grid; place-items: center;
    padding: 16px;
    overflow-y: auto;
}

.modal {
    width: min(560px, 100%);
    background: linear-gradient(180deg, var(--ink-3), var(--ink-2));
    border: 1px solid var(--line-2);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
    margin: auto;
}

.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.modal-title { font-size: 19px; font-weight: 600; margin: 0; }
.modal-sub { color: var(--muted); font-size: 13.5px; margin-top: 3px; }

.close {
    background: none; border: none; color: var(--muted);
    font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.close:hover { color: var(--text); }

/* --- Поля формы в строку (шаблон недели) -------------------------------- */
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0 16px;
    align-items: end;
}

/* --- Пары «название — значение» (заявки) --------------------------------- */
.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 9px 16px; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* --- Вход ---------------------------------------------------------------- */
.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    position: relative;
    width: min(400px, 100%);
    padding: 34px 30px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line-2);
    background: linear-gradient(180deg, var(--ink-3), var(--ink-2));
    box-shadow: var(--shadow);
    overflow: hidden;
}

.login-title { font: 600 27px/1.2 var(--font-display); text-align: center; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 26px; }

[x-cloak] { display: none !important; }

/* Раскрывающаяся панель под окном в шаблоне недели */
.lesson-panel {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--line-2);
}

/* ==========================================================================
   Иконки в шапке
   ========================================================================== */
.topbar-actions { display: flex; align-items: center; gap: 4px; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: none;
    color: var(--muted);
    font: 500 14px/1 var(--font);
    cursor: pointer;
    transition: color .15s, background .15s;
}

.icon-btn svg { width: 19px; height: 19px; flex: none; }
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.icon-btn.is-active { color: var(--pink); background: var(--pink-soft); }

/* Подписи только там, где есть место */
@media (max-width: 900px) {
    .icon-btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .icon-btn { padding: 8px; }
}

/* ==========================================================================
   Телефон
   ========================================================================== */
@media (max-width: 760px) {
    .topbar-inner   { padding: 10px 0; gap: 8px; }
    .topbar-actions { gap: 0; }
    .brand-mark { width: 34px; height: 34px; border-radius: 10px; font-size: 16px; }
    .brand-name { font-size: 14px; }
    .brand-sub  { display: none; }
    .icon-btn   { min-height: 44px; min-width: 44px; justify-content: center; }

    /* Низ страницы не прячется под системный индикатор iPhone */
    .page { padding: 18px 0 calc(24px + env(safe-area-inset-bottom, 0px)); }
    .footer { display: none; }

    /* Плотнее и крупнее там, где пальцем целятся */
    .page-head { margin-bottom: 16px; gap: 12px; }
    .page-title { font-size: 22px; }
    .card { padding: 16px; }

    .list-item { padding: 13px 14px; }
    .avatar { width: 38px; height: 38px; font-size: 15px; }

    .modal { padding: 18px; border-radius: var(--radius); }
}

/* Пять иконок и имя в одну строку не влезают — оставляем знак «A» */
@media (max-width: 480px) {
    .brand-text { display: none; }
}

/* ==========================================================================
   Новые заявки: счётчик на конверте в шапке
   ========================================================================== */
.icon-wrap { position: relative; display: inline-flex; }

.icon-btn.has-news { color: var(--pink-2); }

.icon-badge {
    position: absolute;
    top: -7px;
    right: -9px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--pink), #e8508f);
    color: #2a0714;
    font: 700 10.5px/17px var(--font);
    text-align: center;
    /* тёмная обводка отделяет кружок от линий конверта */
    box-shadow: 0 0 0 2px var(--ink);
}

/* Расходящееся кольцо — заметно, но не мигает */
.icon-badge::after {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    border: 2px solid var(--pink);
    animation: badge-ring 2.2s ease-out infinite;
    pointer-events: none;
}

@keyframes badge-ring {
    0%   { transform: scale(1);   opacity: .85; }
    100% { transform: scale(1.9); opacity: 0; }
}

/* Общее правило про «уменьшить движение» висит на *, а оно не ловит
   псевдоэлементы — выключаем кольцо явно. */
@media (prefers-reduced-motion: reduce) {
    .icon-badge::after { display: none; }
}

/* Разделитель «В архиве» в списке учеников */
.list-divider {
    margin: 14px 2px 2px;
    font-size: 12.5px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .07em;
}

/* ==========================================================================
   Лента дней
   ========================================================================== */
.feed { max-width: 760px; margin-inline: auto; }

.feed-more { display: flex; justify-content: center; padding: 2px 0 16px; }
.feed-more:last-child { padding: 12px 0 4px; }

.feed-day {
    padding-bottom: 26px;
    scroll-margin-top: var(--topbar-h, 0px);
}

/* Заголовок дня прилипает под шапкой, пока листаешь его окна */
.feed-day-head {
    position: sticky;
    top: var(--topbar-h, 0px);
    z-index: 5;
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 2px 12px; flex-wrap: wrap;
    margin: 0 -8px 10px;
    padding: 10px 8px 8px;
    background: rgba(10, 8, 12, .94);
    border-bottom: 1px solid var(--line);
}

.feed-day-title { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: .01em; }
.feed-day-rel { color: var(--pink); }
.feed-day-rel::after { content: " · "; color: var(--faint); font-weight: 400; }
.feed-day-meta { font-size: 12.5px; color: var(--faint); }

.feed-day.is-today .feed-day-head { border-bottom-color: rgba(255, 111, 174, .45); }
.feed-day.is-past .feed-day-title,
.feed-day.is-past .fslot-row { opacity: .6; }

.feed-slots { display: grid; gap: 8px; }
.feed-empty { margin: 0; color: var(--faint); font-size: 14px; }

/* Окно в ленте: строка-кнопка, по нажатию раскрываются действия */
.fslot {
    border: 1px solid var(--line);
    border-left: 3px solid var(--mark, var(--wine-2));
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: rgba(0, 0, 0, .26);
    scroll-margin-top: calc(var(--topbar-h, 0px) + 56px);
}

.fslot:target { box-shadow: 0 0 0 2px var(--pink-soft); }
.fslot.is-free { border-style: dashed; border-left-style: solid; background: transparent; }

.fslot-row {
    display: flex; align-items: center; gap: 12px;
    width: 100%; min-height: 50px;
    padding: 10px 14px;
    background: none; border: 0;
    color: var(--text); font: inherit; text-align: left;
    cursor: pointer;
}

.fslot-row:hover { background: rgba(255, 255, 255, .03); }
.fslot-row:focus-visible { outline: 2px solid var(--pink); outline-offset: -2px; }

.fslot-time { flex: none; min-width: 96px; font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.fslot-end  { color: var(--faint); font-weight: 400; }
.fslot-main { flex: 1 1 auto; min-width: 0; }
.fslot-name { display: block; font-weight: 600; }
.fslot-meta { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fslot-free { color: var(--faint); }
.fslot.is-free .fslot-row:hover .fslot-free { color: var(--pink-2); }
.fslot.is-cancelled .fslot-name { text-decoration: line-through; color: var(--muted); }

/* Ученик не из района этого дня — мягкая пометка, не ошибка */
.fslot-away { color: var(--gold); }
.fslot-away::before {
    content: "";
    display: inline-block;
    width: 6px; height: 6px;
    margin-right: 6px;
    border-radius: 50%;
    background: currentColor;
    vertical-align: 1px;
}

.fslot-panel {
    display: grid; gap: 12px;
    padding: 12px 14px 14px;
    border-top: 1px dashed var(--line-2);
}

.fslot-contacts { display: flex; gap: 6px 18px; flex-wrap: wrap; }
.fslot-notes { display: grid; gap: 3px; }
.fslot-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* Добавить окно */
.feed-add { margin-top: 10px; }
.feed-add-bar { display: flex; gap: 8px; flex-wrap: wrap; }

.feed-add-btn {
    display: inline-flex; align-items: center;
    min-height: 40px; padding: 8px 16px;
    border: 1px dashed var(--line-2); border-radius: 999px;
    background: none; color: var(--muted);
    font: 500 14px/1 var(--font);
    cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
}
.feed-add-btn:hover { color: var(--pink-2); border-color: var(--pink); background: var(--pink-soft); }

.feed-form {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, .2);
}
.fslot-panel .feed-form { padding: 0; border: 0; background: none; }

.feed-form-grid { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 0 10px; }

@media (max-width: 620px) {
    .feed-form-grid { grid-template-columns: 1fr 1fr; }
    .feed-form-wide { grid-column: 1 / -1; }
    .fslot-time { min-width: 0; }
    .fslot-end  { display: none; }
}

/* Короткое сообщение после действия */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    z-index: 70;
    max-width: min(440px, calc(100% - 32px));
    padding: 11px 18px;
    border: 1px solid rgba(86, 211, 160, .35);
    border-radius: 999px;
    background: #0f201a;
    color: var(--text);
    font-size: 14.5px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    opacity: 0;
    transform: translate(-50%, 12px);
    pointer-events: none;
    transition: opacity .2s, transform .2s;
}

.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { border-color: rgba(255, 107, 107, .45); background: #2a1216; }
