/* Agente IA de MRM Integra — usa los tokens de styles.css */

.agente {
  display: flex;
  flex-direction: column;
  min-height: 520px;
  max-height: min(72vh, 680px);
  border: 1px solid var(--line);
  background: var(--paper);
}

.agente-encabezado {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  background: var(--petrol);
  color: #fff;
}
.agente-encabezado svg { width: 26px; height: 26px; flex: none; fill: none; stroke: var(--signal-blue-light); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.agente-encabezado strong { display: block; font-size: 1rem; letter-spacing: -.01em; }
.agente-encabezado span { display: block; margin-top: 2px; color: #b9ccd1; font-size: .78rem; }

.agente-hilo {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 22px;
  scroll-behavior: smooth;
}

.agente-msg { max-width: 82%; font-size: .95rem; line-height: 1.55; }
.agente-msg p { margin: 0 0 10px; }
.agente-msg p:last-child { margin-bottom: 0; }
.agente-msg strong { font-weight: 750; }

.agente-msg-bot {
  align-self: flex-start;
  padding: 15px 19px;
  background: color-mix(in srgb, var(--signal-blue) 6%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--signal-blue) 16%, transparent);
  color: var(--petrol);
}
.agente-msg-yo {
  align-self: flex-end;
  padding: 12px 18px;
  background: var(--petrol);
  color: #fff;
}

.agente-escribiendo { align-self: flex-start; display: flex; gap: 5px; padding: 16px 18px; }
.agente-escribiendo i { width: 7px; height: 7px; border-radius: 50%; background: var(--signal-blue); animation: agente-pulso 1.2s infinite ease-in-out; }
.agente-escribiendo i:nth-child(2) { animation-delay: .18s; }
.agente-escribiendo i:nth-child(3) { animation-delay: .36s; }
@keyframes agente-pulso { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.agente-aviso {
  flex: 1 1 100%;
  margin: 0;
  color: #8a9a9f;
  font-size: .68rem;
  line-height: 1.4;
}
.agente-aviso a { color: #8a9a9f; text-decoration: underline; text-underline-offset: .2em; }
.agente-aviso a:hover { color: var(--signal-blue-dark); }

.agente-entrada {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--line);
}
.agente-entrada textarea {
  width: 100%;
  min-height: 52px;
  max-height: 140px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--petrol);
  font: inherit;
  font-size: .95rem;
  line-height: 1.45;
  resize: none;
}
.agente-entrada textarea:focus { outline: none; border-color: var(--signal-blue); }
.agente-entrada textarea::placeholder { color: #8a9a9f; }
.agente-enviar {
  min-height: 52px;
  padding: 0 24px;
  border: 0;
  background: var(--signal-blue);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background .25s ease;
}
.agente-enviar:hover:not(:disabled) { background: var(--signal-blue-dark); }
.agente-enviar:disabled { background: #9fb3b8; cursor: not-allowed; }

.agente-pie {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  align-items: center;
  padding: 0 22px 18px;
}
.agente-escape {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--ink-muted);
  font: inherit;
  font-size: .84rem;
  font-weight: 700;
  cursor: pointer;
}
.agente-escape:hover { color: var(--signal-blue-dark); border-bottom-color: var(--signal-blue); }

.agente-whatsapp {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 4px 22px 20px;
  padding: 14px 22px;
  background: #1f9d55;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}
.agente-whatsapp:hover { background: #17804a; }
.agente-whatsapp img { width: 20px; height: 20px; filter: brightness(0) invert(1); }

@media (max-width: 900px) {
  .agente { min-height: 460px; max-height: none; }
  .agente-hilo { padding: 18px 16px; }
  .agente-msg { max-width: 92%; }
  .agente-entrada { grid-template-columns: 1fr; padding: 14px 16px 18px; }
  .agente-enviar { width: 100%; }
  .agente-pie { padding-inline: 16px; }
}

/* ── Burbuja flotante ─────────────────────────────────────────────────────── */

.agente-burbuja {
  position: fixed;
  right: clamp(16px, 2.4vw, 32px);
  bottom: clamp(16px, 2.4vw, 32px);
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 60px;
  padding: 0 24px 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--petrol);
  color: #fff;
  font: inherit;
  font-size: .92rem;
  font-weight: 700;
  letter-spacing: -.01em;
  cursor: pointer;
  box-shadow: 0 10px 30px -12px rgba(5, 24, 31, .58), 0 2px 6px -2px rgba(5, 24, 31, .35);
  transition: background .3s var(--ease), box-shadow .3s var(--ease), transform .3s var(--ease);
}
.agente-burbuja svg { width: 26px; height: 26px; fill: none; stroke: var(--signal-blue-light); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.agente-burbuja:hover { background: var(--active-petrol); transform: translateY(-2px); box-shadow: 0 16px 38px -14px rgba(5, 24, 31, .62), 0 3px 8px -2px rgba(5, 24, 31, .35); }
.agente-burbuja.is-activo svg { stroke: var(--copper); }

.agente-panel {
  position: fixed;
  right: clamp(16px, 2.4vw, 32px);
  bottom: calc(60px + clamp(16px, 2.4vw, 32px) + 14px);
  z-index: 59;
  width: min(404px, calc(100vw - 32px));
  max-height: min(640px, calc(100svh - 150px));
  display: none;
  box-shadow: 0 28px 70px -30px rgba(5, 24, 31, .55), 0 6px 18px -8px rgba(5, 24, 31, .28);
}
.agente-panel.is-abierto { display: block; animation: agente-entrada .34s var(--ease) both; }
.agente-panel .agente { min-height: 0; max-height: min(640px, calc(100svh - 150px)); overflow: hidden; }
.agente-panel .agente-hilo { min-height: 0; flex: 1 1 auto; }
.agente-panel .agente-entrada { flex: none; }
.agente-panel .agente-pie { flex: none; }

@keyframes agente-entrada {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.agente-encabezado { position: relative; }
.agente-cerrar {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: none;
  color: #b9ccd1;
  cursor: pointer;
  transition: color .25s ease;
}
.agente-cerrar:hover { color: #fff; }
.agente-cerrar svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }

@media (max-width: 640px) {
  .agente-burbuja { height: 54px; padding: 0 20px 0 17px; font-size: .86rem; }
  .agente-burbuja svg { width: 23px; height: 23px; }
  .agente-panel {
    right: 12px;
    left: 12px;
    bottom: calc(54px + 12px + 12px);
    width: auto;
    max-height: calc(100svh - 150px);
  }
  .agente-panel .agente { max-height: calc(100svh - 150px); }
}

@media (prefers-reduced-motion: reduce) {
  .agente-burbuja, .agente-panel.is-abierto { transition: none; animation: none; }
  .agente-burbuja:hover { transform: none; }
}
