/* ZemGuru modular styles 11/16. Original cascade order preserved. */
/* Step 149: private teacher dialog mode */
.teacher-private-layout {
  display: grid;
  gap: 12px;
  min-height: min(72vh, 760px);
}

.teacher-private-layout.has-student-list {
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
}

.teacher-private-students {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.teacher-private-students-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.teacher-private-students-head h2 {
  margin: 0;
  font-size: 16px;
}

.teacher-private-students-list {
  display: grid;
  gap: 6px;
  padding: 10px;
  overflow: auto;
  max-height: min(72vh, 760px);
}

.teacher-private-student-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  padding: 10px;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.teacher-private-student-row:hover,
.teacher-private-student-row.active {
  border-color: rgba(36, 115, 56, 0.35);
  background: var(--soft-green);
}

.teacher-private-student-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.teacher-private-student-main strong {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.teacher-private-student-preview {
  display: block;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.teacher-private-student-meta {
  display: block;
  font-size: 11px;
  color: var(--muted);
}


.teacher-private-student-row .teacher-private-status {
  justify-self: end;
  font-size: 10px;
  padding: 4px 8px;
}

.teacher-private-status.new {
  background: rgba(214, 168, 40, 0.16);
  color: #8a6400;
}

.messenger-back-btn {
  display: none;
  flex-shrink: 0;
  margin-right: 8px;
}

.messenger-empty-chat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: min(72vh, 760px);
  text-align: center;
  padding: 24px;
}

.groups-messenger-layout .groups-card-list {
  display: grid;
  gap: 8px;
}

.groups-messenger-layout .group-card {
  margin: 0;
}

.groups-messenger-layout .group-card.chat-open {
  border-color: rgba(36, 115, 56, 0.44);
  box-shadow: inset 0 0 0 1px rgba(36, 115, 56, 0.18);
}

.student-appeal-toolbar {
  display: flex;
  gap: 10px;
  padding: 0 16px 10px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.student-appeal-toolbar .compact-field {
  display: grid;
  gap: 4px;
  min-width: 180px;
}

.student-appeal-toolbar select {
  width: 100%;
}

.teacher-private-chat-head {
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .teacher-private-layout.has-student-list.mobile-chat-open .teacher-private-students,
  .teacher-private-layout.has-student-list.mobile-chat-open .groups-list-panel {
    display: none;
  }

  .teacher-private-layout.has-student-list:not(.mobile-chat-open) .messenger-chat-panel,
  .teacher-private-layout.has-student-list:not(.mobile-chat-open) .messenger-empty-chat {
    display: none;
  }

  .messenger-back-btn {
    display: inline-flex;
  }

  .teacher-private-layout.has-student-list {
    grid-template-columns: 1fr;
  }
}

body[data-theme="dark"] .student-appeal-toolbar {
  background: #141c18;
  border-bottom-color: #2a3a30;
}

body[data-theme="dark"] .teacher-private-status.new {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
}

.teacher-private-student-main small {
  font-size: 11px;
  color: var(--muted);
}

.teacher-private-unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.teacher-private-chat {
  display: flex;
  flex-direction: column;
  min-height: min(72vh, 760px);
  padding: 0;
  overflow: hidden;
}

.teacher-private-chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.teacher-private-chat-kicker {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.teacher-private-chat-head h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.teacher-private-chat-meta {
  margin: 0;
  font-size: 13px;
}

.teacher-private-status {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.teacher-private-status.answered {
  background: rgba(36, 115, 56, 0.12);
  color: var(--accent);
}

.teacher-private-status.pending {
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
}

.teacher-private-status.neutral {
  background: var(--soft-green);
  color: var(--muted);
}

.teacher-private-feed {
  flex: 1 1 auto;
  min-height: 280px;
  max-height: none;
}

.teacher-private-empty-feed,
.teacher-private-students-empty,
.teacher-private-chat-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.teacher-private-chat-empty {
  min-height: 320px;
}

.teacher-dialog-composer {
  border-top: 1px solid var(--line);
}

.teacher-dialog-page {
  display: flex;
  flex-direction: column;
  min-height: min(calc(100vh - 180px), 760px);
}

.teacher-dialog-page-chat {
  flex: 1 1 auto;
  min-height: min(calc(100vh - 180px), 760px);
}

.teacher-dialog-page .teacher-private-feed {
  flex: 1 1 auto;
  min-height: 320px;
}

.teacher-private-chat .community-chat-avatar-wrap {
  flex-shrink: 0;
}

:root {
  --messenger-chat-wallpaper-base: #dce8e2;
  --messenger-chat-wallpaper-image: url("assets/messenger-chat-pattern-space-light.svg");
  --messenger-chat-wallpaper-size: 281.25px 609px;
}

body[data-theme="dark"] {
  --messenger-chat-wallpaper-base: #18191d;
  --messenger-chat-wallpaper-image: url("assets/messenger-chat-pattern-space-dark.svg");
}

.messenger-chat-wallpaper,
.teacher-dialog-chat-body,
.teacher-private-feed,
.community-chat-feed {
  background-color: var(--messenger-chat-wallpaper-base);
  background-image: var(--messenger-chat-wallpaper-image);
  background-size: var(--messenger-chat-wallpaper-size);
  background-position: 0 0;
  background-repeat: repeat;
}

.teacher-dialog-chat-body > .teacher-private-feed,
.teacher-dialog-chat-body > .community-chat-feed {
  background-color: transparent;
  background-image: none;
}

.teacher-dialog-chat-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.teacher-dialog-pinned {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-shrink: 0;
  padding: 10px 16px;
  border-bottom: 1px solid #dbe8de;
  background: linear-gradient(180deg, #f8fbf8 0%, #f3f7f3 100%);
}

.teacher-dialog-pinned-icon {
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1.4;
  opacity: 0.85;
}

.teacher-dialog-pinned-body {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.teacher-dialog-pinned-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent);
}

.teacher-dialog-pinned-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.teacher-dialog-pinned-author {
  font-weight: 700;
}

.teacher-dialog-pinned-time {
  font-size: 11px;
  color: var(--muted);
}

.teacher-dialog-pinned-menu-wrap {
  position: relative;
  flex-shrink: 0;
  align-self: center;
  margin-left: auto;
}

.teacher-dialog-pinned-menu-btn {
  opacity: 1;
}

.teacher-dialog-pinned-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 6;
  min-width: 148px;
}

.messenger-unpin-backdrop {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(9, 22, 18, 0.48);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.messenger-unpin-alert {
  width: min(360px, 100%);
  padding: 22px 20px 18px;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #1c1c1e;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  text-align: center;
}

.messenger-unpin-alert h2 {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 700;
  color: #f2f2f7;
}

.messenger-unpin-alert p {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.45;
  color: #8e8e93;
}

.messenger-unpin-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.messenger-unpin-btn {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

.messenger-unpin-btn:hover {
  transform: translateY(-1px);
}

.messenger-unpin-btn-cancel {
  background: rgba(255, 255, 255, 0.08);
  color: #f2f2f7;
}

.messenger-unpin-btn-cancel:hover {
  background: rgba(255, 255, 255, 0.12);
}

.messenger-unpin-btn-confirm {
  background: #007aff;
  color: #fff;
}

.messenger-unpin-btn-confirm:hover {
  background: #0066d6;
}

.teacher-dialog-page-chat .teacher-private-feed {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px 12px;
  gap: 10px;
  scroll-behavior: smooth;
}

.community-chat-feed .community-chat-message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: fit-content;
  max-width: min(85%, 640px);
}

.community-chat-feed .community-chat-message.is-other {
  align-self: flex-start;
  margin-right: auto;
}

.community-chat-feed .community-chat-message.is-mine {
  flex-direction: row-reverse;
  align-self: flex-end;
  margin-left: auto;
}

.community-chat-feed .community-chat-message.is-mine .community-chat-avatar-wrap {
  display: none;
}

.community-chat-feed .community-chat-message.is-send-failed .community-chat-bubble-tg {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}

.community-chat-feed .community-chat-message.is-send-failed .community-chat-time {
  color: #dc2626;
}

.community-chat-feed .community-chat-message.is-pending-send .community-chat-time {
  opacity: 0.72;
}

.community-chat-feed .community-chat-bubble-tg {
  position: relative;
  width: fit-content;
  max-width: min(85%, 640px);
  min-width: min-content;
  padding: 8px 10px 6px;
  border: 1px solid transparent;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  overflow: visible;
}

.community-chat-feed .community-chat-content {
  display: block;
  min-width: min-content;
}

.community-chat-feed .community-chat-body {
  display: block;
  max-width: 100%;
  min-width: min-content;
}

.community-chat-feed .community-chat-body-row {
  display: block;
  width: fit-content;
  max-width: min(85%, 640px);
  line-height: 1.45;
}

.community-chat-feed .community-chat-body-row > .community-chat-text {
  display: inline;
  min-width: 0;
  max-width: none;
}

.community-chat-feed .community-chat-body-row > .community-message-delete-confirm,
.community-chat-feed .community-chat-body-row > .community-message-edit-form {
  display: block;
  width: 100%;
  margin-top: 8px;
  clear: both;
}

.community-chat-feed .community-chat-body-row > .community-chat-tail {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  vertical-align: bottom;
  margin: 0 0 1px 6px;
  white-space: nowrap;
}

.community-chat-feed .community-chat-author-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.community-chat-feed .community-chat-author-line .community-chat-tail {
  margin-left: auto;
  flex-shrink: 0;
  align-self: center;
  margin-bottom: 0;
}

.community-chat-feed .community-chat-author-line .community-chat-author {
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
  cursor: default;
}

.community-chat-feed .community-chat-message.from-teacher.is-other .community-chat-author-line .community-chat-author {
  color: #1f6b3f;
}

.community-chat-feed .community-chat-message.is-other .community-chat-bubble-tg {
  background: #fff;
  border-color: #dce8de;
  border-radius: 18px 18px 18px 6px;
}

.community-chat-feed .community-chat-message.is-mine .community-chat-bubble-tg {
  background: #dff0e2;
  border-color: #c5dfc9;
  border-radius: 18px 18px 6px 18px;
}

.community-chat-feed .community-chat-message.from-teacher.is-other .community-chat-bubble-tg {
  background: #effaf0;
  border-color: #b9dcc0;
}

.community-chat-feed .community-chat-message.is-deleted .community-chat-bubble-tg {
  background: #f8f9f8;
  border-color: #e4ebe5;
}

.community-chat-feed .community-chat-content .community-chat-quote,
.community-chat-feed .community-chat-content .community-message-attachments,
.community-chat-feed .community-chat-content .community-message-delete-confirm,
.community-chat-feed .community-chat-content .community-message-edit-input,
.community-chat-feed .community-chat-content .community-message-edit-form,
.community-chat-feed .community-chat-body .community-chat-quote,
.community-chat-feed .community-chat-body .community-message-attachments,
.community-chat-feed .community-chat-body .community-message-delete-confirm,
.community-chat-feed .community-chat-body .community-message-edit-input,
.community-chat-feed .community-chat-body .community-message-edit-form {
  display: block;
  width: 100%;
}

.community-chat-feed .community-chat-author-line button.community-chat-author {
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.community-chat-feed .community-chat-author-line button.community-chat-author:hover {
  color: var(--accent);
}

.community-chat-feed .community-chat-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: break-word;
  word-break: normal;
  white-space: pre-wrap;
}

.community-chat-feed .community-chat-body > .community-chat-text,
.community-chat-feed .community-chat-body-row > .community-chat-text {
  color: inherit;
  opacity: 1;
  visibility: visible;
}

.community-chat-feed .community-chat-body > .community-chat-text {
  display: block;
}

.community-chat-feed .community-chat-body-row > .community-chat-text {
  display: inline;
}

.community-chat-feed .community-chat-content > .community-chat-text {
  display: block;
}

.community-chat-feed .community-chat-tail {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  margin-left: 6px;
  margin-bottom: 1px;
  white-space: nowrap;
}

.community-chat-feed .community-chat-time {
  font-size: 11px;
  line-height: 1;
  color: rgba(15, 23, 42, 0.42);
  white-space: nowrap;
}

.community-chat-feed .community-chat-message.is-mine .community-chat-time {
  color: rgba(15, 23, 42, 0.46);
}

.community-chat-feed .community-chat-tail .community-message-menu-wrap {
  margin-left: 0;
}

.community-chat-feed .community-chat-bubble-tg .community-message-reactions {
  margin-top: 4px;
}

.community-chat-feed .community-message-menu-wrap {
  position: relative;
  z-index: 2;
  margin-left: 2px;
}

.community-chat-feed .community-message-menu-btn {
  opacity: 0.72;
}

.community-chat-feed .community-chat-message:hover .community-message-menu-btn,
.community-chat-feed .community-message-menu-wrap:focus-within .community-message-menu-btn,
.community-chat-feed .community-message-menu-btn[aria-expanded="true"] {
  opacity: 1;
}

.community-chat-feed .community-chat-message:hover .community-chat-bubble-tg,
.community-chat-feed .community-chat-message:focus-within .community-chat-bubble-tg {
  transform: none;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.teacher-dialog-page-chat .teacher-dialog-composer {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  background: #fff;
  padding: 10px 14px 12px;
}

.teacher-dialog-page-chat .community-chat-input-row {
  gap: 10px;
}

.teacher-dialog-page-chat .community-chat-input-row textarea,
.messenger-composer-textarea {
  min-height: 52px;
  max-height: 200px;
  resize: none;
  overflow-y: hidden;
  overflow-x: hidden;
  border-radius: 16px;
  border: 1px solid #dbe8de;
  background: #f8fbf8;
  padding: 11px 14px;
  line-height: 1.45;
  box-sizing: border-box;
  field-sizing: content;
}

.teacher-dialog-page-chat .teacher-dialog-composer .community-attach-btn {
  width: 48px;
  height: 48px;
  min-width: 48px;
  font-size: 18px;
}

.teacher-dialog-page-chat .teacher-dialog-composer .btn {
  min-height: 48px;
  padding: 10px 16px;
  font-size: 14px;
}

.teacher-dialog-page-chat .community-attach-btn {
  border-radius: 12px;
}

@media (max-width: 720px) {
  .community-chat-feed .community-chat-message {
    max-width: min(88%, 100%);
  }
}

body[data-theme="dark"] .teacher-dialog-chat-body > .teacher-private-feed,
body[data-theme="dark"] .teacher-dialog-chat-body > .community-chat-feed {
  background-color: transparent;
  background-image: none;
}

body[data-theme="dark"] .teacher-dialog-pinned {
  background: linear-gradient(180deg, #18221c 0%, #141c18 100%);
  border-bottom-color: #2a3a30;
}

body[data-theme="dark"] .teacher-dialog-pinned-text {
  color: #e8ede9;
}

body[data-theme="dark"] .teacher-dialog-pinned-menu-btn:hover,
body[data-theme="dark"] .teacher-dialog-pinned-menu-btn:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  color: #eaf3ec;
}

body[data-theme="light"] .messenger-unpin-alert {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.18);
}

body[data-theme="light"] .messenger-unpin-alert h2 {
  color: var(--ink);
}

body[data-theme="light"] .messenger-unpin-alert p {
  color: var(--muted);
}

body[data-theme="light"] .messenger-unpin-btn-cancel {
  background: #eef2ef;
  color: var(--ink);
}

body[data-theme="light"] .messenger-unpin-btn-cancel:hover {
  background: #e4ebe6;
}

body[data-theme="dark"] .community-chat-feed .community-chat-message.is-mine .community-chat-time {
  color: rgba(234, 243, 236, 0.52);
}

body[data-theme="dark"] .community-chat-feed .community-chat-message.is-other .community-chat-time {
  color: rgba(232, 237, 233, 0.48);
}

body[data-theme="dark"] .community-chat-feed .community-chat-message.is-other .community-chat-bubble-tg {
  background: #1a2420;
  border-color: #2f4236;
}

body[data-theme="dark"] .community-chat-feed .community-chat-message.is-mine .community-chat-bubble-tg {
  background: #1f3a28;
  border-color: #3a5a42;
}

body[data-theme="dark"] .community-chat-feed .community-chat-message.is-mine .community-chat-text {
  color: #f2f7f3;
}

body[data-theme="dark"] .community-chat-feed .community-chat-message.from-teacher.is-other .community-chat-bubble-tg {
  background: #1a2a20;
  border-color: #3a5a42;
}

body[data-theme="dark"] .teacher-dialog-page-chat .teacher-dialog-composer {
  background: #141c18;
  border-top-color: #2a3a30;
}

body[data-theme="dark"] .teacher-dialog-page-chat .community-chat-input-row textarea {
  background: #1a2420;
  border-color: #2f4236;
  color: #e8ede9;
}

body[data-theme="dark"] .community-chat-feed .community-message-menu-btn:hover,
body[data-theme="dark"] .community-chat-feed .community-message-menu-btn:focus-visible {
  background: #243028;
}

body[data-theme="dark"] .teacher-private-student-row {
  border-color: #2a3a30;
}

body[data-theme="dark"] .teacher-private-student-row:hover,
body[data-theme="dark"] .teacher-private-student-row.active {
  background: #1a2a20;
  border-color: #3a5a42;
}

body[data-theme="dark"] .teacher-private-student-preview,
body[data-theme="dark"] .teacher-private-student-main small {
  color: #b8c5bb;
}

body[data-theme="dark"] .teacher-private-status.pending {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
}

body[data-theme="dark"] .teacher-private-status.answered {
  color: #86efac;
  background: rgba(134, 239, 172, 0.12);
}

@media (max-width: 820px) {
  .teacher-private-layout.has-student-list {
    grid-template-columns: 1fr;
  }

  .teacher-private-students-list {
    max-height: 220px;
  }

  .teacher-private-chat {
    min-height: 420px;
  }
}

