/* admin-chats.css — Estilo del panel admin de chats (estilo WhatsApp) */

.gscadm-wrap {
  display: grid;
  grid-template-columns: 320px 1fr;
  /* Altura controlada por la ventana, dejando margen para nav/header del admin
     y para que el textarea de respuesta SIEMPRE quede visible abajo */
  height: 75vh;
  min-height: 480px;
  max-height: 700px;
  border: 1px solid #e8e0f5;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  font-family: 'Nunito', sans-serif;
}

/* Sidebar (lista) */
.gscadm-side {
  border-right: 1px solid #e8e0f5;
  display: flex;
  flex-direction: column;
  background: #fdf8f9;
  overflow: hidden;
}
.gscadm-side-head {
  padding: 12px 14px;
  border-bottom: 1px solid #e8e0f5;
  background: #fff;
}
.gscadm-filters {
  display: flex; gap: 6px;
  margin-top: 10px;
}
.gscadm-filters button {
  flex: 1; border: 1px solid #e8e0f5; background: #fff;
  color: #5a4a8f; border-radius: 8px; padding: 5px 8px;
  font-size: 11px; cursor: pointer; font-family: inherit;
}
.gscadm-filters button.active {
  background: #7b68b3; color: #fff; border-color: #7b68b3;
}

.gscadm-list {
  flex: 1; overflow-y: auto;
}
.gscadm-item {
  padding: 12px 14px;
  border-bottom: 1px solid #f0e8f5;
  cursor: pointer;
  display: flex; gap: 10px;
  align-items: flex-start;
}
.gscadm-item:hover { background: #f3eef9; }
.gscadm-item.active { background: #e8e0f5; }
.gscadm-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #7b68b3, #5a4a8f);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0; font-size: 14px;
}
.gscadm-item-body { flex: 1; min-width: 0; }
.gscadm-item-name {
  font-weight: 700; color: #3a2f4e; font-size: 14px;
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 2px;
}
.gscadm-item-time { font-size: 11px; color: #8b7fa6; font-weight: 400; }
.gscadm-item-last {
  font-size: 12px; color: #8b7fa6;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gscadm-item-tags { margin-top: 4px; display: flex; gap: 4px; }
.gscadm-tag {
  font-size: 10px; padding: 2px 7px; border-radius: 8px; font-weight: 700;
}
.gscadm-tag.escalado { background: #ffe5b4; color: #b45309; }
.gscadm-tag.resuelto { background: #d1fae5; color: #065f46; }
.gscadm-tag.abierto  { background: #e0f2fe; color: #0369a1; }
.gscadm-tag.unread   { background: #ff3b6b; color: #fff; }

/* Chat detail */
.gscadm-chat {
  display: flex; flex-direction: column;
  background: #f3eef9;
  min-height: 0;     /* CRÍTICO: permite que .gscadm-msgs haga scroll en flex */
  overflow: hidden;
}
.gscadm-chat-head {
  flex-shrink: 0;      /* el header tampoco se encoge */
  padding: 12px 16px;
  border-bottom: 1px solid #e8e0f5;
  background: #fff;
  display: flex; justify-content: space-between; align-items: center;
}
.gscadm-chat-head h3 { margin: 0; font-size: 16px; color: #3a2f4e; }
.gscadm-chat-head p  { margin: 2px 0 0; font-size: 12px; color: #8b7fa6; }
.gscadm-actions { display: flex; gap: 6px; }
.gscadm-actions button {
  border: 1px solid #e8e0f5; background: #fff; color: #5a4a8f;
  border-radius: 8px; padding: 5px 10px; font-size: 12px; cursor: pointer;
  font-family: inherit;
}
.gscadm-actions button.danger { color: #b91c1c; border-color: #fecaca; }
.gscadm-actions button.primary { background: #7b68b3; color: #fff; border-color: #7b68b3; }

.gscadm-msgs {
  flex: 1 1 auto;
  min-height: 0;     /* CRÍTICO: junto con flex permite scroll real, no overflow */
  overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.gscadm-msg {
  max-width: 70%;
  padding: 9px 12px; border-radius: 14px;
  font-size: 14px; white-space: pre-wrap; word-wrap: break-word;
  line-height: 1.4;
}
.gscadm-msg.cliente { align-self: flex-start; background: #fff; color: #3a2f4e; border: 1px solid #e8e0f5; border-bottom-left-radius: 4px; }
.gscadm-msg.bot     { align-self: flex-start; background: #e8e0f5; color: #3a2f4e; border-bottom-left-radius: 4px; }
.gscadm-msg.admin   { align-self: flex-end;   background: linear-gradient(135deg, #7b68b3, #5a4a8f); color: #fff; border-bottom-right-radius: 4px; }
.gscadm-msg-meta { font-size: 10px; opacity: .6; margin-top: 3px; }

.gscadm-form {
  flex-shrink: 0;      /* CRÍTICO: el form nunca se encoge ni desaparece */
  padding: 12px;
  border-top: 1px solid #e8e0f5;
  background: #fff;
  display: flex; gap: 8px;
}
.gscadm-form textarea {
  flex: 1; border: 1px solid #e8e0f5; border-radius: 10px;
  padding: 8px 12px; font-family: inherit; font-size: 14px;
  resize: none; outline: none; min-height: 40px; max-height: 120px;
  color: #3a2f4e;
}
.gscadm-form textarea:focus { border-color: #7b68b3; }
.gscadm-form button {
  background: #7b68b3; color: #fff; border: 0; border-radius: 10px;
  padding: 0 18px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.gscadm-form button:hover { background: #5a4a8f; }

.gscadm-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: #8b7fa6; font-size: 14px;
}

@media (max-width: 720px) {
  .gscadm-wrap {
    grid-template-columns: 1fr;
    height: 80vh;
    max-height: none;
  }
  .gscadm-side { max-height: 200px; border-right: 0; border-bottom: 1px solid #e8e0f5; }
}
