/* START: AI chat widget (shared/_ai_chat.html.erb) */
.ai-chat-widget {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
  pointer-events: none;
}

.ai-chat-widget * {
  pointer-events: auto;
}

.ai-chat-head {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #3b5bdb;
  border: none;
  color: white;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(59, 91, 219, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
  flex-shrink: 0;
}

.ai-chat-head:hover {
  background: #2f4199;
  box-shadow: 0 6px 20px rgba(59, 91, 219, 0.6);
  transform: scale(1.1);
}

.ai-chat-head:active {
  transform: scale(0.95);
}

.ai-chat-head:focus-visible {
  outline: 3px solid #91a7ff;
  outline-offset: 2px;
}

.ai-chat-head svg {
  width: 28px;
  height: 28px;
}

.ai-chat-panel {
  width: 380px;
  max-width: calc(100vw - 2rem);
  max-height: 520px;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  animation: ai-chat-slide-up 0.3s ease-out;
}

@keyframes ai-chat-slide-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.ai-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
  background: #999;
}

.ai-chat-message {
  display: flex;
}

.ai-chat-message.user {
  justify-content: flex-end;
}

.ai-chat-message.assistant {
  justify-content: flex-start;
}

.ai-chat-message-bubble {
  max-width: 85%;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.ai-chat-message.user .ai-chat-message-bubble {
  background: #3b5bdb;
  color: white;
  border-bottom-right-radius: 4px;
}

.ai-chat-message.assistant .ai-chat-message-bubble {
  background: #f1f3f5;
  color: #212529;
  border-bottom-left-radius: 4px;
}

/* Phones: smaller, tucked-in launcher so it covers less of the page's bottom controls. */
@media (max-width: 575.98px) {
  .ai-chat-widget {
    right: 0.75rem;
    bottom: 0.75rem;
  }

  .ai-chat-head {
    width: 44px;
    height: 44px;
    opacity: 0.85;
  }

  .ai-chat-head:hover,
  .ai-chat-head:focus-visible {
    opacity: 1;
  }

  .ai-chat-head svg {
    width: 22px;
    height: 22px;
  }

  .ai-chat-panel {
    max-width: calc(100vw - 1.5rem);
    max-height: calc(100vh - 1.5rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-chat-head,
  .ai-chat-panel {
    transition: none;
    animation: none;
  }
}
/* END: AI chat widget */
