/* ========================================
   VEZRA AI ASSISTANT — Chat UI
   ======================================== */

/* --- Floating Action Button --- */
.vai-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--copper) 0%, var(--copper-dark) 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(196, 115, 59, 0.35), 0 2px 8px rgba(0,0,0,0.15);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.vai-fab.vai-visible { display: flex; }
.vai-fab:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 30px rgba(196, 115, 59, 0.45), 0 4px 12px rgba(0,0,0,0.2);
}
.vai-fab:active { transform: scale(0.95); }
.vai-fab svg { width: 24px; height: 24px; transition: transform 0.3s ease; }
.vai-fab.open svg { transform: rotate(90deg); }

/* Pulse ring */
.vai-fab::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--copper);
  opacity: 0;
  animation: vai-pulse 2.5s ease-out infinite;
}
.vai-fab.open::before { animation: none; opacity: 0; }

@keyframes vai-pulse {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* --- Chat Panel --- */
.vai-panel {
  position: fixed;
  bottom: 96px;
  right: 28px;
  width: 400px;
  height: 560px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 16px 48px rgba(0,0,0,0.12), 0 4px 16px rgba(0,0,0,0.08);
  z-index: 499;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.vai-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* --- Panel Header --- */
.vai-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-800) 100%);
  color: #fff;
  flex-shrink: 0;
}
.vai-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--copper) 0%, var(--copper-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}
.vai-header-info { flex: 1; }
.vai-header-name { font-size: 14px; font-weight: 700; }
.vai-header-status {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  gap: 5px;
}
.vai-header-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2dd4bf;
  animation: vai-dot-blink 2s ease infinite;
}
@keyframes vai-dot-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.vai-header-actions { display: flex; gap: 4px; }
.vai-header-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.vai-header-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }

/* --- Messages Area --- */
.vai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Message bubbles */
.vai-msg {
  display: flex;
  gap: 8px;
  max-width: 92%;
  animation: vai-msg-in 0.3s ease;
}
.vai-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.vai-msg.ai { align-self: flex-start; }

@keyframes vai-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.vai-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
}
.vai-msg.ai .vai-msg-avatar {
  background: linear-gradient(135deg, var(--copper) 0%, var(--copper-dark) 100%);
  color: #fff;
}
.vai-msg.user .vai-msg-avatar {
  background: var(--navy-800);
  color: #fff;
}

.vai-msg-bubble {
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.55;
  border-radius: 14px;
  word-break: break-word;
}
.vai-msg.ai .vai-msg-bubble {
  background: var(--surface-3);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}
.vai-msg.user .vai-msg-bubble {
  background: linear-gradient(135deg, var(--copper) 0%, var(--copper-dark) 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Rich content in AI messages */
.vai-msg-bubble strong { font-weight: 700; }
.vai-msg-bubble .vai-metric {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13px;
  padding: 2px 6px;
  background: rgba(196,115,59,0.08);
  border-radius: 4px;
  color: var(--copper-dark);
}
.vai-msg-bubble .vai-up { color: var(--positive); }
.vai-msg-bubble .vai-down { color: var(--negative); }
.vai-msg-bubble .vai-list {
  margin: 8px 0 4px;
  padding: 0;
  list-style: none;
}
.vai-msg-bubble .vai-list li {
  padding: 4px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.vai-msg-bubble .vai-list li:last-child { border-bottom: none; }
.vai-msg-bubble .vai-list-name { font-weight: 500; }
.vai-msg-bubble .vai-list-val { font-family: var(--mono); font-weight: 600; font-size: 12px; }

/* Typing indicator */
.vai-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  align-items: center;
}
.vai-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--copper);
  opacity: 0.4;
  animation: vai-bounce 1.2s ease infinite;
}
.vai-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.vai-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes vai-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* --- Quick Action Chips --- */
.vai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.vai-chip {
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.vai-chip:hover {
  border-color: var(--copper);
  color: var(--copper);
  background: var(--copper-bg);
}

/* --- Input Area --- */
.vai-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}
.vai-input {
  flex: 1;
  padding: 10px 14px;
  font-size: 13px;
  border-radius: 12px;
  background: var(--surface-3);
  border: 1px solid transparent;
  color: var(--ink);
  transition: all 0.2s ease;
  outline: none;
}
.vai-input:focus {
  border-color: var(--copper);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px var(--copper-bg);
}
.vai-input::placeholder { color: var(--ink-4); }
.vai-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--copper);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.vai-send:hover { background: var(--copper-dark); transform: scale(1.05); }
.vai-send:active { transform: scale(0.95); }
.vai-send:disabled { opacity: 0.5; cursor: default; transform: none; }
.vai-send svg { width: 18px; height: 18px; }

/* --- Welcome message --- */
.vai-welcome {
  text-align: center;
  padding: 20px 16px 8px;
}
.vai-welcome-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--copper), #7b3f25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .04em;
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 12px 28px rgba(196,115,59,.22);
}
.vai-welcome h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}
.vai-welcome p {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.5;
}

/* --- Data card in messages --- */
.vai-data-card {
  margin: 8px 0 4px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.vai-data-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.vai-data-card-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
  font-family: var(--mono);
}
.vai-data-card-delta {
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 20px;
}
.vai-data-card-delta.up { background: var(--positive-bg); color: var(--positive); }
.vai-data-card-delta.down { background: var(--negative-bg); color: var(--negative); }

/* --- Suggestion follow-ups --- */
.vai-follow-ups {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.vai-follow-up {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 12px;
  background: var(--copper-bg);
  color: var(--copper-dark);
  cursor: pointer;
  border: 1px solid var(--copper-border);
  transition: all 0.2s ease;
  font-weight: 500;
}
.vai-follow-up:hover {
  background: var(--copper);
  color: #fff;
  border-color: var(--copper);
}

/* --- Scrollbar in messages --- */
.vai-messages::-webkit-scrollbar { width: 4px; }
.vai-messages::-webkit-scrollbar-track { background: transparent; }
.vai-messages::-webkit-scrollbar-thumb { background: var(--ink-5); border-radius: 10px; }

/* --- Responsive --- */
@media (max-width: 480px) {
  .vai-panel {
    right: 8px;
    left: 8px;
    bottom: 80px;
    width: auto;
    height: calc(100vh - 100px);
    border-radius: var(--radius-lg);
  }
  .vai-fab {
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
  }
}
