/* ==========================================================================
   Stellion — Messages (liste mobile) et nouvelle conversation
   Maquettes : Messages, NouveauMessage. La conversation ouverte : css/chat.css.
   ========================================================================== */

/* Panneau plein écran sous la barre du bas ; affiché par le JS (style.display) */
.st-messages {
  position: fixed;
  inset: 0;
  bottom: 0;
  z-index: 440;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

@media (min-width: 769px) {
  .st-messages {
    display: none;
  }
}

.st-messages__head {
  flex-shrink: 0;
  height: 60px;
  padding: 0 var(--space-2) 0 var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.st-messages__title {
  margin: 0;
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-title);
}

.st-messages__head > .st-icon-btn {
  border-radius: var(--radius-lg);
}

.st-messages__search {
  flex-shrink: 0;
  margin: 0 var(--space-4);
  border-radius: var(--radius-md);
}

/* Amis en ligne */
.st-messages__actifs {
  flex-shrink: 0;
  padding: var(--space-4) var(--space-4) var(--space-1);
  display: flex;
  gap: var(--space-4);
  overflow-x: auto;
  scrollbar-width: none;
}

.st-messages__actifs[hidden] {
  display: none;
}

.st-messages__actif {
  width: 60px;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--text);
  font: inherit;
  letter-spacing: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.st-messages__actif:hover {
  filter: none;
  transform: none;
  box-shadow: none;
}

.st-messages__actif > .st-avatar {
  --avatar-size: 56px;
}

.st-messages__actif > span:last-child {
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-xs);
}

.st-messages__filters {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-4) var(--space-2);
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
}

.st-messages__req-dot {
  width: 8px;
  height: 8px;
}

.st-messages__req-dot[hidden] {
  display: none;
}

.st-chip[aria-pressed="true"] .st-messages__req-dot {
  background: var(--on-accent);
}

.st-messages__list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: calc(var(--nav-space) + var(--space-4));
}

.st-messages__label {
  margin: 0;
  padding: var(--space-3) var(--space-4) var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ---------- Une conversation ---------- */

.st-conv {
  width: 100%;
  min-height: 72px;
  margin: 0;
  padding: 0 var(--space-4);
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--text);
  font: inherit;
  letter-spacing: 0;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  cursor: pointer;
}

.st-conv:hover {
  background: var(--hover-row);
  filter: none;
  transform: none;
  box-shadow: none;
}

.st-conv > .st-avatar,
.st-conv > .st-avatar-group {
  --avatar-size: var(--avatar-lg);
}

.st-conv__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.st-conv__top,
.st-conv__bottom {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.st-conv__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
}

.st-conv__time {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: var(--text-muted);
}

.st-conv__preview {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.st-conv__empty {
  font-style: italic;
}

.st-conv.is-unread .st-conv__name {
  font-weight: var(--weight-bold);
}

.st-conv.is-unread .st-conv__preview {
  color: var(--text);
  font-weight: var(--weight-medium);
}

.st-conv.is-unread .st-conv__time {
  color: var(--accent-text);
}

/* ---------- Demandes ---------- */

.st-request {
  margin: 0 var(--space-3) var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.st-request--row {
  flex-direction: row;
  align-items: center;
}

.st-request__who {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: var(--space-1);
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  box-shadow: none;
  color: var(--text);
  font: inherit;
  letter-spacing: 0;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  cursor: pointer;
}

.st-request__who:hover {
  background: var(--surface-2);
  filter: none;
  transform: none;
  box-shadow: none;
}

.st-request__msg {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  overflow-wrap: anywhere;
}

.st-request__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.st-request__actions > .st-btn--primary {
  flex: 1;
}

/* ---------- Nouvelle conversation ---------- */

.st-newconv {
  height: min(760px, calc(100dvh - var(--space-8)));
}

.st-newconv__to {
  flex-shrink: 0;
  min-height: 48px;
  margin: 0 var(--space-4);
  padding: 6px var(--space-2);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.st-newconv__to:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.st-newconv__to-label {
  padding: 0 6px;
  font-size: var(--text-md);
  color: var(--text-muted);
}

.st-newconv__chips {
  display: contents;
}

.st-newconv__chip {
  width: auto;
  min-height: 32px;
  margin: 0;
  padding: 0 6px 0 var(--space-1);
  border: 0;
  border-radius: var(--radius-full);
  background: var(--surface);
  box-shadow: none;
  color: var(--text);
  font: inherit;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.st-newconv__chip:hover {
  filter: none;
  transform: none;
  box-shadow: none;
}

.st-newconv__chip > .st-avatar {
  --avatar-size: 24px;
}

.st-newconv__to-field {
  flex: 1;
  min-width: 80px;
  display: flex;
}

.st-newconv__to-field > input,
.st-newconv__name > input {
  flex: 1;
  min-width: 0;
  width: auto;
  height: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  outline: none;
  color: var(--text);
  font: inherit;
  font-size: var(--text-base);
}

.st-newconv__name {
  flex-shrink: 0;
  min-height: 48px;
  margin: 10px var(--space-4) 0;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
}

.st-newconv__name[hidden] {
  display: none;
}

.st-newconv__name:focus-within {
  border-color: var(--accent);
}

.st-newconv__label {
  flex-shrink: 0;
  margin: 0;
  padding: 18px var(--space-4) var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.st-newconv__list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 var(--space-2);
}

.st-newconv__foot {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--hairline);
}

/* Colonne des conversations (ordinateur) : mêmes lignes que la liste mobile */
#mp-list .st-conv {
  min-height: 64px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-md);
}

#mp-list .st-conv > .st-avatar,
#mp-list .st-conv > .st-avatar-group {
  --avatar-size: var(--avatar-md);
}

#mp-list .st-conv[aria-current="true"] {
  background: var(--selected);
}

#mp-list .st-conv[hidden] {
  display: none;
}

/* ---------- Colonne des conversations (ordinateur, maquette BureauMessages) ---------- */

.st-convcol__head {
  min-height: 60px;
  padding: 0 var(--space-2) 0 var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.st-convcol__title {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
}

.st-convcol__head > .st-icon-btn {
  border-radius: var(--radius-lg);
}

.st-convcol__search {
  margin: 0 var(--space-3);
  border-radius: var(--radius-md);
}

.st-convcol__tabs {
  padding: var(--space-3) var(--space-3) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.st-convcol__tabs .st-count {
  margin-left: var(--space-1);
}

.st-convcol__friends {
  justify-content: flex-start;
}

.st-convcol__friends > .st-count {
  margin-left: auto;
}

.st-convcol__list {
  flex: 1;
  min-height: 0;
  padding: var(--space-1) var(--space-2);
  overflow-y: auto;
}

.st-convcol__list[hidden] {
  display: none;
}

/* ---------- Panneau utilisateur en bas des colonnes ---------- */

.st-userbar {
  flex-shrink: 0;
  min-height: 60px;
  padding: 0 var(--space-2);
  border-top: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  gap: 2px;
}

.st-userbar__me {
  flex: 1;
  min-width: 0;
  width: auto;
  min-height: var(--tap-min);
  margin: 0;
  padding: 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  box-shadow: none;
  color: var(--text);
  font: inherit;
  letter-spacing: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  cursor: pointer;
}

.st-userbar__me:hover {
  background: var(--surface-2);
  filter: none;
  transform: none;
  box-shadow: none;
}

.st-userbar__avatar {
  position: relative;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
}

.st-userbar__avatar .st-avatar {
  --avatar-size: 32px;
}

.st-userbar__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.st-userbar__bell {
  position: relative;
}

.st-userbar__bell > .st-count {
  position: absolute;
  top: 4px;
  right: 2px;
}

/* Les compteurs affichés par l'ancien code (style.display) partent masqués */
.st-count[hidden] {
  display: none;
}
