/* ================================================================
   chat.css — Mejoras del chat (avatares, agrupación, admin, enlaces)
   Se carga DESPUÉS de styles.css, así que sus reglas tienen prioridad.
================================================================ */

/* Evita que la página entera scrollee — el scroll es solo dentro de .chat-messages */
html, body { overflow: hidden !important; height: 100% !important; }
.page-wrapper { height: 100vh; overflow: hidden; }
.chat-sidebar { min-height: 0; }

/* ── Mensaje en fila: avatar + cuerpo ── */
.chat-msg {
  flex-direction: row;
  align-items: flex-end;
  gap: .5rem;
  max-width: 82%;
}
.chat-msg.chat-me { flex-direction: row-reverse; align-self: flex-end; }
.chat-msg.grouped { margin-top: -.4rem; }

.chat-msg-body {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: .2rem; min-width: 0;
}
.chat-me .chat-msg-body { align-items: flex-end; }

/* ── Avatar ── */
.chat-avatar {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-u); font-weight: 800; font-size: .78rem;
  color: #fff; background: var(--avc, #3a3a55);
  box-shadow: 0 2px 8px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(255,255,255,0.18);
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  user-select: none; align-self: flex-end; margin-bottom: 2px;
}
.chat-avatar-spacer { background: transparent !important; box-shadow: none !important; }
.chat-msg-admin .chat-avatar {
  box-shadow: 0 0 0 2px var(--gold), 0 2px 10px rgba(245,200,66,0.4),
              inset 0 0 0 1px rgba(255,255,255,0.18);
}

/* ── Distintivo ADMIN ── */
.chat-admin-badge {
  font-size: .55rem; font-weight: 800; letter-spacing: .06em;
  color: #0b0b16; text-transform: uppercase;
  background: linear-gradient(135deg, var(--gold), #ffe7a0);
  border-radius: 6px; padding: .06rem .35rem;
  box-shadow: 0 1px 4px rgba(245,200,66,0.4);
}

/* ── Burbuja de admin (también para sus propios mensajes) ── */
.chat-bubble-admin {
  background: linear-gradient(135deg, rgba(245,200,66,0.12), rgba(245,200,66,0.04)) !important;
  border-color: rgba(245,200,66,0.45) !important;
  box-shadow: 0 2px 16px rgba(245,200,66,0.14) !important;
}

/* ── Enlaces dentro de mensajes ── */
.chat-link { color: #8ab4ff; text-decoration: underline; word-break: break-all; }
.chat-link:hover { color: #b9d1ff; }
.chat-me .chat-link { color: #d3e2ff; }

/* ── Menciones @usuario ── */
.chat-mention {
  display: inline-block;
  background: rgba(88, 101, 242, 0.22);
  color: #a5aeff;
  border-radius: 4px;
  padding: 0 .28rem;
  font-weight: 700;
  font-size: .92em;
  cursor: default;
}
.chat-mention-me {
  background: rgba(250, 197, 21, 0.22);
  color: #fcd34d;
}

/* ── Mensaje que menciona al usuario actual ── */
.chat-msg-mentioned .chat-bubble {
  border-left: 3px solid rgba(250, 197, 21, 0.7) !important;
  background: rgba(250, 197, 21, 0.06) !important;
}
.chat-msg-mentioned.chat-me .chat-bubble {
  border-left: none !important;
  border-right: 3px solid rgba(250, 197, 21, 0.7) !important;
}

/* ── Dropdown de autocomplete de menciones ── */
.mention-dropdown {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0; right: 0;
  background: #1a1a2e;
  border: 1px solid rgba(88, 101, 242, 0.4);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
  z-index: 20;
  max-height: 220px;
  overflow-y: auto;
}
.mention-dropdown[hidden] { display: none; }

.mention-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .8rem;
  cursor: pointer;
  font-size: .82rem;
  transition: background .12s;
  color: #c8c8e0;
}
.mention-item:hover,
.mention-item.active {
  background: rgba(88, 101, 242, 0.18);
  color: #fff;
}
.mention-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--avc, #3a3a55);
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem; font-weight: 800; color: #fff;
}

/* ── Botón flotante "nuevos mensajes" ── */
.chat-scroll-down {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%);
  z-index: 4;
  display: inline-flex; align-items: center; gap: .3rem;
  background: linear-gradient(135deg, var(--blue), #0a2fc4);
  color: #fff; border: none; border-radius: 22px;
  padding: .42rem 1rem; font-size: .74rem; font-weight: 700;
  font-family: var(--font-u); letter-spacing: .02em; cursor: pointer;
  box-shadow: 0 6px 18px rgba(26,79,255,0.45);
  animation: sdIn .25s ease both;
}
.chat-scroll-down[hidden] { display: none; }
.chat-scroll-down:hover { filter: brightness(1.12); transform: translateX(-50%) translateY(-1px); }
@keyframes sdIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translateX(-50%); }
}

/* ── Contador de caracteres en modo admin ── */
.chat-char-admin { color: var(--gold) !important; font-weight: 700; }

/* ── Responsive ── */
@media (max-width: 480px) {
  .chat-msg { max-width: 92%; gap: .4rem; }
  .chat-avatar { width: 30px; height: 30px; font-size: .72rem; }
  .chat-scroll-down { bottom: 90px; font-size: .7rem; padding: .38rem .85rem; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-scroll-down { animation: none; }
}
