/* ═══════════════════════════════════════════════════════════════
   NyViA AI Widget — WallpaperZA
   Glassmorphism Luxury Chat Interface
   ═══════════════════════════════════════════════════════════════ */

/* ─── Chat Bubble Trigger ─── */
.nyvia-bubble {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 600;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #B89A3E, #C4A030, #D4B440);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(212,175,55,0.35), 0 0 0 0 rgba(212,175,55,0.3);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.3s;
  animation: nyvia-pulse 3s ease-in-out infinite;
}
.nyvia-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 32px rgba(212,175,55,0.5);
  animation: none;
}
.nyvia-bubble svg {
  width: 28px;
  height: 28px;
  fill: #111111;
}
.nyvia-bubble__badge {
  position: absolute;
  top: -4px; right: -4px;
  width: 18px; height: 18px;
  background: #E74C3C;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #111111;
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.nyvia-bubble__badge.is-visible {
  opacity: 1;
  transform: scale(1);
}
@keyframes nyvia-pulse {
  0%, 100% { box-shadow: 0 4px 24px rgba(212,175,55,0.35), 0 0 0 0 rgba(212,175,55,0.3); }
  50%      { box-shadow: 0 4px 24px rgba(212,175,55,0.35), 0 0 0 12px rgba(212,175,55,0); }
}
.nyvia-bubble.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0);
}

/* ─── Chat Window ─── */
.nyvia-widget {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  z-index: 601;
  width: 400px;
  max-width: calc(100vw - 2rem);
  height: 580px;
  max-height: calc(100vh - 8rem);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  
  /* Glassmorphism */
  background: rgba(255, 255, 253, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(212,175,55,0.15);
  box-shadow: 0 24px 64px rgba(44,36,29,0.15), 0 0 0 1px rgba(212,175,55,0.06);
  
  /* Enter/Exit */
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.16,1,0.3,1),
              transform 0.4s cubic-bezier(0.16,1,0.3,1);
}
.nyvia-widget.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ─── Header ─── */
.nyvia-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: linear-gradient(180deg, rgba(255,255,253,0.95) 0%, rgba(245,240,232,0.9) 100%);
  border-bottom: 1px solid rgba(212,175,55,0.1);
}
.nyvia-header__left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.nyvia-header__avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #B89A3E, #C4A030);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #111111;
}
.nyvia-header__name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--charcoal, #111111);
  line-height: 1.2;
}
.nyvia-header__status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  color: var(--stone, #443D37);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.nyvia-header__dot {
  width: 6px; height: 6px;
  background: #4ADE80;
  border-radius: 50%;
  animation: nyvia-online 2s ease-in-out infinite;
}
@keyframes nyvia-online {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.nyvia-header__close {
  width: 44px; height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(212,175,55,0.06);
  color: var(--charcoal-soft, #2C241D);
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}
.nyvia-header__close:hover {
  background: rgba(212,175,55,0.15);
  color: #D4AF37;
}
.nyvia-header__close svg { width: 16px; height: 16px; }

/* Header Actions Group */
.nyvia-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.nyvia-header__wa {
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(37,211,102,0.12);
  color: #25D366;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.nyvia-header__wa:hover {
  background: #25D366;
  color: #fff;
  transform: scale(1.08);
}
.nyvia-header__wa svg { width: 16px; height: 16px; }

/* ─── Messages Area ─── */
.nyvia-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}
.nyvia-messages::-webkit-scrollbar { width: 4px; }
.nyvia-messages::-webkit-scrollbar-track { background: transparent; }
.nyvia-messages::-webkit-scrollbar-thumb { background: rgba(212,175,55,0.2); border-radius: 4px; }

/* Message Bubbles */
.nyvia-msg {
  max-width: 85%;
  padding: 0.8rem 1rem;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.6;
  animation: nyvia-msg-in 0.3s cubic-bezier(0.16,1,0.3,1);
}
@keyframes nyvia-msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.nyvia-msg--bot {
  align-self: flex-start;
  background: rgba(212,175,55,0.06);
  color: var(--charcoal, #111111);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(212,175,55,0.06);
}
/* JS appends role as --assistant; alias it to same style as --bot */
.nyvia-msg--assistant {
  align-self: flex-start;
  background: rgba(212,175,55,0.06);
  color: var(--charcoal, #111111);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(212,175,55,0.06);
}
.nyvia-msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, #B89A3E, #C4A030);
  color: #111111;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

/* Message inner bubble */
.nyvia-msg__bubble {
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.nyvia-msg__bubble a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Typing indicator */
.nyvia-typing {
  display: flex;
  gap: 5px;
  padding: 0.8rem 1rem;
  align-self: flex-start;
}
.nyvia-typing__dot {
  width: 7px; height: 7px;
  background: rgba(212,175,55,0.5);
  border-radius: 50%;
  animation: nyvia-typing 1.4s infinite;
}
.nyvia-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.nyvia-typing__dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes nyvia-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Quick Reply Buttons */
.nyvia-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.nyvia-quick-btn {
  padding: 0.4rem 0.9rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #C4A030;
  background: rgba(212,175,55,0.08);
  border: 1px solid rgba(212,175,55,0.2);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}
.nyvia-quick-btn:hover {
  background: linear-gradient(135deg, #B89A3E, #C4A030);
  color: #111111;
  border-color: transparent;
}

/* ─── Input Area ─── */
.nyvia-input-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(245,240,232,0.6);
  border-top: 1px solid rgba(212,175,55,0.06);
}
.nyvia-input {
  flex: 1;
  padding: 0.6rem 1rem;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.875rem;
  color: var(--charcoal, #111111);
  background: rgba(212,175,55,0.06);
  border: 1px solid rgba(212,175,55,0.06);
  border-radius: 999px;
  outline: none;
  transition: border-color 0.2s;
}
.nyvia-input::placeholder { color: #999; }
.nyvia-input:focus { border-color: rgba(212,175,55,0.3); }
.nyvia-send-btn {
  width: 44px; height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #B89A3E, #C4A030);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}
.nyvia-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(212,175,55,0.3);
}
.nyvia-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
.nyvia-send-btn svg { width: 18px; height: 18px; fill: #111111; }

/* ─── Proactive Engagement Tooltip ─── */
.nyvia-proactive {
  position: fixed;
  bottom: 6rem;
  right: 5rem;
  z-index: 599;
  max-width: 280px;
  padding: 1rem 1.25rem;
  background: rgba(255,255,253,0.92);
  -webkit-backdrop-filter: blur(15px);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(212,175,55,0.15);
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 8px 32px rgba(44,36,29,0.12);
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--charcoal, #111111);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.16,1,0.3,1);
}
.nyvia-proactive.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}
.nyvia-proactive__close {
  position: absolute;
  top: 0.25rem; right: 0.25rem;
  width: 44px; height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--stone, #443D37);
  cursor: pointer;
  font-size: 14px;
}
.nyvia-proactive .text-gold {
  background: linear-gradient(135deg, #B89A3E, #C4A030, #D4B440);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 600;
}

/* ─── WhatsApp Handoff Button ─── */
.nyvia-wa-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #FFFFFF;
  background: #25D366;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}
.nyvia-wa-btn:hover { background: #20BD5A; transform: scale(1.03); }
.nyvia-wa-btn svg { width: 16px; height: 16px; fill: #fff; }

/* ─── Mobile Responsive ─── */
@media (max-width: 768px) {
  .nyvia-widget {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    top: auto;
    width: 100%;
    max-width: 100%;
    height: 65vh;
    max-height: 65vh;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%) scale(1);
    opacity: 0;
    transition: opacity 0.35s cubic-bezier(0.16,1,0.3,1),
                transform 0.35s cubic-bezier(0.16,1,0.3,1);
  }
  .nyvia-widget.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  /* Drag-handle visual indicator */
  .nyvia-widget::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: rgba(212,175,55,0.25);
    margin: 0.5rem auto 0;
    flex-shrink: 0;
  }
  .nyvia-header__close {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }
  .nyvia-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .nyvia-input-area {
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  }
  .nyvia-bubble {
    bottom: 1rem;
    right: 1rem;
    width: 54px;
    height: 54px;
  }
  .nyvia-proactive {
    bottom: 5rem;
    right: 1rem;
    left: 1rem;
    max-width: unset;
  }
}

@media (max-width: 480px) {
  .nyvia-widget {
    height: 65vh;
    max-height: 65vh;
    border-radius: 20px 20px 0 0;
  }
  .nyvia-quick-btn {
    padding: 0.5rem 1rem;
    font-size: 0.7rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}
