/* Caja de chat Hispavista · v1.1 */
#hv-chat {
  /* Tokens del Figma "Web HV 2026" */
  --hv-accent: #e8481f;          /* brand/primary/primary-500-default */
  --hv-accent-800: #b52f12;      /* brand/primary/primary-800 */
  --hv-title: #2c2c2c;           /* brand/text + icon/titles */
  --hv-text-soft: #5b5b5b;       /* brand/neutrals/60 */
  --hv-muted: #767676;           /* brand/neutrals/50 */
  --hv-chip: #f5f5f5;            /* fondo de los botones predefinidos */
  --hv-field: #ffffff;           /* fondo del campo de texto */
  --hv-white: #ffffff;
  /* Caja: transparente. Para efecto cristal: --hv-bg: rgba(255,255,255,.12); --hv-blur: 8px; */
  --hv-bg: transparent;
  --hv-blur: 0px;
  --hv-line: rgba(255, 255, 255, 0.55);
  box-sizing: border-box;
  width: 100%;
  max-width: 1020px;
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--hv-title);
  background: var(--hv-bg);
  -webkit-backdrop-filter: blur(var(--hv-blur));
  backdrop-filter: blur(var(--hv-blur));
  border: 1px solid var(--hv-line);
  border-radius: 4px;
  text-align: left;
}
#hv-chat *, #hv-chat *::before, #hv-chat *::after { box-sizing: border-box; }

/* Aislamiento frente a los estilos del tema de WordPress */
#hv-chat :where(button, input) {
  margin: 0; min-height: 0; min-width: 0;
  font-family: inherit; line-height: normal;
  text-transform: none; letter-spacing: normal; text-shadow: none;
  box-shadow: none;
  -webkit-appearance: none; appearance: none;
}
#hv-chat :where(div, span, form, p) { line-height: 1.3; margin: 0; }
#hv-chat :where(a) { box-shadow: none; }

/* Cabecera */
#hv-chat-header {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--hv-line);
}
#hv-chat .hv-logo { width: 30px; height: 30px; color: var(--hv-accent); flex-shrink: 0; }
#hv-chat #hv-chat-title {
  margin: 0; padding: 0; border: 0;
  font-family: inherit; font-size: 22px; font-weight: 500; line-height: 1.2;
  letter-spacing: normal; text-transform: none;
  color: var(--hv-white);
}

/* Cuerpo */
#hv-chat-body {
  display: flex; flex-direction: column; gap: 16px;
  padding: 20px 24px 24px;
}

/* Mensajes */
#hv-chat-messages {
  display: flex; flex-direction: column; gap: 10px;
  max-height: min(420px, 55vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
@supports (height: 1dvh) {
  #hv-chat-messages { max-height: min(420px, 55dvh); }
}
#hv-chat-messages:empty { display: none; }
#hv-chat .hv-msg {
  max-width: 90%;
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#hv-chat .hv-msg.bot { align-self: flex-start; background: var(--hv-white); color: var(--hv-title); }
#hv-chat .hv-msg.bot a { color: var(--hv-accent); font-weight: 600; text-decoration: underline; }
#hv-chat .hv-msg.user { align-self: flex-end; background: var(--hv-accent); color: var(--hv-white); }
#hv-chat .hv-msg.typing { display: flex; gap: 5px; padding: 16px; }
#hv-chat .hv-msg.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--hv-muted);
  animation: hv-bounce 1.2s infinite ease-in-out;
}
#hv-chat .hv-msg.typing span:nth-child(2) { animation-delay: 0.15s; }
#hv-chat .hv-msg.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes hv-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* Preguntas predefinidas */
#hv-chat-presets { display: flex; flex-wrap: wrap; gap: 10px; }
#hv-chat-presets[hidden], #hv-chat-presets:empty { display: none; }
#hv-chat .hv-preset {
  display: inline-flex; align-items: center;
  padding: 9px 14px;
  background: var(--hv-chip);
  border: 1px solid var(--hv-accent);
  border-radius: 2px;
  font: inherit; font-size: 14px; font-weight: 400; line-height: 1.3;
  color: var(--hv-text-soft);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
#hv-chat .hv-preset:hover { background: var(--hv-white); color: var(--hv-accent-800); }
#hv-chat .hv-preset:focus-visible { outline: 2px solid var(--hv-white); outline-offset: 2px; }
#hv-chat .hv-preset:disabled { opacity: 0.55; cursor: default; }

/* Campo de texto */
#hv-chat-form { display: flex; gap: 10px; }
#hv-chat-input {
  flex: 1; min-width: 0;
  height: 48px;
  padding: 0 16px;
  background: var(--hv-field);
  border: 1px solid transparent;
  border-radius: 2px;
  font: inherit; font-size: 14px;
  color: var(--hv-title);
  outline: none;
}
#hv-chat-input::placeholder { color: var(--hv-text-soft); opacity: 1; }
#hv-chat-input:focus { border-color: var(--hv-accent); }
#hv-chat-send {
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  width: 96px; height: 48px;
  padding: 0;
  border: 0; border-radius: 2px;
  background: var(--hv-accent); color: var(--hv-white);
  cursor: pointer;
  transition: background 0.15s;
}
#hv-chat-send:hover:not(:disabled) { background: var(--hv-accent-800); }
#hv-chat-send:focus-visible { outline: 2px solid var(--hv-white); outline-offset: 2px; }
#hv-chat-send:disabled { opacity: 0.6; cursor: default; }

/* Aviso de privacidad opcional */
#hv-chat #hv-chat-privacy { margin-top: -6px; font-size: 12px; line-height: 1.4; color: var(--hv-white); opacity: 0.85; }
#hv-chat #hv-chat-privacy a { color: var(--hv-white); text-decoration: underline; }

/* Tablet y móvil */
@media (max-width: 640px) {
  #hv-chat-header { gap: 10px; padding: 14px 16px; }
  #hv-chat .hv-logo { width: 26px; height: 26px; }
  #hv-chat #hv-chat-title { font-size: 18px; }
  #hv-chat-body { gap: 12px; padding: 16px; }
  #hv-chat .hv-msg { max-width: 100%; font-size: 15px; }

  /* Botones en una fila con desplazamiento horizontal */
  #hv-chat-presets {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 -16px; padding: 1px 16px 2px;
    scroll-snap-type: x proximity;
    scroll-padding: 0 16px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  #hv-chat-presets::-webkit-scrollbar { display: none; }
  #hv-chat .hv-preset { flex: 0 0 auto; min-height: 44px; white-space: nowrap; scroll-snap-align: start; }

  /* 16px evita el zoom automático de iOS al enfocar el campo */
  #hv-chat-input { padding: 0 12px; font-size: 16px; }
  #hv-chat-send { width: 48px; }
}
@media (max-width: 380px) {
  #hv-chat-header { padding: 12px; }
  #hv-chat-body { padding: 12px; }
  #hv-chat-presets { margin: 0 -12px; padding: 1px 12px 2px; scroll-padding: 0 12px; }
  #hv-chat #hv-chat-title { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  #hv-chat .hv-msg.typing span { animation: none; }
}
