/**
 * AI Consultant Chatbot — BizLinxOS
 * Floating widget + chat window styles. No external dependencies.
 */

/* ── Launch button ──────────────────────────────────────────────────────── */
#bizlinx-chat-launch {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9998;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--purple, #8b5cf6);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(139, 92, 246, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#bizlinx-chat-launch:hover {
  transform: scale(1.07);
  box-shadow: 0 8px 32px rgba(139, 92, 246, 0.55);
}
#bizlinx-chat-launch svg { width: 26px; height: 26px; }

/* Badge pulse */
#bizlinx-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--warm, #ff6b4a);
  border: 2px solid #fff;
  animation: badgePulse 2.5s ease-in-out infinite;
}
@keyframes badgePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.8; }
}

/* ── Chat window ─────────────────────────────────────────────────────────── */
#bizlinx-chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9999;
  width: 380px;
  max-width: calc(100vw - 40px);
  max-height: 580px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 16px 60px rgba(139, 92, 246, 0.2), 0 4px 16px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(8px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#bizlinx-chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.blx-chat-header {
  padding: 20px 20px 16px;
  background: linear-gradient(135deg, #1a1a2e 0%, #2d1b69 100%);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
}
.blx-chat-header-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(139,92,246,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.blx-chat-header-icon svg { width: 22px; height: 22px; }
.blx-chat-header-text { flex: 1; min-width: 0; }
.blx-chat-header-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}
.blx-chat-header-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  margin-top: 2px;
}
.blx-chat-close {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.7);
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.blx-chat-close:hover { background: rgba(255,255,255,0.15); color: #fff; }
.blx-chat-close svg { width: 18px; height: 18px; }

/* ── Messages area ───────────────────────────────────────────────────────── */
.blx-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  background: #f8f8fc;
}
.blx-chat-messages::-webkit-scrollbar { width: 4px; }
.blx-chat-messages::-webkit-scrollbar-track { background: transparent; }
.blx-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(139,92,246,0.2);
  border-radius: 4px;
}

/* Bubble */
.blx-msg {
  display: flex;
  gap: 8px;
  animation: msgIn 0.3s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.blx-msg.bot { align-self: flex-start; max-width: 88%; }
.blx-msg.user { align-self: flex-end; max-width: 82%; flex-direction: row-reverse; }

.blx-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--purple, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.blx-msg-avatar svg { width: 15px; height: 15px; }
.blx-msg.user .blx-msg-avatar { background: var(--teal, #14b8a6); }

.blx-msg-content {
  background: #fff;
  border-radius: 14px 14px 14px 4px;
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.55;
  color: #1a1a2e;
  box-shadow: 0 2px 8px rgba(139,92,246,0.08);
  border: 1px solid rgba(139,92,246,0.07);
}
.blx-msg.user .blx-msg-content {
  background: var(--purple, #8b5cf6);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
  box-shadow: none;
}
.blx-msg-content p { margin: 0 0 8px; }
.blx-msg-content p:last-child { margin-bottom: 0; }
.blx-msg-content strong { font-weight: 600; }
.blx-msg-content ul, .blx-msg-content ol {
  margin: 6px 0;
  padding-left: 18px;
}
.blx-msg-content li { margin-bottom: 4px; }

/* CTA bubble */
.blx-msg-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 14px;
  background: linear-gradient(135deg, rgba(139,92,246,0.12), rgba(20,184,166,0.1));
  border: 1px solid rgba(139,92,246,0.18);
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: #8b5cf6;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.blx-msg-cta:hover {
  background: linear-gradient(135deg, rgba(139,92,246,0.2), rgba(20,184,166,0.18));
  transform: translateY(-1px);
}
.blx-msg-cta svg { width: 14px; height: 14px; }

/* Quick reply chips */
.blx-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.blx-quick-chip {
  background: linear-gradient(135deg, rgba(139,92,246,0.1), rgba(20,184,166,0.08));
  border: 1px solid rgba(139,92,246,0.2);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  color: #8b5cf6;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  font-family: 'DM Sans', sans-serif;
}
.blx-quick-chip:hover {
  background: rgba(139,92,246,0.18);
  transform: translateY(-1px);
}

/* Typing indicator */
.blx-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
}
.blx-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(139,92,246,0.4);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.blx-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.blx-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* ── Input area ──────────────────────────────────────────────────────────── */
.blx-chat-input-bar {
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid rgba(139,92,246,0.1);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.blx-chat-input {
  flex: 1;
  border: 1.5px solid rgba(139,92,246,0.15);
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-family: 'DM Sans', sans-serif;
  color: #1a1a2e;
  background: #f8f8fc;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
  max-height: 80px;
  line-height: 1.5;
}
.blx-chat-input::placeholder { color: #9ca3af; }
.blx-chat-input:focus { border-color: rgba(139,92,246,0.4); }
.blx-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--purple, #8b5cf6);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}
.blx-chat-send:hover { background: #7c3aed; transform: scale(1.05); }
.blx-chat-send svg { width: 16px; height: 16px; }
.blx-chat-send:disabled { background: #d1d5db; cursor: not-allowed; transform: none; }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.blx-chat-footer {
  padding: 8px 16px 12px;
  background: #fff;
  text-align: center;
  border-top: 1px solid rgba(139,92,246,0.06);
}
.blx-chat-footer-link {
  font-size: 11px;
  color: #9ca3af;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.blx-chat-footer-link:hover { color: #8b5cf6; }
.blx-chat-footer-link svg { width: 12px; height: 12px; }

/* ── Mobile ──────────────────────────────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════════════
   Skeleton loaders + shimmer — shared across all views
   ══════════════════════════════════════════════════════════════════════ */

.skeleton-wrap {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Generic card skeleton */
.skel-card {
  background: #fff;
  border-radius: 18px;
  padding: 1.5rem;
  border: 1px solid rgba(139,92,246,0.1);
}

/* Text line skeleton */
.skel-line {
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, #f0f0f6 25%, #e8e8f2 50%, #f0f0f6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}
.skel-line.sm  { width: 40%; }
.skel-line.md  { width: 65%; }
.skel-line.lg  { width: 85%; }
.skel-line.full{ width: 100%; }

/* Circle skeleton (for avatars) */
.skel-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(90deg, #f0f0f6 25%, #e8e8f2 50%, #f0f0f6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  flex-shrink: 0;
}

/* Grid skeleton (for exchange/card grids) */
.skel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}
.skel-grid-card {
  background: #fff;
  border-radius: 18px;
  border: 1px solid rgba(139,92,246,0.1);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.skel-grid-card .skel-line { margin-bottom: 0.25rem; }
.skel-badge {
  height: 22px;
  width: 72px;
  border-radius: 6px;
  background: linear-gradient(90deg, #f0f0f6 25%, #e8e8f2 50%, #f0f0f6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}

/* Spinner fallback (replaces shimmer for fast ops) */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(139,92,246,0.15);
  border-top-color: #8b5cf6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-sm { width: 18px; height: 18px; border-width: 2px; }

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Centered loading state */
.loading-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem;
  text-align: center;
}
.loading-center p {
  color: #9ca3af;
  font-size: 0.875rem;
}

/* Empty state shared styles */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  background: #fff;
  border-radius: 18px;
  border: 2px dashed rgba(139,92,246,0.15);
}
.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
}
.empty-state h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 0.5rem;
}
.empty-state p {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 1.5rem;
}

/* Inline form field errors */
.field-error {
  color: #ff6b4a;
  font-size: 0.75rem;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.field-error::before {
  content: '⚠';
  font-size: 0.65rem;
}
input.error-field,
select.error-field,
textarea.error-field {
  border-color: rgba(255,107,74,0.5) !important;
  box-shadow: 0 0 0 3px rgba(255,107,74,0.1);
}
input:focus:not(.error-field) {
  border-color: rgba(139,92,246,0.5);
  box-shadow: 0 0 0 3px rgba(139,92,246,0.08);
  outline: none;
}

/* Dealia typing indicator */
.dealia-typing {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.85rem;
  color: #6b6b85;
}
.dealia-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6b6b85;
  animation: typingBounce 1.2s ease-in-out infinite;
}
.dealia-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.dealia-typing-dot:nth-child(3) { animation-delay: 0.36s; }

@media (max-width: 480px) {
  #bizlinx-chat-launch { bottom: 20px; right: 20px; }
  #bizlinx-chat-window {
    bottom: 84px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: 70vh;
  }
}