/* ═══════════════════════════════════════════════════
   CHAT FAB BUTTON
   ═══════════════════════════════════════════════════ */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255, 153, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-base);
  animation: fab-pulse 3s ease-in-out infinite;
}

.chat-fab:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(255, 153, 0, 0.45);
}

.chat-fab:active {
  transform: scale(0.95);
}

@keyframes fab-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(255, 153, 0, 0.35); }
  50% { box-shadow: 0 4px 24px rgba(255, 153, 0, 0.5); }
}

/* ═══════════════════════════════════════════════════
   CHAT PANEL
   ═══════════════════════════════════════════════════ */
.chat-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 400px;
  height: 520px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  display: none;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  /* Entrance animation */
  transform: scale(0.9) translateY(20px);
  transform-origin: bottom right;
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.chat-panel.open {
  display: flex;
  transform: scale(1) translateY(0);
  opacity: 1;
  animation: chat-entrance 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes chat-entrance {
  from {
    transform: scale(0.9) translateY(20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.chat-panel.fullscreen {
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  transform-origin: center;
}

/* ═══════════════════════════════════════════════════
   CHAT HEADER
   ═══════════════════════════════════════════════════ */
.chat-header {
  background: linear-gradient(135deg, var(--header-bg), var(--sub-header-bg));
  color: var(--text-light);
  padding: var(--space-4) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: var(--font-sm);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.chat-close,
.chat-fullscreen,
.chat-header-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

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

.chat-close {
  font-size: 1.4rem;
}

.chat-fullscreen {
  opacity: 0.8;
}

.chat-fullscreen:hover {
  opacity: 1;
}

/* ═══════════════════════════════════════════════════
   CHAT MESSAGES
   ═══════════════════════════════════════════════════ */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: #fafafa;
}

.message {
  max-width: 85%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  line-height: 1.5;
  word-break: break-word;
}

.user-message {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: var(--text-dark);
  border-bottom-right-radius: var(--space-1);
  box-shadow: 0 1px 3px rgba(255, 153, 0, 0.2);
}

.bot-message {
  align-self: flex-start;
  background: var(--card-bg);
  color: var(--text-dark);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: var(--space-1);
  box-shadow: var(--shadow-sm);
}

/* Product cards inside chat */
.product-card {
  align-self: flex-start;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-width: 90%;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  box-shadow: var(--shadow-sm);
}

.product-card img {
  width: 100%;
  height: 160px;
  object-fit: contain;
  background: #fff;
  padding: var(--space-2);
}

.product-card .product-card-body {
  padding: var(--space-3) var(--space-3) var(--space-1);
}

.product-card .product-card-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.chat-product-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  margin-bottom: var(--space-2);
}

.chat-product-grid .product-card {
  max-width: 100%;
}

/* ═══════════════════════════════════════════════════
   SUGGESTION CHIPS
   ═══════════════════════════════════════════════════ */
.suggestions {
  max-width: 95%;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.suggestion-chip {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  background: var(--card-bg);
  cursor: pointer;
  font-size: var(--font-xs);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.suggestion-chip:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-dark);
  transform: scale(1.03);
  box-shadow: var(--shadow-md);
}

/* ═══════════════════════════════════════════════════
   TYPING INDICATOR
   ═══════════════════════════════════════════════════ */
.typing-indicator {
  align-self: flex-start;
  padding: var(--space-3) var(--space-4);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ═══════════════════════════════════════════════════
   IMAGE PREVIEW BAR
   ═══════════════════════════════════════════════════ */
.chat-image-preview {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: #f0f4ff;
  border-top: 1px solid #d0daf0;
}

.chat-image-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.chat-image-remove {
  background: rgba(0,0,0,0.12);
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
  padding: 0;
}

.chat-image-remove:hover {
  background: rgba(220,50,50,0.15);
  color: #c0392b;
}

/* ═══════════════════════════════════════════════════
   CHAT INPUT
   ═══════════════════════════════════════════════════ */
.chat-input-form,
.chat-form {
  display: flex;
  align-items: center;
  padding: var(--space-3);
  gap: var(--space-2);
  border-top: 1px solid var(--border-color);
  background: var(--card-bg);
}

.chat-input-form input,
.chat-form input {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: var(--font-sm);
  outline: none;
  transition: border-color var(--transition-fast);
}

.chat-input-form input:focus,
.chat-form input:focus {
  border-color: var(--accent);
}

/* Image upload button */
.chat-image-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  padding: 0;
}

.chat-image-btn:hover {
  background: #f0f4ff;
  border-color: #5b8af6;
  color: #3b6fd6;
}

.chat-image-btn:active {
  transform: scale(0.95);
}

/* Submit button */
.chat-input-form button[type="submit"],
.chat-form button[type="submit"] {
  padding: var(--space-3) var(--space-5);
  background: var(--accent);
  border: none;
  border-radius: var(--radius-full);
  font-weight: 600;
  cursor: pointer;
  font-size: var(--font-sm);
  transition: background var(--transition-fast), transform var(--transition-fast);
  color: var(--text-dark);
  flex-shrink: 0;
}

.chat-input-form button[type="submit"]:hover,
.chat-form button[type="submit"]:hover {
  background: var(--accent-hover);
}

.chat-input-form button[type="submit"]:active,
.chat-form button[type="submit"]:active {
  transform: scale(0.97);
}

/* ═══════════════════════════════════════════════════
   USER IMAGE MESSAGE BUBBLE
   ═══════════════════════════════════════════════════ */
.user-image-message {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2) !important;
}

.chat-upload-preview {
  width: 100%;
  max-width: 220px;
  max-height: 180px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  display: block;
}

/* ═══════════════════════════════════════════════════
   COPY LINK BUTTON
   ═══════════════════════════════════════════════════ */
.copy-link-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-dark);
  transition: all var(--transition-fast);
}

.copy-link-btn:hover {
  background: #f0f0f0;
  border-color: var(--accent);
}

.copy-link-btn.copied {
  background: #e8f5e9;
  border-color: #4caf50;
  color: #2e7d32;
}

/* Top bar with View Deal + Copy Link buttons (chat cards) */
.product-card-top-bar {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: #f8f8f8;
  border-bottom: 1px solid #eee;
}

.top-bar-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.top-bar-view {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.top-bar-view:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.top-bar-copy {
  background: #fff;
  color: var(--text-secondary);
}

.top-bar-copy:hover {
  background: #f0f0f0;
  border-color: var(--accent);
}

.top-bar-copy.copied {
  background: #e8f5e9;
  border-color: #4caf50;
  color: #2e7d32;
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .chat-panel {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 84px;
    height: 60vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-fab {
    animation: none;
  }
  .chat-panel.open {
    animation: none;
  }
  .typing-dot {
    animation: none;
    opacity: 0.6;
  }
}

/* ─── Marketplace Mode Selector ─────────────────────────────────────────── */
.chat-mode-selector {
  padding: 12px 16px;
  text-align: center;
}

.chat-mode-prompt {
  font-size: 13px;
  color: #666;
  margin-bottom: 10px;
}

.chat-mode-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chat-mode-btn {
  padding: 8px 16px;
  border: 2px solid #e44d26;
  border-radius: 20px;
  background: white;
  color: #e44d26;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.chat-mode-btn:hover,
.chat-mode-btn.active {
  background: #e44d26;
  color: white;
}
