/* Widget de chat del Agente de Atención al Cliente */

:root {
  --agente-primary: #238343;
  --agente-primary-dark: #238343 ;
  --agente-bg: #ffffff;
  --agente-user-bg: #238343;
  --agente-user-text: #ffffff;
  --agente-bot-bg: #f1f5f9;
  --agente-bot-text: #0f172a;
  --agente-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

/* Botón flotante */
.agente-launcher {
  position: fixed;
  bottom: 124px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--agente-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--agente-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  z-index: 9998;
  transition: transform 0.15s ease, background 0.15s ease;
}
.agente-launcher:hover {
  transform: scale(1.06);
  background: var(--agente-primary-dark);
}

/* Ventana del chat */
.agente-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 300px;
  max-width: calc(100vw - 32px);
  height: 700px;
  max-height: calc(100vh - 130px);
  background: var(--agente-bg);
  border-radius: 16px;
  box-shadow: var(--agente-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.agente-window.agente-open {
  display: flex;
  animation: agente-pop 0.18s ease;
}
@keyframes agente-pop {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Cabecera */
.agente-header {
  background: var(--agente-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.agente-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.agente-header .agente-status { font-size: 12px; opacity: 0.85; }
.agente-close {
  background: none; border: none; color: #fff;
  font-size: 22px; cursor: pointer; line-height: 1;
}

/* Mensajes */
.agente-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fafafa;
}
.agente-msg {
  max-width: 80%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.agente-msg.user {
  align-self: flex-end;
  background: var(--agente-user-bg);
  color: var(--agente-user-text);
  border-bottom-right-radius: 4px;
}
.agente-msg.bot {
  align-self: flex-start;
  background: var(--agente-bot-bg);
  color: var(--agente-bot-text);
  border-bottom-left-radius: 4px;
}

/* Indicador de "escribiendo..." */
.agente-typing { display: flex; gap: 4px; padding: 4px 2px; }
.agente-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #94a3b8;
  animation: agente-blink 1.2s infinite ease-in-out;
}
.agente-typing span:nth-child(2) { animation-delay: 0.2s; }
.agente-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes agente-blink {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* Pie con enlace a "hablar con una persona" */
.agente-footer {
  display: flex;
  justify-content: center;
  padding: 6px;
  border-top: 1px solid #eef2f6;
  background: #fff;
}
.agente-human-link {
  background: none;
  border: none;
  color: var(--agente-primary);
  font-size: 12.5px;
  cursor: pointer;
  padding: 2px 6px;
}
.agente-human-link:hover { text-decoration: underline; }

/* Panel de derivación a humano */
.agente-handoff {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
  background: #fff;
}
.agente-handoff-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.agente-handoff-back {
  background: none; border: none; color: var(--agente-primary);
  cursor: pointer; font-size: 13px;
}
.agente-handoff-form { display: flex; flex-direction: column; gap: 10px; }
.agente-handoff-form input,
.agente-handoff-form textarea {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px 11px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.agente-handoff-form input:focus,
.agente-handoff-form textarea:focus { border-color: var(--agente-primary); }
.agente-handoff-form textarea { resize: vertical; }
.agente-handoff-submit { padding: 11px; border-radius: 10px; }
.agente-handoff-msg { font-size: 13px; color: #b91c1c; min-height: 16px; }

/* Entrada de texto */
.agente-input {
  display: flex;
  border-top: 1px solid #e2e8f0;
  padding: 10px;
  gap: 8px;
  background: #fff;
}
.agente-input textarea {
  flex: 1;
  resize: none;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  max-height: 90px;
  outline: none;
  color: var(--agente-bot-text);
  background: var(--agente-bot-bg);
}
.agente-input textarea:focus { border-color: var(--agente-primary); }
.agente-send {
  background: var(--agente-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 16px;
  cursor: pointer;
  font-size: 15px;
  transition: background 0.15s ease;
}
.agente-send:hover:not(:disabled) { background: var(--agente-primary-dark); }
.agente-send:disabled { opacity: 0.5; cursor: not-allowed; }
