:root {
  --shop-aiplugin-primary: #6366f1;
  --shop-aiplugin-primary-dark: #4f46e5;
  --shop-aiplugin-primary-light: #818cf8;
  --shop-aiplugin-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
  --shop-aiplugin-focus-ring: rgba(99, 102, 241, 0.22);
  --shop-aiplugin-glow-soft: rgba(99, 102, 241, 0.38);
  --shop-aiplugin-glow-strong: rgba(99, 102, 241, 0.5);
  --shop-aiplugin-bg: #f8fafc;
  --shop-aiplugin-surface: #ffffff;
  --shop-aiplugin-border: #e2e8f0;
  --shop-aiplugin-text: #1e293b;
  --shop-aiplugin-text-secondary: #64748b;
  --shop-aiplugin-radius: 16px;
  --shop-aiplugin-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

#shop-aiplugin-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#shop-aiplugin-chat-widget.shop-aiplugin-left {
  right: auto;
  left: 24px;
}

#shop-aiplugin-chat-widget * {
  box-sizing: border-box;
  margin: 0;
}

/* Toggle Button */
#shop-aiplugin-chat-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--shop-aiplugin-gradient);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 25px rgba(99,102,241,0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

#shop-aiplugin-chat-toggle::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.2), transparent);
}

#shop-aiplugin-chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 35px var(--shop-aiplugin-glow-strong);
}

#shop-aiplugin-chat-toggle.shop-aiplugin-hidden {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

#shop-aiplugin-chat-toggle .shop-aiplugin-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: #ef4444;
  color: #fff;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

/* Chat Window */
#shop-aiplugin-chat-window {
  display: none;
  flex-direction: column;
  width: 400px;
  max-width: calc(100vw - 48px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--shop-aiplugin-bg);
  border-radius: 20px;
  box-shadow: var(--shop-aiplugin-shadow);
  overflow: hidden;
  position: absolute;
  bottom: 76px;
  right: 0;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(0,0,0,0.06);
}

.shop-aiplugin-left #shop-aiplugin-chat-window {
  right: auto;
  left: 0;
}

#shop-aiplugin-chat-window.shop-aiplugin-open {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Header */
#shop-aiplugin-chat-header {
  background: var(--shop-aiplugin-gradient);
  color: #fff;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
  overflow: visible;
  z-index: 2;
}

#shop-aiplugin-chat-header::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
}

.shop-aiplugin-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1;
}

.shop-aiplugin-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
}

.shop-aiplugin-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.shop-aiplugin-status {
  font-size: 12px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 5px;
}

.shop-aiplugin-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  animation: shop-aiplugin-pulse 2s infinite;
}

.shop-aiplugin-status-dot.offline { background: #fbbf24; animation: none; }
.shop-aiplugin-status-dot.human { background: #fb923c; }

@keyframes shop-aiplugin-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.shop-aiplugin-header-actions {
  display: flex;
  gap: 6px;
  z-index: 3;
  align-items: center;
}

.shop-aiplugin-header-menu {
  position: relative;
}

.shop-aiplugin-header-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  padding: 6px 0;
  margin: 0;
  background: var(--shop-aiplugin-surface);
  border: 1px solid var(--shop-aiplugin-border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  z-index: 50;
}

#shop-aiplugin-chat-widget.shop-aiplugin-left .shop-aiplugin-header-dropdown {
  right: auto;
  left: 0;
}

.shop-aiplugin-header-dropdown[hidden] {
  display: none !important;
}

.shop-aiplugin-dropdown-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--shop-aiplugin-text);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.shop-aiplugin-dropdown-item:hover {
  background: var(--shop-aiplugin-bg);
}

.shop-aiplugin-dropdown-item#shop-aiplugin-menu-end-chat {
  color: #b91c1c;
}

.shop-aiplugin-dropdown-item#shop-aiplugin-menu-end-chat:hover {
  background: #fef2f2;
}

#shop-aiplugin-chat-close, .shop-aiplugin-header-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background 0.2s;
}

#shop-aiplugin-chat-close:hover, .shop-aiplugin-header-btn:hover {
  background: rgba(255,255,255,0.25);
}

#shop-aiplugin-chat-widget .shop-aiplugin-menu-trigger,
#shop-aiplugin-chat-widget .shop-aiplugin-close-btn {
  color: #fff;
}

#shop-aiplugin-chat-widget .shop-aiplugin-icon-menu {
  display: block;
  color: inherit;
  flex-shrink: 0;
}

#shop-aiplugin-chat-widget .shop-aiplugin-icon-close {
  display: block;
  stroke: #fff;
  flex-shrink: 0;
}

/* Queue Bar */
.shop-aiplugin-queue-bar {
  background: #fef3c7;
  color: #92400e;
  padding: 8px 16px;
  font-size: 12px;
  text-align: center;
  font-weight: 500;
  display: none;
  flex-shrink: 0;
  border-bottom: 1px solid #fde68a;
}

.shop-aiplugin-queue-bar.visible { display: block; }

/* Messages */
#shop-aiplugin-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

#shop-aiplugin-chat-messages::-webkit-scrollbar { width: 4px; }
#shop-aiplugin-chat-messages::-webkit-scrollbar-track { background: transparent; }
#shop-aiplugin-chat-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.shop-aiplugin-message {
  max-width: 90%;
  animation: shop-aiplugin-slide-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes shop-aiplugin-slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.shop-aiplugin-message.shop-aiplugin-user { align-self: flex-end; }
.shop-aiplugin-message.shop-aiplugin-bot { align-self: flex-start; }
.shop-aiplugin-message.shop-aiplugin-operator { align-self: flex-start; }

.shop-aiplugin-message-content {
  padding: 14px 18px;
  border-radius: 16px;
  line-height: 1.65;
  word-wrap: break-word;
  word-break: break-word;
  font-size: 14px;
  min-width: 60px;
}

.shop-aiplugin-user .shop-aiplugin-message-content {
  background: var(--shop-aiplugin-gradient);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.shop-aiplugin-bot .shop-aiplugin-message-content {
  background: var(--shop-aiplugin-surface);
  color: var(--shop-aiplugin-text);
  border: 1px solid var(--shop-aiplugin-border);
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.shop-aiplugin-operator .shop-aiplugin-message-content {
  background: var(--shop-aiplugin-gradient);
  color: #fff;
  border-bottom-left-radius: 6px;
}

.shop-aiplugin-sender-label {
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 4px;
  opacity: 0.7;
}

.shop-aiplugin-message-time {
  font-size: 10px;
  opacity: 0.5;
  margin-top: 4px;
}

.shop-aiplugin-bot .shop-aiplugin-message-content ul {
  margin: 6px 0;
  padding-left: 18px;
}

.shop-aiplugin-bot .shop-aiplugin-message-content li {
  margin-bottom: 3px;
}

/* Product Cards - Modern */
.shop-aiplugin-message.shop-aiplugin-products {
  max-width: 95%;
}

.shop-aiplugin-product-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
}

.shop-aiplugin-product-card {
  background: var(--shop-aiplugin-surface);
  border: 1px solid var(--shop-aiplugin-border);
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.shop-aiplugin-product-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: var(--shop-aiplugin-primary-light);
}

.shop-aiplugin-product-card-inner {
  display: flex;
  gap: 12px;
  padding: 12px;
}

.shop-aiplugin-product-image-link {
  flex-shrink: 0;
  display: block;
  width: 80px;
  height: 80px;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: opacity 0.2s;
}

.shop-aiplugin-product-image-link:hover {
  opacity: 0.85;
}

.shop-aiplugin-product-image {
  width: 80px;
  height: 80px;
  border-radius: 10px;
  object-fit: cover;
  background: #f1f5f9;
  flex-shrink: 0;
  display: block;
}

.shop-aiplugin-product-info {
  flex: 1;
  min-width: 0;
}

.shop-aiplugin-product-name {
  font-weight: 600;
  color: var(--shop-aiplugin-text);
  font-size: 13px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.shop-aiplugin-product-price-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.shop-aiplugin-product-price {
  color: var(--shop-aiplugin-primary);
  font-weight: 700;
  font-size: 15px;
}

.shop-aiplugin-product-original-price {
  color: #94a3b8;
  font-size: 12px;
  text-decoration: line-through;
}

.shop-aiplugin-product-sale-badge {
  background: #fef2f2;
  color: #ef4444;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
}

.shop-aiplugin-product-actions {
  display: flex;
  gap: 8px;
  padding: 0 12px 12px;
}

.shop-aiplugin-product-link {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.shop-aiplugin-btn-view {
  background: #f1f5f9;
  color: var(--shop-aiplugin-text-secondary);
}

.shop-aiplugin-btn-view:hover { background: #e2e8f0; }

.shop-aiplugin-btn-cart {
  background: var(--shop-aiplugin-gradient);
  color: #fff;
}

.shop-aiplugin-btn-cart:hover { opacity: 0.9; }

.shop-aiplugin-btn-outofstock {
  background: #f1f5f9;
  color: #94a3b8;
  cursor: not-allowed;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.02em;
}

/* Order Info */
.shop-aiplugin-order-card {
  background: var(--shop-aiplugin-surface);
  border: 1px solid var(--shop-aiplugin-border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.shop-aiplugin-order-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--shop-aiplugin-border);
}

.shop-aiplugin-order-number {
  font-weight: 700;
  color: var(--shop-aiplugin-text);
  font-size: 14px;
}

.shop-aiplugin-order-status {
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
}

.shop-aiplugin-order-status.processing { background: #dbeafe; color: #1d4ed8; }
.shop-aiplugin-order-status.completed { background: #dcfce7; color: #166534; }
.shop-aiplugin-order-status.on-hold { background: #fef3c7; color: #92400e; }
.shop-aiplugin-order-status.cancelled { background: #fef2f2; color: #991b1b; }
.shop-aiplugin-order-status.pending { background: #f3f4f6; color: #374151; }

.shop-aiplugin-order-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
}

.shop-aiplugin-order-label { color: var(--shop-aiplugin-text-secondary); }
.shop-aiplugin-order-value { color: var(--shop-aiplugin-text); font-weight: 500; }

/* Satisfaction */
.shop-aiplugin-satisfaction {
  background: var(--shop-aiplugin-surface);
  border: 1px solid var(--shop-aiplugin-border);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
}

.shop-aiplugin-satisfaction-title {
  font-size: 13px;
  color: var(--shop-aiplugin-text);
  font-weight: 600;
  margin-bottom: 8px;
}

.shop-aiplugin-satisfaction-stars {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.shop-aiplugin-star-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 24px;
  opacity: 0.3;
  transition: all 0.2s;
}

.shop-aiplugin-star-btn:hover, .shop-aiplugin-star-btn.active {
  opacity: 1;
  transform: scale(1.15);
}

/* Typing Indicator */
.shop-aiplugin-typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: var(--shop-aiplugin-surface);
  border: 1px solid var(--shop-aiplugin-border);
  border-radius: 16px;
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.shop-aiplugin-typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--shop-aiplugin-primary-light);
  animation: shop-aiplugin-typing-bounce 1.2s infinite;
}

.shop-aiplugin-typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.shop-aiplugin-typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes shop-aiplugin-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Emoji Picker */
.shop-aiplugin-emoji-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
  transition: background 0.15s;
  padding: 0;
  line-height: 1;
}
.shop-aiplugin-emoji-btn:hover {
  background: #f1f5f9;
}

.shop-aiplugin-emoji-panel {
  display: none;
  position: absolute;
  bottom: 60px;
  left: 12px;
  right: 12px;
  background: #fff;
  border: 1px solid var(--shop-aiplugin-border);
  border-radius: 12px;
  padding: 10px;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 10;
  max-height: 140px;
  overflow-y: auto;
}

.shop-aiplugin-emoji-item {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.1s;
  user-select: none;
}
.shop-aiplugin-emoji-item:hover {
  background: #f1f5f9;
  transform: scale(1.15);
}

/* Input Area */
#shop-aiplugin-chat-input-area {
  padding: 14px 16px;
  border-top: 1px solid var(--shop-aiplugin-border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--shop-aiplugin-surface);
  flex-shrink: 0;
  position: relative;
}

#shop-aiplugin-chat-input {
  flex: 1;
  padding: 11px 16px;
  border: 1.5px solid var(--shop-aiplugin-border);
  border-radius: 12px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: all 0.2s;
  background: var(--shop-aiplugin-bg);
  color: var(--shop-aiplugin-text);
}

#shop-aiplugin-chat-input:focus {
  border-color: var(--shop-aiplugin-primary);
  background: var(--shop-aiplugin-surface);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

#shop-aiplugin-chat-input::placeholder {
  color: #94a3b8;
}

#shop-aiplugin-chat-send {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--shop-aiplugin-gradient);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 2px 8px var(--shop-aiplugin-glow-soft);
}

#shop-aiplugin-chat-widget #shop-aiplugin-chat-send .shop-aiplugin-icon-send {
  display: block;
  stroke: #fff;
  flex-shrink: 0;
}

#shop-aiplugin-chat-send:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px var(--shop-aiplugin-glow-strong);
}

#shop-aiplugin-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Powered by */
.shop-aiplugin-powered {
  text-align: center;
  padding: 6px;
  font-size: 10px;
  color: #94a3b8;
  background: var(--shop-aiplugin-surface);
  border-top: 1px solid #f1f5f9;
}

.shop-aiplugin-powered a {
  color: var(--shop-aiplugin-primary);
  text-decoration: none;
  font-weight: 600;
}

/* Responsive */
@media (max-width: 480px) {
  #shop-aiplugin-chat-widget { bottom: 16px; right: 16px; }
  #shop-aiplugin-chat-widget.shop-aiplugin-left { left: 16px; }

  #shop-aiplugin-chat-window {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    bottom: 72px;
    border-radius: 16px;
  }

  #shop-aiplugin-chat-toggle { width: 52px; height: 52px; }
}

