/* ═══════════════════════════════════════════════════════════════════════════
   VAULT AI WIDGET — Global Floating Chatbot
   Premium Glassmorphism Design | VaultEXP v2.0
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Keyframes ─────────────────────────────────────────────────────────── */
@keyframes vai-pulse-ring {
  0%   { transform: scale(1);   opacity: 0.6; }
  70%  { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}
@keyframes vai-orb-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(0,229,153,0.5), 0 0 40px rgba(0,184,255,0.3), 0 8px 32px rgba(0,0,0,0.4); }
  50%       { box-shadow: 0 0 30px rgba(0,229,153,0.8), 0 0 60px rgba(0,184,255,0.5), 0 8px 32px rgba(0,0,0,0.4); }
}
@keyframes vai-gradient-spin {
  0%   { background-position: 0%   50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0%   50%; }
}
@keyframes vai-panel-in {
  0%   { opacity: 0; transform: translateY(20px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0)    scale(1);    }
}
@keyframes vai-panel-out {
  0%   { opacity: 1; transform: translateY(0)    scale(1);    }
  100% { opacity: 0; transform: translateY(20px) scale(0.96); }
}
@keyframes vai-msg-in {
  0%   { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0);   }
}
@keyframes vai-dot-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1.0); opacity: 1;   }
}
@keyframes vai-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
@keyframes vai-float {
  0%, 100% { transform: translateY(0px);  }
  50%       { transform: translateY(-6px); }
}

/* ── Container ─────────────────────────────────────────────────────────── */
#vault-ai-widget {
  position:   fixed;
  bottom:     88px;
  right:      24px;
  z-index:    150;
  display:    flex;
  flex-direction: column;
  align-items: flex-end;
  gap:        12px;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── Floating Orb Button ───────────────────────────────────────────────── */
/* ── Floating Orb — Lottie only, no background shape ─────────────────── */
#vai-orb {
  width:           80px;
  height:          80px;
  border-radius:   50%;
  cursor:          pointer;
  position:        relative;
  background:      transparent;
  display:         flex;
  align-items:     center;
  justify-content: center;
  transition:      transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.25s ease;
  border:          none;
  outline:         none;
  user-select:     none;
  flex-shrink:     0;
  filter:          drop-shadow(0 4px 16px rgba(0, 229, 153, 0.45));
}
#vai-orb:hover  { transform: scale(1.12); filter: drop-shadow(0 6px 20px rgba(0, 229, 153, 0.65)); }
#vai-orb:active { transform: scale(0.94); }

/* No pulse rings — clean Lottie-only appearance */
#vai-orb::before { display: none; }
#vai-orb::after  { display: none; }

/* Lottie animation fills the orb */
#vai-orb-icon {
  display:     flex;
  align-items: center;
  justify-content: center;
  width:       80px;
  height:      80px;
  z-index:     1;
  transition:  transform 0.3s ease;
}
#vai-orb.open #vai-orb-icon { transform: scale(0.9); }

/* Unread badge */
#vai-badge {
  position:      absolute;
  top:           -2px;
  right:         -2px;
  width:         18px;
  height:        18px;
  border-radius: 50%;
  background:    #ef4444;
  border:        2px solid #030712;
  font-size:     10px;
  color:         #fff;
  display:       flex;
  align-items:   center;
  justify-content: center;
  font-weight:   700;
  z-index:       2;
}

/* ── Chat Panel ────────────────────────────────────────────────────────── */
#vai-panel {
  width:            380px;
  height:           560px;
  background:       rgba(8, 12, 28, 0.92);
  backdrop-filter:  blur(30px) saturate(1.5);
  -webkit-backdrop-filter: blur(30px) saturate(1.5);
  border-radius:    20px;
  border:           1px solid rgba(255, 255, 255, 0.1);
  box-shadow:       0 32px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(0,229,153,0.1), inset 0 1px 0 rgba(255,255,255,0.07);
  display:          flex;
  flex-direction:   column;
  overflow:         hidden;
  animation:        vai-panel-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transform-origin: bottom right;
}
#vai-panel.closing { animation: vai-panel-out 0.3s ease forwards; }

/* Gradient top border */
#vai-panel::before {
  content:    '';
  position:   absolute;
  top:        0; left: 0; right: 0;
  height:     2px;
  background: linear-gradient(90deg, #00E599, #00B8FF, #7C3AED, #00E599);
  background-size: 200% 100%;
  animation:  vai-gradient-spin 3s ease infinite;
  border-radius: 20px 20px 0 0;
}

/* ── Panel Header ──────────────────────────────────────────────────────── */
#vai-header {
  padding:         16px 18px;
  border-bottom:   1px solid rgba(255,255,255,0.06);
  display:         flex;
  align-items:     center;
  gap:             12px;
  background:      rgba(255,255,255,0.02);
  flex-shrink:     0;
}

.vai-header-avatar {
  width:           36px;
  height:          36px;
  border-radius:   50%;
  background:      linear-gradient(135deg, #00E599, #00B8FF);
  display:         flex;
  align-items:     center;
  justify-content: center;
  font-size:       14px;
  font-weight:     800;
  color:           #fff;
  flex-shrink:     0;
  animation:       vai-float 3s ease-in-out infinite;
}

.vai-header-info { flex: 1; min-width: 0; }
.vai-header-name {
  font-size:   0.9rem;
  font-weight: 700;
  color:       #fff;
  display:     flex;
  align-items: center;
  gap:         6px;
}
.vai-status-dot {
  width:         7px;
  height:        7px;
  border-radius: 50%;
  background:    #00E599;
  box-shadow:    0 0 6px #00E599;
  animation:     vai-orb-glow 2s ease-in-out infinite;
}
.vai-header-sub {
  font-size:  0.72rem;
  color:      rgba(255,255,255,0.45);
  margin-top: 2px;
}

.vai-header-actions { display: flex; gap: 6px; }
.vai-header-btn {
  width:         30px;
  height:        30px;
  border-radius: 8px;
  border:        1px solid rgba(255,255,255,0.08);
  background:    rgba(255,255,255,0.04);
  color:         rgba(255,255,255,0.5);
  cursor:        pointer;
  display:       flex;
  align-items:   center;
  justify-content: center;
  font-size:     14px;
  transition:    all 0.2s ease;
}
.vai-header-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* ── Messages Area ─────────────────────────────────────────────────────── */
#vai-messages {
  flex:       1;
  overflow-y: auto;
  padding:    16px 14px;
  display:    flex;
  flex-direction: column;
  gap:        12px;
  scroll-behavior: smooth;
}
#vai-messages::-webkit-scrollbar { width: 4px; }
#vai-messages::-webkit-scrollbar-track { background: transparent; }
#vai-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Message bubbles */
.vai-msg {
  display:        flex;
  gap:            8px;
  animation:      vai-msg-in 0.35s ease forwards;
  max-width:      100%;
}
.vai-msg.user     { flex-direction: row-reverse; }
.vai-msg.ai       { flex-direction: row; }

.vai-msg-avatar {
  width:         28px;
  height:        28px;
  border-radius: 50%;
  flex-shrink:   0;
  display:       flex;
  align-items:   center;
  justify-content: center;
  font-size:     11px;
  font-weight:   700;
  color:         #fff;
  margin-top:    2px;
}
.vai-msg.ai   .vai-msg-avatar { background: linear-gradient(135deg, #00E599, #00B8FF); }
.vai-msg.user .vai-msg-avatar { background: linear-gradient(135deg, #7C3AED, #4F46E5); }

.vai-msg-bubble {
  max-width:     78%;
  padding:       10px 14px;
  border-radius: 16px;
  font-size:     0.84rem;
  line-height:   1.55;
  word-wrap:     break-word;
}
.vai-msg.ai   .vai-msg-bubble {
  background:    rgba(255,255,255,0.06);
  border:        1px solid rgba(255,255,255,0.07);
  border-bottom-left-radius: 4px;
  color:         #e2e8f0;
}
.vai-msg.user .vai-msg-bubble {
  background:    linear-gradient(135deg, rgba(0,229,153,0.15), rgba(0,184,255,0.15));
  border:        1px solid rgba(0,229,153,0.2);
  border-bottom-right-radius: 4px;
  color:         #f0fdf9;
}

/* Markdown-like formatting inside bubbles */
.vai-msg-bubble strong { color: #00E599; font-weight: 700; }
.vai-msg-bubble em     { color: #00B8FF; font-style: italic; }
.vai-msg-bubble a      { color: #00E599; text-decoration: underline; }
.vai-msg-bubble ul, .vai-msg-bubble ol { padding-left: 16px; margin: 6px 0; }
.vai-msg-bubble li     { margin: 3px 0; }

.vai-msg-time {
  font-size:  0.67rem;
  color:      rgba(255,255,255,0.3);
  margin-top: 4px;
  text-align: right;
}
.vai-msg.ai .vai-msg-time { text-align: left; }

/* ── Typing Indicator ──────────────────────────────────────────────────── */
#vai-typing {
  display:    flex;
  gap:        8px;
  align-items: center;
  padding:    4px 0;
}
.vai-typing-dot {
  width:         7px;
  height:        7px;
  border-radius: 50%;
  background:    linear-gradient(135deg, #00E599, #00B8FF);
}
.vai-typing-dot:nth-child(1) { animation: vai-dot-bounce 1.2s ease-in-out 0.0s infinite; }
.vai-typing-dot:nth-child(2) { animation: vai-dot-bounce 1.2s ease-in-out 0.2s infinite; }
.vai-typing-dot:nth-child(3) { animation: vai-dot-bounce 1.2s ease-in-out 0.4s infinite; }

/* ── Quick Suggestions ─────────────────────────────────────────────────── */
#vai-suggestions {
  padding:    0 14px 10px 14px;
  display:    flex;
  flex-wrap:  wrap;
  gap:        6px;
  flex-shrink: 0;
}
.vai-chip {
  padding:       5px 10px;
  border-radius: 20px;
  background:    rgba(0,229,153,0.08);
  border:        1px solid rgba(0,229,153,0.2);
  color:         #00E599;
  font-size:     0.72rem;
  font-weight:   500;
  cursor:        pointer;
  transition:    all 0.2s ease;
  white-space:   nowrap;
}
.vai-chip:hover {
  background:   rgba(0,229,153,0.18);
  border-color: rgba(0,229,153,0.4);
  transform:    translateY(-1px);
}

/* ── Input Area ────────────────────────────────────────────────────────── */
#vai-input-area {
  padding:       12px 14px 14px;
  border-top:    1px solid rgba(255,255,255,0.06);
  display:       flex;
  gap:           8px;
  align-items:   flex-end;
  background:    rgba(0,0,0,0.2);
  flex-shrink:   0;
}
#vai-input {
  flex:          1;
  background:    rgba(255,255,255,0.05);
  border:        1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding:       10px 14px;
  color:         #fff;
  font-size:     0.84rem;
  font-family:   inherit;
  resize:        none;
  min-height:    40px;
  max-height:    100px;
  line-height:   1.4;
  outline:       none;
  transition:    border-color 0.2s ease, box-shadow 0.2s ease;
  scrollbar-width: thin;
}
#vai-input::placeholder { color: rgba(255,255,255,0.3); }
#vai-input:focus {
  border-color: rgba(0,229,153,0.4);
  box-shadow:   0 0 0 3px rgba(0,229,153,0.08);
}

#vai-send {
  width:         38px;
  height:        38px;
  border-radius: 10px;
  background:    linear-gradient(135deg, #00E599, #00B8FF);
  border:        none;
  cursor:        pointer;
  display:       flex;
  align-items:   center;
  justify-content: center;
  color:         #fff;
  flex-shrink:   0;
  transition:    all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow:    0 4px 12px rgba(0,229,153,0.3);
}
#vai-send:hover  { transform: scale(1.08); box-shadow: 0 6px 16px rgba(0,229,153,0.4); }
#vai-send:active { transform: scale(0.95); }
#vai-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
#vai-send svg { width: 16px; height: 16px; }

/* ── Powered by ────────────────────────────────────────────────────────── */
#vai-footer {
  text-align:  center;
  font-size:   0.65rem;
  color:       rgba(255,255,255,0.2);
  padding:     0 14px 10px;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}
#vai-footer span { color: rgba(0,229,153,0.5); }

/* ── Welcome screen ────────────────────────────────────────────────────── */
.vai-welcome-icon {
  width:         56px;
  height:        56px;
  border-radius: 50%;
  background:    linear-gradient(135deg, #00E599, #00B8FF);
  display:       flex;
  align-items:   center;
  justify-content: center;
  font-size:     24px;
  font-weight:   800;
  color:         #fff;
  margin:        0 auto 12px;
  box-shadow:    0 0 30px rgba(0,229,153,0.4);
  animation:     vai-float 3s ease-in-out infinite;
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #vault-ai-widget {
    bottom: 80px;
    right:  12px;
  }
  #vai-panel {
    width:         calc(100vw - 24px);
    height:        70vh;
    max-height:    520px;
    border-radius: 16px;
  }
}

/* ── Hidden state ──────────────────────────────────────────────────────── */
.vai-hidden { display: none !important; }
