/*
 * GS ASISTENTE — widget.css: el chat de gamosolar.es.
 *
 * Todo cuelga de #gs-asis / .gs-asis-*: nada de aquí puede tocar al tema ni al revés. Tipografía
 * heredada del tema, pero con tamaños propios en píxeles porque Kadence pone button{font-size:.6em}
 * y, en button:hover/:focus/:active, fondo azul de su paleta con texto blanco y sombra: cada botón
 * del widget lleva fondo, color, borde y tamaño explícitos en los cuatro estados. Lo mismo con los
 * enlaces que hacen de botón (a:hover del tema).
 *
 * Colores de marca: azul #003D7A (marca, cabecera, burbuja del visitante), amarillo #FFC107 SOLO
 * para la acción principal (enviar), gris de texto #1F2937, fondos #F3F4F6.
 */

#gs-asis {
  --gsa-az: #003D7A;
  --gsa-az-os: #00305f;
  --gsa-am: #FFC107;
  --gsa-am-os: #f0b400;
  --gsa-tx: #1F2937;
  --gsa-gr: #6B7280;
  --gsa-f: #F3F4F6;
  --gsa-bd: #E5E7EB;
  --gsa-wa: #128C7E;
  --gsa-wa-os: #0e6f64;
  position: fixed;
  right: 16px;
  right: max(16px, env(safe-area-inset-right));
  bottom: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 99999;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.45;
  color: var(--gsa-tx);
  text-align: left;
  -webkit-text-size-adjust: 100%;
  box-sizing: border-box;
}
/* Con el botón flotante de WhatsApp de la web debajo (lo detecta widget.js), el lanzador sube. */
#gs-asis.gs-asis-alto { bottom: 84px; bottom: max(84px, calc(env(safe-area-inset-bottom) + 68px)); }
#gs-asis *, #gs-asis *::before, #gs-asis *::after { box-sizing: border-box; }
#gs-asis [hidden] { display: none !important; }
#gs-asis p, #gs-asis strong { margin: 0; }
#gs-asis .gs-asis-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); border: 0; white-space: nowrap;
}

/* ---- botones: anular lo del tema antes de pintar cada uno ---- */
#gs-asis button {
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  text-transform: none;
  letter-spacing: normal;
  margin: 0;
  cursor: pointer;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color .15s ease, color .15s ease, transform .15s ease;
}
#gs-asis button:hover, #gs-asis button:focus, #gs-asis button:active { box-shadow: none; text-decoration: none; }
#gs-asis button:focus { outline: none; }
#gs-asis button:focus-visible { outline: 3px solid var(--gsa-am); outline-offset: 2px; }
#gs-asis button:disabled { cursor: default; }

/* ---- lanzador ---- */
#gs-asis .gs-asis-lanzador {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; padding: 0;
  border: 0; border-radius: 50%;
  background: var(--gsa-az); color: #fff;
  box-shadow: 0 6px 20px rgba(0, 61, 122, .35);
}
#gs-asis .gs-asis-lanzador:hover, #gs-asis .gs-asis-lanzador:focus, #gs-asis .gs-asis-lanzador:active {
  background: var(--gsa-az-os); color: #fff; box-shadow: 0 8px 24px rgba(0, 61, 122, .4);
}
#gs-asis .gs-asis-lanzador:hover { transform: translateY(-1px); }
/* El detalle amarillo de la marca: un punto en la esquina del botón. */
#gs-asis .gs-asis-lanzador::after {
  content: ""; position: absolute; right: 1px; top: 1px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--gsa-am); border: 2px solid #fff;
}
#gs-asis .gs-asis-ico { display: block; width: 28px; height: 28px; }
#gs-asis .gs-asis-globo {
  position: absolute; left: -4px; top: -4px;
  display: flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; border: 2px solid #fff;
  background: #DC2626; color: #fff;
  font-size: 12px; font-weight: 700; line-height: 1;
}

/* ---- panel ---- */
#gs-asis .gs-asis-panel {
  position: absolute; right: 0; bottom: 72px;
  display: flex; flex-direction: column;
  width: 360px; height: 560px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 104px);
  background: #fff; color: var(--gsa-tx);
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .22), 0 0 0 1px rgba(0, 0, 0, .04);
  animation: gs-asis-subir .18s ease-out;
}
@keyframes gs-asis-subir { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

#gs-asis .gs-asis-cab {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 10px 12px 16px;
  background: var(--gsa-az); color: #fff;
  flex: 0 0 auto;
}
#gs-asis .gs-asis-cab-t { display: flex; align-items: center; gap: 10px; min-width: 0; }
#gs-asis .gs-asis-cab-sol {
  flex: 0 0 auto; width: 14px; height: 14px; border-radius: 50%;
  background: var(--gsa-am); box-shadow: 0 0 0 3px rgba(255, 193, 7, .25);
}
#gs-asis .gs-asis-titulo {
  display: block; font-size: 16px; font-weight: 700; line-height: 1.25; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#gs-asis .gs-asis-ia { font-size: 13px; font-weight: 600; color: rgba(255, 255, 255, .85); }
#gs-asis .gs-asis-cerrar {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0; flex: 0 0 auto;
  border: 0; border-radius: 50%;
  background: transparent; color: #fff;
}
#gs-asis .gs-asis-cerrar:hover, #gs-asis .gs-asis-cerrar:focus, #gs-asis .gs-asis-cerrar:active {
  background: rgba(255, 255, 255, .16); color: #fff;
}

/* ---- mensajes ---- */
#gs-asis .gs-asis-lista {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 12px;
  background: var(--gsa-f);
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
#gs-asis .gs-asis-msg { display: flex; flex-direction: column; max-width: 86%; }
#gs-asis .gs-asis-msg-bot, #gs-asis .gs-asis-msg-equipo { align-self: flex-start; }
#gs-asis .gs-asis-msg-yo { align-self: flex-end; }
#gs-asis .gs-asis-burbuja {
  padding: 9px 12px; border-radius: 14px;
  font-size: 15px; line-height: 1.45;
  word-wrap: break-word; overflow-wrap: anywhere;
  white-space: normal;
}
#gs-asis .gs-asis-msg-bot .gs-asis-burbuja, #gs-asis .gs-asis-msg-equipo .gs-asis-burbuja {
  background: #fff; color: var(--gsa-tx);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
#gs-asis .gs-asis-msg-yo .gs-asis-burbuja {
  background: var(--gsa-az); color: #fff;
  border-bottom-right-radius: 4px;
}
#gs-asis .gs-asis-msg-fallo .gs-asis-burbuja { opacity: .55; }
#gs-asis .gs-asis-etq {
  display: block; margin: 0 0 3px 4px;
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--gsa-az);
}
#gs-asis .gs-asis-burbuja a { color: var(--gsa-az); text-decoration: underline; font-weight: 600; word-break: break-all; }
#gs-asis .gs-asis-burbuja a:hover, #gs-asis .gs-asis-burbuja a:focus { color: var(--gsa-az-os); text-decoration: underline; }
#gs-asis .gs-asis-msg-yo .gs-asis-burbuja a,
#gs-asis .gs-asis-msg-yo .gs-asis-burbuja a:hover, #gs-asis .gs-asis-msg-yo .gs-asis-burbuja a:focus { color: #fff; }

/* Aviso de fallo bajo el mensaje, con el botón de reintentar. */
#gs-asis .gs-asis-msg-sys {
  align-self: stretch; max-width: none;
  flex-direction: row; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  font-size: 13px; color: var(--gsa-gr); text-align: center;
  padding: 2px 4px;
}
#gs-asis .gs-asis-reintentar {
  padding: 7px 14px;
  border: 1px solid var(--gsa-az); border-radius: 999px;
  background: #fff; color: var(--gsa-az);
  font-size: 13px;
}
#gs-asis .gs-asis-reintentar:hover, #gs-asis .gs-asis-reintentar:focus, #gs-asis .gs-asis-reintentar:active {
  background: var(--gsa-az); color: #fff; border-color: var(--gsa-az);
}

/* Los tres puntos de «pensando». */
#gs-asis .gs-asis-pensando .gs-asis-burbuja { display: flex; gap: 5px; align-items: center; padding: 13px 14px; }
#gs-asis .gs-asis-pensando span {
  display: block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--gsa-gr); opacity: .5;
  animation: gs-asis-punto 1.2s infinite ease-in-out;
}
#gs-asis .gs-asis-pensando span:nth-child(2) { animation-delay: .2s; }
#gs-asis .gs-asis-pensando span:nth-child(3) { animation-delay: .4s; }
@keyframes gs-asis-punto { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---- nota de estado, tarjeta de contacto, pie ---- */
#gs-asis .gs-asis-nota {
  flex: 0 0 auto; margin: 0; padding: 7px 14px;
  background: #fff; border-top: 1px solid var(--gsa-bd);
  font-size: 13px; color: var(--gsa-gr); text-align: center;
}
#gs-asis .gs-asis-contacto {
  flex: 0 0 auto; padding: 16px; background: #fff; border-top: 1px solid var(--gsa-bd);
}
#gs-asis .gs-asis-contacto-h { display: block; font-size: 17px; font-weight: 700; color: var(--gsa-az); margin: 0 0 4px; }
#gs-asis .gs-asis-contacto-t { margin: 0 0 12px; font-size: 14px; color: var(--gsa-tx); }
#gs-asis .gs-asis-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
#gs-asis a.gs-asis-btn {
  flex: 1 1 140px;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 10px 14px;
  border-radius: 999px; border: 1px solid transparent;
  font-size: 15px; font-weight: 700; line-height: 1.2;
  text-decoration: none; text-align: center; white-space: nowrap;
}
#gs-asis a.gs-asis-btn-wa { background: var(--gsa-wa); color: #fff; border-color: var(--gsa-wa); }
#gs-asis a.gs-asis-btn-wa:hover, #gs-asis a.gs-asis-btn-wa:focus, #gs-asis a.gs-asis-btn-wa:active {
  background: var(--gsa-wa-os); color: #fff; text-decoration: none;
}
#gs-asis a.gs-asis-btn-mail { background: var(--gsa-az); color: #fff; border-color: var(--gsa-az); }
#gs-asis a.gs-asis-btn-mail:hover, #gs-asis a.gs-asis-btn-mail:focus, #gs-asis a.gs-asis-btn-mail:active { background: var(--gsa-az-os); color: #fff; border-color: var(--gsa-az-os); }
#gs-asis .gs-asis-ref { margin-top: 10px; color: var(--gsa-gr); font-size: 12px; }
#gs-asis a.gs-asis-btn-tel { background: #fff; color: var(--gsa-az); border-color: var(--gsa-az); }
#gs-asis a.gs-asis-btn-tel:hover, #gs-asis a.gs-asis-btn-tel:focus, #gs-asis a.gs-asis-btn-tel:active {
  background: var(--gsa-az); color: #fff; text-decoration: none;
}
#gs-asis .gs-asis-pie {
  flex: 0 0 auto; margin: 0; padding: 6px 14px 10px;
  background: #fff;
  font-size: 11.5px; line-height: 1.4; color: var(--gsa-gr); text-align: center;
}
#gs-asis .gs-asis-pie a { color: var(--gsa-az); text-decoration: underline; }
#gs-asis .gs-asis-pie a:hover, #gs-asis .gs-asis-pie a:focus { color: var(--gsa-az-os); }

/* ---- formulario ---- */
#gs-asis .gs-asis-form {
  position: relative;
  flex: 0 0 auto;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px 6px;
  background: #fff; border-top: 1px solid var(--gsa-bd);
}
/* Honeypot: fuera de pantalla, no display:none (ese ya lo saltan los robots). */
#gs-asis .gs-asis-hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
#gs-asis .gs-asis-texto {
  flex: 1 1 auto; min-width: 0;
  min-height: 44px; max-height: 120px; height: 44px;
  margin: 0; padding: 10px 12px;   /* 10 + 21,6 de línea + 10 + bordes cabe en 44: sin barra de scroll en vacío */
  border: 1px solid var(--gsa-bd); border-radius: 12px;
  background: #fff; color: var(--gsa-tx);
  font-family: inherit; font-size: 16px; line-height: 1.35;   /* 16px: iOS no hace zoom al enfocar */
  resize: none; overflow-y: auto;
  box-shadow: none;
}
#gs-asis .gs-asis-texto::placeholder { color: var(--gsa-gr); opacity: 1; }
#gs-asis .gs-asis-texto:focus { outline: none; border-color: var(--gsa-az); box-shadow: 0 0 0 3px rgba(0, 61, 122, .15); }
/* La acción principal: el único amarillo del widget. */
#gs-asis .gs-asis-enviar {
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 44px; width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 12px;
  background: var(--gsa-am); color: var(--gsa-az);
}
#gs-asis .gs-asis-enviar:hover, #gs-asis .gs-asis-enviar:focus, #gs-asis .gs-asis-enviar:active {
  background: var(--gsa-am-os); color: var(--gsa-az);
}
#gs-asis .gs-asis-enviar:disabled, #gs-asis .gs-asis-enviar:disabled:hover {
  background: var(--gsa-am); color: var(--gsa-az); opacity: .5; transform: none;
}

/* ---- móvil: pantalla completa, con los márgenes de la zona segura ---- */
@media (max-width: 480px) {
  #gs-asis .gs-asis-panel {
    position: fixed; top: 0; right: 0; bottom: 0; left: 0;
    width: auto; height: auto; max-width: none; max-height: none;
    border-radius: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    animation: none;
  }
  #gs-asis.gs-asis-abierto .gs-asis-lanzador { display: none; }
  #gs-asis .gs-asis-msg { max-width: 90%; }
  #gs-asis .gs-asis-cab { padding-left: 14px; }
  #gs-asis .gs-asis-lista { padding: 12px 10px; }
  #gs-asis .gs-asis-form { padding: 10px 10px 6px; }
}
@media (max-height: 640px) and (min-width: 481px) {
  #gs-asis .gs-asis-panel { height: calc(100vh - 104px); }
}

/* ---- menos movimiento, impresión ---- */
@media (prefers-reduced-motion: reduce) {
  #gs-asis *, #gs-asis *::before, #gs-asis *::after { animation: none !important; transition: none !important; }
  #gs-asis .gs-asis-lanzador:hover { transform: none; }
  #gs-asis .gs-asis-pensando span { opacity: .6; }
}
@media print { #gs-asis { display: none !important; } }
