/**
 * Unokidz — professional chat thread (teacher ↔ student dashboards)
 * Neutral surfaces, high-contrast bubbles, restrained radii.
 */

.unokidz-chat {
  font-family: "DM Sans", ui-sans-serif, system-ui, sans-serif;
}

.unokidz-chat-thread {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Fixed viewport: message list scrolls inside __body */
  --unokidz-chat-thread-h: clamp(18rem, 52dvh, 24rem);
  block-size: var(--unokidz-chat-thread-h);
  inline-size: 100%;
  min-block-size: 18rem;
  max-block-size: var(--unokidz-chat-thread-h);
  border-radius: 0.625rem;
  border: 1px solid rgba(63, 63, 70, 0.95);
  background: rgba(9, 9, 11, 0.55);
}

@media (min-width: 1024px) {
  .unokidz-chat-thread {
    --unokidz-chat-thread-h: clamp(22rem, 50dvh, 28rem);
  }
}

.unokidz-chat-thread__head {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid rgba(63, 63, 70, 0.95);
  background: rgba(24, 24, 27, 0.98);
}

.unokidz-chat-thread__head-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.unokidz-chat-thread__title {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #fafafa;
}

.unokidz-chat-thread__meta {
  font-size: 0.75rem;
  font-weight: 500;
  color: #94a3b8;
}

.unokidz-chat-window {
  display: inline-flex;
}

.unokidz-chat-window__select {
  border-radius: 0.375rem;
  border: 1px solid rgba(82, 82, 91, 0.9);
  background: rgba(24, 24, 27, 0.92);
  color: #e4e4e7;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.1;
  padding: 0.3rem 0.45rem;
}

.unokidz-chat-window__select:focus {
  outline: none;
  border-color: rgba(148, 163, 184, 0.95);
}

@media (max-width: 640px) {
  .unokidz-chat-thread__head {
    align-items: flex-start;
    gap: 0.4rem;
  }

  .unokidz-chat-thread__head-actions {
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
  }

  .unokidz-chat-thread__meta {
    text-align: right;
  }
}

.unokidz-chat-thread__body {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.75rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable both-edges;
  padding: 1rem;
  background: rgba(9, 9, 11, 0.4);
}

.unokidz-chat-thread__body::-webkit-scrollbar {
  width: 0.6rem;
}

.unokidz-chat-thread__body::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.45);
}

.unokidz-chat-msg-row {
  display: flex;
  width: 100%;
  min-width: 0;
}

.unokidz-chat-msg-row--out {
  justify-content: flex-end;
}

.unokidz-chat-msg-row--in {
  justify-content: flex-start;
}

.unokidz-chat-bubble {
  max-width: min(100%, 22rem);
  min-width: 0;
  border-radius: 0.625rem;
  padding: 0.65rem 0.9rem;
  font-size: 0.875rem;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.unokidz-chat-bubble--out {
  border: 1px solid rgba(51, 65, 85, 0.65);
  background: #1e293b;
  color: #f8fafc;
  border-bottom-right-radius: 0.25rem;
}

.unokidz-chat-bubble--in {
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #0f172a;
  border-bottom-left-radius: 0.25rem;
}

.unokidz-chat-bubble__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  margin-bottom: 0.35rem;
}

.unokidz-chat-bubble__sender {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.unokidz-chat-bubble__time {
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
}

.unokidz-chat-bubble--out .unokidz-chat-bubble__sender,
.unokidz-chat-bubble--out .unokidz-chat-bubble__time {
  color: rgba(248, 250, 252, 0.78);
}

.unokidz-chat-bubble--in .unokidz-chat-bubble__sender {
  color: #334155;
}

.unokidz-chat-bubble--in .unokidz-chat-bubble__time {
  color: #64748b;
}

.unokidz-chat-bubble__text {
  margin: 0;
  word-break: break-word;
  white-space: pre-wrap;
}

.unokidz-chat-bubble--in .unokidz-chat-bubble__text {
  color: #0f172a;
}

.unokidz-chat-bubble__img {
  margin-top: 0.5rem;
  max-height: 13rem;
  width: 100%;
  max-width: 100%;
  border-radius: 0.375rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  object-fit: contain;
}

.unokidz-chat-bubble--out .unokidz-chat-bubble__img {
  border-color: rgba(148, 163, 184, 0.28);
}

.unokidz-chat-bubble__download {
  margin-top: 0.5rem;
  display: inline-flex;
  width: 100%;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border-radius: 0.375rem;
  border: 1px solid currentColor;
  padding: 0.4rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: transparent;
}

.unokidz-chat-bubble--out .unokidz-chat-bubble__download {
  border-color: rgba(248, 250, 252, 0.35);
  color: #f1f5f9;
}

.unokidz-chat-bubble--out .unokidz-chat-bubble__download:hover {
  background: rgba(255, 255, 255, 0.07);
}

.unokidz-chat-bubble--in .unokidz-chat-bubble__download {
  border-color: #cbd5e1;
  color: #0f172a;
}

.unokidz-chat-bubble--in .unokidz-chat-bubble__download:hover {
  background: #f1f5f9;
}

/* Recipient mode (teacher): segmented control */
.unokidz-chat-seg {
  display: flex;
  gap: 0.2rem;
  border-radius: 0.5rem;
  border: 1px solid #3f3f46;
  background: #18181b;
  padding: 0.2rem;
}

.unokidz-chat-seg__btn {
  flex: 1;
  cursor: pointer;
  border: none;
  border-radius: 0.375rem;
  background: transparent;
  padding: 0.45rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #94a3b8;
  transition: background 0.15s ease, color 0.15s ease;
}

.unokidz-chat-seg__btn:hover {
  color: #e4e4e7;
  background: rgba(255, 255, 255, 0.05);
}

.unokidz-chat-seg__btn--active {
  background: #334155 !important;
  color: #f8fafc !important;
}

/* Attachment control */
.unokidz-chat-attach {
  position: relative;
  display: inline-flex;
  min-height: 2.25rem;
  cursor: pointer;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
  border-radius: 0.5rem;
  border: 1px dashed #52525b;
  background: #18181b;
  padding: 0.45rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #a1a1aa;
}

.unokidz-chat-attach:hover {
  border-color: #71717a;
  background: #27272a;
  color: #e4e4e7;
}

.unokidz-chat-attach__icon {
  flex-shrink: 0;
  opacity: 0.85;
}
