/* Postgradum Hub Madrid · asistente virtual */

.chat-root { --chat-w: 390px; }

.chat-launcher {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 22px 14px 18px;
  border: 0; border-radius: 999px;
  background: var(--lime); color: var(--navy-deep);
  font: 600 12px/1 var(--sans); letter-spacing: 0.12em; text-transform: uppercase;
  box-shadow: 0 10px 30px rgba(0, 10, 60, 0.35);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.chat-launcher:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(0, 10, 60, 0.4); }
.chat-launcher svg { width: 20px; height: 20px; fill: currentColor; }
.chat-root.is-open .chat-launcher { opacity: 0; transform: scale(0.85); pointer-events: none; }

.chat {
  position: fixed; right: 22px; bottom: 22px; z-index: 61;
  display: flex; flex-direction: column;
  width: var(--chat-w); height: min(620px, calc(100dvh - 44px));
  overflow: hidden;
  border-radius: 6px;
  background: #f7f5f1;
  box-shadow: 0 24px 70px rgba(0, 8, 50, 0.38);
  font-family: var(--sans);
  color: var(--ink);
  /* Sale de la esquina del botón al abrirse y vuelve a ella al cerrarse. */
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(16px) scale(0.94);
  pointer-events: none;
  transition: opacity 0.16s ease-in, transform 0.18s ease-in;
}
.chat.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  transition: opacity 0.2s ease-out, transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}
.chat[hidden] { display: none; }

.chat__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 16px 16px 20px;
  background: var(--grad-header); color: #fff;
}
.chat__title { margin: 0; font: 500 19px/1.2 var(--serif); }
.chat__badge { display: inline-block; margin-left: 6px; padding: 2px 6px; border-radius: 3px; background: var(--lime); color: var(--navy-deep); font: 700 9px/1.3 var(--sans); letter-spacing: 0.08em; vertical-align: 3px; }
.chat__sub { margin: 4px 0 0; font-size: 11.5px; line-height: 1.4; color: rgba(255, 255, 255, 0.78); }
.chat__actions { display: flex; gap: 2px; margin-top: -4px; }
.chat__icon {
  display: grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  border: 0; border-radius: 4px;
  background: transparent; color: #fff;
  font-size: 22px; line-height: 1; text-decoration: none;
  cursor: pointer;
}
.chat__icon:hover { background: rgba(255, 255, 255, 0.12); }
.chat__icon svg { width: 20px; height: 20px; fill: currentColor; }
.chat__icon--wa svg { fill: #3ddc84; }

.chat__log { flex: 1; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding: 18px 16px 8px; overscroll-behavior: contain; }
.chat__msg { max-width: 88%; padding: 10px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.55; overflow-wrap: anywhere; }
.chat__msg p { margin: 0 0 0.6em; }
.chat__msg p:last-child { margin-bottom: 0; }
.chat__msg ul, .chat__msg ol { margin: 0 0 0.6em; padding-left: 18px; }
.chat__msg li + li { margin-top: 2px; }
.chat__msg a { color: var(--blue); }
.chat__msg--assistant { align-self: flex-start; border-bottom-left-radius: 4px; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06); }
.chat__msg--user { align-self: flex-end; border-bottom-right-radius: 4px; background: var(--blue); color: #fff; }
.chat__msg--user a { color: #fff; }
.chat__msg--note { align-self: center; max-width: 92%; padding: 6px 12px; border-radius: 999px; background: rgba(0, 34, 175, 0.08); color: var(--navy); font-size: 12px; text-align: center; }
.chat__msg--error { background: #fff3ea; color: #6b3110; }

.chat__typing { display: flex; align-items: center; gap: 4px; min-height: 21px; color: #6d6b66; }
.chat__typing em { font-style: normal; font-size: 12.5px; }
.chat__typing span { width: 6px; height: 6px; border-radius: 50%; background: #a6a39c; animation: chat-dot 1.2s infinite ease-in-out; }
.chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.chat__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-dot { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.chat__suggestions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.chat__suggestions:empty { display: none; }
.chat__chip { padding: 7px 12px; border: 1px solid rgba(0, 34, 175, 0.3); border-radius: 999px; background: #fff; color: var(--blue); font-size: 12.5px; cursor: pointer; }
.chat__chip:hover { border-color: var(--blue); background: rgba(0, 34, 175, 0.05); }

.chat__form { display: flex; align-items: flex-end; gap: 8px; margin: 0 12px; padding: 8px 8px 8px 14px; border: 1px solid #ddd8cf; border-radius: 22px; background: #fff; }
.chat__form:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 34, 175, 0.12); }
.chat__form textarea { flex: 1; max-height: 120px; padding: 6px 0; border: 0; outline: none; background: transparent; color: var(--ink); font: 14px/1.4 var(--sans); resize: none; }
.chat__send { display: grid; place-items: center; flex: none; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: var(--blue); color: #fff; cursor: pointer; }
.chat__send svg { width: 17px; height: 17px; fill: currentColor; }
.chat__send:disabled { opacity: 0.45; cursor: progress; }
.chat__legal { margin: 8px 16px 12px; font-size: 10.5px; line-height: 1.4; text-align: center; color: #7a7770; }
.chat__legal a { color: inherit; }

.chat :focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.chat__head :focus-visible { outline-color: var(--lime); }
/* El foco del campo de texto lo marca el borde redondeado del formulario, no un recuadro. */
.chat__form textarea:focus-visible { outline: none; }

@media (max-width: 560px) {
  .chat-launcher { right: 14px; bottom: 14px; padding: 15px; }
  .chat-launcher span { display: none; }
  .chat { inset: 0; width: auto; height: 100dvh; border-radius: 0; transform: translateY(32px); }
}
