/* ============================================================
   CHAT — Estilos global
   ============================================================ */

#chat-content {
  height: calc(100vh - var(--topbar-h) - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100%;
  gap: 12px;
}

/* ---------- SIDEBAR ---------- */
.chat-sidebar {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,.2);
}

.chat-sidebar-header h2 {
  font-size: 16px;
  color: var(--accent);
  letter-spacing: .5px;
  margin: 0;
}

.chat-nueva-sala-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(128,224,255,.12);
  border: 1px solid rgba(128,224,255,.35);
  color: var(--accent-2);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}

.chat-nueva-sala-btn:hover {
  background: rgba(128,224,255,.25);
  transform: scale(1.08);
}

.chat-grupo {
  padding: 12px 8px;
  overflow-y: auto;
}

.chat-grupo::-webkit-scrollbar { width: 5px; }
.chat-grupo::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

.chat-grupo-titulo {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 800;
  padding: 4px 10px 8px;
}

.chat-sala-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chat-sala-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: all .15s;
  width: 100%;
  position: relative;
}

.chat-sala-item:hover {
  background: rgba(255,255,255,.05);
  border-color: var(--border);
}

.chat-sala-item.miembro {
  background: rgba(128,224,255,.05);
  border-color: rgba(128,224,255,.2);
}

.chat-sala-icono {
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1;
}

.chat-sala-info {
  flex: 1;
  min-width: 0;
}

.chat-sala-nombre {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.chat-sala-meta {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-sala-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  flex-shrink: 0;
}

.chat-tag-vip {
  font-size: 9px;
  font-weight: 800;
  color: var(--gold);
  background: rgba(255,204,68,.15);
  padding: 1px 5px;
  border-radius: 6px;
  margin-left: 4px;
}

.chat-tag-priv {
  font-size: 10px;
  margin-left: 4px;
}

.chat-vacio {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  padding: 12px;
  opacity: .6;
}

/* ---------- PANEL VACÍO ---------- */
.chat-panel-vacio {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-dim);
  text-align: center;
  padding: 40px;
}

.chat-vacio-icon {
  font-size: 72px;
  opacity: .25;
  margin-bottom: 8px;
}

.chat-panel-vacio h3 {
  font-size: 18px;
  color: var(--text);
  margin: 0;
}

.chat-panel-vacio p {
  font-size: 13px;
  max-width: 300px;
  line-height: 1.5;
  margin: 0;
}

/* ---------- PANEL CHAT ---------- */
.chat-panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-panel-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0,0,0,.2);
  flex-shrink: 0;
}

.chat-volver-btn {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
}

.chat-panel-titulo {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-panel-icon {
  font-size: 24px;
  flex-shrink: 0;
  line-height: 1;
}

.chat-panel-nombre {
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-panel-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 1px;
}

.chat-panel-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.chat-action-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}

.chat-action-btn:hover {
  background: rgba(255,255,255,.08);
  color: var(--text);
  border-color: var(--border);
}

/* ---------- MENSAJES ---------- */
.chat-mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,.15) 100%);
  -webkit-overflow-scrolling: touch;
}

.chat-mensajes::-webkit-scrollbar { width: 6px; }
.chat-mensajes::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

.chat-mensajes-vacio {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  text-align: center;
  gap: 8px;
}

.chat-mensajes-vacio p {
  font-size: 13px;
  margin: 0;
}

.chat-fecha-sep {
  text-align: center;
  font-size: 10px;
  color: var(--text-dim);
  padding: 12px 0 6px;
  font-weight: 700;
  letter-spacing: .5px;
  opacity: .7;
}

.chat-msg {
  display: flex;
  gap: 10px;
  padding: 3px 0;
  align-items: flex-start;
  transition: background .15s;
  border-radius: 6px;
}

.chat-msg.mio {
  cursor: pointer;
}

.chat-msg.mio:hover {
  background: rgba(255,255,255,.03);
}

.chat-msg.bloque {
  padding-top: 1px;
}

.chat-msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  overflow: hidden;
}

.chat-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.chat-msg-avatar-spacer {
  visibility: hidden;
}

.chat-msg-body {
  flex: 1;
  min-width: 0;
}

.chat-msg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}

.chat-msg-head b {
  font-size: 13px;
  color: var(--accent-2);
  font-weight: 800;
}

.chat-msg.mio .chat-msg-head b {
  color: var(--gold);
}

.chat-msg-hora {
  font-size: 10px;
  color: var(--text-dim);
  opacity: .7;
}

.chat-msg-texto {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text);
  word-wrap: break-word;
  word-break: break-word;
  white-space: pre-wrap;
}

/* ---------- TYPING ---------- */
.chat-typing-indicator {
  padding: 0 16px;
  height: 0;
  overflow: hidden;
  transition: height .2s, padding .2s;
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chat-typing-indicator.visible {
  height: 22px;
  padding: 2px 16px 4px;
}

.typing-dots {
  display: inline-flex;
  gap: 2px;
}

.typing-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-2);
  animation: typingBounce 1.4s infinite;
}

.typing-dots i:nth-child(2) { animation-delay: .2s; }
.typing-dots i:nth-child(3) { animation-delay: .4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- INPUT ---------- */
.chat-input-bar {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  background: rgba(0,0,0,.2);
  flex-shrink: 0;
}

.chat-input-bar input {
  flex: 1;
  padding: 11px 16px;
  background: rgba(0,0,0,.35);
  border: 1px solid var(--border);
  border-radius: 22px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}

.chat-input-bar input:focus {
  border-color: var(--accent-2);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2), #40a0d0);
  border: none;
  color: #0a0e14;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 14px rgba(128,224,255,.5);
}

.chat-send-btn:active {
  transform: scale(.96);
}

/* ---------- MIEMBROS MODAL ---------- */
.chat-miembros-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 50vh;
  overflow-y: auto;
  margin-top: 10px;
}

.chat-miembro-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(0,0,0,.2);
  border-radius: 8px;
}

.chat-miembro-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  overflow: hidden;
}

.chat-miembro-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.chat-miembro-info { flex: 1; min-width: 0; }
.chat-miembro-nombre {
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-miembro-role {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 1px;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 900px) {
  .chat-layout { grid-template-columns: 260px 1fr; }
}

@media (max-width: 700px) {
  #chat-content {
    height: calc(100dvh - var(--topbar-h) - 20px);
  }

  .chat-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* En móvil, solo se ve un panel a la vez */
  .chat-modo-lista .chat-panel,
  .chat-modo-lista .chat-panel-vacio {
    display: none;
  }

  .chat-modo-chat .chat-sidebar {
    display: none;
  }

  .chat-volver-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .chat-sidebar {
    border-radius: 10px;
  }

  .chat-panel {
    border-radius: 10px;
  }

  .chat-msg-avatar {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  .chat-msg-texto { font-size: 13px; }

  .chat-input-bar input {
    font-size: 16px !important; /* evita zoom iOS */
  }
}

@media (max-width: 400px) {
  .chat-sala-item { padding: 8px 10px; }
  .chat-panel-header { padding: 8px 10px; gap: 8px; }
  .chat-panel-nombre { font-size: 13px; }
}
/* ============================================================
   🆕 Modal invitar
   ============================================================ */
.chat-invite-tab.active { color: var(--accent-2); }
.chat-invite-row:hover { background: rgba(255,255,255,.05) !important; border-color: var(--border-strong) !important; }

@media (max-width: 700px) {
  .chat-invite-tabs { overflow-x: auto; }
  .chat-invite-tab { padding: 8px 12px !important; font-size: 12px !important; white-space: nowrap; }
}

/* 🆕 C2: Salas bloqueadas */
.chat-sala-item.bloqueada {
  opacity: 0.6;
  cursor: not-allowed !important;
}
.chat-sala-item.bloqueada:hover {
  background: rgba(255,85,102,0.05) !important;
  border-color: rgba(255,85,102,0.3) !important;
}
.chat-sala-item.bloqueada .chat-sala-nombre {
  color: var(--text-dim);
}
.chat-tag-lock {
  position: absolute;
  top: 6px;
  right: 8px;
  opacity: 0.9;
}
.chat-nueva-sala-btn.disabled {
  pointer-events: none;
}
