/* ============================================================
   ValidAI Chatbot — Maia Style
   ============================================================ */

/* ── Botón flotante ── */
#validai-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a7fe8 0%, #0d55c3 100%);
  box-shadow: 0 4px 20px rgba(13, 85, 195, 0.45);
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
  overflow: hidden;
}
#validai-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(13, 85, 195, 0.6);
}
#validai-fab img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
#validai-fab .fab-fallback {
  color: #fff;
  font-size: 26px;
}

/* ── Ventana del chat ── */
#validai-chat-window {
  position: fixed;
  bottom: 102px;
  right: 28px;
  width: 370px;
  max-width: calc(100vw - 40px);
  height: 530px;
  max-height: calc(100vh - 130px);
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 12px 50px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99998;
  opacity: 0;
  transform: translateY(20px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#validai-chat-window.vai-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ── */
#validai-chat-header {
  background: linear-gradient(135deg, #1a7fe8 0%, #0d55c3 100%);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#validai-chat-header .vai-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255,255,255,0.4);
}
#validai-chat-header .vai-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#validai-chat-header .vai-avatar .vai-avatar-fallback {
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#validai-chat-header .vai-header-text { flex: 1; }
#validai-chat-header .vai-header-text small {
  color: rgba(255,255,255,0.78);
  font-size: 11px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  display: block;
  margin-bottom: 2px;
}
#validai-chat-header .vai-header-text h3 {
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#validai-close-btn {
  background: rgba(255,255,255,0.18);
  border: none;
  color: #fff;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  transition: background 0.15s;
  flex-shrink: 0;
}
#validai-close-btn:hover { background: rgba(255,255,255,0.3); }

/* ── Mensajes ── */
#validai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: none;
  flex-direction: column;
  gap: 10px;
  background: #f5f7fb;
  scrollbar-width: thin;
  scrollbar-color: #d0d7e8 transparent;
}
#validai-messages::-webkit-scrollbar { width: 4px; }
#validai-messages::-webkit-scrollbar-thumb { background: #d0d7e8; border-radius: 4px; }

.vai-msg {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  word-wrap: break-word;
}
.vai-msg.vai-bot {
  background: #ffffff;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.vai-msg.vai-user {
  background: linear-gradient(135deg, #1a7fe8 0%, #0d55c3 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

/* Indicador de escritura */
.vai-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 12px 14px;
  background: #ffffff;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  max-width: 70px;
}
.vai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: vai-bounce 1.2s infinite;
}
.vai-typing span:nth-child(2) { animation-delay: 0.2s; }
.vai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes vai-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Formulario pre-chat ── */
#validai-lead-form {
  flex: 1;
  overflow-y: auto;
  background: #f5f7fb;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
}
.vai-form-inner {
  width: 100%;
  max-width: 320px;
}
.vai-form-title {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 6px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.vai-form-sub {
  font-size: 13px;
  color: #64748b;
  margin: 0 0 18px;
  line-height: 1.5;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.vai-field {
  margin-bottom: 12px;
}
.vai-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #475569;
  margin-bottom: 5px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.vai-field input {
  width: 100%;
  box-sizing: border-box;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #1e293b;
  outline: none;
  transition: border-color 0.2s;
}
.vai-field input:focus {
  border-color: #1a7fe8;
}
.vai-field input::placeholder {
  color: #94a3b8;
}
#vai-form-submit {
  width: 100%;
  background: linear-gradient(135deg, #1a7fe8 0%, #0d55c3 100%);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity 0.2s;
}
#vai-form-submit:hover { opacity: 0.9; }
#vai-form-submit:disabled { opacity: 0.6; cursor: default; }
.vai-form-privacy {
  font-size: 11px;
  color: #94a3b8;
  text-align: center;
  margin: 10px 0 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Sugerencias rápidas ── */
#validai-suggestions {
  padding: 6px 14px 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
  background: #f5f7fb;
}
.vai-suggestion {
  background: #ffffff;
  border: 1px solid #d0d7e8;
  color: #1a7fe8;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 11.5px;
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}
.vai-suggestion:hover {
  background: #e8f0fc;
  border-color: #1a7fe8;
}

/* ── Input ── */
#validai-input-area {
  padding: 10px 14px;
  background: #ffffff;
  border-top: 1px solid #e8ecf4;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
}
#validai-user-input {
  flex: 1;
  background: #f5f7fb;
  border: 1px solid #e2e8f0;
  color: #1e293b;
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  resize: none;
  outline: none;
  min-height: 42px;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color 0.2s;
}
#validai-user-input::placeholder { color: #94a3b8; }
#validai-user-input:focus { border-color: #1a7fe8; background: #fff; }

#validai-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a7fe8 0%, #0d55c3 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
  box-shadow: 0 2px 10px rgba(13, 85, 195, 0.35);
}
#validai-send-btn:hover { opacity: 0.9; transform: scale(1.06); }
#validai-send-btn:disabled { opacity: 0.4; cursor: default; transform: none; }
#validai-send-btn svg { width: 18px; height: 18px; fill: #fff; }

/* ── Responsive móvil ── */
@media (max-width: 480px) {
  #validai-chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    height: 80vh;
  }
  #validai-fab { bottom: 20px; right: 20px; }
}
