/* ── CHATBOT WIDGET ── */
#chat-widget {
  position: fixed;
  bottom: 155px;
  right: 75px;
  z-index: 999;
  font-family: var(--font-body);
}

#chat-toggle {
  width: 53px;
  height: 53px;
  border-radius: 50%;
  background: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(123,189,232,0.3);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  animation: pulse 1s infinite alternate;
  overflow: hidden;
  padding: 0;
}

#chat-toggle img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

#chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(123,189,232,0.55);
}


/* Ventana del chat */
.chat-box {
  position: absolute;
  bottom: 66px; right: 0;
  width: 320px;
  background: var(--ink);
  border: 1px solid rgba(123,189,232,0.18);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.chat-box.open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
}

/* Header */
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: rgba(123,189,232,0.08);
  border-bottom: 1px solid rgba(123,189,232,0.12);
}
.chat-header-info { display: flex; align-items: center; gap: 10px; }
.chat-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--ink-mid);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.chat-avatar img {
  width: 24px; height: 24px;
  object-fit: contain;
}
.chat-name { font-family: var(--font-display); font-size: 0.85rem; font-weight: 600; color: white; }
.chat-status {
  font-size: 0.7rem; color: #4ade80;
  display: flex; align-items: center; gap: 4px;
}
.chat-status::before {
  content: ''; width: 6px; height: 6px;
  background: #4ade80; border-radius: 50%;
}
.chat-close {
  background: none; border: none;
  color: rgba(200,212,232,0.5); cursor: pointer;
  font-size: 1rem; padding: 4px;
  transition: color 0.2s;
}
.chat-close:hover { color: white; }

/* Mensajes */
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  max-height: 260px; min-height: 160px;
}
.chat-msg { max-width: 85%; animation: fadeUp 0.3s ease forwards; }
.chat-msg p { margin: 0; padding: 10px 14px; border-radius: 12px; font-size: 0.85rem; line-height: 1.5; }
.chat-msg.bot  { align-self: flex-start; }
.chat-msg.bot p { background: rgba(255,255,255,0.07); color: rgba(200,212,232,0.9); border-bottom-left-radius: 4px; }
.chat-msg.user { align-self: flex-end; }
.chat-msg.user p { background: var(--cyan); color: var(--ink); font-weight: 500; border-bottom-right-radius: 4px; }

/* Typing */
.chat-typing p { display: flex; gap: 4px; align-items: center; }
.chat-typing span {
  width: 6px; height: 6px;
  background: rgba(200,212,232,0.4); border-radius: 50%;
  animation: typingDot 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* Cold start notice */
.chat-coldstart {
  font-size: 0.68rem;
  color: rgba(200,212,232,0.3);
  text-align: center;
  padding: 2px 16px 8px;
}

/* Input */
.chat-input-area {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
#chatInput {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 8px 14px;
  color: white; font-size: 0.85rem;
  outline: none; transition: border-color 0.2s;
}
#chatInput:focus { border-color: rgba(123,189,232,0.4); }
#chatInput::placeholder { color: rgba(200,212,232,0.35); }

#chatSend {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--cyan); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink); font-size: 0.8rem;
  transition: background 0.2s, transform 0.2s;
  flex-shrink: 0;
}
#chatSend:hover { transform: scale(1.08); }
#chatSend:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

@media (max-width: 900px) {
  #chat-widget { right: 14px; bottom: 84px; }
  #chat-toggle { width: 44px; height: 44px; }
  #chat-toggle img { width: 30px; height: 30px; }
}
@media (max-width: 480px) {
  #chat-widget { right: 12px; bottom: 73px; }
  #chat-toggle { width: 39px; height: 39px; }
  #chat-toggle img { width: 26px; height: 26px; }
  .chat-box { width: calc(100vw - 32px); }
}
