/* ==========================================================================
   Varshney Ji — AI Assistant Widget  (Premium glassmorphism redesign)
   Design language extracted from assets/css/style.css:
   dark neon-glass, purple->pink->amber gradients, Inter + JetBrains Mono.
   All styles are scoped under #vji-ai-root to avoid clashing with the site.
   ========================================================================== */

#vji-ai-root {
  /* ---- Brand tokens (mirrors the website) ---- */
  --vji-grad:      linear-gradient(270deg, #ff4fd8, #d946ef, #8b5cf6, #ff4fd8);
  --vji-grad-soft: linear-gradient(135deg, #7c3aed 0%, #db2777 55%, #f59e0b 100%);
  --vji-primary:   #8b5cf6;
  --vji-primary-d: #7c3aed;
  --vji-pink:      #ec4899;
  --vji-green:     #34d399;
  --vji-danger:    #f87171;

  --vji-panel-bg:  rgba(18, 7, 38, 0.80);
  --vji-head-bg:   rgba(28, 12, 58, 0.55);
  --vji-surface:   rgba(255, 255, 255, 0.055);
  --vji-surface-2: rgba(255, 255, 255, 0.10);
  --vji-border:    rgba(168, 132, 250, 0.20);
  --vji-border-2:  rgba(236, 72, 153, 0.24);

  --vji-text:      #f5f3ff;
  --vji-text-soft: #d6cbf5;
  --vji-muted:     #9a8cc4;

  --vji-radius:    30px;
  --vji-radius-sm: 14px;
  --vji-bubble:    20px;

  --vji-shadow:    0 24px 70px rgba(124, 58, 237, 0.42), 0 4px 20px rgba(0, 0, 0, 0.45);
  --vji-glow:      0 0 44px rgba(236, 72, 153, 0.45);

  --vji-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --vji-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --vji-ease: cubic-bezier(0.22, 1, 0.36, 1);

  position: fixed;
  z-index: 2147483000;
  font-family: var(--vji-font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- Light theme overrides ---- */
#vji-ai-root[data-vji-theme="light"] {
  --vji-panel-bg:  rgba(255, 255, 255, 0.82);
  --vji-head-bg:   rgba(255, 255, 255, 0.55);
  --vji-surface:   rgba(124, 58, 237, 0.06);
  --vji-surface-2: rgba(124, 58, 237, 0.10);
  --vji-border:    rgba(124, 58, 237, 0.16);
  --vji-border-2:  rgba(236, 72, 153, 0.20);
  --vji-text:      #1e1233;
  --vji-text-soft: #4b3a6b;
  --vji-muted:     #7a6ca0;
  --vji-shadow:    0 24px 70px rgba(124, 58, 237, 0.22), 0 4px 18px rgba(0, 0, 0, 0.12);
}

#vji-ai-root *,
#vji-ai-root *::before,
#vji-ai-root *::after { box-sizing: border-box; }

/* =========================================================================
   FLOATING LAUNCHER
   ========================================================================= */
.vji-fab {
  position: fixed;
  width: 62px;
  height: 62px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: var(--vji-grad);
  background-size: 180% 180%;
  box-shadow: var(--vji-shadow), var(--vji-glow);
  display: grid;
  place-items: center;
  padding: 0;
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.35s var(--vji-ease), box-shadow 0.35s var(--vji-ease);
  animation: vji-fab-gradient 8s ease infinite;
}
.vji-fab::after { /* soft rotating glow ring */
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: var(--vji-grad);
  filter: blur(14px);
  opacity: 0.55;
  z-index: -1;
}
.vji-fab:hover { transform: translateY(-3px) scale(1.06) rotate(-3deg); }
.vji-fab:active { transform: scale(0.94); }
.vji-fab svg { width: 30px; height: 30px; display: block; filter: drop-shadow(0 2px 4px rgba(0,0,0,.3)); }
.vji-fab img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }

/* Availability pulse */
.vji-fab.vji-pulse::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.55);
  animation: vji-pulse 2.2s var(--vji-ease) infinite;
  z-index: -1;
}
@keyframes vji-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.5); }
  70%  { box-shadow: 0 0 0 18px rgba(236, 72, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(236, 72, 153, 0); }
}
@keyframes vji-fab-gradient {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}
.vji-fab.vji-hidden { transform: scale(0); opacity: 0; pointer-events: none; }

/* Notification badge */
.vji-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #ff3b6b;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  border: 2px solid #140829;
  box-shadow: 0 2px 8px rgba(255, 59, 107, 0.6);
  transform: scale(0);
  transition: transform 0.3s var(--vji-ease);
}
.vji-badge.vji-show { transform: scale(1); animation: vji-badge-pop 0.4s var(--vji-ease); }
@keyframes vji-badge-pop { 0% { transform: scale(0); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* Ripple */
.vji-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transform: scale(0);
  animation: vji-ripple 0.6s ease-out;
  pointer-events: none;
}
@keyframes vji-ripple { to { transform: scale(2.6); opacity: 0; } }

/* =========================================================================
   CHAT PANEL
   ========================================================================= */
.vji-panel {
  position: fixed;
  width: 384px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 110px);
  background: var(--vji-panel-bg);
  backdrop-filter: blur(26px) saturate(180%);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  border: 1px solid var(--vji-border);
  border-radius: var(--vji-radius);
  box-shadow: var(--vji-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(16px) scale(0.92);
  pointer-events: none;
  transition: opacity 0.32s var(--vji-ease), transform 0.38s var(--vji-ease);
}
.vji-panel.vji-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.vji-panel.vji-min { height: 66px !important; max-height: 66px; }
.vji-panel.vji-min .vji-messages,
.vji-panel.vji-min .vji-quick,
.vji-panel.vji-min .vji-composer { display: none; }

/* Decorative top glow inside the panel */
.vji-panel::before {
  content: '';
  position: absolute;
  top: -40%;
  left: 50%;
  width: 140%;
  height: 60%;
  transform: translateX(-50%);
  background: radial-gradient(circle at 50% 0%, rgba(236, 72, 153, 0.28), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ---- Header ---- */
.vji-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--vji-head-bg);
  border-bottom: 1px solid var(--vji-border);
  backdrop-filter: blur(10px);
}
.vji-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--vji-grad);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.45);
}
.vji-avatar svg { width: 24px; height: 24px; }
.vji-avatar img { width: 100%; height: 100%; border-radius: 13px; object-fit: cover; }
.vji-avatar .vji-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--vji-green);
  border: 2.5px solid var(--vji-panel-bg);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
  animation: vji-dot 2s var(--vji-ease) infinite;
}
@keyframes vji-dot {
  0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
.vji-htext { flex: 1; min-width: 0; }
.vji-htext h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--vji-text);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vji-htext p {
  margin: 2px 0 0;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--vji-green);
  display: flex;
  align-items: center;
  gap: 5px;
}
.vji-htext p .vji-live { width: 6px; height: 6px; border-radius: 50%; background: var(--vji-green); box-shadow: 0 0 6px var(--vji-green); }
.vji-hbtns { display: flex; gap: 4px; }
.vji-icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--vji-text-soft);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s, color 0.2s, transform 0.2s var(--vji-ease);
}
.vji-icon-btn:hover { background: var(--vji-surface-2); color: var(--vji-text); transform: translateY(-1px); }
.vji-icon-btn:active { transform: scale(0.9); }
.vji-icon-btn svg { width: 17px; height: 17px; }

/* ---- Messages area ---- */
.vji-messages {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.vji-messages::-webkit-scrollbar { width: 6px; }
.vji-messages::-webkit-scrollbar-thumb { background: var(--vji-border); border-radius: 3px; }
.vji-messages::-webkit-scrollbar-thumb:hover { background: var(--vji-primary); }

.vji-row { display: flex; flex-direction: column; max-width: 86%; animation: vji-msg-in 0.42s var(--vji-ease) both; }
.vji-row.user { align-self: flex-end; align-items: flex-end; }
.vji-row.bot  { align-self: flex-start; align-items: flex-start; }
@keyframes vji-msg-in { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }

.vji-bubble {
  padding: 10px 14px;
  border-radius: var(--vji-bubble);
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  position: relative;
}
.vji-row.user .vji-bubble {
  background: var(--vji-grad);
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.4);
}
.vji-row.bot .vji-bubble {
  background: var(--vji-surface);
  color: var(--vji-text);
  border: 1px solid var(--vji-border);
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

/* Markdown inside bubbles */
.vji-bubble p { margin: 0 0 8px; }
.vji-bubble p:last-child { margin-bottom: 0; }
.vji-bubble a { color: var(--vji-pink); text-decoration: underline; text-underline-offset: 2px; }
.vji-row.user .vji-bubble a { color: #fff; }
.vji-bubble strong { font-weight: 700; }
.vji-bubble ul, .vji-bubble ol { margin: 6px 0; padding-left: 18px; }
.vji-bubble li { margin: 2px 0; }
.vji-bubble code {
  font-family: var(--vji-mono);
  font-size: 12.5px;
  background: rgba(0, 0, 0, 0.28);
  padding: 1px 6px;
  border-radius: 6px;
}
#vji-ai-root[data-vji-theme="light"] .vji-bubble code { background: rgba(124, 58, 237, 0.10); }
.vji-bubble pre {
  margin: 8px 0;
  background: #0d0620;
  border: 1px solid var(--vji-border);
  border-radius: 12px;
  padding: 34px 12px 12px;
  overflow-x: auto;
  position: relative;
}
.vji-bubble pre code { background: none; padding: 0; font-size: 12.5px; color: #e9deff; display: block; }
.vji-code-copy {
  position: absolute; top: 7px; right: 7px;
  font-size: 10.5px; font-weight: 600;
  background: var(--vji-surface-2); color: var(--vji-text-soft);
  border: 1px solid var(--vji-border); border-radius: 7px;
  padding: 3px 8px; cursor: pointer; transition: all 0.2s;
}
.vji-code-copy:hover { color: #fff; background: var(--vji-primary-d); }
.vji-bubble img.vji-md-img { max-width: 100%; border-radius: 12px; margin: 6px 0; display: block; border: 1px solid var(--vji-border); }
.vji-linkcard {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px; padding: 9px 11px;
  background: var(--vji-surface); border: 1px solid var(--vji-border);
  border-radius: 12px; text-decoration: none !important; color: var(--vji-text) !important;
  transition: border-color 0.2s, transform 0.2s var(--vji-ease);
}
.vji-linkcard:hover { border-color: var(--vji-pink); transform: translateY(-1px); }
.vji-linkcard .vji-lc-fav { width: 26px; height: 26px; border-radius: 7px; background: var(--vji-grad); display: grid; place-items: center; flex-shrink: 0; }
.vji-linkcard .vji-lc-fav svg { width: 14px; height: 14px; }
.vji-linkcard .vji-lc-meta { min-width: 0; }
.vji-linkcard .vji-lc-meta b { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vji-linkcard .vji-lc-meta span { font-size: 11px; color: var(--vji-muted); }

/* Message action row (AI only) */
.vji-actions { display: flex; gap: 2px; margin-top: 5px; opacity: 0; transform: translateY(-3px); transition: opacity 0.25s, transform 0.25s var(--vji-ease); }
.vji-row.bot:hover .vji-actions, .vji-actions.vji-stick { opacity: 1; transform: none; }
.vji-act {
  width: 26px; height: 26px; border: none; border-radius: 8px;
  background: transparent; color: var(--vji-muted); cursor: pointer;
  display: grid; place-items: center; transition: all 0.18s var(--vji-ease);
}
.vji-act:hover { background: var(--vji-surface-2); color: var(--vji-text); }
.vji-act.vji-on-like { color: var(--vji-green); }
.vji-act.vji-on-dislike { color: var(--vji-danger); }
.vji-act svg { width: 14px; height: 14px; }
.vji-act.vji-copied { color: var(--vji-green); }

/* Typing indicator */
.vji-typing { display: inline-flex; gap: 4px; padding: 13px 15px; align-items: center; }
.vji-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--vji-text-soft); opacity: 0.6; animation: vji-typing 1.3s infinite ease-in-out; }
.vji-typing span:nth-child(2) { animation-delay: 0.18s; }
.vji-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes vji-typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* Streaming caret */
.vji-caret::after { content: '\2588'; margin-left: 1px; color: var(--vji-pink); animation: vji-blink 0.9s steps(2) infinite; }
@keyframes vji-blink { 50% { opacity: 0; } }

/* ---- Quick action chips ---- */
.vji-quick {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 8px;
  padding: 4px 16px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.vji-quick::-webkit-scrollbar { display: none; }
.vji-chip {
  flex-shrink: 0;
  border: 1px solid transparent;
  background: linear-gradient(270deg, #ff4fd8, #d946ef, #8b5cf6, #ff4fd8);
  background-size: 300% 300%;
  color: #fff;
  font-family: var(--vji-font);
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 0 14px rgba(255,79,216,.35);
  transition: all 0.25s var(--vji-ease);
  animation: vji-chip-in 0.5s var(--vji-ease) both, vji-grad-move 5s ease infinite;
}
.vji-chip:hover { color: #fff; border-color: transparent; transform: translateY(-2px); box-shadow: 0 0 22px #ff4fd8, 0 0 44px #8b5cf6; }
.vji-chip:active { transform: scale(0.95); }
.vji-chip svg { width: 14px; height: 14px; }
@keyframes vji-chip-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes vji-grad-move { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

/* ---- Composer ---- */
.vji-composer {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--vji-head-bg);
  border-top: 1px solid var(--vji-border);
  backdrop-filter: blur(10px);
}
.vji-input-wrap {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  background: var(--vji-surface);
  border: 1px solid var(--vji-border);
  border-radius: 22px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.vji-input-wrap:focus-within { border-color: var(--vji-primary); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.22); }
.vji-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  color: var(--vji-text);
  font-family: var(--vji-font);
  font-size: 14px;
  line-height: 1.45;
  max-height: 108px;
  padding: 7px 0;
  scrollbar-width: none;
}
.vji-input::-webkit-scrollbar { display: none; }
.vji-input::placeholder { color: var(--vji-muted); }
.vji-mini-btn {
  width: 32px; height: 32px; border: none; border-radius: 50%;
  background: transparent; color: var(--vji-muted); cursor: pointer;
  display: grid; place-items: center; flex-shrink: 0; transition: all 0.2s var(--vji-ease);
}
.vji-mini-btn:hover { color: var(--vji-primary); background: var(--vji-surface-2); }
.vji-mini-btn svg { width: 18px; height: 18px; }
.vji-send {
  width: 42px; height: 42px; border: none; border-radius: 50%;
  background: var(--vji-grad); background-size: 160% 160%;
  color: #fff; cursor: pointer; flex-shrink: 0;
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.45);
  transition: transform 0.25s var(--vji-ease), box-shadow 0.25s, opacity 0.2s;
  overflow: hidden; position: relative;
}
.vji-send:hover:not(:disabled) { transform: translateY(-2px) scale(1.05); }
.vji-send:active:not(:disabled) { transform: scale(0.9); }
.vji-send:disabled { opacity: 0.5; cursor: default; }
.vji-send svg { width: 19px; height: 19px; }

/* Emoji tray */
.vji-emoji-tray {
  position: absolute;
  bottom: 62px;
  left: 14px;
  width: 232px;
  max-width: calc(100% - 28px);
  background: var(--vji-panel-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--vji-border);
  border-radius: 16px;
  box-shadow: var(--vji-shadow);
  padding: 8px;
  display: none;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  z-index: 5;
}
.vji-emoji-tray.vji-open { display: grid; animation: vji-msg-in 0.25s var(--vji-ease); }
.vji-emoji-tray button { border: none; background: transparent; font-size: 19px; padding: 5px; border-radius: 8px; cursor: pointer; transition: transform 0.15s, background 0.15s; }
.vji-emoji-tray button:hover { background: var(--vji-surface-2); transform: scale(1.25); }

/* Scroll-to-bottom */
.vji-scroll-btn {
  position: absolute;
  right: 16px;
  bottom: 150px;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--vji-border);
  background: var(--vji-panel-bg);
  backdrop-filter: blur(10px);
  color: var(--vji-text);
  cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(0,0,0,.3);
  opacity: 0; transform: translateY(8px) scale(0.8); pointer-events: none;
  transition: all 0.3s var(--vji-ease);
  z-index: 3;
}
.vji-scroll-btn.vji-show { opacity: 1; transform: none; pointer-events: auto; }
.vji-scroll-btn svg { width: 16px; height: 16px; }

/* Footer credit */
.vji-credit { text-align: center; font-size: 10px; color: var(--vji-muted); padding: 0 0 8px; letter-spacing: 0.02em; position: relative; z-index: 1; }
.vji-credit b { color: var(--vji-text-soft); font-weight: 700; }

/* =========================================================================
   RESPONSIVE — full-height sheet on phones
   ========================================================================= */
@media (max-width: 480px) {
  .vji-panel {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    inset: 0 !important;
    transform-origin: center;
  }
  .vji-panel.vji-min { height: 66px !important; top: auto !important; bottom: 0 !important; border-radius: 20px 20px 0 0; }
  .vji-fab { width: 56px; height: 56px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  #vji-ai-root *, #vji-ai-root *::before, #vji-ai-root *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
