/* chat.css — asistente flotante. Hairlines, sin sombras. */

.chat { position: fixed; right: 1rem; bottom: 1rem; z-index: 60; font-family: var(--f-texto); }

.chat { display: flex; align-items: flex-end; gap: .6rem; }

/* El avatar: círculo con anillo de la marca. Flota apenas. */
.chat__boton {
  flex: none;
  width: 4.25rem; height: 4.25rem; padding: 0;
  border: 3px solid var(--superficie);
  border-radius: 50%;
  background: var(--superficie);
  outline: 1px solid var(--linea-fuerte);
  cursor: pointer;
  overflow: hidden;
  transition: transform .4s cubic-bezier(.16,1,.3,1), outline-color .3s;
}
.chat__boton img { display: block; width: 100%; height: 100%; object-fit: cover; }
.chat__boton:hover { transform: scale(1.07) rotate(-4deg); outline-color: var(--acento); }
.chat__boton:active { transform: scale(.95); }

/* El globo de conversación: cola hacia el avatar */
.chat__globo {
  position: relative;
  order: -1;
  margin-bottom: 1rem;
  max-width: 13rem;
  padding: .7rem .95rem;
  background: var(--superficie);
  color: var(--texto);
  border: 1px solid var(--linea-fuerte);
  border-radius: 1.1rem 1.1rem .25rem 1.1rem;
  font: 500 .95rem/1.3 var(--f-texto);
  text-align: left;
  cursor: pointer;
  transform-origin: right bottom;
  animation: chat-globo-entra .6s cubic-bezier(.16,1,.3,1) both;
}
.chat__globo[hidden] { display: none; }
.chat__globo::after {  /* la cola */
  content: ""; position: absolute; right: -7px; bottom: -1px; width: 12px; height: 14px;
  background: var(--superficie);
  border-right: 1px solid var(--linea-fuerte);
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}
.chat__globo:hover { border-color: var(--acento); }
.chat__globo--sale { animation: chat-globo-sale .45s cubic-bezier(.16,1,.3,1) both; }
@keyframes chat-globo-entra { from { opacity: 0; transform: translateY(.6rem) scale(.8); } }
@keyframes chat-globo-sale  { to   { opacity: 0; transform: translateY(.4rem) scale(.9); } }

@media (prefers-reduced-motion: no-preference) {
  .chat__boton { animation: chat-flota 4.5s ease-in-out 1.5s infinite; }
  .chat__boton:hover { animation-play-state: paused; }
  @keyframes chat-flota { 50% { translate: 0 -4px; } }
  .chat__panel { transform-origin: right bottom; animation: chat-abre .5s cubic-bezier(.16,1,.3,1) both; }
  @keyframes chat-abre { from { opacity: 0; transform: translateY(.75rem) scale(.94); } }
  .chat__msj { animation: chat-msj .45s cubic-bezier(.16,1,.3,1) both; }
  @keyframes chat-msj { from { opacity: 0; transform: translateY(.5rem); } }
}
.chat--abierto .chat__boton, .chat--abierto .chat__globo { display: none; }

.chat__panel {
  display: flex; flex-direction: column;
  width: min(23rem, calc(100vw - 2rem));
  height: min(34rem, calc(100dvh - 2rem));
  background: var(--superficie);
  border: 1px solid var(--linea-fuerte);
  border-radius: var(--radio);
  overflow: hidden;
}
.chat__panel[hidden] { display: none; }

.chat__cab {
  display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem;
  padding: .9rem 1rem;
  background: var(--acento);
  color: var(--superficie);
}
.chat__cab strong { display: block; font-size: 1rem; letter-spacing: -.01em; }
.chat__cab span { display: block; font-size: .8rem; opacity: .85; margin-top: .15rem; }
.chat__cerrar {
  flex: none; width: 44px; height: 44px; margin: -.5rem -.5rem 0 0;
  background: none; border: 0; color: inherit; font-size: 1.6rem; line-height: 1; cursor: pointer;
}

.chat__hilo {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 1rem; display: flex; flex-direction: column; gap: .6rem;
  background: var(--fondo);
}
.chat__msj { max-width: 88%; padding: .65rem .8rem; border: 1px solid var(--linea); border-radius: var(--radio); font-size: .95rem; line-height: 1.45; }
.chat__msj p { margin: 0 0 .5rem; max-width: none; }
.chat__msj p:last-child { margin-bottom: 0; }
.chat__msj--bot { align-self: flex-start; background: var(--superficie); color: var(--texto); }
.chat__msj--yo  { align-self: flex-end; background: var(--acento-lavado); color: var(--texto); }
.chat__enlace { color: var(--acento); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

.chat__opciones {
  display: flex; flex-wrap: wrap; gap: .4rem;
  padding: .6rem 1rem; max-height: 9.5rem; overflow-y: auto;
  border-top: 1px solid var(--linea); background: var(--superficie);
}
.chat__opciones button,
.chat__wa {
  min-height: 44px; padding: .5rem .8rem;
  background: var(--superficie); color: var(--acento);
  border: 1px solid var(--linea-fuerte); border-radius: var(--radio);
  font: 500 .9rem/1.2 var(--f-texto); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center;
}
.chat__opciones button:hover { background: var(--acento-lavado); }
.chat__wa { background: var(--acento); color: var(--superficie); border-color: var(--acento); font-weight: 600; width: 100%; justify-content: center; }

.chat__form { display: flex; gap: .4rem; padding: .6rem 1rem 1rem; background: var(--superficie); }
.chat__form input {
  flex: 1; min-width: 0; min-height: 44px; padding: 0 .7rem;
  font: 400 1rem var(--f-texto); color: var(--texto);
  background: var(--fondo); border: 1px solid var(--linea-fuerte); border-radius: var(--radio);
}
.chat__form button {
  min-height: 44px; padding: 0 1rem; cursor: pointer;
  font: 600 .95rem var(--f-texto); color: var(--superficie);
  background: var(--acento); border: 1px solid var(--acento); border-radius: var(--radio);
}

@media (max-width: 640px) {
  .chat { right: .75rem; bottom: .75rem; }
  .chat--abierto { left: .75rem; }
  .chat__panel { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .chat__boton { transition: none; } }

.chat__cab { align-items: center; }
.chat__cab-avatar { flex: none; width: 2.75rem; height: 2.75rem; border-radius: 50%; border: 2px solid var(--superficie); }
.chat__cab > div { flex: 1; min-width: 0; }

.chat__enlace--wa {
  display: inline-flex; align-items: center; min-height: 44px; padding: .5rem .9rem;
  background: var(--acento); color: var(--superficie); border-radius: var(--radio);
  text-decoration: none; font-weight: 600;
}
.chat__enlace--wa:hover { background: var(--acento-claro); }
