/* Demo intake chatbot widget */
#opsloop-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border: none;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
#opsloop-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(37, 99, 235, 0.5);
}
#opsloop-chat-btn svg { width: 28px; height: 28px; fill: white; }

#opsloop-chat-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  z-index: 9998;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
#opsloop-chat-window.open { display: flex; }

#opsloop-chat-header {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: white;
  padding: 16px 20px;
  font-family: 'DM Sans', sans-serif;
}
#opsloop-chat-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
#opsloop-chat-header p { margin: 4px 0 0; font-size: 12px; opacity: 0.85; }
#opsloop-chat-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  opacity: 0.7;
}
#opsloop-chat-close:hover { opacity: 1; }

#opsloop-chat-body {
  flex: 1;
  height: 360px;
  overflow-y: auto;
  padding: 16px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.opsloop-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  animation: fadeSlide 0.25s ease;
}
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.opsloop-msg.bot { background: #fff; border: 1px solid #e2e8f0; align-self: flex-start; color: #1e293b; }
.opsloop-msg.user { background: linear-gradient(135deg, #2563eb, #7c3aed); color: white; align-self: flex-end; }
.opsloop-msg.system { background: #f1f5f9; color: #64748b; font-size: 13px; align-self: center; text-align: center; }

#opsloop-chat-footer {
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  background: white;
}
#opsloop-chat-input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  resize: none;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s;
}
#opsloop-chat-input:focus { border-color: #2563eb; }
#opsloop-chat-submit {
  margin-top: 8px;
  width: 100%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
#opsloop-chat-submit:hover { opacity: 0.88; }
#opsloop-chat-submit:disabled { opacity: 0.5; cursor: not-allowed; }

.opsloop-typing {
  align-self: flex-start;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  font-size: 13px;
  color: #64748b;
  display: none;
}
.opsloop-typing.visible { display: block; }
.opsloop-typing span { display: inline-block; width: 6px; height: 6px; background: #94a3b8; border-radius: 50%; margin-right: 4px; animation: bounce 1.2s infinite; }
.opsloop-typing span:nth-child(2) { animation-delay: 0.15s; }
.opsloop-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%,80%,100%{transform:translateY(0)}50%{transform:translateY(-5px)} }