/* ============================================
   ALVIRAN AI CHAT - V4 (Mockup Match)
   ============================================ */

:root {
  --alv-purple:       #8B5CF6;
  --alv-purple-light: #A78BFA;
  --alv-purple-dark:  #7C3AED;
  --alv-gold:         #F9C86C;
  --alv-gold-dark:    #F59E0B;
  --alv-bg:           #0A0A0F;
  --alv-bg-card:      #0f0d18;
  --alv-text:         #F3F1FA;
  --alv-text-muted:   rgba(243,241,250,0.65);
  --alv-text-dim:     rgba(243,241,250,0.4);
  --alv-border:       rgba(255,255,255,0.08);
}

/* ============================================
   TRIGGER BUTTON (draggable, no pulse)
   ============================================ */
.alvchat-btn {
  position: fixed !important;
  right: 28px;
  bottom: 28px;
  z-index: 2147483647 !important;
  width: 60px !important;
  height: 60px !important;
  border-radius: 50% !important;
  border: 1px solid rgba(255,255,255,0.12) !important;
  background: rgba(15, 13, 24, 0.92) !important;
  backdrop-filter: blur(14px) !important;
  cursor: grab !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 8px 28px rgba(0,0,0,0.55) !important;
  transition: border-color 0.25s ease, box-shadow 0.25s ease !important;
  user-select: none !important;
  pointer-events: auto !important;
  touch-action: none !important;
}

.alvchat-btn:hover {
  border-color: rgba(139,92,246,0.45) !important;
  box-shadow: 0 12px 36px rgba(0,0,0,0.65) !important;
}

.alvchat-btn.alv-dragging {
  cursor: grabbing !important;
  transform: scale(1.08) !important;
  transition: transform 0.1s ease !important;
}

.alvchat-btn svg {
  width: 26px !important;
  height: 26px !important;
  color: #fff !important;
  pointer-events: none !important;
}

/* ============================================
   WELCOME BUBBLE (localStorage — once per device)
   ============================================ */
.alvchat-bubble {
  position: fixed !important;
  right: 98px !important;
  bottom: 34px !important;
  z-index: 2147483646 !important;
  max-width: 240px;
  padding: 12px 16px;
  background: var(--alv-bg-card);
  border: 1px solid rgba(249,200,108,0.22);
  border-radius: 14px 14px 14px 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 28px rgba(249,200,108,0.07);
  backdrop-filter: blur(16px);
  font-family: 'Inter', system-ui, sans-serif;
  opacity: 0;
  visibility: hidden;
  transform: translateX(10px);
  transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  cursor: pointer;
  pointer-events: auto !important;
}

.alvchat-bubble.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

.alvchat-bubble p {
  color: var(--alv-text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  margin: 0;
}

.alvchat-bubble small {
  display: block;
  margin-top: 3px;
  color: var(--alv-gold);
  font-size: 11px;
  font-weight: 600;
}

/* ============================================
   CHAT BOX
   ============================================ */
.alvchat-box {
  position: fixed !important;
  right: 28px !important;
  bottom: 104px !important;
  z-index: 2147483647 !important;
  width: 400px;
  height: 580px;
  background: var(--alv-bg-card);
  border: 1px solid var(--alv-border);
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.03) inset;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: none;
  flex-direction: column;
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  pointer-events: auto !important;
  overflow: hidden;
  animation: alvBoxIn 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.alvchat-box::before {
  content: "";
  position: absolute; top: -60px; left: -60px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(139,92,246,0.12), transparent 70%);
  filter: blur(40px); pointer-events: none; z-index: 0;
}
.alvchat-box::after {
  content: "";
  position: absolute; bottom: -40px; right: -40px;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(249,200,108,0.08), transparent 70%);
  filter: blur(40px); pointer-events: none; z-index: 0;
}

.alvchat-box.open { display: flex !important; }

@keyframes alvBoxIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Reset inside box */
.alvchat-box *, .alvchat-box *::before, .alvchat-box *::after {
  box-sizing: border-box !important;
}
.alvchat-box button, .alvchat-box textarea, .alvchat-box input {
  font-family: 'Inter', system-ui, sans-serif !important;
  letter-spacing: normal !important;
  text-transform: none !important;
}

/* ============================================
   HEADER
   ============================================ */
.alvchat-hdr {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--alv-border);
  background: rgba(0,0,0,0.25);
  flex-shrink: 0;
}

.alvchat-brand { display: flex; align-items: center; gap: 10px; }

/* ALVIRAN AI — gold shimmer text */
.alvchat-brand-name {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 16px; font-weight: 800;
  background: linear-gradient(135deg, var(--alv-gold) 0%, #fff 50%, var(--alv-gold) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: alvShimmer 3s linear infinite;
  line-height: 1;
}
@keyframes alvShimmer {
  0%   { background-position: 0% center; }
  100% { background-position: 200% center; }
}

.alvchat-brand-sub { font-size: 11px; color: var(--alv-text-dim); margin-top: 2px; }

.alvchat-hdr-right { display: flex; align-items: center; gap: 10px; }

.alvchat-status {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  background: rgba(52,211,153,0.1);
  border: 1px solid rgba(52,211,153,0.25);
  border-radius: 999px;
  font-size: 11px; font-weight: 600; color: #34D399;
}

.alvchat-status-dot {
  width: 6px; height: 6px;
  background: #34D399; border-radius: 50%;
  animation: alvStatusPulse 2s ease-in-out infinite;
}
@keyframes alvStatusPulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

.alvchat-close {
  width: 30px !important; height: 30px !important;
  background: rgba(255,255,255,0.05) !important;
  border: 1px solid var(--alv-border) !important;
  border-radius: 8px !important;
  color: var(--alv-text-dim) !important;
  cursor: pointer !important;
  display: flex !important; align-items: center !important; justify-content: center !important;
  transition: all 0.2s !important; padding: 0 !important;
}
.alvchat-close:hover {
  background: rgba(255,255,255,0.1) !important;
  color: var(--alv-text) !important;
}
.alvchat-close svg { width: 15px; height: 15px; }

/* ============================================
   MESSAGES
   ============================================ */
.alvchat-msgs {
  flex: 1; overflow-y: auto;
  padding: 20px; display: flex; flex-direction: column; gap: 16px;
  scroll-behavior: smooth; position: relative; z-index: 1;
}
.alvchat-msgs::-webkit-scrollbar { width: 4px; }
.alvchat-msgs::-webkit-scrollbar-track { background: transparent; }
.alvchat-msgs::-webkit-scrollbar-thumb { background: rgba(139,92,246,0.25); border-radius: 4px; }

.alvchat-msg-wrap {
  display: flex; flex-direction: column; gap: 4px;
  animation: alvMsgIn 0.3s cubic-bezier(0.2,0.8,0.2,1) both;
}
@keyframes alvMsgIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
.alvchat-msg-wrap.user { align-items: flex-end; }
.alvchat-msg-wrap.bot  { align-items: flex-start; }

/* Bot: plain text, no bubble */
.alvchat-msg.bot {
  max-width: 90%;
  font-size: 14px; line-height: 1.65; color: var(--alv-text);
}
.alvchat-msg.bot p  { margin: 0 0 10px 0; }
.alvchat-msg.bot p:last-child { margin-bottom: 0; }
.alvchat-msg.bot strong { color: #fff !important; font-weight: 600 !important; }
.alvchat-msg.bot a {
  color: var(--alv-gold) !important; text-decoration: underline !important;
  text-underline-offset: 2px !important; transition: opacity 0.2s !important;
}
.alvchat-msg.bot a:hover { opacity: 0.8 !important; }
.alvchat-msg.bot code {
  background: rgba(255,255,255,0.08) !important; padding: 1px 5px !important;
  border-radius: 4px !important; font-size: 0.9em !important;
  font-family: 'SFMono-Regular', Consolas, monospace !important;
}

/* User: gold gradient bubble */
.alvchat-msg.user {
  max-width: 82%; padding: 11px 16px;
  background: linear-gradient(135deg, var(--alv-gold) 0%, var(--alv-gold-dark) 100%);
  color: #0f0d18;
  border-radius: 16px 16px 4px 16px;
  font-size: 14px; font-weight: 600; line-height: 1.5;
  box-shadow: 0 4px 16px rgba(249,200,108,0.2);
}

.alvchat-msg.err { color: #fca5a5; }

.alvchat-msg-time { font-size: 10px; color: var(--alv-text-dim); padding: 0 2px; }

/* Welcome screen */
.alvchat-welcome {
  text-align: center; padding: 36px 20px; color: var(--alv-text-muted);
}
.alvchat-welcome h3 {
  margin: 0 0 8px;
  color: var(--alv-text);
  font-family: 'Outfit', sans-serif;
  font-size: 18px; font-weight: 700;
}
.alvchat-welcome p { margin: 0; font-size: 14px; line-height: 1.6; }

/* ============================================
   TYPING INDICATOR
   ============================================ */
.alvchat-typing {
  display: flex; align-items: center; gap: 5px; padding: 4px 0;
}
.alvchat-typing span {
  width: 6px; height: 6px;
  background: var(--alv-purple-light); border-radius: 50%;
  animation: alvTypingDot 1.2s ease-in-out infinite;
}
.alvchat-typing span:nth-child(2) { animation-delay: 0.15s; }
.alvchat-typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes alvTypingDot {
  0%,60%,100% { transform:translateY(0); opacity:0.5; }
  30%          { transform:translateY(-6px); opacity:1; }
}

/* ============================================
   FOOTER
   ============================================ */
.alvchat-footer {
  position: relative; z-index: 5;
  border-top: 1px solid var(--alv-border);
  background: rgba(0,0,0,0.3);
  display: flex; flex-direction: column;
  flex-shrink: 0;
}

/* Quick Actions — all 4 on one visible row */
.alvchat-quick-wrap {
  padding: 12px 16px 0;
  overflow: hidden; /* chips stay visible, no scroll */
}

.alvchat-quick {
  display: flex !important;
  gap: 6px !important;
  flex-wrap: nowrap !important;
  justify-content: space-between !important; /* spread chips evenly */
  margin: 0 !important;
  list-style: none !important;
}

.alvchat-quick-btn {
  flex: 1 !important; /* each chip takes equal width */
  min-width: 0 !important;
  padding: 7px 8px !important;
  background: rgba(255,255,255,0.04) !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  border-radius: 999px !important;
  font-size: 12px !important; font-weight: 500 !important;
  color: var(--alv-text-muted) !important;
  cursor: pointer !important;
  display: flex !important; align-items: center !important; justify-content: center !important;
  gap: 4px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  transition: all 0.2s ease !important;
  text-align: center !important;
}
.alvchat-quick-btn:hover {
  background: rgba(249,200,108,0.08) !important;
  border-color: rgba(249,200,108,0.35) !important;
  color: var(--alv-gold) !important;
  transform: translateY(-1px) !important;
}

/* Input Row */
.alvchat-input-wrapper {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 12px 16px 14px;
}

.alvchat-input-wrapper textarea {
  flex: 1; background: transparent !important; border: none !important;
  resize: none !important; scrollbar-width: none;
  font-family: 'Inter', system-ui, sans-serif !important;
  font-size: 14px !important; color: var(--alv-text) !important;
  line-height: 1.5 !important; min-height: 36px; max-height: 100px;
  padding: 6px 0 !important;
}
.alvchat-input-wrapper textarea::-webkit-scrollbar { display: none; }
.alvchat-input-wrapper textarea:focus { outline: none !important; box-shadow: none !important; }
.alvchat-input-wrapper textarea::placeholder { color: var(--alv-text-dim); }

.alvchat-send-btn {
  width: 38px !important; height: 38px !important; flex-shrink: 0;
  border-radius: 10px !important;
  background: rgba(255,255,255,0.06) !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  color: var(--alv-text-dim) !important;
  cursor: pointer !important;
  display: flex !important; align-items: center !important; justify-content: center !important;
  transition: all 0.25s ease !important; padding: 0 !important;
}
.alvchat-send-btn svg { width: 17px; height: 17px; }

.alvchat-send-btn.active {
  background: linear-gradient(135deg, var(--alv-gold), var(--alv-gold-dark)) !important;
  border-color: var(--alv-gold) !important; color: #0f0d18 !important;
  box-shadow: 0 4px 14px rgba(249,200,108,0.3) !important;
}
.alvchat-send-btn.active:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 6px 20px rgba(249,200,108,0.4) !important;
}
.alvchat-send-btn:disabled { opacity: 0.5 !important; cursor: not-allowed !important; }

.alvchat-disclaimer {
  text-align: center; font-size: 10px;
  color: var(--alv-text-dim); padding: 0 20px 10px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 480px) {
  .alvchat-box {
    right: 0 !important; bottom: 0 !important;
    width: 100% !important; height: 100% !important;
    border-radius: 0 !important;
  }
  .alvchat-btn { right: 16px !important; bottom: 16px !important; }
  .alvchat-bubble { right: 16px !important; bottom: 88px !important; max-width: calc(100vw - 32px); }
}
