* { box-sizing: border-box; margin: 0; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f2f4f7;
  color: #1c2733;
  min-height: 100vh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.2rem;
  background: #1c2733;
  color: #fff;
}
header h1 { font-size: 1.1rem; }
header nav { display: flex; gap: 1rem; align-items: center; }
header a { color: #9fc2ff; text-decoration: none; }

.estado {
  font-size: 0.85rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}
.estado.conectado { background: #17643a; }
.estado.desconectado { background: #7a2222; }

main { padding: 1.2rem; max-width: 1100px; margin: 0 auto; }

.tarjeta {
  background: #fff;
  border-radius: 10px;
  padding: 1.2rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.tarjeta h2 { font-size: 1rem; margin-bottom: 0.8rem; }

.formulario { max-width: 380px; margin: 3rem auto; }
.formulario label { display: block; margin-bottom: 0.8rem; font-size: 0.9rem; }
.formulario input {
  width: 100%; padding: 0.5rem; margin-top: 0.25rem;
  border: 1px solid #c6cdd6; border-radius: 6px; font-size: 1rem;
}
.formulario button {
  width: 100%; padding: 0.6rem; border: 0; border-radius: 6px;
  background: #2456b3; color: #fff; font-size: 1rem; cursor: pointer;
}
.formulario .pie { margin-top: 0.9rem; font-size: 0.85rem; }
.error { color: #a12626; margin-bottom: 0.8rem; font-size: 0.9rem; }

.panel {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.2rem;
}
@media (max-width: 800px) { .panel { grid-template-columns: 1fr; } }

#mensajes {
  height: 420px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 0.4rem; background: #f7f9fb; border-radius: 8px;
}
.mensaje { max-width: 85%; padding: 0.5rem 0.7rem; border-radius: 10px; }
.mensaje .texto { white-space: pre-wrap; font-size: 0.92rem; }
.mensaje.usuario { align-self: flex-end; background: #dcebff; }
.mensaje.asistente { align-self: flex-start; background: #e8ecf1; }
.mensaje img { max-width: 100%; border-radius: 8px; margin-top: 0.4rem; }
.mensaje audio { width: 100%; margin-top: 0.4rem; height: 32px; }

#formulario-chat { display: flex; gap: 0.5rem; margin-top: 0.7rem; }
#formulario-chat input {
  flex: 1; padding: 0.55rem; border: 1px solid #c6cdd6;
  border-radius: 6px; font-size: 0.95rem;
}
#formulario-chat button {
  padding: 0.55rem 1rem; border: 0; border-radius: 6px;
  background: #2456b3; color: #fff; cursor: pointer;
}
#formulario-chat button:disabled { opacity: 0.5; cursor: not-allowed; }
#boton-microfono {
  background: #eef1f5; color: #1c2733; font-size: 1.1rem; padding: 0.55rem 0.8rem;
}
#boton-microfono.grabando {
  background: #c22f2f; color: #fff; animation: pulso 1.2s infinite;
}
#boton-microfono.escuchando {
  background: #17643a; color: #fff; animation: pulso 1.2s infinite;
}
#boton-colgar {
  background: #eef1f5; color: #1c2733; font-size: 1.1rem; padding: 0.55rem 0.8rem;
}
@keyframes pulso {
  0%, 100% { box-shadow: 0 0 0 0 rgba(194, 47, 47, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(194, 47, 47, 0); }
}
.estado-microfono {
  margin-top: 0.4rem; font-size: 0.82rem; color: #4a5a6b;
}

.ayuda { margin-top: 0.7rem; font-size: 0.85rem; color: #4a5a6b; }
.ayuda pre { white-space: pre-wrap; margin-top: 0.4rem; }

#lista-eventos { list-style: none; max-height: 520px; overflow-y: auto; }
#lista-eventos li {
  padding: 0.45rem 0.55rem; border-left: 4px solid #b9c3cf;
  margin-bottom: 0.4rem; background: #f7f9fb;
  border-radius: 0 6px 6px 0; font-size: 0.88rem;
}
#lista-eventos li.atencion { border-color: #d99a1f; background: #fdf6e7; }
#lista-eventos li.alerta { border-color: #c22f2f; background: #fdecec; }
#lista-eventos .meta { color: #617182; font-size: 0.78rem; }
.silencio { color: #7a8794; }
