/* ═══════════════════════════════════════════════
   MODULE — MY CHATS
   All styles scoped under #page-messaging to avoid
   collisions with the global layout system.
═══════════════════════════════════════════════ */

/* ── PAGE CONTAINER ──────────────────────────── */
/* When inactive, ensure it stays hidden like every other .page */
#page-messaging:not(.active) {
  display: none !important;
}

/* ── OUTER SCROLL SUPPRESSION ────────────────────
   Toggled by navigation.js via class "chat-active".
   Only affects #content while the chat tab is open;
   all other pages keep their normal overflow-y:auto.
─────────────────────────────────────────────── */
#content.chat-active {
  overflow: hidden !important;
  padding: 0 !important;
}

/* When active, fill #content exactly (no absolute vh calc) */
#page-messaging.active {
  display: flex !important;
  flex-direction: column;
  padding: 0 !important;
  overflow: hidden;
  height: 100%;       /* 100% of #content — avoids any over-tall calculation */
  min-height: 0;      /* let flexbox shrink it if needed */
}

/* ── WRAPPER ─────────────────────────────────── */
#page-messaging .mc-wrapper {
  display: flex;
  flex: 1;
  min-height: 0;      /* allow shrink below content size */
  gap: 0;
  position: relative;
  overflow: hidden;
  background: transparent;
  height: 100%;       /* fill page-messaging exactly */
}

/* ── GLASS PANEL BASE ────────────────────────── */
#page-messaging .mc-glass {
  background: var(--card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* ── CONVERSATIONS SIDEBAR ───────────────────── */
#page-messaging .mc-sidebar {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
  min-height: 0;      /* allow column to shrink within mc-wrapper */
  height: 100%;       /* fill full wrapper height */
}

#page-messaging .mc-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px 0;
}

#page-messaging .mc-sidebar-header h2 {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--gold);
  font-weight: 600;
  margin: 0;
  text-transform: uppercase;
}

#page-messaging .mc-plus-btn {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 15px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
#page-messaging .mc-plus-btn:hover {
  background: var(--surface2);
  color: var(--gold);
}

#page-messaging .mc-search-wrap {
  padding: 14px 16px;
  flex-shrink: 0;
}

#page-messaging #mc-chat-search {
  width: 100%;
  padding: 9px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface2);
  font-family: 'Lexend', sans-serif;
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
  color: var(--text);
  transition: all 0.25s;
}
#page-messaging #mc-chat-search::placeholder { color: var(--text3); }
#page-messaging #mc-chat-search:focus {
  background: var(--surface);
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--glow);
}

#page-messaging .mc-conv-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;      /* ← the key: lets flex shrink this and scroll instead */
  padding: 4px 12px 12px;
}
#page-messaging .mc-conv-list::-webkit-scrollbar { width: 4px; }
#page-messaging .mc-conv-list::-webkit-scrollbar-thumb {
  background: rgba(201,168,76,0.25);
  border-radius: 2px;
}

#page-messaging .mc-cat-label {
  font-size: 9.5px;
  letter-spacing: 1.5px;
  color: var(--text3);
  font-weight: 600;
  text-transform: uppercase;
  padding: 16px 6px 6px;
}

#page-messaging .mc-conv-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
  gap: 12px;
  margin-bottom: 3px;
}
#page-messaging .mc-conv-item:hover {
  background: var(--surface2);
}
#page-messaging .mc-conv-item.active {
  background: rgba(201,168,76,0.18);
  box-shadow: 0 4px 12px var(--glow);
}

#page-messaging .mc-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  background: rgba(201,168,76,0.15);
  color: var(--gold);
  border: 1px solid rgba(201,168,76,0.25);
}
#page-messaging .mc-conv-item.active .mc-avatar {
  background: rgba(201,168,76,0.3);
}

#page-messaging .mc-conv-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}
#page-messaging .mc-conv-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#page-messaging .mc-conv-sub {
  font-size: 11.5px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* ── MAIN CHAT AREA ──────────────────────────── */
#page-messaging .mc-chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;      /* allow the column to shrink and let children scroll */
  border-radius: 0;
  border-left: none;
  border-right: none;
  position: relative;
  overflow: hidden;
  height: 100%;
}

#page-messaging .mc-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface2);
}

#page-messaging .mc-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

#page-messaging #mc-header-name {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
#page-messaging #mc-header-sub {
  font-size: 12px;
  color: var(--text3);
  display: block;
  margin-top: 2px;
}

#page-messaging .mc-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

#page-messaging .mc-hdr-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 14px;
  font-family: 'Lexend', sans-serif;
  font-weight: 500;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all 0.2s;
}
#page-messaging .mc-hdr-btn:hover {
  background: var(--card);
  border-color: var(--gold);
  box-shadow: 0 0 10px var(--glow);
}

#page-messaging .mc-hdr-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text2);
  transition: all 0.2s;
  font-size: 14px;
}
#page-messaging .mc-hdr-icon-btn:hover {
  background: var(--card);
  border-color: var(--gold);
  color: var(--gold);
}

/* ── MESSAGES AREA ───────────────────────────── */
#page-messaging .mc-messages {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;   /* ← independent scroll zone 2 */
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;      /* ← must be 0, not auto */
}
#page-messaging .mc-messages::-webkit-scrollbar { width: 4px; }
#page-messaging .mc-messages::-webkit-scrollbar-thumb {
  background: rgba(201,168,76,0.25);
  border-radius: 2px;
}

#page-messaging .mc-empty-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text3);
  font-size: 13.5px;
}

/* ── MESSAGE WRAPPERS ────────────────────────── */
#page-messaging .mc-msg-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  position: relative;
  animation: mcFadeIn 0.28s ease-out;
}
#page-messaging .mc-msg-wrap.other {
  align-items: flex-start;
}

@keyframes mcFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

#page-messaging .mc-msg-wrap { width: 100%; max-width: 100%; }

#page-messaging .mc-bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  justify-content: flex-end;            /* own messages hug the right */
  min-width: 0;                         /* allow children to wrap, not overflow */
}
#page-messaging .mc-msg-wrap.other .mc-bubble-row {
  justify-content: flex-start;          /* others hug the left */
}

#page-messaging .mc-msg-actions {
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 10;
}
#page-messaging .mc-msg-wrap:hover .mc-msg-actions {
  display: flex;
  opacity: 1;
}

#page-messaging .mc-action-btn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  color: var(--text3);
  font-size: 12px;
  transition: all 0.2s;
}
#page-messaging .mc-action-btn:hover {
  color: var(--text);
  background: var(--surface);
  transform: scale(1.05);
}

/* ── BUBBLES ─────────────────────────────────── */
#page-messaging .mc-bubble {
  background: linear-gradient(135deg, var(--gold), #B8922A);
  color: var(--text);
  padding: 10px 16px 24px;
  border-radius: 18px 18px 4px 18px;
  /* Grows with content, but never thinner than readable and never wider than 70% */
  width: fit-content;
  min-width: 92px;                       /* keeps short msgs + timestamp horizontal */
  max-width: 70%;
  position: relative;
  font-size: 13.5px;
  line-height: 1.5;
  cursor: pointer;
  transition: opacity 0.2s;
  box-shadow: 0 3px 12px rgba(201,168,76,0.25);
  /* Content containment — nothing leaks outside the bubble */
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  box-sizing: border-box;
}

/* Text content: preserve newlines, wrap naturally, never stack letters */
#page-messaging .mc-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

/* Links inside bubbles must wrap, never overflow */
#page-messaging .mc-bubble a {
  overflow-wrap: anywhere;
  word-break: break-all;
}
#page-messaging .mc-msg-wrap.other .mc-bubble {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
#page-messaging .mc-bubble.mc-editing {
  outline: 2px dashed var(--gold);
  outline-offset: 2px;
}

#page-messaging .mc-bubble.mc-image-bubble {
  padding: 6px 6px 24px;
}
#page-messaging .mc-bubble.mc-image-bubble img,
#page-messaging .mc-bubble.mc-image-bubble video {
  border-radius: 12px;
  width: auto;
  max-width: 100%;              /* scale to bubble, never overflow */
  height: auto;
  display: block;
}

/* File / document attachment cards — stay inside the bubble, truncate long names */
#page-messaging .mc-file-card {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
}
#page-messaging .mc-file-card i { flex-shrink: 0; opacity: 0.7; }
#page-messaging .mc-file-card a {
  color: inherit;
  text-decoration: underline;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

#page-messaging .mc-quoted {
  background: rgba(0,0,0,0.1);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 8px;
  font-size: 12px;
  border-left: 3px solid rgba(201,168,76,0.5);
}
#page-messaging .mc-msg-wrap.other .mc-quoted {
  background: var(--surface2);
  border-left-color: var(--gold);
}

#page-messaging .mc-msg-time {
  position: absolute;
  bottom: 5px;
  right: 12px;
  font-size: 9.5px;
  color: rgba(26,22,18,0.6);
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;          /* time + ticks never split across lines */
}
#page-messaging .mc-msg-wrap.other .mc-msg-time {
  right: auto;
  left: 12px;
  color: var(--text3);
}

#page-messaging .mc-reactions {
  display: flex;
  gap: 4px;
  margin-top: -10px;
  margin-bottom: 6px;
  z-index: 2;
  align-self: flex-end;
  margin-right: 10px;
}
#page-messaging .mc-msg-wrap.other .mc-reactions {
  align-self: flex-start;
  margin-right: 0;
  margin-left: 10px;
}
#page-messaging .mc-reaction-badge {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 7px;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  transition: all 0.2s;
}
#page-messaging .mc-reaction-badge:hover {
  transform: scale(1.1);
}

/* ── AUDIO PLAYER ────────────────────────────── */
#page-messaging .mc-audio-player {
  background: #2A1F3D;
  border-radius: 22px;
  padding: 6px 12px 6px 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  width: 250px;
  max-width: 100%;              /* shrink to fit narrow bubbles */
  box-sizing: border-box;
}
#page-messaging .mc-audio-play { flex-shrink: 0; }
#page-messaging .mc-audio-play {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold);
  color: #1A0F2E;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
  padding-left: 2px;
}
#page-messaging .mc-waveform {
  flex: 1;
  height: 18px;
  display: flex;
  align-items: center;
  gap: 2px;
}
#page-messaging .mc-waveform .mc-bar {
  width: 3px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
}
#page-messaging .mc-waveform .mc-bar.active {
  background: var(--gold);
}
#page-messaging .mc-audio-time {
  font-size: 10.5px;
  opacity: 0.85;
}
#page-messaging .mc-audio-speed {
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
#page-messaging .mc-audio-speed:hover {
  background: rgba(255,255,255,0.25);
}

/* ── INPUT AREA ──────────────────────────────── */
#page-messaging .mc-input-area {
  display: flex;
  align-items: flex-end;        /* buttons stay bottom-aligned as textarea grows */
  gap: 12px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}
#page-messaging .mc-input-area.mc-editing-mode {
  background: rgba(201,168,76,0.08);
  border-top-color: var(--gold);
}

#page-messaging .mc-icon-btn {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 16px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
#page-messaging .mc-icon-btn:hover {
  color: var(--gold);
  background: var(--surface2);
}
#page-messaging .mc-icon-btn.mc-recording {
  color: #E05252;
  animation: mcPulse 1s infinite;
}
@keyframes mcPulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

#page-messaging #mc-msg-input {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 10px 18px;
  font-family: 'Lexend', sans-serif;
  font-size: 13.5px;
  line-height: 1.45;
  outline: none;
  color: var(--text);
  /* Multiline auto-grow composer */
  resize: none;                 /* hide manual resize handle */
  overflow-y: auto;             /* internal scroll once max height reached */
  min-height: 42px;             /* single-line resting height */
  max-height: 132px;            /* ~5–6 lines, then scrolls internally */
  box-sizing: border-box;
  display: block;
  /* transition colours only — never height, so growth is instant/smooth */
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s;
}
#page-messaging #mc-msg-input::placeholder { color: var(--text3); }
#page-messaging #mc-msg-input:focus {
  background: var(--card);
  border-color: rgba(143,117,168,0.5);
  box-shadow: 0 0 0 3px rgba(143,117,168,0.1);
}
#page-messaging #mc-msg-input::-webkit-scrollbar { width: 4px; }
#page-messaging #mc-msg-input::-webkit-scrollbar-thumb {
  background: rgba(201,168,76,0.25);
  border-radius: 2px;
}

#page-messaging .mc-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #8F75A8;
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(143,117,168,0.35);
  transition: all 0.2s;
  flex-shrink: 0;
  padding-right: 2px;
}
#page-messaging .mc-send-btn:hover {
  transform: scale(1.06);
  background: #7A6293;
}

/* ── PINNED SIDEBAR ──────────────────────────── */
#page-messaging .mc-pinned-panel {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 300px;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
  z-index: 90;
  display: flex;
  flex-direction: column;
  padding: 20px;
  box-sizing: border-box;
  border-left: 1px solid var(--border);
}
#page-messaging .mc-pinned-panel.open {
  transform: translateX(0);
}

#page-messaging .mc-pinned-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
#page-messaging .mc-pinned-head h3 {
  margin: 0;
  font-size: 12px;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}
#page-messaging .mc-pinned-close {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s;
}
#page-messaging .mc-pinned-close:hover {
  color: var(--text);
  background: var(--surface2);
}

#page-messaging .mc-pinned-list {
  flex: 1;
  overflow-y: auto;   /* ← independent scroll zone 3 */
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;      /* ← must be 0, not auto */
}
#page-messaging .mc-pinned-list::-webkit-scrollbar { width: 3px; }
#page-messaging .mc-pinned-list::-webkit-scrollbar-thumb {
  background: rgba(201,168,76,0.2);
  border-radius: 2px;
}

#page-messaging .mc-pinned-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 12.5px;
  transition: all 0.2s;
  position: relative;
}
#page-messaging .mc-pinned-item:hover {
  background: var(--card);
  transform: translateY(-1px);
  border-color: rgba(201,168,76,0.3);
}
#page-messaging .mc-unpin-btn {
  position: absolute;
  top: 8px; right: 8px;
  color: #E05252;
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  transition: opacity 0.2s;
  padding: 2px 4px;
}
#page-messaging .mc-pinned-item:hover .mc-unpin-btn { opacity: 1; }

/* ── CONTEXT MENU (fixed position) ───────────── */
.mc-context-menu {
  position: fixed;
  background: var(--card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  padding: 6px 0;
  min-width: 175px;
  display: none;
  z-index: 9000;
}
.mc-context-menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mc-context-menu li {
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  transition: background 0.15s;
  font-family: 'Lexend', sans-serif;
}
.mc-context-menu li i {
  width: 15px;
  text-align: center;
  opacity: 0.65;
  font-size: 13px;
  flex-shrink: 0;
}
.mc-context-menu li:hover {
  background: var(--surface2);
}
.mc-context-menu li.mc-danger {
  color: #E05252;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 10px;
}
.mc-context-menu li.mc-danger i { opacity: 1; }

/* ── EMOJI PICKER (fixed position) ───────────── */
.mc-emoji-picker {
  position: fixed;
  display: none;
  padding: 8px;
  z-index: 9001;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.mc-emoji-list {
  display: flex;
  gap: 3px;
}
.mc-emoji-list span {
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.2s;
}
.mc-emoji-list span:hover {
  background: var(--surface2);
  transform: scale(1.2);
}

/* ── MODALS (fixed position) ─────────────────── */
.mc-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 8000;
}
.mc-modal-overlay.open {
  display: flex;
}
.mc-modal-box {
  width: 380px;
  max-width: 92%;
  background: var(--card);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: mcFadeIn 0.25s ease;
}
.mc-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.mc-modal-header h3 {
  margin: 0;
  font-size: 15px;
  color: var(--text);
  font-weight: 600;
}
.mc-modal-close {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--text3);
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s;
}
.mc-modal-close:hover {
  color: var(--text);
  background: var(--surface2);
}
.mc-modal-input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: 'Lexend', sans-serif;
  font-size: 13.5px;
  outline: none;
  color: var(--text);
  box-sizing: border-box;
  transition: all 0.2s;
}
.mc-modal-input::placeholder { color: var(--text3); }
.mc-modal-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--glow);
}
.mc-modal-create-btn {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  background: #8F75A8;
  color: white;
  border: none;
  font-family: 'Lexend', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(143,117,168,0.3);
}
.mc-modal-create-btn:hover {
  background: #7A6293;
  transform: translateY(-1px);
}

.mc-forward-list {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mc-forward-list::-webkit-scrollbar { width: 3px; }
.mc-forward-list::-webkit-scrollbar-thumb {
  background: rgba(201,168,76,0.2);
  border-radius: 2px;
}
.mc-forward-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}
.mc-forward-item:hover {
  background: var(--surface2);
  border-color: var(--border);
}

.mc-members-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
  padding: 4px 0;
}
.mc-member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.mc-member-row:hover { background: var(--surface2); }
.mc-member-row input[type="checkbox"] {
  accent-color: var(--gold);
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  cursor: pointer;
}
.mc-member-row label {
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  flex: 1;
}

/* ── MOBILE OVERLAY ──────────────────────────── */
#page-messaging .mc-mobile-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 40;
  backdrop-filter: blur(2px);
}
#page-messaging .mc-mobile-overlay.active { display: block; }

#page-messaging .mc-mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text);
  cursor: pointer;
  padding: 6px;
}

/* ── DARK THEME ADJUSTMENTS ──────────────────── */
.dark #page-messaging .mc-bubble {
  color: #1A1205;
}
.dark #page-messaging .mc-msg-time {
  color: rgba(26,18,5,0.65);
}
.dark .mc-context-menu,
.dark .mc-emoji-picker,
.dark .mc-modal-box {
  box-shadow: 0 10px 50px rgba(0,0,0,0.5);
}

/* ── RESPONSIVE ──────────────────────────────── */
@media (max-width: 900px) {
  #page-messaging .mc-sidebar { width: 260px; }
}
@media (max-width: 700px) {
  #page-messaging .mc-sidebar {
    position: absolute;
    left: -100%;
    top: 0;
    height: 100%;
    z-index: 50;
    transition: left 0.3s ease;
    width: 280px !important;
  }
  #page-messaging .mc-sidebar.mc-open { left: 0; }
  #page-messaging .mc-mobile-menu-btn { display: block; }
  #page-messaging .mc-messages { padding: 16px; }
  #page-messaging .mc-input-area { padding: 12px 16px; }
  #page-messaging .mc-chat-header { padding: 12px 16px; }
}

/* ═══════════════════════════════════════════════
   REPORT CARD BUBBLE (type: 'report')
════════════════════════════════════════════════ */

/* Override bubble padding/bg for report cards */
#page-messaging .mc-bubble.mc-report-bubble {
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  max-width: 320px;
  cursor: default;
}
#page-messaging .mc-bubble.mc-report-bubble:hover {
  box-shadow: none;
}

.mc-report-card {
  border-radius: 18px;
  overflow: hidden;
  background: var(--card, #fff);
  border: 1px solid rgba(201,168,76,0.28);
  box-shadow:
    0 4px 20px rgba(14,43,111,0.10),
    0 1px 4px rgba(0,0,0,0.06);
  width: 300px;
  max-width: 90vw;
  font-family: 'Plus Jakarta Sans', 'Lexend', sans-serif;
}

/* Work Progress image at the top */
.mc-report-img-wrap {
  width: 100%;
  height: 160px;
  overflow: hidden;
  position: relative;
  background: var(--surface2, #f3f3f3);
}
.mc-report-img-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;          /* signals the thumbnail is expandable */
  -webkit-user-drag: none;
  user-drag: none;
  -webkit-user-select: none;
  user-select: none;
  /* pointer-events: auto (default) — click + right-click must reach the image */
}
.mc-report-img-wrap::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(14,43,111,0.18) 100%);
  pointer-events: none;
}

/* Card body */
.mc-report-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mc-report-project {
  font-size: 15px;
  font-weight: 800;
  color: #0E2B6F;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.mc-report-stage {
  font-size: 12px;
  font-weight: 600;
  color: var(--text3, #6B7D8E);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.mc-report-times {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: rgba(201,168,76,0.07);
  border: 1px solid rgba(201,168,76,0.18);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 2px 0;
}

.mc-report-time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mc-report-time-label {
  font-size: 11px;
  color: var(--text3, #6B7D8E);
  font-weight: 500;
}

.mc-report-time-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text, #1D2B3C);
  font-variant-numeric: tabular-nums;
}

.mc-report-meta {
  font-size: 11px;
  color: var(--text3, #6B7D8E);
  font-weight: 400;
  margin-top: 2px;
}

/* "Checked by Janab" tag (shown to student after admin marks) */
.mc-report-checked-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 20px;
  background: rgba(34,197,94,0.12);
  border: 1px solid rgba(34,197,94,0.3);
  color: #16a34a;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.1px;
  margin-top: 4px;
  align-self: flex-start;
}

/* "Mark Checked" button (shown to admin) */
.mc-report-mark-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  background: #0E2B6F;
  color: #E7C98F;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  border: none;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s, transform 0.18s;
}
.mc-report-mark-btn:hover {
  background: #0A1D4F;
  transform: translateY(-1px);
}
.mc-report-mark-btn:active { transform: none; }

/* Dark mode adjustments */
html.dark .mc-report-card {
  background: var(--card);
  border-color: rgba(201,168,76,0.2);
}
html.dark .mc-report-project { color: #8BAAF0; }
html.dark .mc-report-mark-btn { background: #1A3880; }

/* ═══════════════════════════════════════════════
   AVATAR — images in chat sidebar & messages
════════════════════════════════════════════════ */

/* Sidebar DM avatar when a profile pic exists */
#page-messaging .mc-avatar-img-wrap {
  overflow: hidden;
  padding: 0;
}
#page-messaging .mc-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  -webkit-user-drag: none;
  user-drag: none;
  pointer-events: none;
}

/* Header avatar (beside conv name) */
.mc-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
}
.mc-header-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  -webkit-user-drag: none;
  pointer-events: none;
}
.mc-header-avatar-init {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: rgba(201,168,76,0.18);
  color: var(--gold);
  font-size: 15px;
  font-weight: 700;
  border-radius: 50%;
}
.mc-header-avatar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: rgba(143,117,168,0.15);
  color: #8F75A8;
  font-size: 15px;
  border-radius: 50%;
}

/* Per-message sender avatar (non-own messages only) */
.mc-msg-sender-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  align-self: flex-end;
  object-fit: cover;
  -webkit-user-drag: none;
  pointer-events: none;
}
.mc-msg-sender-initial {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(201,168,76,0.18);
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
}

/* ═══════════════════════════════════════════════
   STUDENT PICKER MODAL (New Conversation)
════════════════════════════════════════════════ */

/* Wider box for the student picker */
.mc-picker-box {
  width: 440px;
  max-width: 95vw;
  gap: 10px;
}

.mc-picker-hint {
  font-size: 12.5px;
  color: var(--text3);
  margin: 0;
  line-height: 1.5;
}

/* Scrollable student list */
.mc-picker-list {
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 0;
  margin: 0 -4px;
}
.mc-picker-list::-webkit-scrollbar { width: 4px; }
.mc-picker-list::-webkit-scrollbar-thumb {
  background: rgba(201,168,76,0.25);
  border-radius: 3px;
}

.mc-picker-empty {
  padding: 24px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
}

/* Individual student row */
.mc-picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  border-radius: 13px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}
.mc-picker-row:hover {
  background: var(--surface2);
  border-color: var(--border);
}
.mc-picker-row.selected {
  background: rgba(201,168,76,0.10);
  border-color: rgba(201,168,76,0.4);
}

/* Check indicator (visible when selected) */
.mc-picker-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 9px;
  color: transparent;
  background: var(--surface);
  transition: all 0.15s;
}
.mc-picker-row.selected .mc-picker-check {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
}

/* Student profile picture */
.mc-picker-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  -webkit-user-drag: none;
  pointer-events: none;
  display: block;
}
.mc-picker-avatar-initial {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(201,168,76,0.15);
  color: var(--gold);
  font-size: 16px;
  font-weight: 700;
}

.mc-picker-info {
  flex: 1;
  min-width: 0;
}
.mc-picker-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mc-picker-username {
  font-size: 11.5px;
  color: var(--text3);
  margin-top: 1px;
}

/* Footer shown when 2+ selected (group creation) */
.mc-picker-footer {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mc-picker-sel-label {
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
  line-height: 1.4;
}

/* Dark mode for picker */
.dark .mc-picker-row:hover { background: rgba(255,255,255,0.06); }
.dark .mc-picker-row.selected { background: rgba(201,168,76,0.12); }

/* ═══════════════════════════════════════════════
   CHAT — BRANCH / CLASS META IN SIDEBAR & HEADER
════════════════════════════════════════════════ */

/* Sub-line in sidebar conversation items */
.mc-conv-branch {
  font-size: 10.5px;
  color: var(--text3);
}
.mc-conv-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 10.5px;
  color: var(--text3);
  line-height: 1.3;
  margin-top: 1px;
}
/* The .mc-conv-sub sits below .mc-conv-meta */
#page-messaging .mc-conv-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}
#page-messaging .mc-conv-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#page-messaging .mc-conv-sub {
  font-size: 11.5px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Header subtitle line can hold HTML (branch · class badge) */
#page-messaging #mc-header-sub {
  font-size: 12px;
  color: var(--text3);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════
   CHAT IMAGE — standardized container
════════════════════════════════════════════════ */

/* Fixed-size container; image scales to fit proportionally */
#page-messaging .mc-img-wrap {
  position: relative;
  width: 280px;
  max-width: 100%;
  background: var(--surface2);
  border-radius: 12px;
  overflow: hidden;
  line-height: 0;
}
#page-messaging .mc-chat-img {
  display: block;
  width: 280px;
  max-width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: 12px;
  cursor: zoom-in;
  transition: opacity 0.15s;
}
#page-messaging .mc-chat-img:hover { opacity: 0.92; }

/* Remove old auto-sizing rules */
#page-messaging .mc-bubble.mc-image-bubble img {
  border-radius: 12px;
  width: 280px;
  max-width: 100%;
  max-height: 260px;
  height: auto;
  object-fit: contain;
  display: block;
}

/* ── Edit & Reply button — larger ───────────── */
#page-messaging .mc-img-edit {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(14,43,111,0.82);
  color: #E7C98F;
  border: 1.5px solid rgba(231,201,143,0.35);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  transition: transform 0.18s, background 0.18s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
#page-messaging .mc-img-edit:hover {
  background: rgba(14,43,111,1);
  transform: scale(1.12);
}

/* ═══════════════════════════════════════════════
   FULLSCREEN IMAGE VIEWER
════════════════════════════════════════════════ */

.mc-img-viewer {
  position: fixed;
  inset: 0;
  z-index: 12000;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  animation: mcViewerFadeIn 0.22s ease;
  cursor: zoom-out;
}
.mc-img-viewer.open {
  display: flex;
}
@keyframes mcViewerFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.mc-img-viewer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 56px 24px 24px;
  box-sizing: border-box;
  overflow: hidden;
}

.mc-img-viewer-img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  /* cursor is managed entirely by JS (_mcViewerApplyTransform) */
  transform-origin: center center;
  /* transition is overridden by JS during drag and wheel events */
  transition: transform 0.12s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  animation: mcViewerImgPop 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes mcViewerImgPop {
  from { transform: scale(0.88); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.mc-img-viewer-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1;
  transition: background 0.18s, transform 0.18s;
}
.mc-img-viewer-close:hover {
  background: rgba(255,255,255,0.25);
  transform: scale(1.08);
}

/* ═══════════════════════════════════════════════
   READ RECEIPT CHECKMARKS — smooth, role-coloured
════════════════════════════════════════════════ */

/* Base status icon — sits inline after the timestamp */
.mc-status-icon {
  display: inline-block;
  margin-left: 4px;
  font-size: 13px;          /* slightly larger for legibility */
  vertical-align: -1px;
  transition: color 0.35s ease, opacity 0.35s ease;
}

/* Single tick — sent, neutral */
.mc-status-sent {
  opacity: 0.45;
  color: inherit;
}

/* Double tick — delivered, neutral */
.mc-status-delivered {
  opacity: 0.55;
  color: inherit;
}

/* Double tick — read, distinctive blue */
.mc-status-read {
  opacity: 1;
  color: #2F9EDE;
}

/* Keep dark-mode bubbles legible */
.dark #page-messaging .mc-status-read {
  color: #5BB8F5;
}

/* ═══════════════════════════════════════════════
   REPORTS VIEW
   Slides over the message area when opened.
   position:absolute inside position:relative .mc-chat-area.
════════════════════════════════════════════════ */

#page-messaging .mc-reports-view {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: var(--surface, var(--card));
  display: flex;
  flex-direction: column;
  /* slide in from right */
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  /* sit above mc-messages but below the global modals/viewer */
}
#page-messaging .mc-reports-view.open {
  transform: translateX(0);
  pointer-events: all;
}

/* Header row: Back button + title */
#page-messaging .mc-reports-view-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2, var(--card));
  flex-shrink: 0;
}
#page-messaging .mc-reports-back-btn {
  background: none;
  border: none;
  color: var(--gold);
  font-family: 'Lexend', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 8px;
  transition: background 0.15s;
}
#page-messaging .mc-reports-back-btn:hover {
  background: rgba(201,168,76,0.1);
}
#page-messaging .mc-reports-view-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

/* Scrollable list */
#page-messaging .mc-reports-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
#page-messaging .mc-reports-list::-webkit-scrollbar { width: 4px; }
#page-messaging .mc-reports-list::-webkit-scrollbar-thumb {
  background: rgba(201,168,76,0.25);
  border-radius: 3px;
}

/* Individual report entry (message element + jump button) */
#page-messaging .mc-reports-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
#page-messaging .mc-reports-item:last-child {
  border-bottom: none;
}

/* Jump-to-message button */
#page-messaging .mc-reports-jump-btn {
  align-self: flex-end;
  background: none;
  border: 1px solid var(--border);
  color: var(--text3);
  font-family: 'Lexend', sans-serif;
  font-size: 12px;
  padding: 5px 14px;
  border-radius: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s;
}
#page-messaging .mc-reports-jump-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(201,168,76,0.06);
}

/* Empty state when no reports exist */
#page-messaging .mc-reports-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--text3);
  font-size: 13.5px;
  line-height: 1.7;
}

/* Reports button active state */
#page-messaging #mc-reports-btn.active {
  background: rgba(201,168,76,0.12);
  border-color: var(--gold);
  color: var(--gold);
}

/* ─── Message highlight animation (jump-to + notif scroll) ─── */
@keyframes mc-highlight-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(201,168,76,0.55), inset 0 0 0 2px rgba(201,168,76,0.35); background: rgba(201,168,76,0.18); }
  60%  { box-shadow: 0 0 0 8px rgba(201,168,76,0), inset 0 0 0 2px rgba(201,168,76,0.35); background: rgba(201,168,76,0.08); }
  100% { box-shadow: none; background: transparent; }
}
.mc-msg-wrap.mc-msg-highlight .mc-bubble {
  animation: mc-highlight-pulse 2.2s ease forwards;
  border-radius: 16px;
}
