.haa-chat {
  border: 1px solid #e7e0d7;
  border-radius: 18px;
  background: #fffdf9;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 420px;
}

.haa-chat__panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.haa-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.haa-chat__title {
  font-size: 15px;
  line-height: 1.2;
}

.haa-chat__close {
  display: none !important;
}

.haa-chat__window {
  min-height: 320px;
  max-height: 520px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.haa-chat__message {
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 14px;
  white-space: pre-wrap;
}

.haa-chat__message--assistant {
  background: #f4efe8;
  color: #1a1612; /* Darkened from #2a231d for better contrast */
  align-self: flex-start;
  max-width: 90%;
}

.haa-chat__message--user {
  background: #2a231d;
  color: #ffffff;
  align-self: flex-end;
  max-width: 90%;
}

.haa-chat__typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 20px;
}

.haa-chat__typing span {
  width: 6px;
  height: 6px;
  background-color: #8c7d6e;
  border-radius: 50%;
  animation: haaTyping 1.4s infinite ease-in-out both;
}

.haa-chat__typing span:nth-child(1) { animation-delay: -0.32s; }
.haa-chat__typing span:nth-child(2) { animation-delay: -0.16s; }

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

.haa-chat__form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.haa-chat__input {
  resize: vertical;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid #bbaea0; /* Darkened from #d8cfc3 */
  padding: 10px 12px;
  font: inherit;
}

.haa-chat__input--error {
  border-color: #d9534f !important;
  box-shadow: 0 0 0 2px rgba(217, 83, 79, 0.2);
}

.haa-chat__input::placeholder {
  color: #6a5c4e; /* Added darker placeholder for contrast */
}

.haa-chat__submit,
.haa-chat__toggle {
  border: 0;
  border-radius: 12px;
  background: #2a231d;
  color: #fff;
  cursor: pointer;
}

.haa-chat__submit {
  padding: 0 16px;
}

.haa-chat__submit:disabled,
.haa-chat__input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.haa-chat__products {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 8px; /* Room for scrollbar */
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0; /* Prevents window flexbox from shrinking carousel height */
  min-height: min-content;
}

.haa-chat__product-card {
  display: flex;
  flex-direction: column;
  flex: 0 0 calc(70% - 12px); /* Show current and a peek of the next one */
  min-width: 200px;
  scroll-snap-align: start;
  gap: 0;
  border: 1px solid #eadfd0;
  border-radius: 14px;
  text-decoration: none;
  color: inherit;
  background: #fff;
  overflow: hidden;
}

.haa-chat__product-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #fdfbf9;
  border-bottom: 1px solid #eadfd0;
}

.haa-chat__product-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
}

.haa-chat__product-card strong {
  font-size: 14px;
  color: #1a1612 !important; /* Force darker color on title */
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.haa-chat__product-card span {
  font-size: 13px;
  line-height: 1.4;
  color: #4a423a; /* Darker than before to prevent faded look */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.haa-chat--floating {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 999999;
  border: 0;
  background: transparent;
  padding: 0;
  max-width: none;
}

.haa-chat--floating .haa-chat__toggle {
  width: 60px;
  height: 60px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.haa-chat__toggle-icon {
  font-size: 22px;
  line-height: 1;
}

.haa-chat--floating .haa-chat__panel {
  width: min(420px, calc(100vw - 24px));
  max-height: min(720px, calc(100vh - 100px));
  background: #fffdf9;
  border: 1px solid #e7e0d7;
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  margin-bottom: 12px;
}

.haa-chat--floating .haa-chat__panel[hidden] {
  display: none !important;
}

.haa-chat--floating .haa-chat__window {
  min-height: 280px;
  max-height: min(480px, calc(100vh - 240px));
}

@media (max-width: 640px) {
  .haa-chat--floating {
    right: 12px;
    bottom: 12px;
  }

  .haa-chat--floating .haa-chat__panel {
    width: calc(100vw - 24px);
  }
}
