/* ============================================================
   students-workspace.css — двухколоночный workspace раздела «Ученики»
   Активен когда секция data-section-content="students" видна.
   ============================================================ */

/* Корневой контейнер занимает всю высоту t-content */
.sw-page {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: calc(100vh - 56px);     /* минус глобальная шапка */
    background: var(--bg);
    color: var(--text);
}

/* ===== Header band ===== */
.sw-headband {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 16px 28px 14px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
}
.sw-title {
    margin: 0;
    font-size: 22px; font-weight: 600; letter-spacing: -0.01em;
    color: var(--text);
    /* Фикс ширины — чтобы при переключении сегмента «Ученики» / «Группы» layout не дёргался.
       Подобрано так, чтобы вместить «Мои ученики» с минимальным запасом справа. */
    min-width: 150px;
}
.sw-segment {
    display: inline-flex;
    padding: 3px;
    background: var(--bg-soft);
    border-radius: 10px;
    border: 1px solid var(--border);
}
.sw-seg-btn {
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-size: 12.5px; font-weight: 600;
    padding: 5px 12px;
    border-radius: 7px;
    cursor: pointer;
    font-family: inherit;
    transition: background .12s, color .12s, box-shadow .12s;
}
.sw-seg-btn.is-active {
    background: var(--bg-card);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(60,50,40,.04), 0 1px 1px rgba(60,50,40,.03);
}
.sw-metrics {
    display: flex;
    align-items: center;
    gap: 22px;
    margin-left: 8px;
    font-variant-numeric: tabular-nums;
}
.sw-metric {
    display: flex; flex-direction: column; gap: 2px;
    animation: sw-metric-in .28s cubic-bezier(.34,1.56,.64,1) both;
}
.sw-metric:nth-child(1) { animation-delay: 0ms; }
.sw-metric:nth-child(2) { animation-delay: 50ms; }
.sw-metric:nth-child(3) { animation-delay: 100ms; }
@keyframes sw-metric-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.sw-metric-l {
    font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.07em;
    color: var(--text-dim);
}
.sw-metric-v {
    font-size: 18px; font-weight: 700; line-height: 1.1;
    color: var(--text);
    /* «Тиканье» цифры при смене значения внутри одного сегмента */
    animation: sw-metric-tick .35s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes sw-metric-tick {
    0%   { transform: translateY(0); opacity: 1; }
    35%  { transform: translateY(-3px); opacity: 0.6; }
    100% { transform: translateY(0); opacity: 1; }
}
.sw-metric-v.is-rose  { color: var(--red); }
.sw-metric-v.is-amber { color: var(--amber); }
.sw-headband-spacer { flex: 1; }
#sw-archive-btn.is-active {
    background: var(--brand-soft);
    color: var(--brand-ink);
    border-color: var(--brand-soft);
}

/* Кнопка смены сегмента (Добавить ученика / Создать группу) — фикс ширины */
#sw-add-btn {
    /* Ширина закреплена на размер большего из двух текстов «+ Добавить ученика» */
    min-width: 178px;
    justify-content: center;
}
#sw-add-label {
    display: inline-block;
    transition: opacity .12s ease;
}
#sw-add-label.sw-label-fade { opacity: 0; }

/* ===== Two-column workspace ===== */
.sw-grid {
    display: grid;
    grid-template-columns: 440px 1fr;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ===== List column ===== */
.sw-list-col {
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: opacity .11s ease, transform .14s ease;
}
.sw-list-col.sw-seg-leave,
.sw-preview-col.sw-seg-leave {
    opacity: 0;
    transform: translateY(-3px);
}
.sw-list-col.sw-seg-enter,
.sw-preview-col.sw-seg-enter {
    animation: sw-seg-in .24s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes sw-seg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.sw-list-head {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-bottom: 1px solid var(--border);
}

.sw-search {
    position: relative;
    width: 100%;
}
.sw-search-ico {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    display: flex;
    pointer-events: none;
}
.sw-search input {
    all: unset;
    box-sizing: border-box;
    width: 100%;
    height: 34px;
    /* справа оставляем место под крестик-очистку (28px) */
    padding: 0 32px 0 32px;
    background: var(--bg-soft);
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text);
    font-family: inherit;
    transition: background .12s, border-color .12s;
}
.sw-search input:focus {
    background: var(--bg-card);
    border-color: var(--brand);
}
.sw-search input::placeholder { color: var(--text-dim); }

/* Крестик «очистить поиск» — появляется только когда в инпуте есть текст. */
.sw-search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px; height: 22px;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent;
    border: none; border-radius: 50%;
    color: var(--text-dim);
    cursor: pointer;
    font-family: inherit;
    transition: background .12s, color .12s;
}
.sw-search-clear:hover { background: rgba(0,0,0,0.06); color: var(--text); }
.sw-search-clear[hidden] { display: none !important; }

.sw-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.sw-pill {
    background: var(--bg-soft);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    font-size: 11.5px; font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    transition: all .12s;
}
.sw-pill:hover { color: var(--text); }
.sw-pill.is-active {
    background: var(--brand-soft);
    color: var(--brand-ink);
    border-color: transparent;
}
.sw-pill.is-rose {
    background: var(--red-bg);
    color: var(--red-ink, #8e3a4a);
    border-color: transparent;
}
.sw-pill.is-amber {
    background: var(--amber-bg);
    color: var(--amber-ink, #7A5D14);
    border-color: transparent;
}

/* List body */
.sw-list {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.sw-list-empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
}

.sw-row {
    display: block;
    width: 100%;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    text-align: left;
    border-bottom: 1px solid var(--border);
    position: relative;
    font-family: inherit;
    transition: background .12s;
    animation: sw-row-in .22s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes sw-row-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
/* Stagger — каждая последующая карточка появляется чуть позже,
   но не более 8 шт чтобы не было «волны» при больших списках */
.sw-row:nth-child(1) { animation-delay: 0ms; }
.sw-row:nth-child(2) { animation-delay: 22ms; }
.sw-row:nth-child(3) { animation-delay: 44ms; }
.sw-row:nth-child(4) { animation-delay: 66ms; }
.sw-row:nth-child(5) { animation-delay: 88ms; }
.sw-row:nth-child(6) { animation-delay: 110ms; }
.sw-row:nth-child(7) { animation-delay: 132ms; }
.sw-row:nth-child(8) { animation-delay: 154ms; }
.sw-row:nth-child(n+9) { animation-delay: 176ms; }
.sw-row:hover { background: var(--bg-soft); }
.sw-row.is-active {
    background: var(--brand-soft);
}
.sw-row.is-active .sw-row-name { color: var(--brand-ink); }

.sw-row-marker {
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--text-faint);
}
.sw-row-inner {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 10px 14px 10px 16px;
}
.sw-row-main { min-width: 0; }
.sw-row-line1 {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    white-space: nowrap;
}
.sw-row-name {
    font-size: 13px; font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
}
.sw-row-subj {
    font-size: 10px; font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
}
.sw-row-line2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    font-size: 11px;
    color: var(--text-dim);
}
.sw-row-bal { font-variant-numeric: tabular-nums; font-weight: 600; }
.sw-row-bal.is-debt { color: var(--red); }
.sw-row-bal.is-ok   { color: var(--text-secondary); }
.sw-row-bal.is-zero { color: var(--text-dim); font-weight: 400; }
.sw-row-dot {
    width: 2px; height: 2px; border-radius: 999px;
    background: var(--text-faint);
}
.sw-row-last { color: var(--text-dim); }
.sw-state-dot {
    width: 8px; height: 8px;
    border-radius: 999px;
    display: inline-block;
}

/* Avatars */
.sw-avatar {
    width: 32px; height: 32px;
    border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}
.sw-av-lavender { background: var(--lavender-soft); color: var(--lavender-ink); }
.sw-av-emerald  { background: var(--green-bg);      color: var(--green-ink, #2E6849); }
.sw-av-amber    { background: var(--amber-bg);      color: var(--amber-ink, #7A5D14); }
.sw-av-coral    { background: var(--coral-bg);      color: var(--coral-ink, #8C3F25); }
.sw-avatar-mini {
    width: 22px; height: 22px;
    font-size: 10px;
    border: 1.5px solid var(--bg-card);
    margin-left: -5px;
}
.sw-avatar-mini:first-child { margin-left: 0; }

/* Group row right block (stack of avatars + debt) */
.sw-row-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}
.sw-row-stack {
    display: flex;
}
.sw-row-debt {
    font-size: 10.5px; font-weight: 600;
    color: var(--red);
    font-variant-numeric: tabular-nums;
}
.sw-group-ico {
    width: 36px; height: 36px;
    border-radius: 9px;
    background: var(--lavender-soft);
    color: var(--lavender-ink);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

/* ===== Preview column ===== */
.sw-preview-col {
    overflow-y: auto;
    background: var(--bg);
    padding: 24px 28px;
    min-width: 0;
    transition: opacity .11s ease, transform .14s ease;
}
.sw-preview-empty {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-dim);
}
.sw-preview-inner {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Анимация появления карточек в preview при выборе другой карточки в списке.
   Каскадом — каждая следующая чуть позже, как лестница. */
.sw-preview-inner > .sw-card,
.sw-preview-inner > .sw-bigstats {
    animation: sw-pv-in .26s cubic-bezier(.34,1.56,.64,1) both;
}
.sw-preview-inner > *:nth-child(1) { animation-delay: 0ms; }
.sw-preview-inner > *:nth-child(2) { animation-delay: 50ms; }
.sw-preview-inner > *:nth-child(3) { animation-delay: 100ms; }
.sw-preview-inner > *:nth-child(4) { animation-delay: 140ms; }
.sw-preview-inner > *:nth-child(5) { animation-delay: 180ms; }
.sw-preview-inner > *:nth-child(n+6) { animation-delay: 220ms; }
@keyframes sw-pv-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
/* Внутри .sw-bigstats — отдельные плитки тоже с микро-задержкой */
.sw-preview-inner .sw-bigstat {
    animation: sw-pv-stat-in .26s cubic-bezier(.34,1.56,.64,1) both;
}
.sw-preview-inner .sw-bigstat:nth-child(1) { animation-delay: 60ms; }
.sw-preview-inner .sw-bigstat:nth-child(2) { animation-delay: 110ms; }
.sw-preview-inner .sw-bigstat:nth-child(3) { animation-delay: 160ms; }
@keyframes sw-pv-stat-in {
    from { opacity: 0; transform: translateY(6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.sw-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
}
.sw-card-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
}
.sw-card-meta {
    font-size: 11.5px;
    color: var(--text-dim);
}

/* Hero */
.sw-pv-hero {
    padding: 20px 22px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
}
.sw-pv-hero-main { flex: 1; min-width: 0; }
.sw-pv-hero-row {
    display: flex; align-items: center; gap: 10px;
    flex-wrap: wrap;
}
.sw-pv-hero-name {
    margin: 0;
    font-size: 22px; font-weight: 600; letter-spacing: -0.01em;
    color: var(--text);
}
.sw-pv-hero-status {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11.5px; font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
}
.sw-pv-hero-dot {
    width: 6px; height: 6px; border-radius: 999px;
}
.sw-pv-hero-chips {
    display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap;
}
.sw-pv-hero-note {
    font-size: 12px; color: var(--text-dim);
    margin-top: 10px;
}
.sw-pv-hero-act {
    display: flex; flex-direction: column; gap: 8px;
    flex-shrink: 0;
}

.sw-group-hero-ico {
    width: 56px; height: 56px;
    border-radius: 12px;
    background: var(--lavender-soft);
    color: var(--lavender-ink);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sw-group-hero-ico svg { width: 24px; height: 24px; }

/* BigStats */
.sw-bigstats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}
.sw-bigstat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
}
.sw-bigstat-v {
    font-size: 20px; font-weight: 700;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    margin-top: 6px;
}
.sw-bigstat.is-rose {
    background: var(--red-bg);
}
.sw-bigstat.is-rose .sw-bigstat-v { color: var(--red); }
.sw-bigstat.is-lav {
    background: var(--lavender-soft);
}
.sw-bigstat.is-lav .sw-bigstat-v { color: var(--lavender-ink); }

/* Actions */
.sw-actions {
    display: flex; gap: 8px; flex-wrap: wrap;
}

/* Lessons table */
.sw-lessons { display: flex; flex-direction: column; }
.sw-lesson-row {
    display: grid;
    grid-template-columns: 80px 60px 1fr auto;
    align-items: center;
    padding: 10px 0;
    font-size: 13px;
}
.sw-lesson-row.has-border { border-top: 1px solid var(--border); }
.sw-l-date { color: var(--text-secondary); font-weight: 500; }
.sw-l-time { color: var(--text-dim); }
.sw-l-topic { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Прижимаем pill статуса к правому краю строки — чтобы он был на одной
   вертикали с «N всего» в шапке карточки. Применяется и к ученикам,
   и к группам. */
.sw-lesson-row > .lesson-pill { justify-self: end; }

/* Group lesson row variant — 5 колонок (с «N/M были») */
.sw-glesson { grid-template-columns: 80px 60px 1fr 80px auto; }
.sw-l-attended { font-size: 11.5px; color: var(--text-dim); }

/* Status pill */
.lesson-pill {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11.5px; font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    justify-self: start;
}
.lesson-pill-dot { width: 6px; height: 6px; border-radius: 999px; }

.sw-pv-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
}

/* Composition (group preview) */
.sw-comp-head {
    display: grid;
    grid-template-columns: 1fr 80px 100px 20px;
    padding: 0 4px 8px;
    color: var(--text-dim);
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.07em; text-transform: uppercase;
    border-bottom: 1px solid var(--border);
}
.sw-comp-head .ta-r { text-align: right; }
.sw-comp-row {
    display: grid;
    grid-template-columns: 1fr 80px 100px 20px;
    align-items: center;
    padding: 10px 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background .1s;
    border-radius: 6px;
}
.sw-comp-row:hover { background: var(--bg-soft); }
.sw-comp-row.has-border { border-top: 1px solid var(--border); }
.sw-comp-row .ta-r { text-align: right; }
.sw-comp-name {
    display: flex; align-items: center; gap: 10px;
    min-width: 0;
}
.sw-comp-name span {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--text); font-weight: 500;
}
.sw-comp-bal { font-weight: 600; }
.sw-comp-bal.is-debt { color: var(--red); }
.sw-comp-bal.is-ok   { color: var(--green); }
.sw-comp-bal.is-zero { color: var(--text-faint); }
.sw-comp-chev {
    color: var(--text-faint);
    justify-self: end;
    display: flex;
}

.tabular-nums { font-variant-numeric: tabular-nums; }

/* ===== Модалка «Изменить цену» ===== */
.pchg-overlay {
    position: fixed; inset: 0;
    background: rgba(60, 50, 40, 0.42);
    backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    z-index: 1100;
    animation: pchg-fade .14s ease-out;
}
.pchg-overlay[hidden] { display: none !important; }
@keyframes pchg-fade { from { opacity: 0; } to { opacity: 1; } }
.pchg-card {
    width: 420px; max-width: 100%;
    background: var(--bg-card);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(60,50,40,.15), 0 6px 14px rgba(60,50,40,.08);
    overflow: hidden;
    animation: pchg-pop .18s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes pchg-pop {
    from { opacity: 0; transform: translateY(-10px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.pchg-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
}
.pchg-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--text); }
.pchg-close {
    background: transparent; border: none;
    width: 30px; height: 30px;
    border-radius: 6px;
    color: var(--text-dim); font-size: 22px; line-height: 1;
    cursor: pointer; font-family: inherit;
}
.pchg-close:hover { background: var(--bg-soft); color: var(--text); }
.pchg-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.pchg-sub { font-size: 13px; color: var(--text-dim); }
.pchg-field { display: flex; flex-direction: column; gap: 6px; }
.pchg-l { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.pchg-input {
    display: flex; align-items: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    padding: 0 12px;
    height: 40px;
    transition: border-color .12s;
}
.pchg-input:focus-within { border-color: var(--brand); }
.pchg-input input {
    all: unset;
    flex: 1;
    font-size: 16px; font-weight: 600;
    color: var(--text); font-family: inherit;
    font-variant-numeric: tabular-nums;
}
.pchg-cur { color: var(--text-dim); font-size: 14px; }
.pchg-hint { font-size: 11.5px; color: var(--text-dim); line-height: 1.45; }
.pchg-foot {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 12px 20px;
    background: var(--bg-card-2);
    border-top: 1px solid var(--border);
}

/* ===== Адаптация ≤1024px ===== */
@media (max-width: 1024px) {
    .sw-grid {
        grid-template-columns: 1fr;
    }
    .sw-list-col {
        border-right: none;
        max-height: 50vh;
        border-bottom: 1px solid var(--border);
    }
    .sw-headband {
        gap: 12px;
        padding: 12px 16px;
    }
    .sw-headband .sw-title {
        flex: 1 1 auto;
    }
    .sw-metrics { display: none; }
    .sw-bigstats { grid-template-columns: 1fr; }
    .sw-lesson-row,
    .sw-glesson {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}
@media (max-width: 720px) {
    .sw-comp-head, .sw-comp-row {
        grid-template-columns: 1fr 70px 90px 16px;
    }
}
