/* ===================================================
   CHATBOT DEYA LEVEL — Widget de IA
   =================================================== */

/* === BOTÓN FLOTANTE DEL CHAT === */
.chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 1000;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1B2A6B, #2d42a8);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55rem;
  box-shadow: 0 6px 28px rgba(27, 42, 107, 0.5);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: fabPulse 2.5s ease-in-out infinite;
}
.chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 10px 36px rgba(27, 42, 107, 0.65);
}
.chat-fab .fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: #B8963E;
  border-radius: 50%;
  border: 2px solid #fff;
  font-size: 0.62rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
@keyframes fabPulse {
  0%, 100% { box-shadow: 0 6px 28px rgba(27,42,107,.5); }
  50%       { box-shadow: 0 6px 36px rgba(27,42,107,.8), 0 0 0 8px rgba(27,42,107,.1); }
}

/* === VENTANA DEL CHAT === */
.chat-window {
  position: fixed;
  bottom: 108px;
  right: 28px;
  z-index: 1001;
  width: 370px;
  max-height: 580px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(27,42,107,.22), 0 4px 16px rgba(0,0,0,.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform-origin: bottom right;
}
.chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* === HEADER DEL CHAT === */
.chat-header {
  background: linear-gradient(135deg, #1B2A6B, #2d42a8);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  position: relative;
}
.chat-avatar::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background: #25D366;
  border-radius: 50%;
  border: 2px solid #1B2A6B;
}
.chat-header-info { flex: 1 }
.chat-header-info strong { display: block; color: #fff; font-size: .95rem; font-weight: 700; }
.chat-header-info span { color: rgba(255,255,255,.7); font-size: .75rem; }
.chat-close-btn {
  background: rgba(255,255,255,.12);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  transition: background .2s;
}
.chat-close-btn:hover { background: rgba(255,255,255,.25); }

/* === MENSAJES === */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f5f6fa;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: #d0d0e0; border-radius: 4px; }

/* Burbuja */
.msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: msgIn .25s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg.user { flex-direction: row-reverse; }
.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1B2A6B, #2d42a8);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  flex-shrink: 0;
}
.msg.user .msg-avatar { background: #B8963E; }
.msg-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: .88rem;
  line-height: 1.55;
  color: #1a1a2e;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.07);
  border-bottom-left-radius: 4px;
}
.msg.user .msg-bubble {
  background: linear-gradient(135deg, #1B2A6B, #2d42a8);
  color: #fff;
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 4px;
}
.msg-bubble a { color: #25D366; font-weight: 700; text-decoration: underline; }
.msg.user .msg-bubble a { color: #a8d8b9; }
.msg-time { font-size: .65rem; color: #aaa; margin-top: 4px; text-align: right; }

/* Chips de sugerencias */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px;
  background: #f5f6fa;
}
.suggestion-chip {
  background: #fff;
  border: 1.5px solid #d0d4e8;
  color: #1B2A6B;
  border-radius: 50px;
  padding: 6px 14px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  transition: all .2s;
}
.suggestion-chip:hover { background: #1B2A6B; color: #fff; border-color: #1B2A6B; }

/* Typing indicator */
.typing-indicator .msg-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}
.typing-dot {
  width: 7px;
  height: 7px;
  background: #aab;
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: .18s; }
.typing-dot:nth-child(3) { animation-delay: .36s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40%           { transform: translateY(-6px); opacity: 1; }
}

/* === INPUT === */
.chat-input-area {
  padding: 12px 14px;
  border-top: 1px solid #eee;
  background: #fff;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  border: 1.5px solid #e0e4f0;
  border-radius: 22px;
  padding: 10px 16px;
  font-family: 'Outfit', sans-serif;
  font-size: .88rem;
  outline: none;
  resize: none;
  max-height: 90px;
  line-height: 1.45;
  color: #1a1a2e;
  transition: border-color .2s;
}
.chat-input:focus { border-color: #1B2A6B; }
.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1B2A6B, #2d42a8);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  flex-shrink: 0;
  transition: all .2s;
}
.chat-send-btn:hover { transform: scale(1.08); }
.chat-send-btn:disabled { opacity: .4; cursor: default; transform: none; }

/* === POWERED BY === */
.chat-powered {
  text-align: center;
  font-size: .65rem;
  color: #bbb;
  padding: 4px 0 8px;
  background: #fff;
  flex-shrink: 0;
}
.chat-powered span { color: #B8963E; font-weight: 700; }

@media (max-width: 420px) {
  .chat-window { width: calc(100vw - 24px); right: 12px; bottom: 100px; }
  .chat-fab { right: 12px; bottom: 16px; }
}
