/* -- AI chat widget -- */
#cm-chat-bubble {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--green);
  color: var(--bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
  font-size: 26px;
}
#cm-chat-bubble:hover { filter: brightness(1.08); }

#cm-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 90px;
  z-index: 101;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 500px;
  max-height: calc(100vh - 140px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font);
}
#cm-chat-panel.open { display: flex; }

#cm-chat-head {
  background: var(--green);
  color: var(--bg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
}
#cm-chat-close {
  background: none;
  border: none;
  color: var(--bg);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

#cm-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cm-msg {
  max-width: 85%;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.cm-msg-bot {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
}
.cm-msg-user {
  align-self: flex-end;
  background: var(--green);
  color: var(--bg);
}
.cm-typing { align-self: flex-start; color: var(--muted); font-size: 13px; padding: 0 4px; }

#cm-chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
}
#cm-chat-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 14px;
  resize: none;
}
#cm-chat-send {
  background: var(--green);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
}
#cm-chat-send:disabled { opacity: .5; cursor: default; }

.cm-lead-form {
  align-self: stretch;
  background: var(--bg);
  border: 1px solid var(--green-dim);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cm-lead-form label { font-size: 12px; color: var(--muted); }
.cm-lead-form input, .cm-lead-form textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 13px;
  margin-top: 3px;
}
.cm-lead-form button {
  background: var(--green);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  padding: 9px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
}
.cm-lead-success { color: var(--green); font-size: 13px; }

@media (max-width: 768px) {
  #cm-chat-bubble { bottom: 70px; }
  #cm-chat-panel { bottom: 140px; }
}
