:root {
  --color-primario: #031A3D;
  /* Azul Marino */
  --color-primario-hover: #062659;
  --color-acento: #006B75;
  /* Teal Accesible */
  --color-acento-hover: #00545C;
  --color-decorativo: #00C9DB;
  /* Cyan Brillante */
  --color-azul-oscuro: #031A3D;
  --color-gris-fondo: #F3F4F6;
  --color-gris-claro: #F9FAFB;
  --color-gris-borde: #E5E7EB;
  --color-gris-texto: #6B7280;
  --color-gris-muted: #9CA3AF;
  --color-verde-online: #22C55E;
  --color-blanco: #ffffff;
  --sombra-widget: 0 8px 40px rgba(0, 0, 0, 0.15);
  --sombra-boton: 0 4px 20px rgba(0, 0, 0, 0.15);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
}

/* UTILIDADES */
.flex-centrado {
  display: flex;
  align-items: center;
  justify-content: center;
}

.oculto {
  display: none !important;
}

/* PÁGINA DE DEMO */
.pagina-demo {
  min-height: 100vh;
  background: var(--color-gris-fondo);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  padding: 2em;
  text-align: center;
  box-sizing: border-box;
}

.logo-demo {
  max-width: 200px;
  height: auto;
}

.subtitulo-demo {
  color: var(--color-gris-texto);
  font-size: 16px;
  font-weight: 600;
  font-family: Inter, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

.instrucciones-demo {
  color: var(--color-gris-muted);
  font-size: 14px;
  margin-top: 8px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/* BOTÓN DEL WIDGET */
#boton-widget-asintex {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--color-primario);
  border: none;
  cursor: pointer;
  box-shadow: var(--sombra-boton);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.5s ease;
}

#boton-widget-asintex:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}

#boton-widget-asintex svg {
  width: 28px;
  height: 28px;
  fill: var(--color-blanco);
}

/* CONTENEDOR PRINCIPAL DEL WIDGET */
#contenedor-widget-asintex {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9998;
  width: 380px;
  height: 560px;
  background: var(--color-blanco);
  border-radius: 16px;
  box-shadow: var(--sombra-widget);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--color-gris-borde);
  transition: all 0.3s ease;
  z-index: 10000;
}

/* OCULTAR BOTÓN SOLO CUANDO EL CHAT ESTÁ EXPANDIDO (BUG ALTO 1) */
body.widget-expandido #boton-widget-asintex {
  opacity: 0;
  pointer-events: none;
}

#contenedor-widget-asintex.abierto {
  display: flex;
}

#contenedor-widget-asintex.expandido {
  width: 720px;
  height: 85vh;
  bottom: 20px;
  right: 20px;
  border-radius: 16px;
}

/* CABECERA */
.cabecera-widget {
  background: var(--color-azul-oscuro);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.contenedor-logo-cabecera {
  width: 42px;
  height: 42px;
  background: var(--color-blanco);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.contenedor-logo-cabecera img {
  width: 85%;
  height: auto;
  border-radius: 50%;
}

.info-cabecera {
  flex: 1;
}

.info-cabecera h3 {
  color: var(--color-blanco);
  font-size: 14px;
  font-weight: 600;
}

.info-cabecera p {
  color: var(--color-decorativo);
  font-size: 12px;
  margin-top: 2px;
}

.estado-widget {
  display: flex;
  align-items: center;
  gap: 8px;
}

.punto-estado-widget {
  width: 8px;
  height: 8px;
  background: var(--color-verde-online);
  border-radius: 50%;
  animation: pulso 2s infinite;
}

.texto-estado-widget {
  color: var(--color-gris-muted);
  font-size: 11px;
}

@keyframes pulso {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.boton-expandir {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--color-gris-muted);
  transition: color 0.2s;
}

.boton-expandir:hover {
  color: var(--color-decorativo);
}

.boton-expandir svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* FORMULARIO DE CAPTURA */
.formulario-captura {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--color-gris-claro);
  border-bottom: 1px solid var(--color-gris-borde);
}

.formulario-captura h4 {
  font-size: 13px;
  color: var(--color-azul-oscuro);
  font-weight: 600;
}

.formulario-captura p {
  font-size: 12px;
  color: var(--color-gris-texto);
}

.formulario-captura input {
  padding: 10px 12px;
  border: 1px solid var(--color-gris-borde);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: border 0.2s;
}

.formulario-captura input:focus {
  border-color: var(--color-acento);
}

.formulario-captura button {
  padding: 10px;
  background: var(--color-primario);
  color: var(--color-blanco);
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.formulario-captura button:hover {
  background: var(--color-primario-hover);
}

/* CONTENEDOR DE MENSAJES */
.contenedor-mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.contenedor-mensajes::-webkit-scrollbar {
  width: 4px;
}

.contenedor-mensajes::-webkit-scrollbar-thumb {
  background: var(--color-gris-borde);
  border-radius: 2px;
}

.mensaje {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.mensaje-agente {
  background: #F3F4F6;
  color: var(--color-azul-oscuro);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.mensaje-usuario {
  background: var(--color-acento);
  color: var(--color-blanco);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.mensaje-espera {
  background: #F3F4F6;
  color: var(--color-gris-muted);
  align-self: flex-start;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}

.puntos-pensando {
  display: inline-flex;
  gap: 4px;
}

.puntos-pensando span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-acento);
  animation: rebote 1.2s infinite;
}

.puntos-pensando span:nth-child(2) {
  animation-delay: 0.2s;
}

.puntos-pensando span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes rebote {

  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.4;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ÁREA DE ENTRADA */
.area-entrada {
  padding: 12px 16px;
  border-top: 1px solid var(--color-gris-borde);
  display: flex;
  gap: 8px;
  align-items: center;
}

.area-entrada textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--color-gris-borde);
  border-radius: 12px;
  font-size: 13px;
  outline: none;
  transition: border 0.2s;
  resize: vertical;
  min-height: 40px;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
  font-family: inherit;
  width: 100%;
}

.area-entrada textarea:focus {
  border-color: var(--color-acento);
}

.area-entrada button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--color-primario);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.area-entrada button:hover {
  background: var(--color-primario-hover);
}

.area-entrada button.boton-clip {
  background: transparent;
  border: 1px solid var(--color-gris-borde);
  color: var(--color-gris-texto);
}

.area-entrada button.boton-clip:hover {
  background: var(--color-gris-fondo);
  border-color: var(--color-acento);
  color: var(--color-acento);
}

.area-entrada button.boton-clip svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.area-entrada button svg {
  width: 16px;
  height: 16px;
  fill: var(--color-blanco);
}

/* PIE DE PÁGINA */
.pie-pagina-widget {
  padding: 8px;
  text-align: center;
  font-size: 10px;
  color: var(--color-gris-muted);
  border-top: 1px solid #F3F4F6;
}

.pie-pagina-widget span {
  color: var(--color-acento);
}

/* FORMULARIO INICIAL - VALIDACIÓN */
.input-invalido {
  border-color: #EF4444 !important;
  /* Rojo */
  background-color: #FEF2F2 !important;
}

#boton-iniciar:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(1);
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .logo-demo {
    max-width: 160px !important;
    margin-bottom: 2rem;
  }

  #contenedor-widget-asintex {
    width: 100vw !important;
    height: 100dvh !important;
    bottom: 0 !important;
    right: 0 !important;
    border-radius: 0 !important;
    border: 0 !important;
  }

  /* Ocultar iconos que no sirven en móvil */
  #icono-expandir {
    display: none !important;
  }

  #icono-cerrar-movil {
    display: block !important;
    fill: currentColor;
    width: 20px;
    height: 20px;
  }

  /* Fix zoom iOS */
  .formulario-captura input,
  .area-entrada textarea {
    font-size: 16px !important;
  }

  /* En móvil, ocultamos el botón siempre que esté abierto */
  body.widget-abierto #boton-widget-asintex {
    opacity: 0;
    pointer-events: none;
  }
}