/* AI Chat Widget Styles */
:root {
  --chat-primary: #0f766e;
  --chat-primary-light: #14b8a6;
  --chat-primary-dark: #0d5a54;
  --chat-bg: #ffffff;
  --chat-surface: #f8fafc;
  --chat-border: #e2e8f0;
  --chat-text: #1e293b;
  --chat-text-muted: #64748b;
  --chat-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

/* Chat Toggle Button */
.chat-toggle-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-light) 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(15, 118, 110, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 9998;
}

.chat-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(15, 118, 110, 0.5);
}

.chat-toggle-btn i {
  color: white;
  font-size: 24px;
  transition: transform 0.3s;
}

.chat-toggle-btn.active i {
  transform: rotate(90deg);
}

.chat-toggle-btn .chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: #ef4444;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: white;
  border: 2px solid white;
}

/* Chat Container */
.chat-widget {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 400px;
  height: 600px;
  max-height: calc(100vh - 140px);
  background: var(--chat-bg);
  border-radius: 20px;
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-widget.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Chat Header */
.chat-header {
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-light) 100%);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-header-avatar i {
  color: white;
  font-size: 22px;
}

.chat-header-info {
  flex: 1;
}

.chat-header-title {
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}

.chat-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.chat-header-status .dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

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

.chat-header-status span {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.85rem;
}

.chat-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.chat-close-btn i {
  color: white;
  font-size: 18px;
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--chat-surface);
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

/* Message Bubbles */
.message {
  display: flex;
  gap: 10px;
  max-width: 85%;
  animation: fadeInUp 0.3s ease;
}

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

.message.bot {
  align-self: flex-start;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.message.bot .message-avatar {
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-light) 100%);
}

.message.bot .message-avatar i {
  color: white;
  font-size: 14px;
}

.message.user .message-avatar {
  background: #e2e8f0;
}

.message.user .message-avatar i {
  color: #64748b;
  font-size: 14px;
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-line;
  word-break: break-word;
  overflow-wrap: break-word;
}

.message.bot .message-bubble {
  background: white;
  color: var(--chat-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.message.user .message-bubble {
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-light) 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.message-time {
  font-size: 0.75rem;
  color: var(--chat-text-muted);
  padding: 0 4px;
}

.message.user .message-time {
  text-align: right;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 10px;
  align-self: flex-start;
  max-width: 85%;
}

.typing-indicator .message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.typing-indicator .message-avatar i {
  color: white;
  font-size: 14px;
}

.typing-dots {
  background: white;
  padding: 16px 20px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  display: flex;
  gap: 4px;
  align-items: center;
}

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

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

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: scale(1);
    opacity: 0.5;
  }
  40% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* Product Card in Chat */
.chat-product-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-top: 8px;
}

.chat-product-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
}

.chat-product-card-body {
  padding: 12px;
}

.chat-product-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--chat-text);
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.chat-product-card-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
}

.chat-product-stat {
  display: flex;
  flex-direction: column;
}

.chat-product-stat-label {
  font-size: 0.7rem;
  color: var(--chat-text-muted);
  text-transform: uppercase;
}

.chat-product-stat-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--chat-text);
}

.chat-product-stat-value.profit {
  color: #10b981;
}

.chat-product-card-btn {
  width: 100%;
  padding: 10px;
  background: var(--chat-primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-product-card-btn:hover {
  background: var(--chat-primary-dark);
}

/* Quick Actions */
.chat-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-bottom: 8px;
}

.quick-action-btn {
  padding: 10px 16px;
  background: white;
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--chat-text);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.quick-action-btn:hover {
  border-color: var(--chat-primary);
  color: var(--chat-primary);
  background: rgba(15, 118, 110, 0.05);
  transform: translateY(-1px);
}

/* Chat Input */
.chat-input-container {
  padding: 16px 20px;
  background: white;
  border-top: 1px solid var(--chat-border);
  position: relative;
}

.chat-input-wrapper {
  display: flex;
  gap: 12px;
  align-items: center;
  background: #f8fafc;
  border: 2px solid var(--chat-border);
  border-radius: 28px;
  padding: 6px 8px 6px 16px;
  transition: all 0.3s ease;
}

.chat-input-wrapper:focus-within {
  border-color: var(--chat-primary);
  background: white;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.1);
}

.chat-input {
  flex: 1;
  padding: 10px 4px;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  outline: none;
  resize: none;
  max-height: 100px;
  min-height: 24px;
  line-height: 1.5;
  font-family: inherit;
}

.chat-input:focus {
  outline: none;
}

.chat-input::placeholder {
  color: #94a3b8;
  font-size: 0.9rem;
}

.chat-send-btn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-light) 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 4px 15px rgba(15, 118, 110, 0.4);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.chat-send-btn i {
  color: white;
  font-size: 16px;
  margin-left: 2px;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .chat-widget {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  
  .chat-widget.active {
    transform: translateY(0) scale(1);
  }
  
  .chat-toggle-btn {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }
  
  .chat-toggle-btn i {
    font-size: 22px;
  }
  
  .chat-header {
    padding: 16px;
  }
  
  .chat-messages {
    padding: 16px;
  }
  
  .message {
    max-width: 90%;
  }
  
  .chat-input-container {
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 768px) and (min-width: 481px) {
  .chat-widget {
    width: 360px;
    height: 550px;
    right: 16px;
    bottom: 90px;
  }
  
  .chat-toggle-btn {
    bottom: 20px;
    right: 20px;
  }
}

/* Welcome Screen */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
}

.chat-welcome-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.chat-welcome-icon i {
  color: white;
  font-size: 36px;
}

.chat-welcome h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--chat-text);
  margin-bottom: 10px;
}

.chat-welcome p {
  font-size: 0.95rem;
  color: var(--chat-text-muted);
  line-height: 1.6;
  margin-bottom: 24px;
}

.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.chat-suggestion-btn {
  padding: 14px 18px;
  background: white;
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  font-size: 0.9rem;
  color: var(--chat-text);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-suggestion-btn:hover {
  border-color: var(--chat-primary);
  background: rgba(15, 118, 110, 0.03);
}

.chat-suggestion-btn i {
  color: var(--chat-primary);
  font-size: 18px;
}

/* Upgrade Prompt Styles */
.message-bubble.upgrade-prompt {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #f59e0b;
  color: #92400e;
}

.upgrade-btn-container {
  margin-top: 16px;
  text-align: center;
}

.chat-upgrade-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  border: none;
  border-radius: 25px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.chat-upgrade-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
  color: white;
  text-decoration: none;
}

.chat-upgrade-btn i {
  font-size: 16px;
}
