/* گفتگو و کارنامه — استایل‌های بخش‌های جدید */

.nav-badge { margin-inline-start: auto; min-width: 1.4rem; padding: 0 .45rem; border-radius: 999px; background: var(--primary); color: #fff; font-size: .75rem; font-weight: 700; text-align: center; line-height: 1.4rem; }
.nav-badge[hidden] { display: none; }

.chat-toggle { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; padding: .7rem 1rem; margin-bottom: 1rem; border-radius: 16px; background: var(--pink-50); border: 1px solid var(--line); }
.chat-toggle.off { background: #f4f1f2; }

.filters { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.filters .field { margin: 0; flex: 1 1 160px; min-width: 0; }

.contact-list { display: grid; gap: .5rem; }
.contact { display: flex; align-items: center; gap: .8rem; padding: .65rem .9rem; border-radius: 14px; background: var(--pink-50); border: 1px solid var(--line); color: inherit; min-width: 0; }
.contact:hover { background: var(--pink-100); color: inherit; }
.contact .who { display: grid; min-width: 0; flex: 1; }
.contact .who strong, .contact .who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { flex: none; width: 2.6rem; height: 2.6rem; border-radius: 50%; display: grid; place-items: center; background: var(--pink-200); color: var(--primary-dark); font-weight: 800; }
.badge.unread { background: var(--primary); color: #fff; }
.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-top: 1rem; flex-wrap: wrap; }

.chat-box { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; height: calc(100vh - 8.5rem); height: calc(100dvh - 8.5rem); min-height: 380px; max-width: 820px; }
.chat-head { display: flex; align-items: center; gap: .7rem; padding: .7rem .9rem; background: var(--pink-100); flex-wrap: wrap; }
.chat-head .who { display: grid; min-width: 0; flex: 1; }
.chat-head .who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-toggle { margin: 0; }
.chat-notice { margin: .6rem; }
.chat-notice[hidden], .chat-error[hidden], #chat-empty[hidden] { display: none; }
.chat-scroll { flex: 1; overflow-y: auto; padding: .9rem; display: flex; flex-direction: column; gap: .35rem; background: var(--pink-50); overscroll-behavior: contain; }
.chat-scroll .more { text-align: center; margin-bottom: .5rem; }
#chat-messages { display: flex; flex-direction: column; gap: .35rem; }
.day-sep { text-align: center; margin: .6rem 0 .2rem; }
.day-sep span { display: inline-block; padding: .1rem .8rem; border-radius: 999px; background: var(--pink-200); color: var(--primary-dark); font-size: .78rem; }
.msg-block { display: flex; }
.msg-block.mine { justify-content: flex-start; }   /* در راست‌به‌چپ، «شروع» = سمت راست */
.msg-block.theirs { justify-content: flex-end; }
.bubble { max-width: min(80%, 34rem); padding: .5rem .8rem .3rem; border-radius: 16px; background: #fff; border: 1px solid var(--line); overflow-wrap: anywhere; }
.msg-block.mine .bubble { background: var(--primary); border-color: var(--primary); color: #fff; border-end-start-radius: 4px; }
.msg-block.theirs .bubble { border-end-end-radius: 4px; }
.bubble p { margin: 0; white-space: pre-wrap; }
.bubble time { display: block; font-size: .7rem; opacity: .7; margin-top: .15rem; text-align: end; }
.chat-form { display: flex; gap: .6rem; padding: .7rem; border-top: 1px solid var(--line); align-items: flex-end; background: #fff; }
.chat-form textarea { flex: 1; min-width: 0; resize: none; max-height: 140px; }
.chat-form .btn[disabled], .chat-form textarea[disabled] { opacity: .55; cursor: not-allowed; }
.chat-error { margin: 0 .7rem .7rem; }

.grade-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 14rem); gap: .8rem; align-items: center; padding-bottom: .8rem; border-bottom: 1px dashed var(--pink-200); }
.grade-row > label { margin: 0; }
.grade-row select { width: 100%; }

@media (max-width: 600px) {
  .chat-box { height: calc(100dvh - 7.2rem); border-radius: 14px; }
  .bubble { max-width: 88%; }
  .grade-row { grid-template-columns: 1fr; gap: .3rem; }
  .chat-head-toggle { width: 100%; }
  .chat-head-toggle .btn { width: 100%; }
}

@media print {
  .sidebar, .topbar, .overlay, .head-actions, .btn, .nav-badge { display: none !important; }
  .app { display: block !important; }
  .main { margin: 0 !important; }
  .card { box-shadow: none; border: 1px solid #999; }
  .table-wrap { overflow: visible; }
}
.table-wrap .btn { white-space: nowrap; }
.grade-ctl { display: flex; gap: .5rem; align-items: center; }
.grade-ctl select { flex: 1; min-width: 0; }
.footer-copy {
  margin: 0; padding: .8rem 1.2rem; text-align: center;
  font-size: .85rem; color: var(--muted);
  border-top: 1px dashed var(--pink-200); background: var(--pink-50);
}
.msg-del { background: none; border: 0; padding: 0 .2rem; margin-inline-start: .4rem; cursor: pointer; font-size: .75rem; opacity: .6; color: inherit; }
.msg-del:hover { opacity: 1; }
.bubble time { display: flex; justify-content: flex-end; align-items: center; }
.chat-clear { margin: 0; padding: .3rem .9rem; text-align: end; background: var(--pink-50); border-bottom: 1px solid var(--line); }
