/* Widget del chat web. Todo cuelga de #fsr-chat para no pisar el tema.
 * 0.2.0 (28/10/2026): avatar y subtitulo, botones de cabecera con icono, sugerencias,
 * puntos animados, "Reintentar", aviso "¿Te ayudo?" y pantalla completa en el movil. */
#fsr-chat {
  --fsr-acento: #14213d;
  --fsr-acento-texto: #ffffff;
  --fsr-realce: #f4a261;
  --fsr-fondo: #ffffff;
  --fsr-texto: #16181d;
  --fsr-suave: #eef0f4;
  --fsr-borde: #d6d9e0;
  /* Por encima del boton flotante .fs-whatsapp del tema (90 px del borde, 55 px de alto). */
  --fsr-abajo: 160px;
  position: fixed; right: 20px; bottom: var(--fsr-abajo); z-index: 99990;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--fsr-texto);
}
#fsr-chat * { box-sizing: border-box; }
/* El tema (Woodmart) da a todo textarea min-height: 190px y a todo boton mayusculas,
   min-height: 42px y relleno propio. Se anulan aqui para que el widget no dependa del tema. */
#fsr-chat button, #fsr-chat textarea, #fsr-chat input {
  min-height: 0; height: auto; margin: 0; box-shadow: none;
  text-transform: none; letter-spacing: normal; line-height: 1.4;
}
#fsr-chat .fsr-chat-oculto {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
#fsr-chat .fsr-chat-burbuja {
  padding: 0;
  width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--fsr-acento); color: var(--fsr-acento-texto);
  display: grid; place-items: center; box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
}
#fsr-chat .fsr-chat-burbuja svg { width: 26px; height: 26px; fill: currentColor; }
#fsr-chat .fsr-chat-burbuja:focus-visible,
#fsr-chat button:focus-visible, #fsr-chat textarea:focus-visible, #fsr-chat input:focus-visible {
  outline: 3px solid var(--fsr-realce); outline-offset: 2px;
}
#fsr-chat .fsr-chat-panel {
  display: none; position: absolute; right: 0; bottom: 68px;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - var(--fsr-abajo) - 90px));
  background: var(--fsr-fondo); border: 1px solid var(--fsr-borde); border-radius: 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .18); overflow: hidden;
  flex-direction: column;
}
#fsr-chat.fsr-chat-abierto .fsr-chat-panel { display: flex; }
/* 0.3.1 (17/11/2026): con la barra de administracion de WordPress (32 px arriba, por encima
   de todo), el panel no debe meterse debajo de ella. Solo la ven los administradores. */
@media (min-width: 481px) {
  body.admin-bar #fsr-chat:not(.fsr-chat-grande) .fsr-chat-panel {
    height: min(560px, calc(100vh - var(--fsr-abajo) - 90px - 32px));
  }
}

/* Cabecera: avatar con la inicial, nombre y subtitulo, y los botones de icono. */
#fsr-chat .fsr-chat-cabecera {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 10px 10px 14px; background: var(--fsr-acento); color: var(--fsr-acento-texto);
}
#fsr-chat .fsr-chat-quien { display: flex; align-items: center; gap: 10px; min-width: 0; }
#fsr-chat .fsr-chat-avatar {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--fsr-realce); color: var(--fsr-acento); font-weight: 700; font-size: 16px;
}
#fsr-chat .fsr-chat-nombres { display: grid; min-width: 0; }
#fsr-chat .fsr-chat-cabecera h2 {
  margin: 0; font-size: 15px; font-weight: 600; color: inherit; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#fsr-chat .fsr-chat-subtitulo { font-size: 12px; opacity: .78; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#fsr-chat .fsr-chat-acciones { display: flex; align-items: center; gap: 2px; flex: none; }
#fsr-chat .fsr-chat-icono {
  width: 32px; height: 32px; padding: 0; border: 0; border-radius: 6px; cursor: pointer;
  background: transparent; color: inherit; display: grid; place-items: center;
}
#fsr-chat .fsr-chat-icono:hover, #fsr-chat .fsr-chat-cerrar:hover { background: rgba(255, 255, 255, .12); }
#fsr-chat svg.fsr-chat-trazo {
  width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
#fsr-chat .fsr-chat-cerrar {
  background: transparent; border: 0; border-radius: 6px; color: inherit; font-size: 24px; line-height: 1;
  cursor: pointer; width: 32px; height: 32px; padding: 0;
}

/* Vista ampliada: el panel pasa a ser una ventana centrada con fondo oscuro. */
#fsr-chat .fsr-chat-fondo { display: none; position: fixed; inset: 0; background: rgba(10, 15, 30, .45); }
#fsr-chat.fsr-chat-abierto.fsr-chat-grande .fsr-chat-fondo { display: block; }
#fsr-chat.fsr-chat-grande .fsr-chat-panel {
  position: fixed; top: 50%; left: 50%; right: auto; bottom: auto;
  transform: translate(-50%, -50%);
  width: min(760px, calc(100vw - 32px)); height: min(720px, calc(100vh - 48px));
}
#fsr-chat.fsr-chat-grande .fsr-chat-burbuja { visibility: hidden; }
#fsr-chat.fsr-chat-grande .fsr-chat-msg { max-width: 75%; }

/* Conversacion */
#fsr-chat .fsr-chat-lista { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; background: #fbfbfd; }
#fsr-chat .fsr-chat-msg {
  max-width: 85%; margin: 6px 0; padding: 8px 12px; border-radius: 14px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
#fsr-chat .fsr-chat-bot { background: var(--fsr-suave); border-bottom-left-radius: 4px; }
#fsr-chat .fsr-chat-visitante {
  margin-left: auto; background: var(--fsr-acento); color: var(--fsr-acento-texto);
  border-bottom-right-radius: 4px;
}
#fsr-chat .fsr-chat-msg a { color: inherit; text-decoration: underline; }
#fsr-chat .fsr-chat-fallo { background: #fff4e5; border: 1px solid #f1d3a6; }
#fsr-chat .fsr-chat-reintentar {
  margin-top: 6px; padding: 4px 12px; border: 1px solid var(--fsr-acento); border-radius: 999px;
  background: #fff; color: var(--fsr-acento); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}

/* Puntos mientras responde */
#fsr-chat .fsr-chat-escribiendo { display: inline-flex; gap: 4px; align-items: center; padding: 12px 14px; }
#fsr-chat .fsr-chat-punto {
  width: 7px; height: 7px; border-radius: 50%; background: #8a90a0; opacity: .5;
}

/* Sugerencias con la conversacion vacia */
#fsr-chat .fsr-chat-sugerencias { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
#fsr-chat .fsr-chat-sugerencias-titulo { flex-basis: 100%; margin: 0 0 2px; font-size: 13px; color: #5b6170; }
#fsr-chat .fsr-chat-sugerencia {
  padding: 7px 12px; border: 1px solid var(--fsr-borde); border-radius: 999px; cursor: pointer;
  background: #fff; color: var(--fsr-acento); font: inherit; font-size: 13.5px; text-align: left;
}
#fsr-chat .fsr-chat-sugerencia:hover { border-color: var(--fsr-acento); background: var(--fsr-suave); }

#fsr-chat .fsr-chat-nota { margin: 0; padding: 4px 12px; font-size: 12px; color: #5b6170; }
#fsr-chat .fsr-chat-nota a { color: inherit; text-decoration: underline; }
#fsr-chat .fsr-chat-form {
  display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--fsr-borde);
}
#fsr-chat textarea, #fsr-chat input[type=text], #fsr-chat input[type=email], #fsr-chat input[type=tel] {
  width: 100%; font: inherit; color: inherit; background: #fff;
  border: 1px solid var(--fsr-borde); border-radius: 10px; padding: 8px 10px;
}
#fsr-chat .fsr-chat-form textarea { resize: none; flex: 1; max-height: 120px; overflow-y: auto; }
#fsr-chat .fsr-chat-enviar {
  flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; padding: 0; cursor: pointer;
  background: var(--fsr-acento); color: var(--fsr-acento-texto); display: grid; place-items: center;
}
#fsr-chat .fsr-chat-enviar svg { width: 18px; height: 18px; fill: currentColor; }
#fsr-chat .fsr-chat-contacto button {
  border: 0; border-radius: 8px; padding: 10px 14px; width: 100%; cursor: pointer;
  background: var(--fsr-acento); color: var(--fsr-acento-texto); font: inherit; font-weight: 600;
}
#fsr-chat button:disabled { opacity: .55; cursor: default; }
#fsr-chat .fsr-chat-contacto {
  margin: 8px 0; padding: 10px; border: 1px solid var(--fsr-borde); border-radius: 10px;
  display: grid; gap: 8px; background: #fff;
}
#fsr-chat .fsr-chat-campo { display: grid; gap: 4px; font-size: 13px; }
#fsr-chat .fsr-chat-privacidad { font-size: 13px; }
#fsr-chat .fsr-chat-error { margin: 0; color: #9b2226; font-size: 13px; }

/* Aviso "¿Te ayudo?" junto a la burbuja */
#fsr-chat .fsr-chat-aviso {
  position: absolute; right: 64px; bottom: 8px; display: flex; align-items: center; gap: 4px;
  background: #fff; color: var(--fsr-texto); border: 1px solid var(--fsr-borde); border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .14); padding: 4px 4px 4px 12px;
  /* 0.4.0: el saludo aprobado es largo (106 caracteres): parte la linea. */
  white-space: normal; width: max-content; max-width: min(340px, calc(100vw - 100px));
}
#fsr-chat .fsr-chat-aviso-texto { text-align: left; line-height: 1.35; }
#fsr-chat .fsr-chat-aviso-texto {
  border: 0; background: transparent; color: inherit; font: inherit; font-size: 14px; cursor: pointer; padding: 6px 0;
}
#fsr-chat .fsr-chat-aviso-cerrar {
  border: 0; background: transparent; color: #5b6170; font-size: 18px; width: 26px; height: 26px; cursor: pointer; padding: 0;
}
#fsr-chat.fsr-chat-abierto .fsr-chat-aviso { display: none; }

/* 0.4.0: letrero fijo «¿Te ayudo?» junto a la burbuja */
#fsr-chat .fsr-chat-letrero {
  position: absolute; right: 64px; bottom: 12px; white-space: nowrap; cursor: pointer;
  background: var(--fsr-acento); color: var(--fsr-acento-texto); border: 0; border-radius: 999px;
  padding: 7px 14px; font: inherit; font-size: 14px; font-weight: 600;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}
#fsr-chat .fsr-chat-letrero[hidden], #fsr-chat.fsr-chat-abierto .fsr-chat-letrero { display: none; }
#fsr-chat .fsr-chat-sugerencia-enlace { display: inline-block; text-decoration: none; }
#fsr-chat .fsr-chat-confirmar {
  margin: 8px 0; padding: 10px 12px; border: 1px solid var(--fsr-borde); border-radius: 12px;
  background: var(--fsr-suave);
}
#fsr-chat .fsr-chat-confirmar p { margin: 0 0 8px; }

/* Movil: el chat ocupa la pantalla entera; ampliar no tiene sentido. */
@media (max-width: 480px) {
  #fsr-chat { right: 12px; }
  #fsr-chat.fsr-chat-abierto .fsr-chat-panel {
    position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh;
    border-radius: 0; border: 0; transform: none;
  }
  #fsr-chat.fsr-chat-abierto .fsr-chat-burbuja { visibility: hidden; }
  #fsr-chat .fsr-chat-ampliar { display: none; }
  #fsr-chat .fsr-chat-aviso { white-space: normal; max-width: calc(100vw - 100px); }
  #fsr-chat .fsr-chat-letrero { font-size: 13px; padding: 6px 12px; }
}
@media (prefers-reduced-motion: no-preference) {
  #fsr-chat .fsr-chat-burbuja { transition: transform .15s ease; }
  #fsr-chat .fsr-chat-burbuja:hover { transform: scale(1.05); }
  #fsr-chat .fsr-chat-msg, #fsr-chat .fsr-chat-sugerencias, #fsr-chat .fsr-chat-aviso {
    animation: fsr-chat-entra .18s ease-out;
  }
  #fsr-chat .fsr-chat-punto { animation: fsr-chat-punto 1.2s infinite ease-in-out; }
  #fsr-chat .fsr-chat-punto:nth-child(2) { animation-delay: .15s; }
  #fsr-chat .fsr-chat-punto:nth-child(3) { animation-delay: .3s; }
}
@keyframes fsr-chat-entra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fsr-chat-punto { 0%, 80%, 100% { opacity: .35; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

/* 0.4.3 (18/11/2026): «Beta» junto al nombre y el boton «Sugerencias o problemas». */
#fsr-chat .fsr-chat-linea-titulo { display: flex !important; align-items: center !important; gap: 6px !important; }
#fsr-chat .fsr-chat-beta { display: inline-block !important; font-size: 10px !important; line-height: 1 !important;
  font-weight: 700 !important; letter-spacing: .04em !important; text-transform: uppercase !important;
  padding: 3px 6px !important; border-radius: 999px !important; background: #f4a259 !important; color: #14213d !important; }
#fsr-chat button.fsr-chat-sugerir { all: unset; cursor: pointer !important; text-decoration: underline !important;
  color: inherit !important; font: inherit !important; }
#fsr-chat button.fsr-chat-sugerir:focus-visible { outline: 2px solid #f4a259 !important; outline-offset: 2px !important; }
#fsr-chat .fsr-chat-sugerir-form textarea { width: 100% !important; box-sizing: border-box !important; }
#fsr-chat .fsr-chat-sugerir-form .fsr-chat-sugerir-cancelar { margin-left: 8px !important; }
