/* AI Project Chatbot Styles — City of Portsmouth color scheme */

.ai-chatbot-wrapper {
  max-width: 800px;
  margin: 2rem auto;
  border: 1px solid #e0e7ee;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.ai-chatbot-header {
  background: #14143D;
  color: #fff;
  padding: 1.25rem 1.5rem;
  border-bottom: 3px solid #FDB813;
}

.ai-chatbot-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #fff;
}

.ai-chatbot-subtitle {
  margin: 0.25rem 0 0;
  font-size: 1rem;
  opacity: 0.85;
}

/* Messages area */
.ai-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  min-height: 350px;
  max-height: 500px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: #f1f1f1;
}

/* Individual message */
.ai-chatbot-message {
  display: flex;
  gap: 0.75rem;
  max-width: 90%;
  /* Let the bubble shrink within the row instead of overflowing the widget. */
  min-width: 0;
  animation: chatFadeIn 0.3s ease-out;
}

.ai-chatbot-message--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ai-chatbot-message--bot {
  align-self: flex-start;
}

/* Avatars */
.ai-chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.ai-chatbot-avatar--bot {
  background: #1C66A6;
  color: #fff;
}

.ai-chatbot-avatar--user {
  background: #14143D;
  color: #fff;
}

/* Chat bubbles */
.ai-chatbot-bubble {
  padding: 1rem 1.25rem;
  border-radius: 12px;
  font-size: 16px;
  line-height: 1.65;
  /* min-width:0 lets the flex item shrink; overflow-wrap breaks long links
     and words so content never overflows the bubble / widget. */
  min-width: 0;
  flex: 1 1 auto;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.ai-chatbot-message--bot .ai-chatbot-bubble {
  background: #fff;
  color: #414042;
  border: 1px solid #e0e7ee;
  border-top-left-radius: 4px;
}

.ai-chatbot-message--user .ai-chatbot-bubble {
  background: #1C66A6;
  color: #fff;
  border-top-right-radius: 4px;
}

.ai-chatbot-bubble p {
  margin: 0 0 0.5rem;
}

.ai-chatbot-bubble p:last-child {
  margin-bottom: 0;
}

.ai-chatbot-bubble ul {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}

.ai-chatbot-bubble li {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.ai-chatbot-bubble strong {
  color: #14143D;
}

.ai-chatbot-message--user .ai-chatbot-bubble strong {
  color: #fff;
}

.ai-chatbot-bubble a {
  color: #1C66A6;
  text-decoration: underline;
  font-weight: 500;
}

.ai-chatbot-message--user .ai-chatbot-bubble a {
  color: #FDB813;
}

/* Images inside chat bubbles */
.ai-chatbot-bubble img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 8px 0;
  display: block;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.1);
}

.ai-chatbot-bubble h3 {
  margin: 1rem 0 0.375rem;
  font-size: 1.0625rem;
  color: #14143D;
}

/* Input area */
.ai-chatbot-input-wrapper {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid #e0e7ee;
  background: #fff;
}

.ai-chatbot-input {
  flex: 1;
  padding: 0.875rem 1rem;
  border: 1px solid #e0e7ee;
  border-radius: 8px;
  font-size: 1.0625rem;
  outline: none;
  transition: border-color 0.2s;
}

.ai-chatbot-input:focus {
  border-color: #1C66A6;
  box-shadow: 0 0 0 3px rgb(28 102 166 / 0.15);
}

.ai-chatbot-send {
  padding: 0.875rem 1.5rem;
  background: #1C66A6;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1.0625rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.ai-chatbot-send:hover {
  background: #14143D;
}

.ai-chatbot-send:disabled {
  background: #979797;
  cursor: not-allowed;
}

/* Loading indicator */
.ai-chatbot-loading .ai-chatbot-bubble {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-chatbot-dots {
  display: inline-flex;
  gap: 4px;
}

.ai-chatbot-dots span {
  width: 8px;
  height: 8px;
  background: #1C66A6;
  border-radius: 50%;
  animation: chatBounce 1.4s infinite ease-in-out both;
}

.ai-chatbot-dots span:nth-child(1) { animation-delay: -0.32s; }
.ai-chatbot-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes chatBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

@keyframes chatFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive */
@media (max-width: 768px) {
  .ai-chatbot-wrapper {
    margin: 1rem;
    border-radius: 8px;
  }

  .ai-chatbot-messages {
    min-height: 250px;
    max-height: 400px;
    padding: 1rem;
  }

  .ai-chatbot-message {
    max-width: 95%;
  }

  .ai-chatbot-input-wrapper {
    padding: 0.75rem 1rem;
  }
}

/* Suggestion chips */
.ai-chatbot-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.ai-chatbot-suggestion-btn {
  background: #f0f4ff;
  border: 1px solid #c7d4f5;
  border-radius: 16px;
  color: #1a3a8f;
  cursor: pointer;
  font-size: 1.3rem;
  padding: 4px 12px;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.ai-chatbot-suggestion-btn:hover {
  background: #dce6ff;
  border-color: #1a3a8f;
}
