/* ============================================================
   Chat en vivo — estilos complementarios
   Usa exclusivamente variables CSS del tema (--accent, --bg-*, etc.)
   Compatible con modo oscuro y claro automáticamente.
   ============================================================ */

/* ── Wrapper de mensajes (posición para el botón flotante) ── */
.chat-messages-wrap {
  position: relative;
  height: 400px;   /* Iguala la altura original de .chat-messages en style.css */
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Sobrescribir altura fija definida en style.css para que ocupe todo el wrap */
.chat-messages-wrap .chat-messages {
  flex: 1 1 0;
  min-height: 0;
  height: 100% !important;   /* Anula el height:400px de style.css */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0 4px;
  scroll-behavior: smooth;
}

@media (max-width: 768px) {
  .chat-messages-wrap {
    height: 280px;   /* Iguala el override del media query de style.css */
  }
}

/* Scrollbar fina al estilo Twitch */
.chat-messages-wrap .chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages-wrap .chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages-wrap .chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* ── Botón "scroll to bottom" ─────────────────────────────── */
.chat-scroll-btn {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
  z-index: 5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-scroll-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.chat-scroll-btn:hover {
  background: var(--accent-hover);
}

/* ── Mensaje individual (estilo Twitch: compacto, sin burbujas) ── */
.chat-message {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 3px;
  padding: 3px 12px;
  line-height: 1.45;
  border-radius: 0;
  background: transparent;
  animation: chatMsgIn 0.12s ease;
}

.chat-message:hover {
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .chat-message:hover {
  background: rgba(0, 0, 0, 0.04);
}

@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Badges de rol ────────────────────────────────────────── */
.chat-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.58rem;
  font-weight: 800;
  padding: 1px 5px 1px;
  border-radius: 3px;
  margin-right: 3px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  flex-shrink: 0;
  vertical-align: baseline;
  line-height: 1.5;
  position: relative;
  top: -1px;
}

.chat-badge-admin {
  background: rgba(239, 68, 68, 0.18);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.chat-badge-spicy {
  background: linear-gradient(135deg,
    rgba(139, 92, 246, 0.22),
    rgba(236, 72, 153, 0.18));
  color: var(--accent);
  border: 1px solid rgba(139, 92, 246, 0.4);
}

/* ── Nombre de usuario coloreado ──────────────────────────── */
.chat-user {
  font-size: 0.82rem;
  font-weight: 700;
  cursor: default;
  flex-shrink: 0;
  color: var(--accent);
}

.chat-user-admin  { color: #ef4444; }
.chat-user-spicy  { color: var(--accent); }
.chat-user-normal {
  /* Color único por usuario, calculado en JS */
  color: inherit;
}

.chat-separator {
  font-size: 0.82rem;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-right: 1px;
}

.chat-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  word-break: break-word;
  line-height: 1.45;
}

/* ── Área de input mejorada ───────────────────────────────── */
.chat-input-area {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-input-wrapper .chat-input {
  flex: 1 1 0;
  min-width: 0;
  cursor: text;
  opacity: 1;
  color: var(--text-primary);
}

.chat-input-wrapper .chat-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Botón enviar */
.chat-send-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.chat-send-btn:hover  { background: var(--accent-hover); }
.chat-send-btn:active { transform: scale(0.92); }

.chat-send-btn:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

/* Contador de caracteres */
.chat-char-count {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 3px;
  transition: color 0.2s;
}

.chat-char-count.warn  { color: #f59e0b; }
.chat-char-count.limit { color: #ef4444; }

/* Prompt de login */
.chat-login-prompt {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 6px 0;
}

.chat-login-prompt a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.chat-login-prompt a:hover {
  text-decoration: underline;
}

/* ── Pill de usuarios online (override) ───────────────────── */
#chat-users {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
}

[data-theme="light"] #chat-users {
  background: rgba(0, 0, 0, 0.05);
}

/* ── Mensaje de sistema (bienvenida, conexión, etc.) ──────── */
.chat-msg-system {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 6px 12px;
  font-style: italic;
}
