/* Asistente de chat de gesturist.es (widget flotante). Colores de marca:
   turquesa #4ecdc4, negro #111111, blanco. */
.gchat {
  --gchat-teal: #4ecdc4;
  --gchat-teal-dark: #2a9d95;
  --gchat-black: #111111;
  --gchat-white: #ffffff;
  --gchat-gray: #f4f5f5;
  --gchat-border: #e2e4e4;
  --gchat-text: #333333;
  --gchat-muted: #6b6f6f;
  --gchat-bottom: 20px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--gchat-text);
}
.gchat *, .gchat *::before, .gchat *::after { box-sizing: border-box; }

/* Botón flotante: por debajo del banner de cookies (z-index 9999) y del
   motor de reservas; se eleva cuando el banner está visible. */
.gchat-launcher {
  position: fixed;
  right: 20px;
  bottom: var(--gchat-bottom);
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 18px 0 14px;
  border: none;
  border-radius: 26px;
  background: var(--gchat-black);
  color: var(--gchat-white);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.22);
  transition: background .2s, bottom .2s;
}
.gchat-launcher:hover { background: var(--gchat-teal-dark); }
.gchat-launcher:focus-visible { outline: 3px solid var(--gchat-teal); outline-offset: 3px; }
.gchat-launcher svg { flex-shrink: 0; color: var(--gchat-teal); }
.gchat-launcher:hover svg { color: var(--gchat-white); }
.gchat.is-open .gchat-launcher { display: none; }

.gchat-panel {
  position: fixed;
  right: 20px;
  bottom: var(--gchat-bottom);
  z-index: 9000;
  display: none;
  flex-direction: column;
  width: 370px;
  height: min(600px, calc(100vh - var(--gchat-bottom) - 40px));
  background: var(--gchat-white);
  border: 1px solid var(--gchat-border);
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  overflow: hidden;
}
.gchat.is-open .gchat-panel { display: flex; }

.gchat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  background: var(--gchat-black);
  color: var(--gchat-white);
}
.gchat-title { font-weight: 700; font-size: 15px; }
.gchat-subtitle { font-size: 12px; color: rgba(255,255,255,.65); }
.gchat-close {
  border: none;
  background: transparent;
  color: var(--gchat-white);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.gchat-close:focus-visible { outline: 2px solid var(--gchat-teal); }

/* Aviso de IA fijo bajo la cabecera (Reglamento de IA, art. 50). */
.gchat-ai-notice {
  padding: 8px 14px;
  background: #e8f8f7;
  border-bottom: 1px solid var(--gchat-teal);
  color: var(--gchat-black);
  font-size: 12.5px;
  line-height: 1.45;
}
.gchat-ai-notice p { margin: 0; }
.gchat-ai-notice a { color: var(--gchat-teal-dark); font-weight: 600; }
.gchat-ai-badge {
  display: inline-block;
  padding: 0 5px;
  line-height: 16px;
  vertical-align: 1px;
  background: var(--gchat-black);
  color: var(--gchat-white);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
}

.gchat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--gchat-gray);
}
.gchat-msg {
  max-width: 88%;
  padding: 10px 13px;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.gchat-msg p { margin: 0 0 .5em; }
.gchat-msg p:last-child { margin-bottom: 0; }
.gchat-msg ul { margin: .3em 0 .5em 1.2em; padding: 0; }
.gchat-msg a { color: var(--gchat-teal-dark); font-weight: 600; }
.gchat-msg--bot { align-self: flex-start; background: var(--gchat-white); border: 1px solid var(--gchat-border); }
.gchat-msg--user { align-self: flex-end; background: var(--gchat-black); color: var(--gchat-white); }
.gchat-msg--notice { font-size: 13px; border-left: 3px solid var(--gchat-teal); }

.gchat-suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.gchat-suggestion {
  border: 1px solid var(--gchat-teal);
  background: var(--gchat-white);
  color: var(--gchat-black);
  font: inherit;
  font-size: 13px;
  padding: 6px 10px;
  cursor: pointer;
  text-align: left;
}
.gchat-suggestion:hover { background: var(--gchat-teal); color: var(--gchat-white); }

.gchat-consent {
  align-self: stretch;
  background: var(--gchat-white);
  border: 1px solid var(--gchat-teal);
  padding: 12px;
  font-size: 12.5px;
}
.gchat-consent p { margin: 0 0 8px; }
.gchat-consent label { display: flex; gap: 8px; align-items: flex-start; font-weight: 600; cursor: pointer; }
.gchat-consent input { margin-top: 3px; accent-color: var(--gchat-teal-dark); }
.gchat-consent a { color: var(--gchat-teal-dark); }

.gchat-typing { align-self: flex-start; color: var(--gchat-muted); font-size: 13px; font-style: italic; }

.gchat-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--gchat-border);
  background: var(--gchat-white);
}
.gchat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--gchat-border);
  padding: 9px 10px;
  font: inherit;
  /* 64px al abrir y crece al escribir (JS). min-height: 0 anula la regla general
     "textarea { min-height: 110px }" de la página solo para este cuadro. */
  min-height: 0;
  height: 64px;
  max-height: 110px;
  overflow-y: auto;
}
.gchat-input:focus { outline: 2px solid var(--gchat-teal); border-color: var(--gchat-teal); }
.gchat-send {
  border: none;
  background: var(--gchat-teal);
  color: var(--gchat-white);
  font: inherit;
  font-weight: 700;
  padding: 0 14px;
  cursor: pointer;
}
.gchat-send:hover { background: var(--gchat-black); }
.gchat-send:disabled, .gchat-input:disabled { opacity: .55; cursor: not-allowed; }
.gchat-footnote { padding: 0 12px 8px; font-size: 11px; color: var(--gchat-muted); background: var(--gchat-white); }
.gchat-footnote a { color: var(--gchat-muted); }

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

@media (max-width: 640px) {
  /* En móvil, botón redondo solo con el icono, por encima de la zona segura. */
  .gchat-launcher {
    right: 16px;
    bottom: calc(var(--gchat-bottom) + env(safe-area-inset-bottom, 0px));
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
  }
  .gchat-launcher svg { width: 26px; height: 26px; }
  .gchat-launcher-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
  }
  /* Mientras el banner de cookies está visible, el botón no se muestra. */
  .gchat--banner-visible .gchat-launcher { display: none; }

  /* Ventana a casi toda la pantalla, por encima del banner de cookies (z-index 9999). */
  .gchat-panel {
    z-index: 10000;
    left: 6px;
    right: 6px;
    top: calc(8px + env(safe-area-inset-top, 0px));
    bottom: auto;
    width: auto;
    height: calc(100vh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    height: calc(100dvh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    max-height: none;
  }

  /* Cabecera en una sola línea */
  .gchat-header { padding: 10px 12px 10px 14px; }
  .gchat-subtitle { display: none; }

  /* Aviso de IA compacto */
  .gchat-ai-notice { padding: 6px 8px; font-size: 13px; line-height: 1.35; }
  .gchat-ai-badge { padding: 0 4px; font-size: 10px; line-height: 15px; }

  .gchat-messages { padding: 12px; }
  .gchat-msg { max-width: 92%; }

  /* Sugerencias: como mucho 3, en una fila que se desplaza en horizontal */
  .gchat-suggestions {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    margin: 0 -12px;
    padding: 0 12px 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .gchat-suggestions::-webkit-scrollbar { display: none; }
  .gchat-suggestion { flex: 0 0 auto; white-space: nowrap; font-size: 12.5px; padding: 5px 9px; }

  /* Cuadro de escribir: 1 línea que crece hasta 4; Enviar compacto y de la misma altura */
  .gchat-form { align-items: flex-end; padding: 8px; }
  .gchat-input {
    font-size: 16px; /* evita el zoom automático de iOS */
    line-height: 1.35;
    padding: 8px 10px;
    height: 40px;
    max-height: none;
    overflow-y: auto;
  }
  .gchat-send { flex: 0 0 auto; height: 40px; padding: 0 14px; font-size: 14px; }

  .gchat-footnote { display: none; }
}

/* Página de fondo bloqueada mientras el chat está abierto en móvil */
html.gchat-bloqueo-scroll, html.gchat-bloqueo-scroll body { overflow: hidden; }
html.gchat-bloqueo-scroll body { position: fixed; left: 0; right: 0; width: 100%; }
@media (prefers-reduced-motion: reduce) {
  .gchat-launcher { transition: none; }
}
