/* ===== chat.css — Chat de equipo tipo Slack, adjuntos y llamadas de voz/video ===== */

/* ============================================================
   CHAT (tipo Slack)
   ============================================================ */
.chat-view {
  padding: 12px 24px 16px;
  flex: 1;                 /* llena el alto que deja la topbar dentro de .main */
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.chat-layout {
  flex: 1;                 /* ocupa todo el alto disponible, sin número mágico */
  min-height: 0;
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 16px;
}

/* --- Lista de canales --- */
.chat-channels {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-channels-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; font-size: 12px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--navy-500); border-bottom: 1px solid var(--border);
}
.chat-new-group {
  border: none; background: var(--primary-light); color: var(--primary);
  width: 26px; height: 26px; border-radius: 50%; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all var(--transition);
}
.chat-new-group:hover { background: var(--primary); color: #fff; }
.chat-channel-list { flex: 1; overflow-y: auto; padding: 8px; }
.chat-channel {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--transition); margin-bottom: 2px;
}
.chat-channel:hover { background: var(--paper); }
.chat-channel.active { background: var(--primary); }
.chat-channel.active .chat-channel-name,
.chat-channel.active .chat-channel-meta { color: #fff; }
.chat-channel-name { font-size: 13.5px; font-weight: 700; color: var(--navy-900); display: flex; align-items: center; gap: 6px; }
.chat-channel-meta { font-size: 11px; color: var(--navy-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-channel-tag { font-size: 9.5px; font-weight: 800; text-transform: uppercase; background: var(--yellow-bg); color: #b45309; padding: 1px 6px; border-radius: 999px; }
.chat-channel.active .chat-channel-tag { background: rgba(255,255,255,0.25); color: #fff; }

/* --- Panel de mensajes --- */
.chat-main {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden; min-width: 0;
}
.chat-main-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  font-weight: 800; font-size: 15px; color: var(--navy-900);
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.chat-main-head .chat-head-sub { font-size: 12px; font-weight: 500; color: var(--navy-500); }

.chat-messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.chat-empty { margin: auto; text-align: center; color: var(--navy-500); font-size: 13px; }

.chat-msg { display: flex; gap: 10px; animation: fade-in 220ms ease; }
.chat-msg-body { min-width: 0; flex: 1; }
.chat-msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.chat-msg-author { font-size: 13px; font-weight: 700; color: var(--navy-900); }
.chat-msg-time { font-size: 10.5px; color: var(--navy-500); }
.chat-msg-text { font-size: 13.5px; color: var(--navy-700); line-height: 1.45; word-wrap: break-word; white-space: pre-wrap; }

.chat-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chat-att-img { max-width: 220px; max-height: 200px; border-radius: var(--radius-sm); cursor: pointer; box-shadow: var(--shadow-sm); object-fit: cover; }
.chat-att-video { max-width: 260px; max-height: 220px; border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }
.chat-att-file {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--paper); border-radius: var(--radius-sm); font-size: 12.5px;
  color: var(--navy-700); text-decoration: none; font-weight: 600;
}
.chat-att-file:hover { background: #eef0f5; }

/* --- Composer --- */
.chat-composer { border-top: 1px solid var(--border); padding: 12px 14px; flex-shrink: 0; }
.chat-attach-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chat-attach-preview:empty { display: none; }
.chat-preview-item { position: relative; }
.chat-preview-item img, .chat-preview-item video { width: 60px; height: 60px; object-fit: cover; border-radius: var(--radius-sm); }
.chat-preview-file { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: var(--paper); border-radius: var(--radius-sm); font-size: 11.5px; max-width: 160px; }
.chat-preview-remove {
  position: absolute; top: -6px; right: -6px; background: var(--red); color: #fff;
  border: none; width: 18px; height: 18px; border-radius: 50%; font-size: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.chat-composer-row { display: flex; align-items: center; gap: 8px; }
.chat-icon-btn {
  background: var(--paper); border: 1.5px solid var(--border); width: 40px; height: 40px;
  border-radius: var(--radius-sm); font-size: 17px; cursor: pointer; flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}
.chat-icon-btn:hover { background: var(--primary-light); border-color: var(--primary); }
#chatInput {
  flex: 1; padding: 11px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  font-size: 13.5px; outline: none; transition: border-color var(--transition); min-width: 0;
}
#chatInput:focus { border-color: var(--primary); }
.chat-send-btn { flex-shrink: 0; }

/* Grupos: selección de miembros en el modal */
.group-members { display: flex; flex-direction: column; gap: 6px; }
.group-member-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--paper); border-radius: var(--radius-sm); cursor: pointer;
}
.group-member-row input { width: 16px; height: 16px; accent-color: var(--primary); }
.group-member-row .gm-name { font-size: 13px; font-weight: 600; }

/* --- Botones de llamada en la cabecera del canal --- */
.chat-head-info { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.chat-call-actions { margin-left: auto; display: flex; gap: 8px; flex-shrink: 0; }
.chat-call-icon {
  width: 40px; height: 40px; border-radius: 50%;
  border: none; cursor: pointer;
  background: var(--navy-900); color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}
.chat-call-icon:hover { background: var(--primary); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(79,70,229,0.4); }
.chat-call-icon:active { transform: scale(0.94); }
.chat-call-icon svg { width: 18px; height: 18px; display: block; }

/* --- Modal de videollamada (Jitsi incrustado) --- */
.call-modal {
  background: var(--navy-900);
  border-radius: 16px;
  width: min(960px, 94vw);
  height: min(82vh, 760px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.97);
  opacity: 0;
  transition: transform var(--transition), opacity var(--transition);
}
.call-overlay.open .call-modal { transform: translateY(0) scale(1); opacity: 1; }
.call-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; color: #fff; flex-shrink: 0; gap: 12px;
}
.call-title { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-end-btn { padding: 8px 14px; font-size: 13px; flex-shrink: 0; }
.jitsi-container { flex: 1; min-height: 0; background: #000; }
.jitsi-container iframe { width: 100%; height: 100%; border: 0; }
.call-loading { color: #cbd5e1; display: flex; align-items: center; justify-content: center; height: 100%; font-size: 14px; text-align: center; padding: 20px; }

/* Chat responsive */
@media (max-width: 760px) {
  .chat-view { padding: 10px 14px 12px; }
  /* En móvil: canales arriba (tira corta) y mensajes abajo llenando el resto */
  .chat-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; gap: 10px; }
  .chat-channels { max-height: 30vh; }
  .chat-main { height: auto; }        /* el grid 1fr le da el alto correcto */
  .chat-att-img { max-width: 70vw; }
  .chat-att-video { max-width: 78vw; }
}

