#ai-assistant-widget {
  --ai-primary: #6f42c1;
  --ai-bg: #fff;
  --ai-text: #1a1a2e;
  --ai-bot-bg: #f0f0f5;
  --ai-user-bg: #6f42c1;
  --ai-user-text: #fff;
  --ai-shadow: 0 8px 32px rgba(0,0,0,0.18);
  --ai-radius: 16px;
  --ai-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-family: var(--ai-font);
  z-index: 999999;
}

#ai-assistant-widget[data-position="right"] {
  position: fixed;
  bottom: 24px;
  right: 24px;
}
#ai-assistant-widget[data-position="left"] {
  position: fixed;
  bottom: 24px;
  left: 24px;
}

/* Bubble button */
.ai-assistant-bubble {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000000;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 28px;
}
.ai-assistant-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0,0,0,0.35);
}
.ai-icon-close { display: none; }
#ai-assistant-widget.active .ai-icon { display: none; }
#ai-assistant-widget.active .ai-icon-close { display: inline; font-size: 20px; }

/* Panel */
.ai-assistant-panel {
  position: absolute;
  bottom: 76px;
  width: 380px;
  height: 600px;
  background: var(--ai-bg);
  border-radius: var(--ai-radius);
  box-shadow: var(--ai-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: ai-slide-up 0.3s ease;
}
#ai-assistant-widget[data-position="right"] .ai-assistant-panel { right: 0; }
#ai-assistant-widget[data-position="left"] .ai-assistant-panel { left: 0; }

@keyframes ai-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Header */
.ai-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
  flex-shrink: 0;
}
.ai-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ai-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}
.ai-title { font-weight: 600; font-size: 15px; }
.ai-status { font-size: 11px; opacity: 0.85; }
.ai-header-actions { display: flex; gap: 8px; }
.ai-btn-new, .ai-btn-close {
  background: none; border: none; color: #fff;
  cursor: pointer; font-size: 16px; opacity: 0.8; padding: 4px;
  border-radius: 6px; transition: all 0.2s;
}
.ai-btn-new:hover, .ai-btn-close:hover { opacity: 1; background: rgba(255,255,255,0.15); }

/* Messages */
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8f9fc;
}
.ai-message {
  display: flex;
  max-width: 88%;
  animation: ai-fade-in 0.3s ease;
}
.ai-message.ai-bot { align-self: flex-start; }
.ai-message.ai-user { align-self: flex-end; }

@keyframes ai-fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.ai-message-content {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.ai-bot .ai-message-content {
  background: var(--ai-bot-bg);
  color: var(--ai-text);
  border-bottom-left-radius: 4px;
}
.ai-user .ai-message-content {
  background: var(--ai-primary, #6f42c1);
  color: var(--ai-user-text);
  border-bottom-right-radius: 4px;
}

/* Quick actions */
.ai-quick-actions {
  padding: 8px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid #eee;
}
.ai-quick-btn {
  padding: 6px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  color: #555;
  transition: all 0.2s;
  white-space: nowrap;
}
.ai-quick-btn:hover {
  border-color: var(--ai-primary);
  color: var(--ai-primary);
  background: rgba(111, 66, 193, 0.05);
}

/* Input area */
.ai-input-area {
  padding: 12px 16px 16px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #fff;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}
.ai-input {
  flex: 1;
  border: 1px solid #e0e0e0;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  resize: none;
  max-height: 120px;
  font-family: var(--ai-font);
  transition: border-color 0.2s;
}
.ai-input:focus { border-color: var(--ai-primary); }
.ai-btn-voice, .ai-btn-image, .ai-btn-send {
  background: none; border: none; cursor: pointer;
  font-size: 20px; padding: 8px; border-radius: 50%;
  transition: all 0.2s; flex-shrink: 0;
  width: 40px; height: 40px; display: flex;
  align-items: center; justify-content: center;
}
.ai-btn-voice:hover, .ai-btn-image:hover { background: #f0f0f5; }
.ai-btn-send {
  background: var(--ai-primary);
  color: #fff;
  font-size: 16px;
}
.ai-btn-send:hover { opacity: 0.9; transform: scale(1.05); }

/* Footer */
.ai-footer {
  padding: 8px 16px;
  text-align: center;
  font-size: 10px;
  color: #aaa;
  background: #f8f9fc;
  flex-shrink: 0;
}

/* Typing indicator */
.ai-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--ai-bot-bg);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.ai-typing span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #999;
  animation: ai-bounce 1.4s infinite ease-in-out both;
}
.ai-typing span:nth-child(1) { animation-delay: -0.32s; }
.ai-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes ai-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Product cards in chat */
.ai-product-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 12px;
  padding: 10px 14px;
  margin-top: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.ai-product-card:hover { border-color: var(--ai-primary); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.ai-product-img {
  width: 48px; height: 48px; border-radius: 8px;
  object-fit: cover; background: #f5f5f5;
}
.ai-product-info { flex: 1; }
.ai-product-name { font-weight: 600; font-size: 13px; color: var(--ai-text); }
.ai-product-price { font-size: 14px; color: var(--ai-primary); font-weight: 700; }
.ai-product-add {
  padding: 6px 12px; background: var(--ai-primary); color: #fff;
  border: none; border-radius: 8px; cursor: pointer; font-size: 12px;
  white-space: nowrap;
}

/* Error state */
.ai-error {
  text-align: center; padding: 20px; color: #e74c3c;
}

/* Streaming cursor */
.ai-streaming .ai-message-content::after {
  content: '▊';
  animation: ai-blink 1s step-end infinite;
  margin-left: 2px;
}
@keyframes ai-blink { 50% { opacity: 0; } }

/* Responsive */
@media (max-width: 480px) {
  .ai-assistant-panel {
    width: 100vw !important;
    height: 100vh !important;
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    border-radius: 0 !important;
  }
  #ai-assistant-widget[data-position="right"],
  #ai-assistant-widget[data-position="left"] {
    right: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
  }
  .ai-assistant-bubble { margin: 16px; }
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
  #ai-assistant-widget {
    --ai-bg: #1a1a2e;
    --ai-text: #e0e0e0;
    --ai-bot-bg: #2a2a3e;
  }
  .ai-messages { background: #16162a; }
  .ai-input-area, .ai-quick-actions, .ai-footer { background: #1a1a2e; border-color: #333; }
  .ai-input { background: #2a2a3e; border-color: #444; color: #e0e0e0; }
  .ai-quick-btn { background: #2a2a3e; border-color: #444; color: #ccc; }
}
