/* CalmView Chatbot - lightweight floating widget */
:root {
  --cv-chat-bg: #ffffff;
  --cv-chat-text: #1f2933;
  --cv-chat-muted: #667085;
  --cv-chat-border: rgba(31, 41, 51, 0.12);
  --cv-chat-accent: #557c83;
  --cv-chat-accent-dark: #355b61;
  --cv-chat-soft: #f3f7f7;
  --cv-chat-shadow: 0 18px 45px rgba(20, 37, 43, 0.18);
  --cv-chat-radius: 22px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --cv-chat-bg: #101820;
    --cv-chat-text: #f5f7f8;
    --cv-chat-muted: #b7c0c8;
    --cv-chat-border: rgba(255, 255, 255, 0.12);
    --cv-chat-accent: #8db5b8;
    --cv-chat-accent-dark: #6fa0a5;
    --cv-chat-soft: #18232d;
    --cv-chat-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  }
}

#calmview-chatbot {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 99999;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--cv-chat-text);
}

.cv-chat-toggle {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 0;
  background: var(--cv-chat-accent);
  color: #fff;
  box-shadow: var(--cv-chat-shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease;
}

.cv-chat-toggle:hover {
  transform: translateY(-2px);
  background: var(--cv-chat-accent-dark);
}

.cv-chat-toggle svg {
  width: 29px;
  height: 29px;
}

.cv-chat-window {
  width: 370px;
  max-width: calc(100vw - 28px);
  height: 540px;
  max-height: calc(100vh - 110px);
  background: var(--cv-chat-bg);
  border: 1px solid var(--cv-chat-border);
  border-radius: var(--cv-chat-radius);
  box-shadow: var(--cv-chat-shadow);
  overflow: hidden;
  display: none;
  flex-direction: column;
  transform-origin: bottom right;
  animation: cvChatIn 0.22s ease-out;
}

#calmview-chatbot.cv-open .cv-chat-window {
  display: flex;
}

#calmview-chatbot.cv-open .cv-chat-toggle {
  display: none;
}

@keyframes cvChatIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.cv-chat-header {
  padding: 18px 18px 16px;
  background: linear-gradient(135deg, var(--cv-chat-accent), var(--cv-chat-accent-dark));
  color: #fff;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.cv-chat-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.cv-chat-subtitle {
  font-size: 13px;
  opacity: 0.9;
  margin-top: 4px;
  line-height: 1.35;
}

.cv-chat-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.cv-lang-toggle,
.cv-chat-close {
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 999px;
  height: 32px;
  padding: 0 10px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.cv-chat-close {
  width: 32px;
  padding: 0;
  font-size: 18px;
}

.cv-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--cv-chat-soft);
}

.cv-message {
  max-width: 86%;
  margin-bottom: 12px;
  padding: 11px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
}

.cv-message-bot {
  background: var(--cv-chat-bg);
  border: 1px solid var(--cv-chat-border);
  border-bottom-left-radius: 5px;
}

.cv-message-user {
  margin-left: auto;
  background: var(--cv-chat-accent);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.cv-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 14px;
}

.cv-suggestion {
  border: 1px solid var(--cv-chat-border);
  background: var(--cv-chat-bg);
  color: var(--cv-chat-text);
  border-radius: 999px;
  padding: 8px 11px;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.cv-suggestion:hover {
  border-color: var(--cv-chat-accent);
  transform: translateY(-1px);
}

.cv-chat-inputbar {
  padding: 12px;
  border-top: 1px solid var(--cv-chat-border);
  display: flex;
  gap: 8px;
  background: var(--cv-chat-bg);
}

.cv-chat-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--cv-chat-border);
  border-radius: 999px;
  padding: 12px 14px;
  outline: none;
  background: transparent;
  color: var(--cv-chat-text);
  font-size: 14px;
}

.cv-chat-input:focus {
  border-color: var(--cv-chat-accent);
}

.cv-chat-send {
  border: 0;
  border-radius: 999px;
  background: var(--cv-chat-accent);
  color: #fff;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.cv-chat-send:hover {
  background: var(--cv-chat-accent-dark);
  transform: translateY(-1px);
}

.cv-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.cv-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cv-chat-muted);
  animation: cvPulse 1s infinite ease-in-out;
}

.cv-typing span:nth-child(2) { animation-delay: 0.15s; }
.cv-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes cvPulse {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

@media (max-width: 520px) {
  #calmview-chatbot {
    right: 14px;
    bottom: 14px;
  }

  .cv-chat-window {
    width: calc(100vw - 28px);
    height: min(560px, calc(100vh - 88px));
  }
}

/* More ready-topic chips */
.cv-suggestions {
  max-height: 118px;
  overflow-y: auto;
  padding-right: 2px;
}

.cv-suggestion {
  font-size: 11.8px;
  padding: 7px 10px;
}
