/* ================================================================
   CHAT WIDGET — NOG Design Web
   Usa las variables CSS del proyecto (--azul, --indigo, --oscuro…)
   ================================================================ */

/* ── LAUNCHER (burbuja flotante) ── */
.chat-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 91;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--azul), var(--indigo));
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(14, 165, 233, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
.chat-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(14, 165, 233, 0.6);
}
.chat-launcher.is-open .chat-icon-bubble { display: none; }
.chat-launcher:not(.is-open) .chat-icon-close { display: none; }

/* Cuando el FAB de auditoría está visible, el chat sube para no solaparse */
.chat-launcher.fab-visible { bottom: 92px; }
.chat-panel.fab-visible    { bottom: 160px; }

/* Punto de notificación verde */
.chat-notification-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 13px;
  height: 13px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid var(--oscuro);
  display: none;
  animation: chat-pulse 2s infinite;
}
.chat-notification-dot.is-visible { display: block; }

@keyframes chat-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.2); opacity: 0.7; }
}

/* ── PANEL DEL CHAT ── */
.chat-panel {
  position: fixed;
  bottom: 96px;
  right: 28px;
  z-index: 91;
  width: 360px;
  max-height: 530px;
  background: var(--oscuro2);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(2, 6, 23, 0.55);
  /* Estado cerrado */
  transform: translateY(16px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.28s ease;
}
.chat-panel.is-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* Línea gradiente superior (igual que .modal-box::before del sitio) */
.chat-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--azul), var(--indigo));
  z-index: 1;
}

/* ── HEADER ── */
.chat-panel-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--oscuro);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.chat-agent-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-agent-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--azul), var(--indigo));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.chat-agent-name {
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--texto);
  line-height: 1.3;
}
.chat-agent-status {
  font-size: 0.72rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  animation: chat-pulse 2s infinite;
}
.chat-close-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}
.chat-close-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

/* ── ÁREA DE MENSAJES ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Burbujas de mensaje */
.chat-msg {
  max-width: 84%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 0.83rem;
  line-height: 1.65;
  animation: chat-step-in 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes chat-step-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Agente (izquierda) */
.chat-msg.agent {
  background: var(--oscuro);
  border: 1px solid var(--border);
  color: var(--texto);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

/* Usuario (derecha) */
.chat-msg.user {
  background: linear-gradient(135deg, var(--azul), var(--indigo));
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

/* Indicador de escritura "..." */
.chat-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 10px 14px;
  background: var(--oscuro);
  border: 1px solid var(--border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  width: 54px;
}
.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: chat-typing-dot 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chat-typing-dot {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* ── ZONA DE BOTONES DE RESPUESTA RÁPIDA ── */
.chat-quick-replies {
  padding: 10px 12px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  border-top: 1px solid var(--border);
  background: var(--oscuro);
  flex-shrink: 0;
}

.chat-btn {
  background: rgba(14, 165, 233, 0.08);
  border: 1px solid rgba(14, 165, 233, 0.25);
  color: var(--azul);
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 0.77rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  white-space: nowrap;
}
.chat-btn:hover {
  background: rgba(14, 165, 233, 0.18);
  border-color: rgba(14, 165, 233, 0.5);
  transform: translateY(-1px);
}
.chat-btn.primary {
  background: linear-gradient(135deg, var(--azul), var(--indigo));
  border-color: transparent;
  color: #fff;
}
.chat-btn.primary:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .chat-launcher {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
  }
  .chat-launcher.fab-visible { bottom: 80px; }

  .chat-panel {
    right: 10px;
    left: 10px;
    width: auto;
    bottom: 82px;
    max-height: 72vh;
    border-radius: 16px;
  }
  .chat-panel.fab-visible { bottom: 148px; }
}
