@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
  --primary-color: #006FEE;
  --background-color: #F7F9FC;
  --widget-background: #FFFFFF;
  --header-background: #FFFFFF;
  --user-message-background: #006FEE;
  --bot-message-background: #F0F1F3;
  --text-color-primary: #1D232A;
  --text-color-secondary: #FFFFFF;
  --border-color: #E5E7EB;
  --font-family: 'Inter', sans-serif;
}

/* Universal box-sizing for consistent layout */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background-color: var(--background-color);
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
}

#chat-widget {
  width: 400px;
  height: 600px;
  background: var(--widget-background);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  transition: all 0.3s ease-in-out;
}

#chat-header {
  background-color: var(--header-background);
  color: var(--text-color-primary);
  padding: 20px;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

#chat-header::before {
  content: '🐾';
  font-size: 1.5rem;
}

#chat-messages {
  flex-grow: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px; /* Increased gap between messages */
}

.message {
  padding: 16px 22px; /* Increased padding */
  border-radius: 22px;
  max-width: 80%; /* Slightly reduced max-width for better line length */
  line-height: 1.7; /* Increased line-height for better readability */
  font-size: 0.98rem; /* Slightly larger font size */
  word-wrap: break-word;
  overflow-wrap: break-word; /* Ensure long words break */
}

.bot-message p {
    margin: 0 0 16px 0; /* Clean paragraph spacing like modern chatbots */
    line-height: 1.6;
}

.bot-message p:last-child {
    margin-bottom: 0;
}

.bot-message p:first-child {
    margin-top: 0;
}

.bot-message ul,
.bot-message ol {
    margin: 16px 0;
    padding-left: 20px;
}

.bot-message ul {
    margin: 15px 0;
    padding-left: 20px;
}

.bot-message li {
    margin-bottom: 8px;
    line-height: 1.5;
    list-style-type: disc;
}

.bot-message li:last-child {
    margin-bottom: 0;
}

.bot-message p {
    margin-bottom: 15px;
}

.bot-message p:last-child {
    margin-bottom: 0;
}

.bot-message blockquote {
    border-left: 4px solid var(--border-color);
    padding-left: 15px;
    margin: 15px 0;
    color: #555;
    font-style: italic;
}

.user-message {
  background-color: var(--user-message-background);
  color: var(--text-color-secondary);
  align-self: flex-end;
  border-bottom-right-radius: 6px;
}

.bot-message {
  background-color: var(--bot-message-background);
  color: var(--text-color-primary);
  align-self: flex-start;
  border-bottom-left-radius: 6px;
}

.bot-message a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
    padding: 2px 4px;
    border-radius: 4px;
}

.bot-message a:hover {
    text-decoration: none;
    background-color: rgba(0, 111, 238, 0.1);
    border-bottom: 1px solid var(--primary-color);
}

#chat-input-container {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--widget-background);
}

#chat-input {
  flex-grow: 1;
  border: 1px solid var(--border-color);
  border-radius: 25px;
  padding: 12px 20px;
  font-size: 1rem;
  font-family: var(--font-family);
  transition: border-color 0.2s;
}

#chat-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

#send-button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  margin-left: 10px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.2s;
}

#send-button:hover {
  background-color: #0056b3;
}

#send-button svg {
    width: 24px;
    height: 24px;
}

.loading-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    align-self: flex-start;
}

.loading-indicator .dot {
    width: 8px;
    height: 8px;
    background-color: #B0B0B0;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-indicator .dot:nth-child(1) { animation-delay: -0.32s; }
.loading-indicator .dot:nth-child(2) { animation-delay: -0.16s; }

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

.suggestion {
  color: var(--primary-color);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 500;
}

.suggestion:hover {
  color: #0056b3;
}

.bot-message ul {
    list-style: disc; /* Use standard bullet points */
    padding-left: 20px; /* Indent lists */
    margin-top: 10px;
    margin-bottom: 10px;
}

.bot-message ol {
    list-style: decimal; /* Use standard numbered lists */
    padding-left: 20px; /* Indent lists */
    margin-top: 10px;
    margin-bottom: 10px;
}

.bot-message li {
    margin-bottom: 8px; /* More space between list items */
}

.bot-message strong {
    font-weight: 600; /* Make bold text stand out more */
    color: #1a1a1a;
}

.bot-message em {
    font-style: italic; /* Ensure italic text is rendered correctly */
}

/* Enhanced formatting for structured responses */
.bot-message h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 16px 0 8px 0;
    color: var(--text-color-primary);
}

.bot-message h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 12px 0 6px 0;
    color: var(--text-color-primary);
}

/* Better spacing for nested content */
.bot-message p + ul,
.bot-message p + ol {
    margin-top: 8px;
}

.bot-message ul + p,
.bot-message ol + p {
    margin-top: 16px;
}

/* Improved list styling */
.bot-message ul li {
    position: relative;
    padding-left: 8px;
}

.bot-message ol li {
    padding-left: 8px;
}

/* Better visual hierarchy */
.bot-message > p:first-child {
    margin-top: 0;
}

.bot-message > p:last-child {
    margin-bottom: 0;
}

/* Enhanced link styling for better visibility */
.bot-message a[href] {
    display: inline-block;
    margin: 1px 0;
}

/* Enhanced loading indicator styling */
.loading-indicator .loading-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.loading-indicator .dots {
    display: flex;
    gap: 5px;
}

.loading-indicator .loading-text {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

/* Enhanced link hover effects */
.bot-message .resource-link {
    position: relative;
    transition: all 0.2s ease;
}

.bot-message .resource-link:hover {
    transform: translateY(-1px);
}

/* Message animation styles */
.message {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Enhanced input states */
#chat-input:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.7;
}

#send-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Better focus states */
#chat-input:focus {
    box-shadow: 0 0 0 3px rgba(0, 111, 238, 0.1);
}

/* Improved suggestion styling */
.suggestion {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.suggestion:hover {
    background-color: rgba(0, 111, 238, 0.1);
    transform: translateX(2px);
}

@media (max-width: 480px) {
  body {
    height: 100%;
    width: 100%;
    position: fixed;
    overflow: hidden;
  }

  #chat-widget {
    width: 100%;
    height: 100%;
    border-radius: 0;
    box-shadow: none;
  }

  #chat-header {
    padding: 15px;
    font-size: 1.1rem;
  }

  #chat-messages {
    padding: 15px;
  }

  .message {
    padding: 12px 18px;
    font-size: 0.95rem;
  }

  #chat-input-container {
    padding: 10px;
  }

  #chat-input {
    padding: 10px 15px;
    font-size: 0.95rem;
  }

  #send-button {
    width: 40px;
    height: 40px;
  }
}
