.cmt-chat {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.cmt-chat__toggle {
  width: 64px; /* Increased size slightly for the image */
  height: 64px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: #ffffff; /* Use white background to make the icon pop */
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.18);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: cmt-pulse 3s infinite;
  overflow: hidden; /* Ensure image stays in bounds */
}

.cmt-chat__toggle-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cmt-chat__toggle:hover {
  transform: scale(1.1) rotate(-5deg);
  animation: none; /* Stop pulse on hover */
}

@keyframes cmt-pulse {
  0% { box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.7); }
  70% { box-shadow: 0 0 0 15px rgba(15, 118, 110, 0); }
  100% { box-shadow: 0 0 0 0 rgba(15, 118, 110, 0); }
}

.cmt-chat__toggle:focus-visible {
  outline: 3px solid rgba(13, 148, 136, 0.35);
  outline-offset: 3px;
}

.cmt-chat__panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: min(360px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 120px));
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cmt-chat__panel[aria-hidden="true"] {
  display: none;
}

.cmt-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: linear-gradient(90deg, #0f766e, #0ea5a3);
  color: #fff;
}

.cmt-chat__title {
  font-size: 14px;
  font-weight: 600;
}

.cmt-chat__close {
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
}

.cmt-chat__close:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.45);
  outline-offset: 2px;
}

.cmt-chat__messages {
  flex: 1;
  overflow: auto;
  padding: 12px;
  background: #f8fafc;
}

.cmt-chat__msg {
  display: flex;
  margin: 10px 0;
  align-items: flex-end; /* Align bubble and avatar to bottom */
}

.cmt-chat__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-right: 8px;
  object-fit: cover;
  border: 1px solid rgba(0,0,0,0.1);
  background: #fff;
}

.cmt-chat__msg--user {
  justify-content: flex-end;
}

.cmt-chat__msg--assistant {
  justify-content: flex-start;
}

.cmt-chat__bubble {
  max-width: 80%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.cmt-chat__msg--user .cmt-chat__bubble {
  background: #0f766e;
  color: #fff;
  border-bottom-right-radius: 4px;
  white-space: pre-wrap; /* User messages are plain text */
}

.cmt-chat__msg--assistant .cmt-chat__bubble {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-bottom-left-radius: 4px;
}

/* Markdown Styles for Assistant Bubbles */
.cmt-chat__msg--assistant .cmt-chat__bubble p {
  margin: 0 0 8px 0;
}
.cmt-chat__msg--assistant .cmt-chat__bubble p:last-child {
  margin-bottom: 0;
}
.cmt-chat__msg--assistant .cmt-chat__bubble strong,
.cmt-chat__msg--assistant .cmt-chat__bubble b {
  font-weight: 600;
  color: #0d9488; /* Teal accent for bold text */
}
.cmt-chat__msg--assistant .cmt-chat__bubble ul,
.cmt-chat__msg--assistant .cmt-chat__bubble ol {
  margin: 8px 0;
  padding-left: 20px;
}
.cmt-chat__msg--assistant .cmt-chat__bubble li {
  margin-bottom: 4px;
  list-style-type: disc;
}
.cmt-chat__msg--assistant .cmt-chat__bubble ol li {
  list-style-type: decimal;
}
.cmt-chat__msg--assistant .cmt-chat__bubble h1, 
.cmt-chat__msg--assistant .cmt-chat__bubble h2,
.cmt-chat__msg--assistant .cmt-chat__bubble h3,
.cmt-chat__msg--assistant .cmt-chat__bubble h4 {
  font-weight: 700;
  margin: 12px 0 6px 0;
  font-size: 1.1em;
  color: #111827;
}
.cmt-chat__msg--assistant .cmt-chat__bubble h1:first-child,
.cmt-chat__msg--assistant .cmt-chat__bubble h2:first-child,
.cmt-chat__msg--assistant .cmt-chat__bubble h3:first-child {
  margin-top: 0;
}

/* Quick Replies Styles */
.cmt-chat__suggestions {
  --suggestions-collapsed-height: 64px;
  padding: 8px 12px;
  background: #ffffff;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  max-height: var(--suggestions-collapsed-height);
  overflow: hidden;
  position: relative;
  transition: max-height 0.2s ease;
}

.cmt-chat__suggestions.has-more::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.95));
  pointer-events: none;
}

.cmt-chat__suggestions.is-expanded {
  overflow: hidden;
}

.cmt-chat__suggestions-toggle {
  align-self: flex-start;
  margin: 0 12px 8px 12px;
  border: none;
  background: transparent;
  color: #0f766e;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  display: none;
}
.cmt-chat__suggestion-btn {
  white-space: nowrap;
  background: #f0fdfa; /* Teal-50 */
  color: #0f766e; /* Teal-700 */
  border: 1px solid #ccfbf1; /* Teal-100 */
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}
.cmt-chat__suggestion-btn:hover {
  background: #0f766e;
  color: #fff;
  border-color: #0f766e;
}

.cmt-chat__status {
  padding: 8px 12px;
  font-size: 12px;
  color: #475569;
  background: #ffffff;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.cmt-chat__error {
  display: none;
  padding: 10px 12px;
  background: #fff7ed;
  border-top: 1px solid rgba(234, 88, 12, 0.25);
  color: #9a3412;
  font-size: 13px;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.cmt-chat__error.is-visible {
  display: flex;
}

.cmt-chat__error-btn {
  border: 1px solid rgba(234, 88, 12, 0.35);
  background: #fff;
  color: #9a3412;
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
}

.cmt-chat__composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #ffffff;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.cmt-chat__input {
  flex: 1;
  resize: none;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.3;
}

.cmt-chat__input:focus-visible {
  outline: 3px solid rgba(13, 148, 136, 0.25);
  outline-offset: 2px;
}

.cmt-chat__send {
  border: none;
  cursor: pointer;
  border-radius: 12px;
  padding: 0 14px;
  background: #0f766e;
  color: #fff;
  font-weight: 600;
}

.cmt-chat__send:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
