/* PROSPER Messages (Phase 5b) — extends styles.css + the chat surface look.
   Only the rules this page needs; shared tokens/classes come from styles.css
   and chat.css conventions. */

.msg-badge {
  display: inline-block;
  min-width: 1.25rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: var(--ice, #7fd4ff);
  color: #04121f;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  vertical-align: middle;
}

.msg-shell { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.msg-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; justify-content: space-between; margin-bottom: 1rem; }
.msg-head h1 { margin: 0.25rem 0; }
.msg-head-actions { display: flex; gap: 0.5rem; }
.msg-gate { max-width: 640px; }

.msg-layout { display: grid; grid-template-columns: 320px 1fr; gap: 1rem; align-items: start; }
@media (max-width: 820px) { .msg-layout { grid-template-columns: 1fr; } }

.msg-tabs { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.msg-tab {
  flex: 1; padding: 0.45rem 0.5rem; border-radius: 0.6rem; cursor: pointer;
  border: 1px solid var(--line, #28455e); background: transparent; color: inherit; font: inherit;
}
.msg-tab.is-active { border-color: var(--ice, #7fd4ff); background: rgba(127, 212, 255, 0.08); }

.msg-search { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.msg-search input { flex: 1; }

.msg-list { display: flex; flex-direction: column; gap: 0.35rem; max-height: 62vh; overflow-y: auto; }
.msg-list-empty { padding: 0.5rem 0.25rem; }
.msg-conv-item {
  display: flex; gap: 0.6rem; align-items: center; width: 100%; text-align: left;
  padding: 0.55rem 0.6rem; border-radius: 0.7rem; cursor: pointer;
  border: 1px solid transparent; background: transparent; color: inherit; font: inherit;
}
.msg-conv-item:hover { border-color: var(--line, #28455e); }
.msg-conv-item.is-active { border-color: var(--ice, #7fd4ff); background: rgba(127, 212, 255, 0.07); }
.msg-conv-item .msg-conv-meta { flex: 1; min-width: 0; }
.msg-conv-item .msg-conv-name { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-conv-item .msg-conv-last { display: block; font-size: 0.82rem; opacity: 0.75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-conv-item .msg-conv-side { display: flex; flex-direction: column; align-items: end; gap: 0.2rem; }
.msg-conv-item .msg-conv-time { font-size: 0.72rem; opacity: 0.6; }

.msg-avatar {
  flex: none; width: 2.4rem; height: 2.4rem; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(127, 212, 255, 0.12); border: 1px solid var(--line, #28455e);
  font-size: 1.15rem; overflow: hidden;
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

.msg-search-results { margin-top: 0.75rem; border-top: 1px solid var(--line, #28455e); padding-top: 0.75rem; }
.msg-search-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.msg-search-hit { display: block; width: 100%; text-align: left; padding: 0.45rem 0.5rem; border-radius: 0.5rem; border: 1px solid transparent; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.msg-search-hit:hover { border-color: var(--line, #28455e); }
.msg-search-hit .hit-where { font-size: 0.75rem; opacity: 0.65; display: block; }

.msg-view-panel { min-height: 50vh; }
.msg-empty { padding: 3rem 1rem; text-align: center; }
.msg-conv-head { display: flex; gap: 0.7rem; align-items: center; padding-bottom: 0.75rem; border-bottom: 1px solid var(--line, #28455e); }
.msg-conv-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.msg-conv-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-conv-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.msg-request-banner, .msg-invite-banner {
  margin: 0.75rem 0; padding: 0.7rem 0.9rem; border-radius: 0.7rem;
  border: 1px solid var(--ice, #7fd4ff); background: rgba(127, 212, 255, 0.07);
}
.msg-request-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }

.msg-stream { display: flex; flex-direction: column; gap: 0.9rem; max-height: 58vh; overflow-y: auto; padding: 1rem 0.25rem; }
.msg-pending-note { margin: 0.5rem 0; }

/* Message rows reuse the .chat-msg shape from chat.css conventions. */
.msg-row { display: flex; gap: 0.6rem; }
.msg-row .msg-avatar { width: 2rem; height: 2rem; font-size: 0.95rem; }
.msg-body-wrap { flex: 1; min-width: 0; }
.msg-meta { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }
.msg-author { font-weight: 600; }
.msg-time { font-size: 0.72rem; opacity: 0.6; }
.msg-edited { font-size: 0.72rem; opacity: 0.6; font-style: italic; }
.msg-text { margin: 0.15rem 0 0; white-space: pre-wrap; word-break: break-word; }
.msg-menu-wrap { position: relative; flex: none; }
.msg-menu-btn {
  border: 1px solid transparent; background: transparent; color: inherit; cursor: pointer;
  border-radius: 0.45rem; padding: 0.1rem 0.45rem; font-size: 1rem; line-height: 1.2; opacity: 0.65;
}
.msg-menu-btn:hover, .msg-menu-btn:focus-visible { opacity: 1; border-color: var(--line, #28455e); }
.msg-menu {
  position: absolute; right: 0; top: calc(100% + 0.25rem); z-index: 30; min-width: 10rem;
  display: flex; flex-direction: column; padding: 0.3rem; border-radius: 0.6rem;
  border: 1px solid var(--line, #28455e); background: var(--panel, #0d1b29);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.msg-menu button {
  text-align: left; padding: 0.45rem 0.6rem; border: none; background: transparent; color: inherit;
  font: inherit; border-radius: 0.4rem; cursor: pointer;
}
.msg-menu button:hover { background: rgba(127, 212, 255, 0.1); }
.msg-edit-box { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.3rem; }
.msg-edit-box textarea { width: 100%; }
.msg-edit-actions { display: flex; gap: 0.5rem; }

/* Modals */
.msg-modal-backdrop {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: rgba(2, 8, 16, 0.72); padding: 1rem;
}
.msg-modal { width: min(560px, 100%); max-height: 88vh; overflow-y: auto; }
.msg-modal label { display: block; margin: 0.6rem 0; }
.msg-modal label input, .msg-modal label textarea { width: 100%; margin-top: 0.25rem; }
.msg-modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.msg-field-label { display: block; margin-top: 0.6rem; font-weight: 600; }

.msg-icon-picker { display: flex; gap: 0.45rem; flex-wrap: wrap; margin: 0.4rem 0 0.6rem; }
.msg-icon-choice {
  width: 2.6rem; height: 2.6rem; border-radius: 50%; font-size: 1.25rem; cursor: pointer;
  border: 1px solid var(--line, #28455e); background: rgba(127, 212, 255, 0.08); color: inherit;
}
.msg-icon-choice.is-selected { border-color: var(--ice, #7fd4ff); background: rgba(127, 212, 255, 0.2); }

.msg-picker-list { display: flex; flex-direction: column; gap: 0.3rem; margin: 0.5rem 0; }
.msg-picker-item { display: flex; gap: 0.6rem; align-items: center; padding: 0.45rem 0.5rem; border-radius: 0.6rem; border: 1px solid var(--line, #28455e); }
.msg-picker-item .grow { flex: 1; min-width: 0; }
.msg-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0.4rem 0; }
.msg-chip {
  display: inline-flex; gap: 0.35rem; align-items: center; padding: 0.2rem 0.55rem; border-radius: 999px;
  border: 1px solid var(--ice, #7fd4ff); background: rgba(127, 212, 255, 0.08); font-size: 0.85rem;
}
.msg-chip button { border: none; background: transparent; color: inherit; cursor: pointer; font: inherit; padding: 0; }
.member-state { font-size: 0.72rem; padding: 0.1rem 0.45rem; border-radius: 999px; border: 1px solid var(--line, #28455e); opacity: 0.85; }

/* Composer — messages.html never loaded chat.css, so this form rendered
   with browser defaults (white textarea, cramped). Self-contained dark
   styling, deliberately roomier: taller input, generous padding, clear
   separation from the thread above and the rules note below. */
.chat-composer { border-top: 1px solid var(--line-soft); padding-top: 1.25rem; margin-top: 1.1rem; }
.chat-composer textarea {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 4.5rem;
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--line);
  border-radius: 14px; padding: 0.95rem 1.05rem; font: inherit; line-height: 1.55;
}
.chat-composer textarea:focus { outline: 2px solid var(--sapphire); outline-offset: 1px; }
.chat-composer textarea:disabled { opacity: 0.55; }
.chat-composer-side { display: flex; align-items: center; gap: 1rem; margin-top: 0.9rem; }
.chat-count { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chat-count.over { color: var(--err); font-weight: 700; }
.chat-rules-note { margin-top: 1.15rem; line-height: 1.65; }

/* Message-row alignment (owner fix): the avatar, the author line and the
   body now share one grid: a fixed 40px circular avatar (any source image
   is cover-cropped to it), a header line exactly the avatar's height with
   its contents vertically centered, and the text aligned under the author.
   The <p> UA margins that pushed the name off the avatar's line are reset. */
.msg-row { align-items: flex-start; gap: 0.75rem; }
.msg-row .msg-avatar {
  width: 2.5rem; height: 2.5rem; flex: none; border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center; font-size: 1.05rem;
  border: 1px solid var(--ice-mid, #28455e); background: rgba(127, 212, 255, 0.08);
}
.msg-row .msg-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.msg-meta { margin: 0; min-height: 2.5rem; align-items: center; align-content: center; column-gap: 0.55rem; }
.msg-text { margin: 0.25rem 0 0; line-height: 1.55; }
.msg-menu-wrap { margin-top: 0.4rem; }

/* Symbol profile pictures (design/09). */
.msg-avatar-symbol { line-height: 1; }
