@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ============================================
   Site Assistant Chat Widget
   ============================================ */

/* Floating Bubble */
.assistant-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  border: none;
  cursor: pointer;
  z-index: 8000;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 30px rgba(108, 92, 231, 0.45), 0 0 0 0 rgba(108, 92, 231, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: assistantPulse 3s ease-in-out infinite;
}

.assistant-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 40px rgba(108, 92, 231, 0.6);
  animation: none;
}

.assistant-bubble.open {
  transform: rotate(0deg) scale(1);
  animation: none;
  background: linear-gradient(135deg, #ef4444, #f87171);
  box-shadow: 0 6px 30px rgba(239, 68, 68, 0.4);
}

.assistant-bubble .bubble-icon {
  width: 28px;
  height: 28px;
  color: white;
  transition: all 0.3s ease;
}

.assistant-bubble .bubble-icon.icon-close {
  display: none;
}

.assistant-bubble.open .bubble-icon.icon-chat {
  display: none;
}

.assistant-bubble.open .bubble-icon.icon-close {
  display: block;
}

@keyframes assistantPulse {
  0%, 100% { box-shadow: 0 6px 30px rgba(108, 92, 231, 0.45), 0 0 0 0 rgba(108, 92, 231, 0.3); }
  50% { box-shadow: 0 6px 30px rgba(108, 92, 231, 0.45), 0 0 0 12px rgba(108, 92, 231, 0); }
}

/* Chat Window */
.assistant-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 440px;
  height: 620px;
  background: #111118;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  z-index: 8000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(108, 92, 231, 0.1);
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.assistant-window.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* Header */
.assistant-header {
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.15), rgba(162, 155, 254, 0.05));
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.assistant-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.assistant-avatar svg {
  width: 20px;
  height: 20px;
  color: white;
}

.assistant-avatar::after {
  content: '';
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 12px;
  height: 12px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #111118;
}

.assistant-header-info {
  flex: 1;
  min-width: 0;
}

.assistant-header-name {
  font-size: 15px;
  font-weight: 700;
  color: #f0f0f5;
  line-height: 1.2;
}

.assistant-header-status {
  font-size: 12px;
  color: #22c55e;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.assistant-header-status .dot {
  width: 6px;
  height: 6px;
  background: #22c55e;
  border-radius: 50%;
  animation: statusBlink 2s ease-in-out infinite;
}

@keyframes statusBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.assistant-header-actions {
  display: flex;
  gap: 4px;
}

.assistant-header-actions button {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: #8888a0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.assistant-header-actions button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #f0f0f5;
}

/* Messages Area — KEY FIX: flex: 1 + overflow-y scroll, NO min/max-height */
.assistant-messages {
  flex: 1 1 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Message Row */
.assistant-msg {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  animation: msgAppear 0.35s ease;
  width: 100%;
  box-sizing: border-box;
}

.assistant-msg.bot {
  flex-direction: row;
}

.assistant-msg.user {
  flex-direction: row-reverse;
}

/* Avatar in messages */
.assistant-msg-avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.assistant-msg.bot .assistant-msg-avatar {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
}

.assistant-msg.user .assistant-msg-avatar {
  background: linear-gradient(135deg, #00cec9, #55efc4);
}

.assistant-msg-avatar svg {
  width: 14px;
  height: 14px;
  color: white;
}

/* Message Content Bubble */
.assistant-msg-body {
  min-width: 0;
  max-width: 80%;
}

.assistant-msg.user .assistant-msg-body {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.assistant-msg-content {
  width: fit-content;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 12.5px;
  line-height: 1.55;
  overflow-wrap: break-word;
}

.assistant-msg.bot .assistant-msg-content {
  background: rgba(255, 255, 255, 0.07);
  color: #d0d0dd;
  border-bottom-left-radius: 4px;
}

.assistant-msg.user .assistant-msg-content {
  background: linear-gradient(135deg, #6c5ce7, #8b7cf6);
  color: white;
  border-bottom-right-radius: 4px;
}

.assistant-msg-time {
  font-size: 10px;
  color: #55556a;
  margin-top: 3px;
  display: block;
}

.assistant-msg.user .assistant-msg-time {
  text-align: right;
  color: rgba(255, 255, 255, 0.45);
}

/* Quick Actions */
.assistant-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 14px 10px;
  flex-shrink: 0;
}

.assistant-quick-btn {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid rgba(108, 92, 231, 0.25);
  background: rgba(108, 92, 231, 0.08);
  color: #a29bfe;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
}

.assistant-quick-btn:hover {
  background: rgba(108, 92, 231, 0.2);
  border-color: rgba(108, 92, 231, 0.5);
  color: #c4bdff;
  transform: translateY(-1px);
}

/* Input Area */
.assistant-input-area {
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.assistant-input-wrapper {
  flex: 1;
  position: relative;
}

.assistant-input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  color: #f0f0f5;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  resize: none;
  max-height: 80px;
  min-height: 40px;
  line-height: 1.4;
  transition: border-color 0.2s;
  box-sizing: border-box;
  margin-top: 6px;
}

.assistant-input:focus {
  border-color: rgba(108, 92, 231, 0.5);
}

.assistant-input::placeholder {
  color: #55556a;
}

.assistant-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

.assistant-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 25px rgba(108, 92, 231, 0.5);
}

.assistant-send-btn:active {
  transform: scale(0.95);
}

.assistant-send-btn svg {
  width: 18px;
  height: 18px;
}

/* Typing indicator */
.assistant-typing {
  display: none;
  padding: 0 14px 6px;
  flex-shrink: 0;
}

.assistant-typing.active {
  display: block;
}

.assistant-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  border-bottom-left-radius: 6px;
}

.assistant-typing-dots span {
  width: 6px;
  height: 6px;
  background: #6c5ce7;
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.assistant-typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.assistant-typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

@keyframes msgAppear {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Powered By */
.assistant-powered {
  text-align: center;
  padding: 6px;
  font-size: 10px;
  color: #44445a;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  background: rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

/* Scrollbar inside chat */
.assistant-messages::-webkit-scrollbar {
  width: 4px;
}
.assistant-messages::-webkit-scrollbar-track {
  background: transparent;
}
.assistant-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}
/* ============================================
   Markdown & Code Blocks
   ============================================ */

/* Code blocks — Premium VS Code inspired */
.neva-code-block {
  margin: 10px 0;
  border-radius: 12px;
  overflow: hidden;
  background: #0a0a1a;
  border: 1px solid rgba(108, 92, 231, 0.2);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(108, 92, 231, 0.05);
  transition: border-color 0.3s;
}

.neva-code-block:hover {
  border-color: rgba(108, 92, 231, 0.35);
}

.neva-code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.15) 0%, rgba(72, 52, 212, 0.08) 100%);
  border-bottom: 1px solid rgba(108, 92, 231, 0.12);
}

.neva-code-header > span {
  font-size: 11px;
  color: #a29bfe;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.neva-code-header > span::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6c5ce7;
  box-shadow: 0 0 6px rgba(108, 92, 231, 0.6);
}

.neva-code-copy {
  background: rgba(108, 92, 231, 0.12);
  border: 1px solid rgba(108, 92, 231, 0.25);
  color: #a29bfe;
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.neva-code-copy svg {
  flex-shrink: 0;
}

.neva-code-copy.copied {
  background: rgba(0, 200, 83, 0.15);
  border-color: rgba(0, 200, 83, 0.4);
  color: #00c853;
}

.neva-code-copy:hover {
  background: rgba(108, 92, 231, 0.3);
  color: #fff;
  border-color: rgba(108, 92, 231, 0.5);
  box-shadow: 0 0 12px rgba(108, 92, 231, 0.2);
  transform: translateY(-1px);
}

.neva-code-copy:active {
  transform: translateY(0);
}

.neva-code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(108, 92, 231, 0.3) transparent;
}

.neva-code-block pre::-webkit-scrollbar {
  height: 5px;
}

.neva-code-block pre::-webkit-scrollbar-track {
  background: transparent;
}

.neva-code-block pre::-webkit-scrollbar-thumb {
  background: rgba(108, 92, 231, 0.3);
  border-radius: 3px;
}

.neva-code-block code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 12.5px;
  line-height: 1.6;
  color: #e2e0f0;
  white-space: pre;
  tab-size: 2;
}

/* Inline code */
.neva-inline-code {
  background: rgba(108, 92, 231, 0.12);
  color: #c4bdff;
  padding: 2px 7px;
  border-radius: 5px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Menlo', monospace;
  font-size: 11.5px;
  border: 1px solid rgba(108, 92, 231, 0.15);
}

/* Markdown headings */
.neva-h {
  margin: 8px 0 4px;
  color: #f0f0f5;
  font-weight: 700;
  line-height: 1.3;
}
h3.neva-h { font-size: 14px; }
h4.neva-h { font-size: 13px; }

/* Markdown list */
.neva-list {
  margin: 4px 0;
  padding-left: 18px;
}
.neva-list li {
  margin-bottom: 2px;
  line-height: 1.5;
}
.neva-list li::marker {
  color: #6c5ce7;
}

/* Markdown links */
.neva-link {
  color: #a29bfe;
  text-decoration: underline;
  text-decoration-color: rgba(162, 155, 254, 0.3);
}
.neva-link:hover {
  color: #c4bdff;
}

/* ============================================
   Tool Indicators
   ============================================ */

.tool-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 4px 0;
  background: rgba(108, 92, 231, 0.08);
  border: 1px solid rgba(108, 92, 231, 0.15);
  border-radius: 10px;
  font-size: 12px;
  color: #a29bfe;
  animation: msgAppear 0.3s ease;
}

.tool-indicator.done {
  opacity: 0.6;
  border-color: rgba(34, 197, 94, 0.2);
  background: rgba(34, 197, 94, 0.06);
  color: #55efc4;
}

.tool-indicator-label {
  flex: 1;
}

.tool-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(108, 92, 231, 0.3);
  border-top-color: #a29bfe;
  border-radius: 50%;
  animation: toolSpin 0.8s linear infinite;
}

@keyframes toolSpin {
  to { transform: rotate(360deg); }
}

/* ============================================
   Stream Cursor
   ============================================ */

.stream-cursor {
  display: inline-block;
  width: 2px;
  height: 14px;
  background: #a29bfe;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: cursorBlink 0.7s ease-in-out infinite;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Typing Dots */
.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(162, 155, 254, 0.6);
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ============================================
   System Messages
   ============================================ */

.assistant-system-msg {
  text-align: center;
  padding: 6px 12px;
  font-size: 11px;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
  border-radius: 8px;
  margin: 4px 0;
}

/* ============================================
   Bot message markdown content adjustments
   ============================================ */

.assistant-msg.bot .assistant-msg-content strong {
  color: #e0e0ee;
}

.assistant-msg.bot .assistant-msg-content br + br {
  display: block;
  margin-top: 4px;
  content: '';
}

/* Responsive */
@media (max-width: 480px) {
  .assistant-window {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: 90px;
    height: calc(100vh - 120px);
    border-radius: 16px;
  }
  
  .assistant-bubble {
    right: 16px;
    bottom: 16px;
    width: 54px;
    height: 54px;
  }

  .neva-code-block pre {
    font-size: 11px;
  }
}

