/* theCRUX Chatbot Widget */

#crux-chatbot-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #f26b4f;
  border: none;
  cursor: pointer;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(242, 107, 79, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: crux-chat-bounce 0.5s ease 1s both;
}
#crux-chatbot-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(242, 107, 79, 0.45);
}
#crux-chatbot-trigger svg {
  width: 26px;
  height: 26px;
  fill: white;
}

@keyframes crux-chat-bounce {
  0% { transform: scale(0) translateY(20px); opacity: 0; }
  60% { transform: scale(1.1) translateY(-4px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Nudge tooltip */
#crux-chatbot-nudge {
  position: fixed;
  bottom: 88px;
  right: 24px;
  background: white;
  color: #17263a;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  z-index: 999;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  max-width: 220px;
  line-height: 1.4;
}
#crux-chatbot-nudge.visible {
  opacity: 1;
  transform: translateY(0);
}
#crux-chatbot-nudge::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 28px;
  width: 12px;
  height: 12px;
  background: white;
  transform: rotate(45deg);
  box-shadow: 2px 2px 4px rgba(0,0,0,0.05);
}

/* Chat panel */
#crux-chatbot-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  height: 520px;
  background: #fffaf0;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  z-index: 1000;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Space Grotesk', system-ui, sans-serif;
}
#crux-chatbot-panel.open {
  display: flex;
  animation: crux-panel-slide 0.25s ease;
}

@keyframes crux-panel-slide {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.crux-chat-header {
  background: linear-gradient(135deg, #f26b4f, #e85d3a);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.crux-chat-header-title {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.crux-chat-header-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  opacity: 0.8;
  transition: opacity 0.15s;
}
.crux-chat-header-close:hover { opacity: 1; }
.crux-chat-header-close svg { width: 20px; height: 20px; }
.crux-chat-header-reset {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  display: none;
  align-items: center;
  opacity: 0.7;
  transition: opacity 0.15s;
  font-size: 0;
}
.crux-chat-header-reset.visible { display: flex; }
.crux-chat-header-reset:hover { opacity: 1; }
.crux-chat-header-reset svg { width: 18px; height: 18px; }

/* Messages area */
.crux-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.crux-chat-messages::-webkit-scrollbar { width: 4px; }
.crux-chat-messages::-webkit-scrollbar-track { background: transparent; }
.crux-chat-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

/* Message bubbles */
.crux-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.55;
  word-wrap: break-word;
}
.crux-msg a {
  color: inherit;
  text-decoration: underline;
  font-weight: 600;
}
.crux-msg-user {
  align-self: flex-end;
  background: #f26b4f;
  color: white;
  border-bottom-right-radius: 4px;
}
.crux-msg-user a { color: white; }
.crux-msg-assistant {
  align-self: flex-start;
  background: white;
  color: #17263a;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.crux-msg-assistant a { color: #f26b4f; }
.crux-msg-assistant strong { font-weight: 700; }
.crux-msg-assistant em { font-style: italic; }

/* Typing indicator */
.crux-typing {
  align-self: flex-start;
  display: flex;
  gap: 5px;
  padding: 12px 16px;
  background: white;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.crux-typing-dot {
  width: 7px;
  height: 7px;
  background: #b0b8c4;
  border-radius: 50%;
  animation: crux-dot-pulse 1.2s ease-in-out infinite;
}
.crux-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.crux-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes crux-dot-pulse {
  0%, 60%, 100% { transform: scale(1); opacity: 0.4; }
  30% { transform: scale(1.3); opacity: 1; }
}

/* Suggested questions */
.crux-starters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 16px 8px;
}
.crux-starter-chip {
  background: white;
  border: 1px solid #e8e0d4;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.84rem;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  color: #17263a;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.4;
}
.crux-starter-chip:hover {
  border-color: #f26b4f;
  background: #fff5f2;
}

/* Input area */
.crux-chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid #e8e0d4;
  display: flex;
  gap: 8px;
  background: #fffaf0;
  flex-shrink: 0;
}
.crux-chat-input {
  flex: 1;
  border: 1px solid #e8e0d4;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  color: #17263a;
  background: white;
  outline: none;
  resize: none;
  min-height: 40px;
  max-height: 80px;
  line-height: 1.4;
}
.crux-chat-input::placeholder { color: #94a3b8; }
.crux-chat-input:focus { border-color: #f26b4f; }
.crux-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #f26b4f;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
  align-self: flex-end;
}
.crux-chat-send:hover { background: #e85d3a; }
.crux-chat-send:disabled { background: #d4ccc2; cursor: not-allowed; }
.crux-chat-send svg { width: 18px; height: 18px; fill: white; }

/* Turn limit message */
.crux-chat-limit {
  text-align: center;
  padding: 12px 16px;
  font-size: 0.82rem;
  color: #64748b;
  border-top: 1px solid #e8e0d4;
  background: #fffaf0;
  flex-shrink: 0;
}
.crux-chat-limit a {
  color: #f26b4f;
  font-weight: 600;
}

/* Mobile: hide chatbot entirely */
@media (max-width: 768px) {
  #crux-chatbot-trigger,
  #crux-chatbot-nudge,
  #crux-chatbot-panel {
    display: none !important;
  }
}
