/* Animación de “latido” sutil para el logo */
:root {
  --pulse-scale: 1.12;        /* Intensidad del latido (antes 1.06) */
  --pulse-duration: 2.4s;     /* Un poco más de tiempo entre latidos */
}

/* Fondo full-page con la imagen back */
html, body { height: 100%; }
body {
  margin: 0;
  background: #000 url('/assets/img/back.jpeg') center center / cover no-repeat fixed;
  animation: bg-pan 50s ease-in-out infinite alternate; /* paneo sutil */
}

/* Animación sutil del fondo (paneo muy leve) */
@keyframes bg-pan {
  0%   { background-position: 48% 52%; }
  50%  { background-position: 52% 48%; }
  100% { background-position: 50% 50%; }
}

@media (prefers-reduced-motion: reduce) {
  body { animation: none; }
}

.logo {
  display: inline-block;
  transform-origin: center center;
  transition: transform .18s ease;
}

.logo--pulse {
  animation: logo-pulse var(--pulse-duration) ease-in-out infinite;
  will-change: transform;
}

/* Enfocado o abierto: agranda y detiene el latido */
.assist-widget:focus-within .logo,
.assist-widget.is-open .logo {
  transform: scale(var(--hover-scale, 1.15));
}

.assist-widget:focus-within .logo--pulse,
.assist-widget.is-open .logo--pulse {
  animation: none;
}

@keyframes logo-pulse {
  0% { transform: scale(1); }
  30% { transform: scale(var(--pulse-scale)); }
  60% { transform: scale(1); }
  100% { transform: scale(1); }
}

/* Respeta preferencias de accesibilidad */
@media (prefers-reduced-motion: reduce) {
  .logo--pulse { animation: none; }
}

/* Posición y tamaño solicitados */
/* Contenedor del widget de ayuda (esquina inferior derecha) */
.assist-widget {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  outline: none;
  /* Color de marca (ajústalo si tu logo usa otro) */
  --brand-color: rgb(0, 105, 171); /* #0069AB */
  cursor: pointer;
}

.logo--small {
  width: calc(78px * 0.7); /* ~55px */
  height: auto;
}

/* Burbuja/llamada de ayuda */

.assist-bubble {
  position: absolute;
  right: 0;
  bottom: calc(100% + 14px);
  background: var(--brand-color);
  color: #ffffff;
  border-radius: 18px;
  padding: 18px 18px 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
  font-size: 18px;
  line-height: 1.35;
  width: min(76vw, 420px);
  max-height: 70vh;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .22s ease, transform .22s ease, visibility .22s ease, bottom .22s ease, width .25s ease, max-height .25s ease;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.assist-panel {
  background: #ffffff;
  color: #111111;
  border-radius: 16px;
  padding: 18px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 260px;
}

.assist-bubble::after {
  content: "";
  position: absolute;
  left: calc(100% - 44px); /* ligeramente hacia la derecha */
  bottom: -8px;            /* flecha abajo, hacia el logo */
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--brand-color);
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.08));
}

/* Mostrar burbuja al enfocar con teclado o al abrir por clic */
.assist-widget:focus-within .assist-bubble,
.assist-widget.is-open .assist-bubble {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* Al agrandarse el logo, aumenta el margen con la burbuja */
.assist-widget:focus-within .assist-bubble,
.assist-widget.is-open .assist-bubble {
  bottom: calc(100% + 32px);
}

.assist-widget.has-history .assist-bubble {
  width: min(90vw, 720px);
  max-height: 90vh;
}

/* Chat: estructura interna */
.assist-title {
  font-weight: 700;
  margin: 0 4px 8px 4px;
}

.assist-messages {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  padding: 8px;
  border-radius: 10px;
  background: #f8fafc;
  flex: 1 1 auto;
  min-height: 160px;
}

.assist-msg {
  display: block;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  box-sizing: border-box;
}

.assist-msg.bot {
  background: #f4f6f8;
  color: #111;
  align-self: flex-start;
  white-space: normal;
}

.assist-msg.user {
  background: #e8f4ff;
  color: #0b3d62;
  align-self: flex-end;
  white-space: pre-line;
}

.assist-msg.bot.is-loading {
  opacity: 0.75;
  font-style: italic;
}

.assist-msg.bot.is-active {
  background: #dbeafe;
  box-shadow: inset 0 0 0 1px rgba(11, 61, 98, 0.12);
}

.assist-msg.bot.is-error {
  background: #fee2e2;
  color: #7f1d1d;
  box-shadow: inset 0 0 0 1px rgba(127, 29, 29, 0.15);
}

.assist-msg.bot p {
  margin: 6px 0;
}

.assist-msg.bot h1,
.assist-msg.bot h2,
.assist-msg.bot h3,
.assist-msg.bot h4,
.assist-msg.bot h5,
.assist-msg.bot h6 {
  margin: 10px 0 4px;
  font-size: 1rem;
  line-height: 1.35;
  color: #0b3d62;
  font-weight: 700;
}

.assist-msg.bot h1 { font-size: 1.3rem; }
.assist-msg.bot h2 { font-size: 1.15rem; }
.assist-msg.bot h3 { font-size: 1.05rem; }
.assist-msg.bot h4 { font-size: 1rem; }

.assist-msg.bot ul,
.assist-msg.bot ol {
  margin: 8px 0 10px;
  padding-left: 20px;
}

.assist-msg.bot li {
  margin: 4px 0;
}

.assist-msg.bot hr {
  border: 0;
  border-top: 1px dashed rgba(11, 61, 98, 0.25);
  margin: 12px 0;
}

.assist-msg.bot code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 13px;
}

.assist-code {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0;
  overflow: auto;
}

.assist-code pre {
  margin: 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  color: #0f172a;
  white-space: pre;
  word-break: normal;
}

.assist-code code {
  background: none;
  padding: 0;
  border-radius: 0;
  color: inherit;
}

.assist-input { display: flex; gap: 8px; align-items: stretch; padding: 0; }
.assist-input__fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.assist-input input[type="text"] {
  flex: 1;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d0d7de;
  outline: none;
}
.assist-input input[type="text"]:focus { border-color: var(--brand-color); box-shadow: 0 0 0 3px rgba(0,105,171,0.15); }
.assist-input input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  border: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
  opacity: 0;
}

.assist-upload {
  flex: 1;
  border: 2px dashed rgba(0,105,171,0.35);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1.3;
  background: rgba(232, 244, 255, 0.55);
  color: #0b3d62;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}

.assist-upload__action { color: var(--brand-color); font-weight: 600; }
.assist-upload__status {
  font-size: 11px;
  color: rgba(11,61,98,0.75);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.assist-upload__status.has-multiple {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.assist-upload.is-dragover {
  border-color: var(--brand-color);
  background: rgba(232, 244, 255, 0.85);
  box-shadow: 0 0 0 3px rgba(0,105,171,0.15);
}

.assist-upload.is-file {
  border-style: solid;
  border-color: var(--brand-color);
}
.assist-input button {
  background: var(--brand-color);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  align-self: flex-end;
}
.assist-input button:hover { filter: brightness(0.95); }

/* Responsive: ajusta ancho del chat en pantallas pequeñas */
@media (max-width: 600px) {
  .assist-bubble { width: min(94vw, 340px); }
  .assist-widget.has-history .assist-bubble { width: min(96vw, 96vw); }
}

/* Responsive: en móviles el logo a 80% del actual */
@media (max-width: 600px) {
  .logo--small { width: calc(78px * 0.8); } /* ~62px */
  .assist-upload { flex-basis: 100%; }
}
