/* =========================================================
   Asistente del sitio — widget de chat
   Usa los tokens definidos en style.css
   ========================================================= */

/* ---------- Botón flotante ---------- */
.chat-launcher {
  position: fixed;
  bottom: 96px;              /* queda arriba del botón de WhatsApp */
  right: 26px;
  z-index: 91;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 26px rgba(14, 74, 146, 0.45);
  transition: transform 0.3s var(--ease), background 0.3s var(--ease);
}

.chat-launcher:hover { transform: scale(1.08); background: var(--blue-dark); }

.chat-launcher svg { width: 28px; height: 28px; fill: var(--white); }
.chat-launcher .chat-launcher__close { display: none; }

.chat-launcher.is-open .chat-launcher__open { display: none; }
.chat-launcher.is-open .chat-launcher__close { display: block; }

/* Punto de aviso la primera vez */
.chat-launcher__dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--white);
}

.chat-launcher.is-open .chat-launcher__dot { display: none; }

/* ---------- Ventana ---------- */
.chat-panel {
  position: fixed;
  bottom: 96px;
  right: 26px;
  z-index: 92;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(10, 47, 99, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}

.chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---------- Encabezado ---------- */
.chat-head {
  background: var(--blue-dark);
  color: var(--white);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chat-head__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.chat-head__avatar svg { width: 22px; height: 22px; fill: var(--white); }

.chat-head__title { font-family: var(--font-head); font-size: 15px; font-weight: 700; line-height: 1.3; }

.chat-head__status {
  font-size: 12px;
  color: #a9c8ef;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-head__status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
}

.chat-head__close {
  margin-left: auto;
  background: none;
  border: 0;
  color: var(--white);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
  padding: 0 2px;
}

.chat-head__close:hover { opacity: 1; }

/* ---------- Mensajes ---------- */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--gray-light);
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chat-msg {
  max-width: 84%;
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.55;
  animation: chatIn 0.25s var(--ease);
  word-wrap: break-word;
}

@keyframes chatIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-msg--bot {
  align-self: flex-start;
  background: var(--white);
  color: var(--text);
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 8px rgba(10, 47, 99, 0.07);
}

.chat-msg--user {
  align-self: flex-end;
  background: var(--blue);
  color: var(--white);
  border-bottom-right-radius: 5px;
}

/* ---------- Escribiendo… ---------- */
.chat-typing {
  align-self: flex-start;
  background: var(--white);
  border-radius: 16px;
  border-bottom-left-radius: 5px;
  padding: 14px 17px;
  display: flex;
  gap: 5px;
  box-shadow: 0 2px 8px rgba(10, 47, 99, 0.07);
}

.chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b9c4d4;
  animation: chatDot 1.3s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.18s; }
.chat-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes chatDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* ---------- Sugerencias y acciones ---------- */
.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-self: flex-start;
  max-width: 100%;
}

.chat-chip {
  background: var(--white);
  border: 1.5px solid #d9e2f0;
  color: var(--blue);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  text-align: left;
}

.chat-chip:hover { background: var(--blue); border-color: var(--blue); color: var(--white); }

.chat-actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-self: flex-start;
  width: 84%;
}

.chat-action {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  background: var(--white);
  border: 1.5px solid #d9e2f0;
  color: var(--blue-dark);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s var(--ease);
}

.chat-action:hover { border-color: var(--blue); background: rgba(14, 74, 146, 0.04); }
.chat-action svg { width: 17px; height: 17px; fill: var(--blue); flex-shrink: 0; }

/* ---------- Entrada de texto ---------- */
.chat-foot {
  padding: 12px 14px;
  background: var(--white);
  border-top: 1px solid #e6ebf3;
  flex-shrink: 0;
}

.chat-form { display: flex; gap: 9px; align-items: flex-end; }

.chat-input {
  flex: 1;
  border: 1.5px solid #dde3ed;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: 14.5px;
  color: var(--text);
  resize: none;
  max-height: 96px;
  line-height: 1.45;
}

.chat-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(14, 74, 146, 0.12);
}

.chat-send {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s var(--ease);
}

.chat-send:hover { background: var(--blue-dark); }
.chat-send:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-send svg { width: 19px; height: 19px; fill: var(--white); }

.chat-legal {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-soft);
  text-align: center;
  line-height: 1.4;
}

/* ---------- Accesibilidad y responsive ---------- */
@media (prefers-reduced-motion: reduce) {
  .chat-panel, .chat-msg, .chat-typing span, .chat-launcher { transition: none; animation: none; }
}

@media (max-width: 560px) {
  .chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .chat-launcher { bottom: 92px; right: 20px; width: 54px; height: 54px; }
  .chat-actions { width: 100%; }
}

@media print {
  .chat-launcher, .chat-panel { display: none !important; }
}
