/* rumorea — chat flotante del landing (ver render_chat_widget en partials.php).
   Depende de styles.css.

   Escrito para el teléfono primero: el panel es una hoja a pantalla completa, y
   recién de 680px para arriba se convierte en la tarjeta flotante de escritorio.
   Una cajita de 380px encogida en un teléfono deja el textarea inusable. */

.rum-chat {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
}

/* — botón flotante — */
.rum-chat-fab {
  display: flex;
  align-items: center;
  gap: 9px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  background: var(--lime);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 13px 20px;
  cursor: pointer;
  box-shadow: 4px 4px 0 0 var(--ink);
}
.rum-chat-fab:hover { filter: brightness(0.94); }
.rum-chat-fab:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 0 var(--ink); }

/* con el panel abierto el botón estorba: en mobile queda tapado por la hoja */
.rum-chat.is-open .rum-chat-fab { display: none; }

/* — panel — */
.rum-chat-panel {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--ground);
  border: none;
  border-radius: 0;
}
/* El `display:flex` de arriba es una regla de autor y le gana al `[hidden] {
   display:none }` del navegador — sin esto, el panel se vería abierto siempre,
   aunque el atributo hidden esté puesto. */
.rum-chat-panel[hidden] { display: none; }

.rum-chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: var(--ink);
  color: var(--ground);
  flex-shrink: 0;
}
.rum-chat-head strong { display: block; font-size: 15px; }
.rum-chat-head span { display: block; font-size: 12.5px; color: rgba(250, 246, 238, 0.68); margin-top: 3px; }

.rum-chat-close {
  font: inherit;
  color: var(--ground);
  background: transparent;
  border: none;
  padding: 4px;
  cursor: pointer;
  line-height: 0;
  flex-shrink: 0;
}

/* el hilo es lo único que scrollea: el encabezado y el formulario quedan fijos */
.rum-chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.rum-chat-intro p {
  font-size: 13.5px;
  line-height: 21px;
  color: var(--muted);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 0;
}

/* — burbujas — */
.rum-chat-msg { display: grid; justify-items: start; }
.rum-chat-msg-staff { justify-items: end; }

.rum-chat-bubble {
  max-width: 88%;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 14.5px;
  line-height: 22px;
  color: var(--ink);
  /* un link largo sin espacios no puede ensanchar la burbuja */
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.rum-chat-msg-staff .rum-chat-bubble { background: var(--tint); }

.rum-chat-meta {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}

.rum-chat-error {
  margin: 0;
  padding: 10px 18px;
  background: #fdecea;
  color: #a3231a;
  font-size: 13px;
  flex-shrink: 0;
}

/* — formulario — */
.rum-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-top: 2px solid var(--line);
  background: #fff;
  flex-shrink: 0;
}
.rum-chat-form textarea {
  flex: 1;
  font: inherit;
  /* 16px a propósito: por debajo de eso, Safari en iPhone hace zoom al enfocar
     y deja la página zoomeada */
  font-size: 16px;
  line-height: 22px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--ground);
  resize: none;
  max-height: 120px;
}
.rum-chat-form button {
  font: inherit;
  color: var(--ink);
  background: var(--pink);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 11px 13px;
  cursor: pointer;
  line-height: 0;
  flex-shrink: 0;
}
.rum-chat-form button:hover { background: var(--pink-dark); }
.rum-chat-form button[disabled] { opacity: 0.5; cursor: default; }

/* el campo trampa no se muestra, pero tampoco con display:none —
   algunos bots saltean justamente lo que está en display:none */
.rum-chat-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.rum-chat-sronly {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.rum-chat-foot {
  margin: 0;
  padding: 10px 18px;
  font-size: 11.5px;
  line-height: 17px;
  color: var(--muted);
  background: #fff;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.rum-chat-foot a { font-weight: 600; color: var(--ink); text-decoration: underline; }

/* — de tablet para arriba: tarjeta flotante en vez de hoja completa —
   Pasa a position:absolute para colgar del contenedor (que es el que está fijo en
   la esquina). Con position:fixed se pegaría al borde del viewport y se comería
   los 16px de margen. */
@media (min-width: 681px) {
  .rum-chat-panel {
    position: absolute;
    inset: auto;
    right: 0;
    bottom: 0;
    width: 380px;
    height: min(560px, calc(100vh - 120px));
    border: 2px solid var(--ink);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 6px 6px 0 0 var(--ink);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rum-chat-fab:active { transform: none; }
}
