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