/* ============================================================
   teacher-form.css — стили для формы add/edit ученика v2
   Использует токены из teacher.css (--bg, --surface, --indigo, etc).
   ============================================================ */

/* Overlay */
.sf2-overlay {
    position: fixed; inset: 0;
    background: rgba(60, 50, 40, 0.42);
    backdrop-filter: blur(2px);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 5vh 16px;
    z-index: 1000;
    overflow-y: auto;
    animation: sf2-fade .14s ease-out;
}
.sf2-overlay[hidden] { display: none !important; }
html.sf2-open { overflow: hidden; }

@keyframes sf2-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Card */
.sf2-card {
    width: 600px; max-width: 100%;
    max-height: 90vh;
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow-3, 0 18px 40px rgba(60,50,40,.10), 0 6px 14px rgba(60,50,40,.06));
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: sf2-pop .18s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes sf2-pop {
    from { opacity: 0; transform: translateY(-12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Head */
.sf2-head {
    padding: 18px 24px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: flex-start; gap: 12px;
}
.sf2-head-main { flex: 1; min-width: 0; }
.sf2-title { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.sf2-sub { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.sf2-close {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    font-size: 22px; line-height: 1;
    color: var(--text-dim);
    background: transparent;
    border: 1px solid transparent;
    padding: 0;
}
.sf2-close:hover { background: var(--bg-soft); color: var(--text); }

/* Body */
.sf2-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex; flex-direction: column; gap: 20px;
}

/* Footer */
.sf2-foot {
    padding: 14px 24px;
    background: var(--bg-card-2);
    border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; gap: 8px;
}
.sf2-foot-l, .sf2-foot-r { display: flex; gap: 8px; }

/* Section */
.sf2-section { display: flex; flex-direction: column; gap: 12px; }
.sf2-section-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 0;
}
.sf2-section-body { display: flex; flex-direction: column; gap: 12px; }
.sf2-section-rm {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 8px; border-radius: 6px;
    background: transparent; border: none;
    color: var(--red); font-size: 12px; font-weight: 600; font-family: inherit;
    cursor: pointer;
}
.sf2-section-rm:hover { background: var(--red-bg); }

/* Field + row */
.sf2-row { display: flex; gap: 12px; }
.sf2-field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.sf2-field-l { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.sf2-req { color: var(--red); }

/* Input */
.sf2-input {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 12px;
    height: 38px;
    transition: border-color .12s;
}
.sf2-input:focus-within { border-color: var(--brand); }
.sf2-input.sf2-input-error { border-color: var(--red); animation: sf2-shake .35s; }
@keyframes sf2-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}
.sf2-input input {
    all: unset;
    flex: 1;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--text);
    min-width: 0;
}
.sf2-input input::placeholder { color: var(--text-dim); }
.sf2-input-icon { color: var(--text-dim); display: flex; }
.sf2-input-suffix { font-size: 12px; color: var(--text-dim); }

/* Toggle Card */
.sf2-toggle {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background .12s, border-color .12s;
}
.sf2-toggle:hover { border-color: var(--border-strong); }
.sf2-toggle.is-on {
    background: var(--brand-soft);
    border-color: var(--brand);
}
.sf2-toggle-box {
    width: 18px; height: 18px;
    border: 1.5px solid var(--border-strong);
    border-radius: 5px;
    background: var(--bg-card);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    flex-shrink: 0;
    margin-top: 1px;
    transition: all .12s;
}
.sf2-toggle.is-on .sf2-toggle-box {
    background: var(--brand);
    border-color: var(--brand);
}
.sf2-toggle-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sf2-toggle-title {
    font-size: 14px; font-weight: 600;
    color: var(--text);
}
.sf2-toggle.is-on .sf2-toggle-title { color: var(--brand-ink); }
.sf2-toggle-sub { font-size: 12px; color: var(--text-dim); }

/* CustomSelect */
.sf2-select { position: relative; }
.sf2-select-trigger {
    display: flex; align-items: center; gap: 8px;
    width: 100%; height: 38px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 12px;
    font-size: 13.5px;
    color: var(--text);
    font-family: inherit;
    cursor: pointer;
    transition: border-color .12s;
}
.sf2-select.is-open .sf2-select-trigger { border-color: var(--brand); }
.sf2-select-ico { color: var(--text-dim); display: flex; }
.sf2-select-v {
    flex: 1; text-align: left;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sf2-select-v.is-placeholder { color: var(--text-dim); }
.sf2-select-caret {
    color: var(--text-dim);
    transform: rotate(90deg);
    transition: transform .15s;
    display: flex;
}
.sf2-select.is-open .sf2-select-caret { transform: rotate(-90deg); }

.sf2-status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    flex-shrink: 0;
}

/* Pop (универсальный для select / contact-type / subjects) */
.sf2-pop {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    z-index: 100;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 4px;
    max-height: 280px;
    overflow-y: auto;
    animation: sf2-pop-in .14s cubic-bezier(.34,1.56,.64,1) both;
}
/* Поле, в котором открыт попап, временно поднимаем над соседними секциями,
   чтобы абсолютные дропдауны точно перекрывали последующие поля
   (например, контакт-тип над предметами/уровнем). */
.sf2-contact:has(> .sf2-pop),
.sf2-select.is-open,
.sf2-date.is-open,
.sf2-subjects.is-open,
.sf2-price.is-open {
    position: relative;
    z-index: 90;
}
@keyframes sf2-pop-in {
    from { opacity: 0; transform: translateY(-4px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* Плавное закрытие любого попапа/календаря */
.sf2-pop.sf2-pop-leaving,
.sf2-cal.sf2-pop-leaving {
    animation: sf2-pop-out .14s ease-in both !important;
}
@keyframes sf2-pop-out {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(-4px) scale(0.98); }
}

/* Анимация блока «Родители» теперь делается inline через JS (точный scrollHeight),
   чтобы плавно сжимать без janking max-height. Сам блок — обычный.
   ВАЖНО: НЕ используем will-change: opacity, потому что это создаёт новый stacking
   context, и абсолютные дропдауны (выбор типа контакта Telegram/Phone) застревают
   внутри блока «Родители» и оказываются под полями секции «Занятия». */
.sf2-parents { will-change: height; }

/* ===== Модалка «Длительность занятия» ===== */
.sf2-dur-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: 1200;
    animation: sf2-fade .14s ease-out;
}
.sf2-dur-overlay[hidden] { display: none !important; }
.sf2-dur-card {
    width: 360px; max-width: 100%;
    max-height: 80vh;
    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;
    display: flex; flex-direction: column;
    animation: sf2-pop .18s cubic-bezier(.34,1.56,.64,1) both;
}
.sf2-dur-card.sf2-dur-leaving {
    animation: sf2-pop-out .14s ease-in both !important;
}
.sf2-dur-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.sf2-dur-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--text); }
.sf2-dur-close {
    background: transparent; border: 1px solid transparent;
    width: 28px; height: 28px;
    border-radius: 6px;
    color: var(--text-dim); font-size: 22px; line-height: 1;
    cursor: pointer; font-family: inherit;
}
.sf2-dur-close:hover { background: var(--bg-soft); color: var(--text); }
.sf2-dur-list {
    padding: 6px;
    overflow-y: auto;
    flex: 1;
    min-height: 60px;
}
.sf2-dur-list .sf2-pop-item {
    width: 100%;
    padding: 10px 12px;
    border-radius: 7px;
    border: none; background: transparent;
    color: var(--text); font-size: 13.5px;
    font-family: inherit;
    cursor: pointer;
    display: flex; align-items: center; justify-content: space-between;
    transition: background .1s;
}
.sf2-dur-list .sf2-pop-item:hover { background: var(--bg-soft); }
.sf2-dur-list .sf2-pop-item.is-active {
    background: var(--brand-soft);
    color: var(--brand-ink);
    font-weight: 600;
}
.sf2-dur-add {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    background: var(--bg-card-2);
}
.sf2-dur-add input[type="number"] {
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text);
    font-family: inherit;
}
.sf2-dur-add input[type="number"]:focus {
    outline: none; border-color: var(--brand);
}

/* ===== Анимация появления новой строки контакта / родителя ===== */
.sf2-contact.is-entering {
    animation: sf2-row-in 280ms cubic-bezier(.34, 1.4, .64, 1) both;
}
@keyframes sf2-row-in {
    from { opacity: 0; transform: translateY(-10px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.sf2-section.sf2-parent-entering {
    animation: sf2-row-in 320ms cubic-bezier(.34, 1.3, .64, 1) both;
}
.sf2-pop-item {
    display: flex; align-items: center; gap: 8px;
    width: 100%;
    padding: 9px 10px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background .1s;
}
.sf2-pop-item:hover { background: var(--bg-soft); }
.sf2-pop-item.is-active {
    background: var(--brand-soft);
    color: var(--brand-ink);
    font-weight: 600;
}
.sf2-pop-item .sf2-pop-l { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sf2-pop-ico { color: var(--text-dim); display: flex; }
.sf2-pop-item.is-active .sf2-pop-ico { color: var(--brand); }
.sf2-pop-check { color: var(--brand); display: flex; }
.sf2-pop-empty { padding: 10px; text-align: center; color: var(--text-dim); font-size: 12px; }

/* PriceField */
.sf2-price {
    display: flex; align-items: stretch;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    overflow: hidden;
    position: relative;
    transition: border-color .12s;
}
.sf2-price:focus-within { border-color: var(--brand); }
.sf2-price-l {
    display: flex; align-items: center; gap: 4px;
    flex: 1; min-width: 0;
    padding: 0 12px;
}
.sf2-price-l input {
    all: unset; flex: 1;
    font-size: 13.5px; font-family: inherit; color: var(--text);
    min-width: 0;
}
.sf2-price-cur { font-size: 12px; color: var(--text-dim); }
.sf2-price-divider { width: 1px; background: var(--border); }
.sf2-price-r {
    display: flex; align-items: center; gap: 6px;
    padding: 0 12px;
    background: var(--bg-card-2);
    border: none;
    cursor: pointer;
    font-family: inherit;
    border-radius: 0 9px 9px 0;
}
.sf2-price-pre { font-size: 11px; color: var(--text-dim); }
.sf2-price-dur { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.sf2-price-pop { right: 0; left: auto; min-width: 180px; }

/* DateField */
.sf2-date { position: relative; }
.sf2-date-trigger {
    display: flex; align-items: center; gap: 8px;
    width: 100%; height: 38px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 12px;
    font-size: 13.5px;
    color: var(--text);
    font-family: inherit;
    cursor: pointer;
    transition: border-color .12s;
}
.sf2-date.is-open .sf2-date-trigger { border-color: var(--brand); }
.sf2-date-trigger.is-placeholder .sf2-date-v { color: var(--text-dim); }
.sf2-date-ico { color: var(--text-dim); display: flex; }
.sf2-date-v { flex: 1; text-align: left; }

.sf2-cal {
    position: absolute; top: calc(100% + 6px); left: 0;
    width: 280px;
    z-index: 60;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 14px;
    animation: sf2-pop-in .14s cubic-bezier(.34,1.56,.64,1) both;
}
.sf2-cal-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
}
.sf2-cal-month { font-size: 13.5px; font-weight: 600; color: var(--text); }
.sf2-cal-nav {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: none; border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
}
.sf2-cal-nav:hover { background: var(--bg-soft); color: var(--text); }
.sf2-cal-wd {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
    margin-bottom: 4px;
}
.sf2-cal-wd span {
    font-size: 10.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-dim);
    text-align: center;
    padding: 4px 0;
}
.sf2-cal-grid {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
}
.sf2-cal-day {
    height: 32px;
    background: transparent; border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text); font-size: 13px; font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background .1s, color .1s, border-color .1s;
}
.sf2-cal-day:hover { background: var(--bg-soft); }
.sf2-cal-day.is-other { color: var(--text-faint); }
.sf2-cal-day.is-today { border-color: var(--brand); font-weight: 600; }
.sf2-cal-day.is-selected {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
    font-weight: 600;
}
.sf2-cal-foot {
    display: flex; justify-content: space-between;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.sf2-cal-link {
    background: transparent; border: none;
    color: var(--text-secondary); font-size: 12px; font-family: inherit;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
}
.sf2-cal-link:hover { background: var(--bg-soft); color: var(--text); }
.sf2-cal-link-clr { color: var(--text-dim); }

/* ContactsList */
.sf2-contacts { display: flex; flex-direction: column; gap: 8px; }
.sf2-contact {
    display: flex; align-items: stretch;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    overflow: visible;
    position: relative;
}
.sf2-contact:focus-within { border-color: var(--brand); }
.sf2-contact-type {
    display: flex; align-items: center; gap: 6px;
    min-width: 130px;
    padding: 0 12px;
    background: var(--bg-card-2);
    border: none;
    border-right: 1px solid var(--border);
    cursor: pointer;
    font-family: inherit;
    border-radius: 9px 0 0 9px;
}
.sf2-contact-type-ico { color: var(--text-dim); display: flex; }
.sf2-contact-type-l { font-size: 13px; color: var(--text); flex: 1; text-align: left; }
.sf2-contact-type-caret { color: var(--text-dim); display: flex; }
.sf2-contact-value {
    all: unset;
    flex: 1; min-width: 0;
    padding: 0 12px;
    font-size: 13.5px; font-family: inherit; color: var(--text);
}
.sf2-contact-value::placeholder { color: var(--text-dim); }
.sf2-contact-rm {
    display: flex; align-items: center; justify-content: center;
    width: 36px;
    background: transparent;
    border: none; border-left: 1px solid var(--border);
    color: var(--text-dim);
    cursor: pointer;
    font-family: inherit;
}
.sf2-contact-rm:hover { color: var(--red); background: var(--red-bg); }
.sf2-contact > .sf2-pop { left: 0; right: auto; min-width: 180px; top: calc(100% + 4px); }
.sf2-contact-add {
    align-self: flex-start;
    background: transparent; border: none;
    color: var(--brand); font-size: 13px; font-weight: 500;
    font-family: inherit;
    padding: 4px 0;
    cursor: pointer;
}
.sf2-contact-add:hover { text-decoration: underline; }

/* SubjectsPicker */
.sf2-subjects { position: relative; }
.sf2-subjects-pop {
    /* Делаем настоящий «плавающий» дропдаун — не раздвигает форму,
       перекрывает последующие поля, как и любой другой попап. */
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    max-height: 280px;
    overflow-y: auto;
    animation: sf2-pop-in .14s cubic-bezier(.34,1.56,.64,1) both;
}
.sf2-subjects-pop.sf2-pop-leaving {
    animation: sf2-pop-out .14s ease-in both !important;
}
.sf2-subjects-row {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    min-height: 38px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    cursor: text;
    transition: border-color .12s;
}
.sf2-subjects.is-open .sf2-subjects-row { border-color: var(--brand); }
.sf2-subjects-row .chip { padding: 4px 6px 4px 10px; }
.sf2-chip-rm {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px;
    background: transparent;
    border: none;
    color: currentColor; opacity: 0.7;
    cursor: pointer;
    border-radius: 50%;
    margin-left: 2px;
    font-family: inherit;
}
.sf2-chip-rm:hover { background: rgba(0,0,0,0.08); opacity: 1; }
.sf2-subjects-input {
    all: unset;
    flex: 1; min-width: 80px;
    height: 26px;
    padding: 0 4px;
    font-size: 13.5px; color: var(--text);
}
.sf2-subjects-pop { padding: 4px; }
.sf2-subjects-add {
    width: 100%;
    margin-top: 4px;
    padding: 9px 10px;
    background: var(--brand-soft);
    color: var(--brand);
    border: none; border-radius: 6px;
    font-size: 13px; font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex; align-items: center; gap: 6px;
}
.sf2-subjects-add:hover { background: var(--brand); color: #fff; }

/* Parents */
.sf2-parents { display: flex; flex-direction: column; gap: 14px; }
.sf2-add-parent { align-self: flex-start; }

/* Адаптив */
@media (max-width: 640px) {
    .sf2-card { width: 100%; }
    .sf2-head, .sf2-body, .sf2-foot { padding-left: 16px; padding-right: 16px; }
    .sf2-row { flex-direction: column; }
}
