/* Store AI Chatbot Widget */

#store-chatbot {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-popover, 1100);
  font-family: inherit;
}

.chatbot-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: var(--primary-text, #fff);
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-fab:hover {
  transform: scale(1.08);
  box-shadow: var(--primary-shadow-lg);
}

.chatbot-fab.hidden {
  display: none;
}

.chatbot-panel {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  width: 360px;
  max-width: calc(100vw - var(--space-8));
  height: 480px;
  max-height: 70vh;
  background: var(--bg-surface, #fff);
  border-radius: var(--radius-lg, 16px);
  box-shadow: var(--shadow-xl);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.chatbot-panel.open {
  display: flex;
  animation: chatbotSlideIn 0.25s ease-out;
}

@keyframes chatbotSlideIn {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--primary-gradient);
  color: var(--primary-text, #fff);
}

.chatbot-title {
  font-weight: 600;
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.chatbot-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  opacity: 0.8;
  padding: 0;
}

.chatbot-close:hover {
  opacity: 1;
}

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.chatbot-msg {
  max-width: 85%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  line-height: var(--leading-normal, 1.5);
  word-break: break-word;
  white-space: pre-wrap;
}

.chatbot-msg-user {
  align-self: flex-end;
  background: var(--primary-color);
  color: var(--primary-text, #fff);
  border-bottom-right-radius: var(--radius-sm, 4px);
}

.chatbot-msg-assistant {
  align-self: flex-start;
  background: var(--bg-muted, #f1f5f9);
  color: var(--text-primary);
  border-bottom-left-radius: var(--radius-sm, 4px);
}

.chatbot-input {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface, #fff);
}

.chatbot-input input {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-family: inherit;
  background: var(--bg-surface, #fff);
  color: var(--text-primary);
}

.chatbot-input input:focus-visible {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: var(--primary-focus-ring);
}

.chatbot-input button {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--primary-gradient);
  color: var(--primary-text, #fff);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.chatbot-input button:hover {
  transform: scale(1.05);
}

/* Dark mode */
[data-theme="dark"] .chatbot-panel {
  background: var(--dark-surface-solid, #0f172a);
  border-color: var(--dark-border);
}

[data-theme="dark"] .chatbot-msg-assistant {
  background: var(--dark-surface-bg, rgba(15, 23, 42, 0.8));
  color: var(--text-dark-body);
}

[data-theme="dark"] .chatbot-input {
  background: var(--dark-surface-solid, #0f172a);
  border-color: var(--dark-border);
}

[data-theme="dark"] .chatbot-input input {
  background: var(--dark-surface-bg);
  border-color: var(--dark-border);
  color: var(--text-dark-body);
}

/* Mobile */
@media (max-width: 480px) {
  .chatbot-panel {
    width: calc(100vw - var(--space-4));
    right: var(--space-2);
    bottom: var(--space-2);
    height: 60vh;
  }

  #store-chatbot {
    bottom: var(--space-4);
    right: var(--space-4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chatbot-panel.open {
    animation: none;
  }
}
