/* ——— По-задачный чат ученика и преподавателя, подсветка в мониторе и уведомление ——— */

.student-chat-btn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1180;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto !important;
  margin: 0 !important;
  padding: 11px 18px !important;
  border-radius: 999px;
  border: 1.5px solid #1564D9;
  background: #1564D9;
  color: #FFFFFF;
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(17, 24, 39, 0.22);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}
.student-chat-btn:hover {
  background: #104FAE;
  border-color: #104FAE;
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(17, 24, 39, 0.28);
}
.student-chat-btn.has-unread {
  background: #F59E0B;
  border-color: #D97706;
  color: #0F172A;
}
.student-chat-btn-ico {
  font-size: 1.05rem;
  line-height: 1;
}
.student-chat-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #DC2626;
  color: #FFFFFF;
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1;
}

/* Непропадающее уведомление у ученика в правом нижнем углу (прямо над кнопкой чата) */
.student-chat-toast {
  position: fixed;
  right: 20px;
  bottom: 76px;
  z-index: 1200;
  max-width: 340px;
  width: calc(100vw - 32px);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 2px solid #1564D9;
  background: #FFFFFF;
  color: #0F172A;
  box-shadow: 0 16px 36px rgba(17, 24, 39, 0.22);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  animation: chatToastPop 0.24s ease-out;
}
.student-chat-toast:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 42px rgba(17, 24, 39, 0.28);
  border-color: #104FAE;
}
.student-chat-toast-ico {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 12px;
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}
.student-chat-toast-body {
  min-width: 0;
  flex: 1 1 auto;
}
.student-chat-toast-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 800;
  color: #1564D9;
  margin-bottom: 3px;
}
.student-chat-toast-preview {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1E293B;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.student-chat-toast-hint {
  margin-top: 5px;
  font-size: 0.76rem;
  font-weight: 700;
  color: #4A5D78;
}

@keyframes chatToastPop {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Подсветка строки ученика с непрочитанным сообщением в мониторе */
.mon-table tbody tr.mon-student-row.is-chat-unread td {
  background: #FFFBEB !important;
}
.mon-table tbody tr.mon-student-row.is-chat-unread td.mon-name {
  background: #FEF3C7 !important;
  box-shadow: inset 4px 0 0 #F59E0B;
}
.mon-table tbody tr.mon-student-row.is-chat-unread:hover td.mon-name {
  background: #FDE68A !important;
}
.mon-table td.mon-name.is-chat-clickable {
  cursor: pointer;
}
.mon-table td.mon-name.is-chat-clickable:hover .mon-name-text {
  color: #1564D9;
  text-decoration: underline;
}
.mon-chat-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 999px;
  background: #D97706;
  color: #FFFFFF;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
}
.mon-chat-read-quick {
  flex: 0 0 auto;
  width: auto !important;
  margin: 0 !important;
  padding: 2px 6px !important;
  border-radius: 6px;
  border: 1px solid #F59E0B;
  background: #FFFFFF;
  color: #92400E;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
}
.mon-chat-read-quick:hover {
  background: #15803D;
  border-color: #15803D;
  color: #FFFFFF;
}

/* Модальное окно чата */
.chat-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1300;
  background: rgba(15, 23, 42, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.chat-modal {
  width: 100%;
  max-width: 560px;
  max-height: min(86vh, 680px);
  background: #FFFFFF;
  border-radius: 18px;
  border: 1px solid #CBD8EE;
  box-shadow: 0 22px 48px rgba(17, 24, 39, 0.24);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-modal-head {
  padding: 14px 18px 12px;
  background: #F8FAFC;
  border-bottom: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.chat-modal-head-info {
  min-width: 0;
}
.chat-modal-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: #0F172A;
}
.chat-modal-sub {
  font-size: 0.8rem;
  color: #4A5D78;
  margin-top: 2px;
}
.chat-modal-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.chat-mark-read-btn {
  width: auto !important;
  margin: 0 !important;
  padding: 6px 12px !important;
  border-radius: 9px;
  border: 1px solid #86EFAC;
  background: #ECFDF5;
  color: #15803D;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.chat-mark-read-btn:hover {
  background: #15803D;
  border-color: #15803D;
  color: #FFFFFF;
}
.chat-close-btn {
  width: 32px !important;
  height: 32px;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 9px;
  border: 1px solid #CBD5E1;
  background: #FFFFFF;
  color: #334155;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chat-close-btn:hover {
  background: #F1F5F9;
}

/* Вкладки задач внутри окна чата */
.chat-task-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #FFFFFF;
  border-bottom: 1px solid #E2E8F0;
  overflow-x: auto;
  flex: 0 0 auto;
}
.chat-task-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: auto !important;
  margin: 0 !important;
  padding: 5px 11px !important;
  border-radius: 999px;
  border: 1.5px solid #CBD8EE;
  background: #F8FAFC;
  color: #334155;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.14s ease;
}
.chat-task-tab:hover {
  border-color: #93C5FD;
  background: #EFF6FF;
  color: #1564D9;
}
.chat-task-tab.is-active {
  border-color: #1564D9;
  background: #1564D9;
  color: #FFFFFF;
}
.chat-task-tab.has-unread:not(.is-active) {
  border-color: #F59E0B;
  background: #FEF3C7;
  color: #92400E;
}
.chat-task-tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #64748B;
  opacity: 0.65;
}
.chat-task-tab.is-active .chat-task-tab-dot {
  background: #FFFFFF;
  opacity: 0.9;
}
.chat-task-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: #D97706;
  color: #FFFFFF;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
}
.chat-task-tab.is-active .chat-task-tab-badge {
  background: #FFFFFF;
  color: #1564D9;
}

.chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #F8FAFC;
  min-height: 220px;
}
.chat-empty {
  margin: auto;
  text-align: center;
  color: #64748B;
  font-size: 0.9rem;
  padding: 24px 12px;
}
.chat-msg {
  max-width: 84%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-msg.is-mine {
  align-self: flex-end;
  background: #1564D9;
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
}
.chat-msg.is-peer {
  align-self: flex-start;
  background: #FFFFFF;
  color: #0F172A;
  border: 1px solid #DCE5F2;
  border-bottom-left-radius: 4px;
}
.chat-msg-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 0.74rem;
  font-weight: 700;
}
.chat-msg.is-mine .chat-msg-meta {
  color: rgba(255, 255, 255, 0.86);
}
.chat-msg.is-peer .chat-msg-meta {
  color: #4A5D78;
}

.chat-compose {
  padding: 12px 14px;
  background: #FFFFFF;
  border-top: 1px solid #E2E8F0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-compose-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-input {
  flex: 1 1 auto;
  min-height: 42px;
  max-height: 120px;
  resize: vertical;
  margin: 0 !important;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1.5px solid #CBD8EE;
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.35;
}
.chat-input:focus {
  outline: none;
  border-color: #1564D9;
  box-shadow: 0 0 0 3px rgba(21, 100, 217, 0.16);
}
.chat-send-btn {
  width: auto !important;
  margin: 0 !important;
  padding: 10px 18px !important;
  border-radius: 10px;
  white-space: nowrap;
}
.chat-error {
  font-size: 0.8rem;
  color: #DC2626;
  font-weight: 700;
}

@media (max-width: 640px) {
  .student-chat-btn {
    right: 14px;
    bottom: 14px;
    padding: 11px 14px !important;
  }
  .student-chat-btn .student-chat-btn-lbl {
    display: none;
  }
  .student-chat-toast {
    right: 12px;
    bottom: 68px;
    width: calc(100vw - 24px);
  }
}
