/* ═══════════════════════════════════════════════════════════════
   NyViA AI Assistant - LENCOE
   Dark Crystalline Intelligence 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, #014751, #016d7a, #014751);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(1,71,81,0.4), 0 0 0 0 rgba(1,71,81,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(1,71,81,0.55);
  animation: none;
}
.nyvia-bubble svg {
  width: 28px;
  height: 28px;
  fill: rgba(255,255,255,0.9);
}
.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 #070708;
  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(1,71,81,0.4), 0 0 0 0 rgba(1,71,81,0.3); }
  50%      { box-shadow: 0 4px 24px rgba(1,71,81,0.4), 0 0 0 12px rgba(1,71,81,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: 600px;
  max-height: calc(100vh - 8rem);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;

  /* Dark Glassmorphism */
  background: rgba(10, 10, 12, 0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(1,71,81,0.2);
  box-shadow: 0 24px 64px rgba(0,0,0,0.5), 0 0 0 1px rgba(1,71,81,0.08), inset 0 1px 0 rgba(255,255,255,0.03);

  /* 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(14,14,17,0.98) 0%, rgba(10,10,12,0.95) 100%);
  border-bottom: 1px solid rgba(1,71,81,0.15);
}
.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, #014751, #016d7a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
}
.nyvia-header__name {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  line-height: 1.2;
}
.nyvia-header__status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: 'Inter', sans-serif;
}
.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(255,255,255,0.04);
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}
.nyvia-header__close:hover {
  background: rgba(1,71,81,0.2);
  color: rgba(255,255,255,0.8);
}
.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.1);
  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(1,71,81,0.3); 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;
  font-family: 'Inter', sans-serif;
  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,
.nyvia-msg--assistant {
  align-self: flex-start;
  background: rgba(1,71,81,0.1);
  color: rgba(255,255,255,0.85);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(1,71,81,0.1);
}
.nyvia-msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, #014751, #016d7a);
  color: rgba(255,255,255,0.95);
  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 {
  color: #4ADE80;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.nyvia-msg__bubble strong {
  color: rgba(255,255,255,0.95);
}

/* 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(1,71,81,0.6);
  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: rgba(1,109,122,1);
  background: rgba(1,71,81,0.08);
  border: 1px solid rgba(1,71,81,0.25);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
}
.nyvia-quick-btn:hover {
  background: linear-gradient(135deg, #014751, #016d7a);
  color: rgba(255,255,255,0.95);
  border-color: transparent;
}

/* ─── Input Area ─── */
.nyvia-input-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(14,14,17,0.6);
  border-top: 1px solid rgba(1,71,81,0.1);
}
.nyvia-input {
  flex: 1;
  padding: 0.6rem 1rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(1,71,81,0.12);
  border-radius: 999px;
  outline: none;
  transition: border-color 0.2s;
}
.nyvia-input::placeholder { color: rgba(255,255,255,0.3); }
.nyvia-input:focus { border-color: rgba(1,71,81,0.4); }
.nyvia-send-btn {
  width: 44px; height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #014751, #016d7a);
  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(1,71,81,0.35);
}
.nyvia-send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}
.nyvia-send-btn svg { width: 18px; height: 18px; fill: rgba(255,255,255,0.9); }

/* ─── Proactive Engagement Tooltip ─── */
.nyvia-proactive {
  position: fixed;
  bottom: 6rem;
  right: 5rem;
  z-index: 599;
  max-width: 280px;
  padding: 1rem 1.25rem;
  background: rgba(10,10,12,0.94);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(1,71,81,0.2);
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  font-size: 0.8rem;
  line-height: 1.6;
  color: rgba(255,255,255,0.75);
  font-family: 'Inter', sans-serif;
  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: rgba(255,255,255,0.4);
  cursor: pointer;
  font-size: 14px;
}
.nyvia-proactive .text-accent {
  color: #016d7a;
  font-weight: 600;
}

/* ─── Retry Button ─── */
.nyvia-retry-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  padding: 0.35rem 0.8rem;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: #014751;
  background: rgba(1,71,81,0.08);
  border: 1px solid rgba(1,71,81,0.15);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}
.nyvia-retry-btn:hover {
  background: rgba(1,71,81,0.15);
  color: #013038;
}
.nyvia-retry-btn svg {
  flex-shrink: 0;
}

/* ─── 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;
  text-decoration: none;
}
.nyvia-wa-btn:hover { background: #20BD5A; transform: scale(1.03); color: #fff; }
.nyvia-wa-btn svg { width: 16px; height: 16px; fill: #fff; }

/* ─── Context Memory Indicator ─── */
.nyvia-memory-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.6rem;
  color: rgba(255,255,255,0.3);
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-top: 1px solid rgba(1,71,81,0.08);
  background: rgba(7,7,8,0.5);
}
.nyvia-memory-indicator__dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: #014751;
}

/* ─── Mobile Responsive ─── */
@media (max-width: 768px) {
  .nyvia-widget {
    position: fixed;
    bottom: 5rem;
    right: 0.75rem;
    left: 0.75rem;
    top: auto;
    width: auto;
    max-width: 100%;
    height: 50vh;
    max-height: 50vh;
    max-height: 50dvh;
    border-radius: 20px;
    transform: translateY(110%) 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);
  }
  .nyvia-header {
    padding: 0.85rem 1rem;
  }
  .nyvia-header__avatar {
    width: 32px; height: 32px;
    font-size: 13px;
  }
  .nyvia-header__name {
    font-size: 0.9rem;
  }
  .nyvia-header__close {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }
  .nyvia-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 1rem;
    gap: 0.75rem;
  }
  .nyvia-msg {
    max-width: 90%;
    font-size: 0.85rem;
    padding: 0.7rem 0.9rem;
  }
  .nyvia-input-area {
    padding: 0.6rem 0.75rem;
    padding-bottom: calc(0.6rem + env(safe-area-inset-bottom, 0px));
  }
  .nyvia-input {
    font-size: 16px; /* Prevents iOS zoom on focus */
    padding: 0.55rem 0.9rem;
  }
  .nyvia-send-btn {
    width: 40px; height: 40px;
  }
  .nyvia-bubble {
    bottom: 1rem;
    right: 1rem;
    width: 52px;
    height: 52px;
  }
  .nyvia-bubble svg {
    width: 24px; height: 24px;
  }
  .nyvia-proactive {
    bottom: 4.5rem;
    right: 1rem;
    left: 1rem;
    max-width: unset;
    font-size: 0.78rem;
  }
  .nyvia-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .nyvia-quick-btn {
    padding: 0.4rem 0.7rem;
    font-size: 0.7rem;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    flex: 0 1 auto;
    max-width: 48%;
  }
}

@media (max-width: 480px) {
  .nyvia-widget {
    height: 50vh;
    max-height: 50vh;
    border-radius: 18px;
    bottom: 4.5rem;
    left: 0.5rem;
    right: 0.5rem;
  }
  .nyvia-header__wa {
    width: 36px; height: 36px;
  }
  .nyvia-msg {
    max-width: 92%;
  }
}

@media (max-width: 360px) {
  .nyvia-widget {
    height: 50vh;
    max-height: 50vh;
    bottom: 4.5rem;
    left: 0.5rem;
    right: 0.5rem;
    border-radius: 16px;
  }
  .nyvia-bubble {
    width: 48px;
    height: 48px;
  }
  .nyvia-bubble svg {
    width: 22px; height: 22px;
  }
}
