/* MegaOne AI Chatbot — Megaone Webservices ─────────────────────────────── */

/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --mo-primary:      #7C3AED;
  --mo-primary-glow: rgba(124,58,237,.35);
  --mo-accent:       #06B6D4;
  --mo-accent-glow:  rgba(6,182,212,.3);
  --mo-bg:           #0A0A14;
  --mo-surface:      rgba(14,14,26,.97);
  --mo-surface-2:    rgba(22,22,42,.85);
  --mo-border:       rgba(124,58,237,.16);
  --mo-text:         #E2E8F0;
  --mo-muted:        rgba(226,232,240,.45);
  --mo-user-bg:      linear-gradient(135deg,#7C3AED,#9333EA);
  --mo-bot-bg:       rgba(22,22,42,.9);
  --mo-radius:       22px;
  --mo-shadow:       0 24px 72px rgba(0,0,0,.65), 0 0 0 1px rgba(124,58,237,.12);
  --mo-w:            400px;
  --mo-h:            600px;
  --mo-z:            999999;
}

[data-mo-theme="light"] {
  --mo-surface:   rgba(255,255,255,.97);
  --mo-surface-2: rgba(246,243,255,.92);
  --mo-border:    rgba(124,58,237,.14);
  --mo-text:      #1E1B4B;
  --mo-muted:     rgba(30,27,75,.45);
  --mo-bot-bg:    rgba(243,240,255,.95);
  --mo-shadow:    0 24px 72px rgba(124,58,237,.12), 0 0 0 1px rgba(124,58,237,.1);
}

/* ── Root ──────────────────────────────────────────────────────────────── */
#megaone-chatbot-root {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: var(--mo-z);
  font-family: 'DM Sans', -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#megaone-chatbot-root * { box-sizing: border-box; margin: 0; padding: 0; }

/* Position classes (applied by JS) */
#megaone-chatbot-root.pos-bottom-left  { right: auto; left: 28px; }
#megaone-chatbot-root.pos-top-right    { bottom: auto; top: 28px; }
#megaone-chatbot-root.pos-top-left     { bottom: auto; top: 28px; right: auto; left: 28px; }

/* ── Launcher ──────────────────────────────────────────────────────────── */
.megaone-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  position: relative;
  /* IMPORTANT: no pointer-events tracking on root — only on launcher itself */
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  filter: drop-shadow(0 6px 20px var(--mo-primary-glow));
  transition: filter .25s, transform .2s;
}

/* Grabbing cursor only while actively dragging (JS adds class) */
.megaone-launcher.dragging {
  cursor: grabbing;
  filter: drop-shadow(0 10px 28px var(--mo-primary-glow));
  transform: scale(1.08);
}

.launcher-ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--mo-primary), var(--mo-accent), var(--mo-primary));
  animation: moSpin 5s linear infinite;
  opacity: .55;
}

.launcher-inner {
  position: absolute;
  inset: 2px;
  background: linear-gradient(135deg, var(--mo-primary), #9333EA 50%, var(--mo-accent));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
}

.megaone-launcher:hover:not(.dragging) .launcher-inner { transform: scale(1.06); }

.launcher-icon {
  width: 26px;
  height: 26px;
  color: #fff;
  position: absolute;
  transition: opacity .22s, transform .22s;
}
.launcher-chat-icon  { opacity: 1; transform: scale(1)   rotate(0deg); }
.launcher-close-icon { opacity: 0; transform: scale(.6)  rotate(-90deg); }
.megaone-launcher.open .launcher-chat-icon  { opacity: 0; transform: scale(.6) rotate(90deg); }
.megaone-launcher.open .launcher-close-icon { opacity: 1; transform: scale(1)  rotate(0deg); }

.launcher-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--mo-primary);
  animation: moPulse 3s ease-out infinite;
  z-index: 0;
}

@keyframes moPulse { 0% { transform: scale(1); opacity: .4; } 100% { transform: scale(1.85); opacity: 0; } }
@keyframes moSpin  { to { transform: rotate(360deg); } }

/* ── Chat window ───────────────────────────────────────────────────────── */
.megaone-chat-window {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: var(--mo-w);
  height: var(--mo-h);
  max-height: var(--mo-h);
  display: flex;
  flex-direction: column;
  background: var(--mo-surface);
  border: 1px solid var(--mo-border);
  border-radius: var(--mo-radius);
  box-shadow: var(--mo-shadow);
  overflow: hidden;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);

  /* Hidden state */
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px) scale(.96);
  transform-origin: bottom right;
  transition: opacity .28s cubic-bezier(.34,1.56,.64,1), transform .28s cubic-bezier(.34,1.56,.64,1);
}

.megaone-chat-window.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

/* Size variants */
.megaone-chat-window.size-compact { width: 360px; height: 520px; }
.megaone-chat-window.size-large   { width: 460px; height: 680px; }

/* Position adjustments */
.pos-bottom-left .megaone-chat-window { right: auto; left: 0; transform-origin: bottom left; }
.pos-top-right   .megaone-chat-window { bottom: auto; top: 72px; transform-origin: top right; }
.pos-top-left    .megaone-chat-window { bottom: auto; top: 72px; right: auto; left: 0; transform-origin: top left; }

/* ── Header ────────────────────────────────────────────────────────────── */
.chat-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(124,58,237,.12), rgba(6,182,212,.06));
  border-bottom: 1px solid var(--mo-border);
  position: relative;
  z-index: 2;
}

.chat-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--mo-primary), var(--mo-accent));
  opacity: .4;
}

.chat-header-left  { display: flex; align-items: center; gap: 11px; }
.chat-header-right { display: flex; align-items: center; gap: 4px; }

.bot-avatar-wrap { position: relative; width: 42px; height: 42px; flex-shrink: 0; }

.bot-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(124,58,237,.35);
  box-shadow: 0 0 14px var(--mo-primary-glow);
}
.bot-avatar svg, .bot-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.bot-status-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 10px; height: 10px;
  background: #22C55E;
  border-radius: 50%;
  border: 2px solid var(--mo-surface);
}

.bot-name {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--mo-text);
}

.bot-status-text { font-size: 11px; color: var(--mo-accent); }

.icon-btn {
  width: 34px; height: 34px;
  border: none;
  background: rgba(255,255,255,.05);
  border-radius: 9px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--mo-muted);
  transition: all .18s;
}
.icon-btn:hover { background: rgba(124,58,237,.2); color: var(--mo-text); }
.icon-btn svg   { width: 15px; height: 15px; }

/* ── Language dropdown ─────────────────────────────────────────────────── */
.lang-selector-wrap { position: relative; }

.lang-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  width: 190px;
  background: rgba(12,12,24,.98);
  border: 1px solid var(--mo-border);
  border-radius: 13px;
  padding: 7px;
  max-height: 260px;
  overflow-y: auto;
  z-index: 200;
  backdrop-filter: blur(20px);
  box-shadow: 0 16px 50px rgba(0,0,0,.55);
  animation: moFadeIn .18s ease;
}
.lang-dropdown.open { display: block; }
.lang-dropdown::-webkit-scrollbar { width: 3px; }
.lang-dropdown::-webkit-scrollbar-thumb { background: rgba(124,58,237,.3); border-radius: 3px; }

.mo-lang-opt {
  padding: 8px 11px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  color: var(--mo-muted);
  transition: all .14s;
}
.mo-lang-opt:hover  { background: rgba(124,58,237,.14); color: var(--mo-text); }
.mo-lang-opt.active { background: rgba(124,58,237,.2);  color: var(--mo-primary); font-weight: 600; }

/* ── Messages ──────────────────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  z-index: 1;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(124,58,237,.25); border-radius: 3px; }

/* Message row */
.mo-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: moMsgIn .3s cubic-bezier(.34,1.56,.64,1);
  max-width: 100%;
}
.mo-msg.user { flex-direction: row-reverse; }

@keyframes moMsgIn { from { opacity:0; transform:translateY(10px) scale(.96); } to { opacity:1; transform:none; } }

.mo-msg-body { display: flex; flex-direction: column; max-width: 82%; }
.mo-msg.user .mo-msg-body { align-items: flex-end; }

/* Mini avatar */
.mo-mini-av {
  width: 28px; height: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.mo-mini-av svg, .mo-mini-av img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Bubble */
.mo-bubble {
  padding: 11px 14px;
  border-radius: 17px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
  position: relative;
}

.mo-msg.bot  .mo-bubble { background: var(--mo-bot-bg); border: 1px solid var(--mo-border); border-bottom-left-radius: 4px; color: var(--mo-text); }
.mo-msg.user .mo-bubble { background: var(--mo-user-bg); border-bottom-right-radius: 4px; color: #fff; box-shadow: 0 3px 16px var(--mo-primary-glow); }
.mo-msg.error .mo-bubble { background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.2); color: #fca5a5; }

/* Markdown inside bubbles */
.mo-bubble strong { font-weight: 600; }
.mo-bubble em     { font-style: italic; opacity: .85; }
.mo-bubble code   { background: rgba(124,58,237,.14); padding: 2px 5px; border-radius: 4px; font-size: 12px; font-family: monospace; border: 1px solid rgba(124,58,237,.18); }
.mo-bubble pre    { background: rgba(0,0,0,.3); border-radius: 8px; padding: 10px 12px; overflow-x: auto; margin: 8px 0; }
.mo-bubble pre code { background: none; border: none; padding: 0; }
.mo-bubble ul, .mo-bubble ol { padding-left: 16px; margin: 6px 0; }
.mo-bubble li     { margin-bottom: 3px; }
.mo-bubble a      { color: var(--mo-accent); text-decoration: underline; text-underline-offset: 2px; }
.mo-bubble p      { margin: 0 0 7px; }
.mo-bubble p:last-child { margin-bottom: 0; }
.mo-bubble h1, .mo-bubble h2, .mo-bubble h3 { font-family: 'Syne', sans-serif; font-weight: 700; margin: 8px 0 3px; font-size: 14px; }
.mo-bubble hr     { border: none; border-top: 1px solid var(--mo-border); margin: 8px 0; }

.mo-time {
  font-size: 10px;
  opacity: .3;
  margin-top: 4px;
  padding: 0 2px;
}

/* ── Welcome card ──────────────────────────────────────────────────────── */
.mo-welcome {
  background: linear-gradient(135deg, rgba(124,58,237,.1), rgba(6,182,212,.06));
  border: 1px solid var(--mo-border);
  border-radius: 18px;
  padding: 22px;
  text-align: center;
}

.mo-orbs { display: flex; justify-content: center; gap: 7px; margin-bottom: 12px; }
.mo-orbs i {
  width: 10px; height: 10px; border-radius: 50%;
  animation: moFloat 2s ease-in-out infinite;
  font-style: normal;
}
.mo-orbs i:nth-child(1) { background: var(--mo-primary); }
.mo-orbs i:nth-child(2) { background: var(--mo-accent);  animation-delay: .25s; }
.mo-orbs i:nth-child(3) { background: #F59E0B;            animation-delay: .5s; }
@keyframes moFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.mo-welcome-name { font-family: 'Syne', sans-serif; font-size: 17px; font-weight: 700; color: var(--mo-text); margin-bottom: 6px; }
.mo-welcome-sub  { font-size: 13px; color: var(--mo-muted); }

/* ── Typing indicator ──────────────────────────────────────────────────── */
.typing-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 0;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}
.typing-indicator.visible { display: flex; }

.typing-dots {
  background: var(--mo-bot-bg);
  border: 1px solid var(--mo-border);
  border-radius: 13px;
  padding: 9px 13px;
  display: flex;
  gap: 4px;
  align-items: center;
}
.typing-dots span {
  width: 6px; height: 6px;
  background: var(--mo-primary);
  border-radius: 50%;
  animation: moDot 1.1s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .18s; }
.typing-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes moDot { 0%,80%,100% { transform: scale(.7); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

.typing-text { font-size: 11px; color: var(--mo-muted); font-style: italic; }

/* ── Quick replies ─────────────────────────────────────────────────────── */
#megaone-quick-replies {
  padding: 8px 14px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.mo-qr {
  padding: 6px 13px;
  border: 1px solid var(--mo-border);
  border-radius: 18px;
  background: rgba(124,58,237,.07);
  color: var(--mo-text);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all .18s;
  white-space: nowrap;
}
.mo-qr:hover {
  background: var(--mo-primary);
  border-color: var(--mo-primary);
  color: #fff;
  transform: translateY(-1px);
}

/* ── Product cards ─────────────────────────────────────────────────────── */
.mo-products { padding: 0 0 4px; }

.mo-products-hd {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--mo-accent);
  font-weight: 700;
  margin-bottom: 10px;
}

.mo-products-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x mandatory;
}
.mo-products-list::-webkit-scrollbar { height: 3px; }
.mo-products-list::-webkit-scrollbar-thumb { background: rgba(124,58,237,.25); border-radius: 3px; }

.mo-pcard {
  flex-shrink: 0;
  width: 160px;
  background: var(--mo-surface-2);
  border: 1px solid var(--mo-border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  display: block;
  scroll-snap-align: start;
  transition: transform .22s cubic-bezier(.34,1.2,.64,1), border-color .22s, box-shadow .22s;
}
.mo-pcard:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: rgba(124,58,237,.4);
  box-shadow: 0 12px 36px rgba(0,0,0,.4);
}

.mo-pcard-img { height: 105px; overflow: hidden; background: rgba(255,255,255,.03); position: relative; }
.mo-pcard-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; display: block; }
.mo-pcard:hover .mo-pcard-img img { transform: scale(1.07); }

.mo-sale-dot {
  position: absolute; top: 7px; left: 7px;
  background: linear-gradient(135deg,#EF4444,#F97316);
  color: #fff; font-size: 9px; font-weight: 700;
  padding: 2px 6px; border-radius: 10px; text-transform: uppercase; letter-spacing: .5px;
}

.mo-pcard-body { padding: 10px 11px; }
.mo-pcard-stars { font-size: 10px; color: #FBBF24; margin-bottom: 4px; }
.mo-pcard-stars span { color: var(--mo-muted); }
.mo-pcard-name {
  font-size: 12px; font-weight: 600; color: var(--mo-text); line-height: 1.3; margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mo-pcard-desc {
  font-size: 11px; color: var(--mo-muted); line-height: 1.35; margin-bottom: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mo-pcard-price  { font-family: 'Syne', sans-serif; font-size: 13px; font-weight: 700; color: var(--mo-accent); }
.mo-pcard-stock  { font-size: 10px; margin-top: 3px; }
.mo-pcard-stock.in  { color: #22C55E; }
.mo-pcard-stock.out { color: #EF4444; }
.mo-pcard-atc {
  display: block;
  margin-top: 8px;
  padding: 6px;
  background: linear-gradient(135deg, var(--mo-primary), #9333EA);
  color: #fff;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: filter .18s;
}
.mo-pcard-atc:hover { filter: brightness(1.15); }

/* ── Input area ────────────────────────────────────────────────────────── */
.chat-input-area {
  flex-shrink: 0;
  padding: 12px 14px;
  border-top: 1px solid var(--mo-border);
  background: rgba(0,0,0,.15);
  position: relative;
  z-index: 2;
}

.input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--mo-surface-2);
  border: 1px solid var(--mo-border);
  border-radius: 15px;
  padding: 8px 10px;
  transition: border-color .2s, box-shadow .2s;
}
.input-wrap:focus-within {
  border-color: var(--mo-primary);
  box-shadow: 0 0 0 3px var(--mo-primary-glow);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--mo-text);
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  max-height: 110px;
  min-height: 20px;
  line-height: 1.5;
  padding: 0;
}
.chat-input::placeholder { color: var(--mo-muted); }
.chat-input::-webkit-scrollbar { width: 3px; }
.chat-input::-webkit-scrollbar-thumb { background: rgba(124,58,237,.2); border-radius: 3px; }

.send-btn {
  width: 36px; height: 36px;
  border: none;
  background: linear-gradient(135deg, var(--mo-primary), var(--mo-accent));
  border-radius: 11px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  flex-shrink: 0;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
}
.send-btn:hover  { transform: scale(1.08); box-shadow: 0 5px 18px var(--mo-primary-glow); }
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { opacity: .38; cursor: not-allowed; transform: none; box-shadow: none; }
.send-btn svg { width: 15px; height: 15px; }

.chat-footer-brand { text-align: center; font-size: 10px; color: var(--mo-muted); margin-top: 7px; }
.chat-footer-brand a { color: var(--mo-primary); text-decoration: none; }

/* ── Utility ───────────────────────────────────────────────────────────── */
@keyframes moFadeIn { from { opacity:0; transform: translateY(-6px); } to { opacity:1; transform:none; } }

/* ── Mobile ────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #megaone-chatbot-root { bottom: 16px; right: 16px; }
  .megaone-chat-window {
    width: calc(100vw - 32px);
    height: calc(100svh - 110px);
    max-height: calc(100svh - 110px);
    bottom: 70px; right: 0;
  }
  .pos-bottom-left .megaone-chat-window { right: 0; left: 0; }
}
