/* ═══════════════════════════════════════════════════════════
   AI Chatbot Widget — BD Electronics XYZ
   ═══════════════════════════════════════════════════════════ */

/* ── Toggle Button ─────────────────────────────────────── */
.chatbot-toggle {
  position: fixed;
  bottom: 20px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary, #0d47a1);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(13, 71, 161, 0.5);
  z-index: 10000;
  transition: transform 0.2s, background 0.2s;
}
.chatbot-toggle:hover {
  transform: scale(1.1);
  background: var(--secondary, #1565c0);
}
.chatbot-toggle .icon-chat { display: block; }
.chatbot-toggle .icon-close { display: none; }
.chatbot-toggle.active .icon-chat { display: none; }
.chatbot-toggle.active .icon-close { display: block; }

/* ── Chat Panel ────────────────────────────────────────── */
.chatbot-panel {
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: 380px;
  max-height: 520px;
  background: #1a1a2e;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.25s ease;
}
.chatbot-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ── Header ────────────────────────────────────────────── */
.chatbot-header {
  background: linear-gradient(135deg, #0d47a1, #1565c0);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.chatbot-header h3 {
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chatbot-header h3 i {
  color: #ffc107;
}
.chatbot-status {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.7);
  font-weight: 400;
}

/* ── Messages ──────────────────────────────────────────── */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 300px;
  max-height: 340px;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}
.chatbot-messages::-webkit-scrollbar { width: 4px; }
.chatbot-messages::-webkit-scrollbar-thumb { background: #444; border-radius: 2px; }

.chatbot-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #e0e0e0;
  animation: msgIn 0.2s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.chatbot-msg.assistant {
  background: #2a2a40;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.chatbot-msg.user {
  background: #0d47a1;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chatbot-msg.system {
  background: transparent;
  color: rgba(255,255,255,0.4);
  font-size: 0.8rem;
  text-align: center;
  align-self: center;
  padding: 4px 0;
  max-width: 100%;
}

/* Typing indicator */
.chatbot-typing {
  display: inline-flex;
  gap: 4px;
  padding: 6px 0;
}
.chatbot-typing span {
  width: 7px;
  height: 7px;
  background: rgba(255,255,255,0.3);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}
.chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

/* Product cards inside messages */
.chatbot-product {
  background: #16162a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 10px;
  margin: 6px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}
.chatbot-product:hover {
  background: #1f1f3a;
}
.chatbot-product-name {
  font-weight: 600;
  color: #fff;
  font-size: 0.85rem;
}
.chatbot-product-price {
  color: #ffc107;
  font-size: 0.8rem;
  font-weight: 600;
}
.chatbot-product-sale {
  color: #ff6b6b;
  text-decoration: line-through;
  font-size: 0.75rem;
  margin-left: 6px;
}

/* ── Input Area ────────────────────────────────────────── */
.chatbot-input-wrap {
  padding: 12px;
  background: #16162a;
  border-top: 1px solid #2a2a40;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.chatbot-input-wrap textarea {
  flex: 1;
  background: #2a2a40;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 10px 12px;
  color: #e0e0e0;
  font-size: 0.875rem;
  font-family: inherit;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.15s;
}
.chatbot-input-wrap textarea:focus {
  border-color: #0d47a1;
}
.chatbot-input-wrap textarea::placeholder {
  color: rgba(255,255,255,0.3);
}
.chatbot-send {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: #0d47a1;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.chatbot-send:hover { background: #1565c0; }
.chatbot-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Powered by ────────────────────────────────────────── */
.chatbot-powered {
  text-align: center;
  padding: 6px;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.2);
  background: #16162a;
  flex-shrink: 0;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 480px) {
  .chatbot-panel {
    right: 10px;
    left: 10px;
    bottom: 150px;
    width: auto;
    max-height: 60vh;
  }
  .chatbot-toggle {
    right: 16px;
  }
}
