/* =========================
   CONTENEDOR FIJO DEL WIDGET
   ========================= */
#vectoryal-chat {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 99999;
  pointer-events: none;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* =========================
   BOTÓN FLOTANTE (ABRIR/CERRAR)
   ========================= */
.vy-chat-button {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 20%, #3ED9FA, #22ABF3 40%, #2210E9);
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f9fafb;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
  pointer-events: auto;
}
.vy-chat-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.75);
}

/* icono SVG dentro del botón flotante */
.vy-chat-button-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}
.vy-chat-button-icon img {
  width: 34px;
  height: 34px;
  display: block;
}

/* =========================
   VENTANA DEL CHAT
   ========================= */
.vy-chat-window {
  position: absolute;
  right: 0;
  bottom: 80px;
  width: 380px;
  max-height: min(620px, calc(100vh - 96px));
  border-radius: 1.3rem;
  background: radial-gradient(circle at top, #020617 0%, #020617 30%, #020816 70%, #020617 100%);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.75);
  overflow: hidden;
  display: none;
  flex-direction: column;
  color: #e5e7eb;
  margin-bottom: 0;
  pointer-events: auto;
}
.vy-chat-window.vy-open {
  display: flex;
}

/* =========================
   HEADER
   ========================= */
.vy-chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  background: linear-gradient(135deg, #22ABF3, #2210E9);
  color: #f9fafb;
}

/* avatar + punto verde */
.vy-chat-avatar-wrapper {
  position: relative;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.vy-chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #020617;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px rgba(248, 250, 252, 0.9);
  overflow: hidden;
}

.vy-chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.vy-chat-status-dot {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.5);
  bottom: -1px;
  right: -1px;
}

.vy-chat-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.vy-chat-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.vy-chat-subtitle {
  font-size: 0.78rem;
  opacity: 0.95;
}

/* botón cerrar (oculto) */
.vy-chat-close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: #e5e7eb;
  cursor: default;
  font-size: 0.9rem;
  padding: 0.25rem;
  display: none !important;
}

/* =========================
   BODY
   ========================= */
.vy-chat-body {
  flex: 1;
  padding: 0.95rem;
  overflow-y: auto;
  background: radial-gradient(circle at top, #020617 0%, #020617 25%, #020617 70%, #020617 100%);
}

/* Bloqueo scroll body en móvil (por si se usara) */
body.vy-body-locked {
  overflow: hidden;
  touch-action: none;
}

/* FILA DE MENSAJE */
.vy-message-row {
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
  margin-bottom: 0.7rem;
  width: 100%;
}

.vy-message-row-bot {
  justify-content: flex-start;
}

.vy-message-row-user {
  justify-content: flex-end;
}

/* AVATARES */
.vy-avatar-bot,
.vy-avatar-user {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, #3ED9FA, #22ABF3 40%, #2210E9);
  color: #ffffff;
  font-size: 14px;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 1);
  overflow: hidden;
}

.vy-avatar-bot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* WRAPPER COLUMNA MENSAJE (burbuja + meta)
   → misma columna para bot y user, como en Carlos Pedrol */
.vy-message-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: calc(100% - 72px); /* 28 avatar + ~0.65rem gap en cada lado */
}

.vy-message-wrapper-bot {
  align-items: flex-start;
}

.vy-message-wrapper-user {
  align-items: flex-end;
}

/* BURBUJAS */
.vy-message {
  max-width: 100%;
  font-size: 0.9rem;
}

.vy-message-bot {
  background: #020617;
  border-radius: 1.1rem;
  padding: 0.7rem 0.95rem;
  border: 1px solid rgba(148, 163, 184, 0.55);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.5);
  color: #e5e7eb;
}

.vy-message-user {
  background: radial-gradient(circle at 20% 0%, #3ED9FA, #22ABF3 45%, #2210E9);
  border-radius: 1.1rem 1.1rem 0.3rem 1.1rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(56, 189, 248, 0.9);
  color: #ffffff;
  text-align: left;
  line-height: 1.45;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.55);
}

.vy-message p {
  margin: 0;
  white-space: pre-line;
  line-height: 1.45;
}

.vy-message-typing {
  opacity: 0.8;
  font-size: 0.82rem;
}

/* META debajo del bocadillo */
.vy-message-meta-row {
  font-size: 0.7rem;
  color: #9ca3af;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* bot: que el meta empiece alineado con el TEXTO, no con el borde de la burbuja */
.vy-message-meta-row-bot {
  justify-content: flex-start;
  padding-left: 0.6rem; /* coincide con padding horizontal de la burbuja */
}

.vy-message-meta-row-user {
  justify-content: flex-end;
}

.vy-message-meta-name {
  font-weight: 500;
}

.vy-message-meta-role {
  opacity: 0.9;
}

.vy-message-meta-time {
  opacity: 0.9;
}

.vy-message-meta-dot {
  opacity: 0.7;
}

/* =========================
   FOOTER / INPUT
   ========================= */
.vy-chat-footer {
  padding: 0.75rem 1rem 1rem;
  background: #020617;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(8px);
  position: relative;
}

/* Fila input */
.vy-chat-input-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.35rem;
}

/* Pastilla del input (también contenedor de UI de grabación) */
.vy-chat-input-wrapper {
  position: relative;
  flex: 1 1 auto;        /* ocupa más ancho */
  height: 46px;
  border-radius: 9999px;
  background: rgba(10, 15, 30, 0.85);
  border: 1px solid rgba(120, 162, 255, 0.45);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  overflow: hidden;
}

/* Input */
.vy-chat-input-wrapper input {
  flex: 1;
  width: 100%;
  border: none !important;
  background: transparent !important;
  color: #e5e7eb;
  font-size: 16px;
  line-height: 1.3;
  padding: 0 !important;
  margin: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  -webkit-appearance: none;
  border-radius: 9999px;
}

.vy-chat-input-wrapper input::placeholder {
  color: rgba(180, 192, 210, 0.55);
}

.vy-chat-input-wrapper input:focus {
  background: transparent !important;
  outline: none !important;
  box-shadow: none !important;
}

/* =========================
   BOTÓN PRINCIPAL (MIC / ENVIAR)
   ========================= */
#vectoryal-chat .vy-chat-main-button {
  flex: 0 0 40px;
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  min-height: 40px !important;
  border-radius: 50% !important;
  padding: 0 !important;
  border: none !important;
  outline: none !important;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    135deg,
    #3ED9FA 0%,
    #22ABF3 40%,
    #2210E9 100%
  ) !important;
  box-shadow:
    0 0 12px rgba(34, 16, 233, 0.45),
    0 8px 16px rgba(0, 0, 0, 0.4) !important;
  transition:
    transform 0.18s ease-out,
    box-shadow 0.18s ease-out;
  overflow: hidden;
  margin-left: 2px; /* equilibra el aire con respecto al input */
}

/* Icono dentro del botón */
#vectoryal-chat .vy-chat-main-button .vy-chat-main-icon {
  width: 18px !important;
  height: 18px !important;
  object-fit: contain;
  display: block;
  background: transparent !important;
  border: none !important;
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.45));
}

/* Hover / focus */
#vectoryal-chat .vy-chat-main-button:hover,
#vectoryal-chat .vy-chat-main-button:focus-visible {
  transform: translateY(-1px) scale(1.04);
  box-shadow:
    0 0 14px rgba(34, 16, 233, 0.6),
    0 10px 20px rgba(0, 0, 0, 0.55) !important;
}

/* Estado grabando */
#vectoryal-chat .vy-chat-main-button.vy-chat-main-button-recording {
  background: linear-gradient(135deg, #4EF3FA 0%, #22ABF3 40%, #2210E9 100%) !important;
  animation: vy-pulse 1s infinite;
}

/* Refuerzo forma redonda */
#vectoryal-chat .vy-chat-main-button-mic,
#vectoryal-chat .vy-chat-main-button-send {
  border-radius: 50% !important;
}

/* Powered by */
.vy-chat-powered {
  text-align: center;
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 4px;
}

/* =========================
   RESPONSIVE MÓVIL
   ========================= */
@media (max-width: 768px) {
  html,
  body {
    overflow-x: hidden;
  }

  #vectoryal-chat {
    position: fixed;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-width: none;
    z-index: 9999;
  }

  #vectoryal-chat .vy-chat-button {
    position: fixed;
    right: 16px;
    bottom: 16px;
  }

  #vectoryal-chat .vy-chat-window {
    position: fixed;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    bottom: 88px !important;
    width: calc(100vw - 20px) !important;
    max-width: 420px;
    flex-direction: column;
    max-height: min(640px, 80vh);
    margin: 0;
  }

  #vectoryal-chat .vy-chat-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #vectoryal-chat .vy-chat-input-wrapper input {
    font-size: 16px;
    line-height: 1.3;
  }

  #vectoryal-chat .vy-chat-header,
  #vectoryal-chat .vy-chat-footer {
    flex-shrink: 0;
  }
}

/* =========================
   UI GRABACIÓN AUDIO
   ========================= */
.vy-chat-recording-ui {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  background: radial-gradient(
      circle at 0% 0%,
      rgba(34, 160, 243, 0.35),
      transparent 55%
    ),
    rgba(10, 22, 56, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.3);
  pointer-events: none;
}

.vy-recording-left {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  min-width: 52px;
}

.vy-recording-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.9);
  animation: vy-recording-blink 1.2s infinite;
}

.vy-recording-time {
  color: #e5e7eb;
  font-variant-numeric: tabular-nums;
}

/* Waveform */
.vy-recording-wave {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1px;
  height: 32px;
  overflow: hidden;
}

.vy-recording-bar {
  flex: 1;
  max-width: 2px;
  border-radius: 999px;
  background: #2333ea;
  height: var(--bar-height, 4px);
  opacity: 0.95;
  transform-origin: center center;
  transition: height 0.09s ease-out;
}

/* =========================
   ANIMACIONES
   ========================= */
@keyframes vy-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  70% {
    transform: scale(1.06);
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

@keyframes vy-recording-blink {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.9);
  }
  50% {
    transform: scale(1.15);
    box-shadow: 0 0 0 6px rgba(248, 113, 113, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(248, 113, 113, 0);
  }
}

/* =========================
   BURBUJA MENSAJE DE VOZ
   ========================= */
.vy-message-user-audio .vy-voice-bubble {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #22ABF3, #2210E9);
  padding: 10px 14px;
  border-radius: 18px;
  max-width: 240px;
  color: #fff;
  font-weight: 500;
  font-size: 14px;
}

.vy-voice-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: block;
}

.vy-voice-label {
  white-space: nowrap;
}

/* =========================
   BOTÓN + Y MENÚ DE ADJUNTOS
   ========================= */

.vy-attach-toggle {
  flex: 0 0 40px;
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  min-height: 40px !important;
  border-radius: 50% !important;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  box-shadow: none !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
  margin-right: 2px; /* equilibra aire respecto al input */
}

.vy-attach-toggle:hover {
  background: rgba(15, 23, 42, 0.4) !important;
  transform: translateY(-1px);
}

.vy-attach-icon {
  font-size: 24px;
  line-height: 1;
  color: #e5e7eb;
}

/* Menú flotante */
.vy-attach-menu {
  position: absolute;
  left: 16px;
  bottom: 90px; /* más alto para no tapar la cruz ni el input */
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-radius: 12px;
  background: #020617;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.85);
  opacity: 0;
  transform: translateY(4px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.16s ease-out, transform 0.16s ease-out;
  z-index: 30;
}

.vy-attach-menu.vy-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.vy-attach-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 8px !important;
  padding: 6px 10px !important;
  border-radius: 8px !important;
  border: none !important;
  background: transparent !important;
  color: #f9fafb !important;
  font-size: 0.8rem !important;
  cursor: pointer;
  min-width: 180px;
  box-shadow: none !important;
}

.vy-attach-item:hover {
  background: rgba(31, 41, 55, 0.9) !important;
}

.vy-attach-item-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  padding: 0;
}

.vy-attach-item-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}


.vy-attach-item-icon-file {
  background: rgba(148, 163, 184, 0.25);
}

.vy-attach-item-label {
  white-space: nowrap;
  color: #f9fafb;
}

/* móvil: subimos un poco más el menú para no tapar UI */
@media (max-width: 768px) {
  .vy-attach-menu {
    left: 16px;
    bottom: 100px;
  }
}
