/*
 * Estilos comunes a todas las encuestas.
 * Los colores de abajo son los valores por defecto: cada encuesta los cambia
 * en su propio tema.css (encuestas/<nombre>/tema.css), junto con el fondo del chat.
 */
:root {
  --fondo-pagina: #020617; /* a los lados del chat en pantallas anchas */
  --fondo-app: #111b21;
  --cabecera: #202c33;
  --burbuja-bot: #202c33;
  --burbuja-usuario: #005c4b;
  --texto: #e9edef;
  --texto-secundario: #8696a0;
  --iconos: #aebac1;
  --acento: #00a884;
  --acento-pulsado: #0b3b33;
  --borde: #2a3942;
  --check-leido: #53bdeb;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--fondo-pagina);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 430px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--fondo-app);
}

/* ---------- Cabecera ---------- */

.cabecera {
  background: var(--cabecera);
  color: #fff;
  padding: 6px 6px 6px 2px;
  padding-top: max(6px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  flex-shrink: 0;
  min-height: 56px;
  gap: 2px;
}

.cabecera__volver {
  color: #fff;
  padding: 6px 2px 6px 4px;
  display: flex;
  align-items: center;
  border-radius: 50%;
}

.cabecera__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--borde);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
}

.cabecera__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cabecera__info {
  flex: 1;
  margin-left: 10px;
  min-width: 0;
}

.cabecera__nombre {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
  color: var(--texto);
}

.cabecera__estado {
  font-size: 12px;
  line-height: 1.3;
  color: var(--texto-secundario);
}

.cabecera__iconos {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--iconos);
}

.cabecera__iconos span {
  display: flex;
  padding: 6px;
}

.aviso-prueba {
  background: #7a5b00;
  color: #fff;
  font-size: 12px;
  text-align: center;
  padding: 4px 8px;
  flex-shrink: 0;
}

/* ---------- Chat ---------- */

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background-color: #ece5dd;
  /* la imagen de fondo la pone cada encuesta en su tema.css */
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center top;
}

.mensaje {
  max-width: 84%;
  margin-bottom: 3px;
}

.mensaje--bot {
  align-self: flex-start;
}

.mensaje--usuario {
  align-self: flex-end;
}

.burbuja {
  padding: 7px 10px 4px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--texto);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  white-space: pre-wrap;
  word-break: break-word;
}

.mensaje--bot .burbuja {
  background: var(--burbuja-bot);
  border-radius: 0 8px 8px 8px;
}

.mensaje--usuario .burbuja {
  background: var(--burbuja-usuario);
  border-radius: 8px 0 8px 8px;
}

.burbuja__hora {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  font-size: 11px;
  color: var(--texto-secundario);
  margin-top: 3px;
}

.burbuja__check {
  color: var(--check-leido);
  flex-shrink: 0;
}

/* Indicador "escribiendo..." (tres puntos) */
.escribiendo {
  padding: 12px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.escribiendo span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--texto-secundario);
  display: block;
  animation: rebote 1.3s ease-in-out infinite;
}

.escribiendo span:nth-child(2) {
  animation-delay: 0.22s;
}

.escribiendo span:nth-child(3) {
  animation-delay: 0.44s;
}

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

/* ---------- Botones de respuesta ---------- */

.acciones {
  background: var(--fondo-app);
  padding: 8px 10px 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  flex-shrink: 0;
}

.acciones[hidden] {
  display: none;
}

.fila {
  display: flex;
  gap: 8px;
}

.columna {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.boton {
  font-family: inherit;
  cursor: pointer;
  border-radius: 24px;
  transition: background 0.12s, filter 0.12s;
}

.boton:focus-visible,
.cabecera__volver:focus-visible {
  outline: 2px solid var(--check-leido);
  outline-offset: 2px;
}

.boton--no {
  flex: 1;
  padding: 12px;
  border: 1.5px solid var(--borde);
  background: var(--cabecera);
  color: var(--texto-secundario);
  font-size: 14px;
  font-weight: 500;
}

.boton--si {
  flex: 2;
  padding: 12px;
  border: none;
  background: var(--acento);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.boton--si:active {
  filter: brightness(0.9);
}

.boton--opcion,
.boton--final {
  width: 100%;
  border: 1.5px solid var(--acento);
  background: var(--cabecera);
  color: var(--acento);
  font-weight: 500;
}

.boton--opcion {
  padding: 10px 16px;
  font-size: 13px;
  text-align: left;
}

.boton--final {
  padding: 12px 16px;
  font-size: 14px;
}

.boton--opcion:active,
.boton--final:active,
.boton--no:active {
  background: var(--acento-pulsado);
}

.sin-js {
  color: var(--texto);
  text-align: center;
  padding: 24px;
}

@media (prefers-reduced-motion: reduce) {
  .escribiendo span {
    animation: none;
    opacity: 0.6;
  }
}
