/* ============================================
   MobileLux – Chatbot Widget Styles
   ============================================ */

.chatbot {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: 'Inter', sans-serif;
}

/* ── Toggle button ───────────────────────────── */
.chatbot-toggle {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #2F2FE4 0%, #162E93 100%);
  color: #fff;
  font-size: 1.5rem;
  box-shadow: 0 10px 40px rgba(47, 47, 228, 0.5);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.chatbot-toggle:hover {
  transform: scale(1.08) rotate(8deg);
  box-shadow: 0 14px 50px rgba(47, 47, 228, 0.65);
}
.chatbot-toggle:active { transform: scale(0.95); }

.chatbot-icon-chat,
.chatbot-icon-close {
  position: absolute;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.chatbot-icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}
.chatbot.open .chatbot-icon-chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}
.chatbot.open .chatbot-icon-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* Pulse ring */
.chatbot-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(47, 47, 228, 0.4);
  animation: chatPulse 2s ease-out infinite;
  pointer-events: none;
}
.chatbot.open .chatbot-pulse { display: none; }
@keyframes chatPulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Unread notification */
.chatbot-notif {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ff3b5c;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 50px;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: chatNotifPop 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.chatbot-notif.hidden { display: none; }
@keyframes chatNotifPop {
  0% { transform: scale(0); }
  60% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ── Chat window ─────────────────────────────── */
.chatbot-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.chatbot.open .chatbot-window {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

[data-theme="dark"] .chatbot-window {
  background: #080616;
  color: #f1f5f9;
}

/* ── Header ──────────────────────────────────── */
.chatbot-header {
  background: linear-gradient(135deg, #2F2FE4 0%, #162E93 100%);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.chatbot-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.chatbot-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}
.chatbot-status-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #2F2FE4;
  border: 2px solid #fff;
  animation: statusBlink 2s ease-in-out infinite;
}
@keyframes statusBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.chatbot-status-dot-inline {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2F2FE4;
  margin-right: 4px;
  vertical-align: middle;
}
.chatbot-header strong {
  display: block;
  font-size: 0.98rem;
  font-weight: 700;
}
.chatbot-header small {
  display: block;
  font-size: 0.72rem;
  opacity: 0.9;
  margin-top: 2px;
}
.chatbot-header-right {
  display: flex;
  gap: 4px;
}
.chatbot-hbtn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.25s;
}
.chatbot-hbtn:hover { background: rgba(255, 255, 255, 0.3); }

/* ── Body ────────────────────────────────────── */
.chatbot-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8f9ff;
  scroll-behavior: smooth;
}
[data-theme="dark"] .chatbot-body { background: #080616; }

.chatbot-body::-webkit-scrollbar { width: 6px; }
.chatbot-body::-webkit-scrollbar-thumb {
  background: rgba(47, 47, 228, 0.3);
  border-radius: 10px;
}

/* Message bubble */
.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: msgIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 100%;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg-bot { align-self: flex-start; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2F2FE4 0%, #162E93 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.msg-user .msg-avatar {
  background: linear-gradient(135deg, #2F2FE4 0%, #1A1953 100%);
}

.msg-bubble {
  background: #fff;
  padding: 10px 14px;
  border-radius: 18px 18px 18px 4px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #080616;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  max-width: 78%;
  word-wrap: break-word;
}
.msg-user .msg-bubble {
  background: linear-gradient(135deg, #2F2FE4 0%, #162E93 100%);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
}
[data-theme="dark"] .msg-bot .msg-bubble {
  background: #1A1953;
  color: #f1f5f9;
}
.msg-bubble strong { font-weight: 700; }
.msg-bubble a {
  color: #2F2FE4;
  text-decoration: underline;
  font-weight: 600;
}
.msg-user .msg-bubble a { color: #fff; }

.msg-time {
  font-size: 0.65rem;
  color: #94a3b8;
  margin-top: 3px;
  padding: 0 8px;
}

/* Product card inside chat */
.msg-product {
  display: flex;
  gap: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 10px;
  margin-top: 6px;
  transition: all 0.25s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.msg-product:hover {
  border-color: #2F2FE4;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(47, 47, 228, 0.15);
}
.msg-product img {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}
.msg-product-info { flex: 1; min-width: 0; }
.msg-product-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #080616;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-product-brand {
  font-size: 0.7rem;
  color: #64748b;
  margin-bottom: 4px;
}
.msg-product-price {
  font-size: 0.88rem;
  font-weight: 800;
  color: #2F2FE4;
}
[data-theme="dark"] .msg-product {
  background: #1A1953;
  border-color: #2a2870;
}
[data-theme="dark"] .msg-product-name { color: #f1f5f9; }

/* Typing indicator */
.typing-bubble {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}
.typing-bubble span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: typing 1.2s ease-in-out infinite;
}
.typing-bubble span:nth-child(2) { animation-delay: 0.15s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Quick replies ───────────────────────────── */
.chatbot-quick {
  padding: 10px 14px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  scrollbar-width: none;
}
.chatbot-quick::-webkit-scrollbar { display: none; }
[data-theme="dark"] .chatbot-quick {
  background: #080616;
  border-color: #2a2870;
}
.chip {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 50px;
  border: 1.5px solid #e2e8f0;
  background: #f8f9ff;
  color: #080616;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s;
  white-space: nowrap;
}
.chip:hover {
  background: linear-gradient(135deg, #2F2FE4 0%, #162E93 100%);
  color: #fff;
  border-color: transparent;
  transform: translateY(-2px);
}
[data-theme="dark"] .chip {
  background: #080616;
  border-color: #2a2870;
  color: #f1f5f9;
}

/* ── Input ───────────────────────────────────── */
.chatbot-input {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
}
[data-theme="dark"] .chatbot-input {
  background: #080616;
  border-color: #2a2870;
}
.chatbot-input input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 50px;
  border: 1.5px solid #e2e8f0;
  background: #f8f9ff;
  font-size: 0.85rem;
  font-family: inherit;
  color: #080616;
  outline: none;
  transition: border 0.25s;
}
.chatbot-input input:focus { border-color: #2F2FE4; }
[data-theme="dark"] .chatbot-input input {
  background: #080616;
  border-color: #2a2870;
  color: #f1f5f9;
}
.chatbot-ibtn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.25s;
}
.chatbot-ibtn:hover { color: #2F2FE4; background: #f8f9ff; }
.chatbot-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #2F2FE4 0%, #162E93 100%);
  color: #fff;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.25s;
  flex-shrink: 0;
}
.chatbot-send:hover {
  transform: scale(1.08) rotate(-10deg);
  box-shadow: 0 6px 18px rgba(47, 47, 228, 0.5);
}
.chatbot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Emoji panel */
.emoji-panel {
  position: absolute;
  bottom: 110px;
  left: 14px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  display: none;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  z-index: 10;
  max-width: 260px;
}
.emoji-panel.open { display: grid; }
[data-theme="dark"] .emoji-panel {
  background: #1A1953;
  border-color: #2a2870;
}
.emoji-panel button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  transition: background 0.2s;
}
.emoji-panel button:hover { background: #f8f9ff; }
[data-theme="dark"] .emoji-panel button:hover { background: #080616; }

/* Footer */
.chatbot-footer {
  padding: 8px 14px;
  text-align: center;
  font-size: 0.68rem;
  color: #94a3b8;
  background: #fff;
  border-top: 1px solid #e2e8f0;
}
[data-theme="dark"] .chatbot-footer {
  background: #080616;
  border-color: #2a2870;
}
.chatbot-footer a {
  color: #2F2FE4;
  text-decoration: none;
  font-weight: 600;
}
.chatbot-footer a:hover { text-decoration: underline; }

/* ── Mobile ──────────────────────────────────── */
@media (max-width: 480px) {
  .chatbot {
    bottom: 16px;
    right: 16px;
  }
  .chatbot-window {
    width: calc(100vw - 32px);
    height: calc(100vh - 110px);
    bottom: 76px;
    right: 0;
  }
  .chatbot-toggle {
    width: 56px;
    height: 56px;
    font-size: 1.3rem;
  }
}
