#iq-chat-btn {
  position: fixed;
  bottom: 28px; right: 28px;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: #00b5e7;
  border: none; cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 181, 231,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  transition: transform .2s, box-shadow .2s;
}
#iq-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0, 181, 231,.6);
}

/* Íconos: chat visible por defecto, X oculta */
#iq-chat-btn .icon-chat { display: flex; }
#iq-chat-btn .icon-close { display: none; }

/* Cuando el botón tiene clase .is-open, se intercambian */
#iq-chat-btn.is-open .icon-chat { display: none; }
#iq-chat-btn.is-open .icon-close { display: flex; }

/* Badge de notificación */
#iq-chat-badge {
  position: absolute; top: -4px; right: -4px;
  width: 18px; height: 18px;
  background: #e84040; border-radius: 50%;
  border: 2px solid #fff;
  font-size: 10px; font-weight: 700; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: sans-serif;
  pointer-events: none;
}

/* Ventana del chat */
#iq-chat-window {
  position: fixed;
  bottom: 100px; right: 28px;
  width: 360px; max-height: 520px;
  background: #fff; border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,.22);
  display: none; flex-direction: column;
  z-index: 9998; overflow: hidden;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
#iq-chat-window.open { display: flex; }

/* Header con botón X integrado */
#iq-chat-header {
  background: #1a1a2e; color: #fff;
  padding: 12px 14px 12px 18px;
  display: flex; align-items: center; gap: 10px;
}
#iq-chat-header .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #00b5e7;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #1a1a2e; flex-shrink: 0;
}
#iq-chat-header .info { flex: 1; }
#iq-chat-header .info strong { display: block; font-size: 14px; }
#iq-chat-header .info span {
  font-size: 11px; color: #00b5e7;
  display: flex; align-items: center; gap: 4px;
}
#iq-chat-header .info span::before {
  content: ''; width: 7px; height: 7px;
  border-radius: 50%; background: #4cde80;
  display: inline-block;
}

/* Botón cerrar dentro del header */
#iq-chat-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
#iq-chat-close:hover { background: rgba(255,255,255,.25); }

/* Mensajes */
#iq-chat-messages {
  flex: 1; overflow-y: auto;
  padding: 16px 14px;
  display: flex; flex-direction: column; gap: 10px;
  background: #f7f7f8;
}
#iq-chat-messages::-webkit-scrollbar { width: 4px; }
#iq-chat-messages::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 4px; }

.iq-msg {
  max-width: 82%; padding: 10px 13px;
  border-radius: 14px; font-size: 13.5px;
  line-height: 1.55; word-break: break-word;
}
.iq-msg.bot {
  background: #fff; color: #222;
  align-self: flex-start; border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.iq-msg.user {
  background: #1a1a2e; color: #fff;
  align-self: flex-end; border-bottom-right-radius: 4px;
}
.iq-msg.typing {
  background: #fff; align-self: flex-start;
  padding: 12px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  border-bottom-left-radius: 4px;
}
.iq-dots { display: flex; gap: 5px; }
.iq-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #bbb; animation: iq-bounce .9s infinite;
}
.iq-dots span:nth-child(2) { animation-delay: .15s; }
.iq-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes iq-bounce {
  0%,60%,100% { transform: translateY(0); }
  30% { transform: translateY(-5px); background: #f4c430; }
}

/* Respuestas rápidas */
.iq-quick-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.iq-quick-btns button {
  background: #fff; border: 1.5px solid #e0e0e0;
  border-radius: 20px; padding: 5px 12px;
  font-size: 12px; cursor: pointer; color: #1a1a2e;
  transition: background .15s, border-color .15s;
  font-family: inherit;
}
.iq-quick-btns button:hover { background: #00b5e7; border-color: #00b5e7; color: #FFF; }

/* Footer / input */
#iq-chat-footer {
  padding: 10px 12px; background: #fff;
  border-top: 1px solid #eee;
  display: flex; gap: 8px; align-items: flex-end;
}
#iq-chat-input {
  flex: 1; border: 1.5px solid #e0e0e0; border-radius: 22px;
  padding: 9px 14px; font-size: 13.5px; font-family: inherit;
  resize: none; outline: none; line-height: 1.4;
  max-height: 90px; overflow-y: auto;
  transition: border-color .2s;
}
#iq-chat-input:focus { border-color: #00b5e7; }
#iq-chat-send {
  width: 38px; height: 38px; border-radius: 50%;
  background: #00b5e7; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s, transform .1s;
}
#iq-chat-send:hover { background: #062a7c; }
#iq-chat-send:active { transform: scale(0.93); }

@media (max-width: 420px) {
  #iq-chat-window { width: calc(100vw - 24px); right: 12px; bottom: 90px; }
  #iq-chat-btn { bottom: 18px; right: 16px; }
}