/* ===== AI Chatbot Widget ===== */

.demg-ai-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: transform 0.2s, box-shadow 0.2s;
}
.demg-ai-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.5);
}
.demg-ai-fab svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.demg-ai-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  max-height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  z-index: 99998;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.demg-ai-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.demg-ai-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
}
.demg-ai-header h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  flex: 1;
}
.demg-ai-header button {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 1.2rem;
  opacity: 0.8;
}
.demg-ai-header button:hover { opacity: 1; }

.demg-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 200px;
  max-height: 340px;
}

.demg-ai-msg {
  max-width: 85%;
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  word-wrap: break-word;
}
.demg-ai-msg--user {
  align-self: flex-end;
  background: #6366f1;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.demg-ai-msg--assistant {
  align-self: flex-start;
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}
.demg-ai-msg--assistant strong { font-weight: 600; }
.demg-ai-msg--assistant ul { margin: 0.3rem 0; padding-left: 1.2rem; }
.demg-ai-msg--assistant li { margin-bottom: 0.15rem; }

.demg-ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1rem 0.5rem;
}
.demg-ai-suggestion-btn {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.78rem;
  cursor: pointer;
  color: #6366f1;
  transition: background 0.15s;
}
.demg-ai-suggestion-btn:hover {
  background: #e0e7ff;
}

.demg-ai-input-area {
  display: flex;
  padding: 0.75rem;
  border-top: 1px solid #e2e8f0;
  gap: 0.5rem;
}
.demg-ai-input-area input {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.88rem;
  outline: none;
}
.demg-ai-input-area input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}
.demg-ai-input-area button {
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s;
}
.demg-ai-input-area button:hover { background: #4f46e5; }
.demg-ai-input-area button:disabled { opacity: 0.5; cursor: not-allowed; }

.demg-ai-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 0.5rem 0.75rem;
}
.demg-ai-typing span {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: demgAiDot 1.2s infinite;
}
.demg-ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.demg-ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes demgAiDot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.1); }
}

@media (max-width: 480px) {
  .demg-ai-panel {
    bottom: 80px;
    right: 12px;
    width: calc(100vw - 24px);
    max-height: calc(100vh - 120px);
  }
  .demg-ai-fab {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }
}
