/* psiholog.erudit23.ru — стили журнала психолога (стилистика как в «Поведении») */

:root {
    --bg: #f1f5f9;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #667eea;
    --primary-dark: #4f5fd0;
    --danger: #dc2626;
    --risk: #f97316;
    --ok: #16a34a;
    --warn: #ca8a04;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}

.hidden { display: none !important; }

/* ===== Логин ===== */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-card {
    background: #fff;
    border-radius: 14px;
    padding: 2rem;
    width: 340px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.login-title { font-size: 1.3rem; font-weight: 700; text-align: center; }
.login-subtitle { color: var(--muted); text-align: center; margin: 0.25rem 0 1.25rem; }

/* ===== Поля и кнопки ===== */
.field {
    display: block;
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 0.6rem;
    background: #fff;
}
.field--small { width: auto; display: inline-block; margin: 0 0.25rem 0.25rem 0; }
textarea.field { min-height: 70px; resize: vertical; }
.field-label { font-weight: 600; margin: 0.6rem 0 0.25rem; font-size: 13px; color: var(--muted); }

.button {
    border: none;
    border-radius: 8px;
    padding: 0.5rem 0.9rem;
    font-size: 14px;
    cursor: pointer;
    background: #e2e8f0;
    color: var(--text);
}
.button:hover { filter: brightness(0.95); }
.button--primary { background: var(--primary); color: #fff; }
.button--primary:hover { background: var(--primary-dark); }
.button--danger { background: #fee2e2; color: var(--danger); }
.button--ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.4); }
.button--small { padding: 0.35rem 0.6rem; font-size: 13px; }
.button--wide { width: 100%; margin-top: 0.5rem; }

.hint { color: var(--muted); font-size: 13px; }
.hint--error { color: var(--danger); margin-top: 0.5rem; }

/* ===== Верхняя панель и вкладки ===== */
.topbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 0.7rem 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.brand { font-size: 1.15rem; font-weight: 700; }
.userbox { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.username { font-weight: 600; }
.role-tag {
    background: rgba(255,255,255,0.2);
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    font-size: 12px;
}

.tabs {
    display: flex;
    gap: 0.25rem;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0 1rem;
    overflow-x: auto;
}
.tab {
    border: none;
    background: transparent;
    padding: 0.8rem 1rem;
    font-size: 14px;
    cursor: pointer;
    color: var(--muted);
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}
.tab.active { color: var(--primary-dark); border-bottom-color: var(--primary); font-weight: 600; }
.badge {
    background: var(--danger);
    color: #fff;
    border-radius: 999px;
    font-size: 11px;
    padding: 0.05rem 0.4rem;
    margin-left: 0.2rem;
}

.main { padding: 1rem 1.2rem; max-width: 1400px; margin: 0 auto; }
.page-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 0.8rem; }
.section-label { font-weight: 600; color: var(--muted); font-size: 13px; margin: 0.9rem 0 0.4rem; }

/* ===== Чипы классов и учеников ===== */
.class-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 0.6rem;
}
.chip {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 10px;
    padding: 0.55rem 0.7rem;
    cursor: pointer;
    font-size: 14px;
    text-align: center;
    transition: all 0.15s;
}
.chip:hover { border-color: var(--primary); }
.chip--class { font-weight: 700; }
.chip--class.active, .chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip--student { display: inline-flex; align-items: center; gap: 0.5rem; text-align: left; }
.chip--student.risk-flag { border-color: var(--risk); background: #fff7ed; }

/* Фото в чипах учеников (как в «Поведении») */
.chip-photo {
    height: 2.2rem;
    width: 2.2rem;
    border-radius: 9999px;
    object-fit: cover;
    background: #e5e7eb;
    flex-shrink: 0;
    display: block;
}
.chip-photo--placeholder { background: #e5e7eb; }

.chips-container { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* ===== Панель класса ===== */
.class-panel-head { display: flex; align-items: baseline; gap: 0.8rem; flex-wrap: wrap; }
.directions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.4rem; }
.direction-btn {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 10px;
    padding: 0.6rem 0.9rem;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-dark);
}
.direction-btn:hover { border-color: var(--primary); background: #eef2ff; }

/* Кнопки конкретного ученика под списком */
.student-actions { margin-top: 0.9rem; }
.student-actions__btns { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* Профиль карты: крупное фото слева */
.card-profile__row { display: flex; align-items: flex-start; gap: 0.7rem; }
.card-profile__photo {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    object-fit: cover;
    border-radius: 12px;
    background: #e5e7eb;
    display: block;
}
.card-profile__photo--placeholder { background: #e5e7eb; }
.card-profile__info { min-width: 0; }

/* Ручные поля карты: читаемый вид + редактирование каждого поля по клику */
.card-field-read { margin-bottom: 0.45rem; border-radius: 6px; }
.card-field-read--editable {
    cursor: pointer;
    padding: 0.3rem;
    margin-left: -0.3rem;
    border: 1px dashed transparent;
    transition: background 0.12s, border-color 0.12s;
}
.card-field-read--editable:hover {
    background: #e0e7ff;
    border-color: var(--primary);
}
.card-field-read--editable:hover .field-label { color: var(--primary-dark); }
.card-field-read--editable:hover .field-label::after { content: ' ✏️'; }
.card-field-read .field-label { margin: 0 0 0.1rem; }
.card-field-read__value {
    font-size: 12.5px;
    color: var(--text);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ===== Фильтры ===== */
.filters {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.7rem;
    margin-bottom: 0.8rem;
}
.checkbox-label { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 14px; margin-right: 0.5rem; }

/* ===== Прошлые значения в форме диагностики ===== */
.diag-student-row { display: flex; align-items: flex-start; gap: 0.7rem; margin-bottom: 0.6rem; }
.diag-student-photo { flex-shrink: 0; }
.diag-student-select { flex: 1; min-width: 0; }
.diag-student-select .field { margin-bottom: 0.4rem; }

/* Текстовые поля форм: кликабельный блок + редактирование в модалке */
.form-text-field {
    position: relative;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 2rem 0.5rem 0.7rem;
    margin-bottom: 0.6rem;
    cursor: pointer;
    min-height: 2.35rem;
    transition: border-color 0.15s, background 0.15s;
}
.form-text-field:hover { border-color: var(--primary); background: #f8faff; }
.form-text-field__value {
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.form-text-field__icon {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 13px;
}
.diag-prev {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 0.5rem;
    align-items: baseline;
    background: #eef2ff;
    border: 1px solid #dbe4ff;
    border-radius: 8px;
    padding: 0.25rem 0.5rem;
    margin: 0.4rem 0 0.35rem;
    font-size: 12px;
    cursor: pointer;
}
.diag-prev:hover { border-color: var(--primary); }
.diag-prev__label { font-weight: 600; color: var(--primary-dark); }
.diag-prev__text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
    max-width: 100%;
}
.diag-prev--open .diag-prev__text { white-space: pre-wrap; overflow: visible; }
.diag-prev__meta { width: 100%; color: var(--muted); font-size: 11px; }

/* ===== Глобальный поиск учеников (как в «Поведении») ===== */
.global-search {
    position: relative;
    margin-bottom: 1rem;
    max-width: 560px;
}
.global-search__input {
    width: 100%;
    padding: 0.6rem 0.85rem 0.6rem 2.2rem;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #f9fafb;
    color: #1f2937;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.global-search__input:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
    background: #fff;
}
.global-search__input::placeholder { color: #9ca3af; }
.global-search__icon {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 0.95rem;
    pointer-events: none;
}
.global-search__clear {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 1.15rem;
    cursor: pointer;
    padding: 0.2rem;
    line-height: 1;
    display: none;
}
.global-search__clear:hover { color: #6b7280; }
.global-search__results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    max-height: 320px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}
.global-search__results.open { display: block; }
.search-result-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.85rem;
    cursor: pointer;
    transition: background 0.12s;
    border-bottom: 1px solid #f3f4f6;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: #f1f5f9; }
.search-result-item__icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
}
.search-result-item__icon--student { background: #dbeafe; color: #2563eb; }
.search-result-item__text { flex: 1; min-width: 0; }
.search-result-item__name {
    font-weight: 600;
    font-size: 0.85rem;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-result-item__meta { font-size: 0.72rem; color: #6b7280; }
.search-no-results { padding: 1rem; text-align: center; color: #9ca3af; font-size: 0.85rem; }

/* ===== Таблицы ===== */
.table-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
    text-align: left;
    padding: 0.55rem 0.7rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}
.data-table td { padding: 0.5rem 0.7rem; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.data-table tr:hover td { background: #f8fafc; cursor: pointer; }
.data-table tr.risk-row td { background: #fff7ed; }

.tag {
    display: inline-block;
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    font-size: 12px;
    background: #eef2ff;
    color: var(--primary-dark);
}
.tag--risk { background: #ffedd5; color: var(--risk); font-weight: 700; }
.tag--status-done { background: #dcfce7; color: var(--ok); }
.tag--status-work { background: #fef9c3; color: var(--warn); }
.tag--status-cancel { background: #fee2e2; color: var(--danger); }

/* ===== Модальные окна (правила как в povedenie) ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
    z-index: 1000;
    overflow-y: auto;
    overscroll-behavior: contain;
}
body.modal-open { overflow: hidden; }

.modal-content--unified {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 25px 70px rgba(0,0,0,0.3);
    padding: 0;
    max-width: 720px;
    width: 100%;
    position: relative;
    margin: auto 0;
}
.modal-content--unified.modal-content--wide { max-width: 1200px; }
.modal-content--field-edit { max-width: 900px; }
.modal-content--field-edit .modal-body { padding: 1rem 1.2rem 1.2rem; }
textarea.field.field--big {
    min-height: 420px;
    resize: vertical;
    font-size: 15px;
    line-height: 1.5;
}
.modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    z-index: 2;
}
.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 0.9rem 1.2rem;
    border-radius: 12px 12px 0 0;
}
.modal-header h2 { margin: 0; font-size: 1.05rem; }
.modal-header .modal-sub { font-size: 12.5px; opacity: 0.85; margin-top: 0.15rem; }
.modal-controls {
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 1.2rem;
}
.modal-body { padding: 1rem 1.2rem 1.4rem; }
.modal-footer { padding: 0 1.2rem 1.2rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }

.form-row { display: flex; gap: 0.7rem; flex-wrap: wrap; }
.form-row > * { flex: 1 1 200px; }

/* ===== История правок ===== */
.history-item {
    border-left: 3px solid var(--primary);
    background: #f8fafc;
    border-radius: 6px;
    padding: 0.4rem 0.7rem;
    margin-bottom: 0.4rem;
    font-size: 13px;
}
.history-item .h-who { font-weight: 600; }
.history-item .h-when { color: var(--muted); font-size: 12px; }

/* ===== Карточки записей в журнале ===== */
.record-mini {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.7rem;
    margin-bottom: 0.35rem;
    font-size: 13.5px;
    cursor: pointer;
}
.record-mini:hover { border-color: var(--primary); }
.record-mini.risk-mini { border-color: var(--risk); background: #fff7ed; }

/* ===== Карта ученика ===== */
.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
@media (max-width: 800px) { .card-grid { grid-template-columns: 1fr; } }
.card-block {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.7rem 0.9rem;
}
.card-block h4 { margin: 0 0 0.4rem; font-size: 14px; color: var(--primary-dark); }

/* Встроенная карта под выбранным учеником */
.student-card-wrap { margin-top: 1rem; }
.student-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.9rem 1rem;
}
.student-card__head { font-weight: 700; font-size: 15px; margin-bottom: 0.7rem; color: var(--primary-dark); }

.student-chips-list { max-height: 340px; overflow-y: auto; }
