/* CommerceIQ Chatbot Widget — brand colors: Royal Purple #330066, Electric Purple #7800f2, Deep Teal #33cccc, Soft Teal #a6fae8 */
:root {
  --ciq-purple-dark: #330066;
  --ciq-purple: #7800f2;
  --ciq-teal: #33cccc;
  --ciq-teal-soft: #a6fae8;
  --ciq-white: #ffffff;
  --ciq-gray-bg: #f7f7fa;
  --ciq-gray-border: #e2e2ea;
  --ciq-text: #1a1a2e;
  --ciq-text-muted: #6b6b8a;
  --ciq-radius: 16px;
  --ciq-shadow: 0 8px 40px rgba(51, 0, 102, 0.18);
}

/* Launcher button */
#ciq-chat-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ciq-purple-dark), var(--ciq-purple));
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(120, 0, 242, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: transform 0.2s, box-shadow 0.2s;
}
#ciq-chat-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(120, 0, 242, 0.55);
}
#ciq-chat-launcher svg { width: 28px; height: 28px; fill: var(--ciq-white); }

/* Chat window */
#ciq-chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 380px;
  max-height: 600px;
  display: flex;
  flex-direction: column;
  background: var(--ciq-white);
  border-radius: var(--ciq-radius);
  box-shadow: var(--ciq-shadow);
  z-index: 9998;
  overflow: hidden;
  transition: opacity 0.25s, transform 0.25s;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#ciq-chat-window.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.97);
}

/* Header */
#ciq-header {
  background: linear-gradient(135deg, var(--ciq-purple-dark) 0%, var(--ciq-purple) 100%);
  color: var(--ciq-white);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#ciq-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(166, 250, 232, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#ciq-header-avatar svg { width: 22px; height: 22px; fill: var(--ciq-teal-soft); }
#ciq-header-title { font-weight: 700; font-size: 15px; }
#ciq-header-title sup {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.6px;
  vertical-align: super;
  opacity: 0.9;
  background: rgba(255,255,255,0.22);
  border-radius: 4px;
  padding: 1px 4px;
  margin-left: 2px;
  text-transform: uppercase;
}
#ciq-header-subtitle { font-size: 12px; opacity: 0.8; margin-top: 1px; }
#ciq-restart-btn {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.7);
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  transition: color 0.15s, transform 0.2s;
}
#ciq-restart-btn:hover { color: var(--ciq-white); transform: rotate(-30deg); }
#ciq-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.7);
  font-size: 20px;
  line-height: 1;
  padding: 2px 4px;
  transition: color 0.15s;
}
#ciq-close-btn:hover { color: var(--ciq-white); }

/* Messages area */
#ciq-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--ciq-gray-bg);
  scroll-behavior: smooth;
}
#ciq-messages::-webkit-scrollbar { width: 4px; }
#ciq-messages::-webkit-scrollbar-track { background: transparent; }
#ciq-messages::-webkit-scrollbar-thumb { background: var(--ciq-gray-border); border-radius: 4px; }

/* Message bubbles */
.ciq-msg {
  display: flex;
  gap: 8px;
  animation: ciq-fadein 0.2s ease;
}
@keyframes ciq-fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.ciq-msg.user { flex-direction: row-reverse; }
.ciq-msg.bot  { flex-direction: column; align-items: flex-start; }
.ciq-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ciq-text);
  background: var(--ciq-white);
  border: 1px solid var(--ciq-gray-border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  white-space: pre-wrap;
  word-break: break-word;
}
.ciq-msg.user .ciq-bubble {
  background: linear-gradient(135deg, var(--ciq-purple-dark), var(--ciq-purple));
  color: var(--ciq-white);
  border: none;
}

/* Bullet list spacing inside bubbles */
.ciq-bubble ul {
  margin: 8px 0 6px 0;
  padding-left: 20px;
  list-style: disc;
}
.ciq-bubble li {
  margin-bottom: 7px;
  line-height: 1.55;
  padding-left: 2px;
}
.ciq-bubble li:last-child { margin-bottom: 2px; }
.ciq-bubble ul + br { display: none; } /* hide orphan <br> right after a list */

/* Typing indicator */
.ciq-typing .ciq-bubble {
  padding: 12px 16px;
}
.ciq-dots { display: flex; gap: 4px; align-items: center; }
.ciq-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ciq-purple);
  animation: ciq-bounce 1.2s infinite;
}
.ciq-dot:nth-child(2) { animation-delay: 0.2s; }
.ciq-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes ciq-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* Calendar embed wrapper — keeps HubSpot iframe within chat bubble */
.ciq-calendar-wrap {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
.ciq-calendar-wrap .meetings-iframe-container {
  width: 100%;
  max-width: 100%;
  min-height: 520px;
}
.ciq-calendar-wrap iframe,
.ciq-calendar-wrap .meetings-iframe-container iframe {
  width: 100% !important;
  max-width: 100% !important;
  border: none;
  display: block;
  border-radius: 8px;
}
/* When a calendar appears inside a bot message, let the bubble grow wider */
.ciq-msg.bot > .ciq-bubble:has(.ciq-calendar-wrap),
.ciq-msg.bot > .ciq-calendar-wrap {
  max-width: 95%;
  width: 95%;
}

/* Sources — compact chips below the bubble */
.ciq-sources {
  margin-top: 8px;
  max-width: 82%;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  font-size: 11px;
  color: var(--ciq-text-muted);
}
.ciq-sources .ciq-sources-label {
  font-weight: 600;
  color: var(--ciq-text-muted);
  margin-right: 4px;
}
.ciq-sources a {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(194, 49, 255, 0.08);
  border: 1px solid rgba(194, 49, 255, 0.2);
  border-radius: 12px;
  color: var(--ciq-purple);
  text-decoration: none;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 0.15s;
}
.ciq-sources a:hover {
  background: rgba(194, 49, 255, 0.15);
  text-decoration: none;
}

/* Booking CTA */
.ciq-booking-cta {
  margin-top: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(51,0,102,0.06), rgba(120,0,242,0.08));
  border: 1px solid rgba(120,0,242,0.2);
  border-radius: 10px;
  font-size: 13px;
  color: var(--ciq-text);
}
.ciq-booking-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--ciq-purple-dark), var(--ciq-purple));
  color: var(--ciq-white);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.15s;
}
.ciq-booking-btn:hover { opacity: 0.9; }

/* Input area */
#ciq-input-area {
  padding: 12px 14px;
  background: var(--ciq-white);
  border-top: 1px solid var(--ciq-gray-border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
#ciq-input {
  flex: 1;
  border: 1.5px solid var(--ciq-gray-border);
  border-radius: 22px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 100px;
  line-height: 1.4;
  color: var(--ciq-text);
  transition: border-color 0.15s;
}
#ciq-input:focus { border-color: var(--ciq-purple); }
#ciq-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--ciq-purple-dark), var(--ciq-purple));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
#ciq-send-btn:hover { opacity: 0.88; }
#ciq-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
#ciq-send-btn svg { width: 18px; height: 18px; fill: var(--ciq-white); }

/* Suggested questions — wraps up to 5 chips across 2-3 rows */
#ciq-suggestions {
  padding: 8px 12px 6px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-height: 112px;   /* ~3 rows of chips */
  overflow-y: auto;
  background: var(--ciq-white);
  border-top: 1px solid var(--ciq-gray-border);
}
#ciq-suggestions::-webkit-scrollbar { width: 3px; height: 3px; }
#ciq-suggestions::-webkit-scrollbar-thumb { background: var(--ciq-gray-border); border-radius: 3px; }
.ciq-suggestion {
  font-size: 11px;
  padding: 4px 10px;
  background: rgba(51,204,204,0.1);
  border: 1px solid rgba(51,204,204,0.4);
  border-radius: 12px;
  cursor: pointer;
  color: var(--ciq-purple-dark);
  font-weight: 500;
  transition: background 0.15s;
  white-space: nowrap;
}
.ciq-suggestion:hover { background: rgba(51,204,204,0.22); }

/* Follow-up chips — shown after every answer, inline with conversation */
.ciq-follow-ups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 0 4px 0;
  animation: ciq-fadein 0.25s ease;
}
.ciq-follow-up-btn {
  font-size: 12px;
  padding: 6px 12px;
  background: var(--ciq-white);
  border: 1.5px solid var(--ciq-purple);
  border-radius: 16px;
  cursor: pointer;
  color: var(--ciq-purple);
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.ciq-follow-up-btn:hover {
  background: var(--ciq-purple);
  color: var(--ciq-white);
}


/* Streaming cursor — blinks while Claude is generating */
.ciq-stream-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--ciq-purple);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: ciq-cursor-blink 0.7s steps(1) infinite;
}
@keyframes ciq-cursor-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

@media (max-width: 440px) {
  #ciq-chat-window { right: 0; bottom: 0; width: 100vw; max-height: 100dvh; border-radius: 0; }
  #ciq-chat-launcher { bottom: 16px; right: 16px; }
}

/* Qualification option buttons */
.ciq-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 16px 12px 16px;
}
.ciq-option-btn {
  background: #fff;
  border: 1.5px solid var(--ciq-purple);
  border-radius: 20px;
  color: var(--ciq-purple);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  padding: 9px 16px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ciq-option-btn:hover {
  background: var(--ciq-purple);
  color: #fff;
}

/* ── Soft content offer card ─────────────────────────────────────────────── */
.ciq-offer-wrap { animation: ciq-fadein 0.3s ease; }
.ciq-offer-card {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: linear-gradient(135deg, rgba(51,0,102,0.04) 0%, rgba(166,250,232,0.18) 100%);
  border: 1.5px solid rgba(51,204,204,0.45);
  border-radius: 14px;
  padding: 14px 16px;
  max-width: 88%;
  font-size: 13px;
}
.ciq-offer-dismiss {
  position: absolute;
  top: 8px; right: 10px;
  background: none; border: none;
  color: var(--ciq-text-muted);
  font-size: 16px; line-height: 1;
  cursor: pointer; padding: 0;
}
.ciq-offer-dismiss:hover { color: var(--ciq-text); }
.ciq-offer-icon { font-size: 22px; flex-shrink: 0; margin-top: 1px; }
.ciq-offer-body { display: flex; flex-direction: column; gap: 4px; padding-right: 14px; }
.ciq-offer-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--ciq-purple-dark);
}
.ciq-offer-desc {
  font-size: 12px;
  color: var(--ciq-text-muted);
  line-height: 1.45;
}
.ciq-offer-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 7px 14px;
  background: linear-gradient(135deg, var(--ciq-purple-dark), var(--ciq-purple));
  color: var(--ciq-white);
  border-radius: 18px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  width: fit-content;
  transition: opacity 0.15s;
}
.ciq-offer-btn:hover { opacity: 0.88; }
