/* =========================
   PALETA CARLOS PEDROL + VECTORYAL
   ========================= */
:root {
  /* Colores base cliente (Carlos Pedrol) */
  --cp-bg-main: #020617;
  --cp-bg-alt: #020816;

  --cp-gold-main: #cc9f53;   /* header + burbuja usuario */
  --cp-gold-soft: #f8f2be;   /* botón flotante + acentos suaves */

  --cp-header-text: #f9fafb;
  --cp-chat-text: #e5e7eb;
  --cp-user-text: #020617;

  --cp-avatar-bg: #020617;
  --cp-avatar-ring: rgba(248, 250, 252, 0.9);

  --cp-status-online: #22c55e;
  --cp-status-ring: rgba(34, 197, 94, 0.5);

  --cp-bot-bubble-bg: #020617;
  --cp-bot-bubble-border: rgba(148, 163, 184, 0.55);

  /* borde burbuja usuario → dorado un poco más oscuro */
  --cp-user-bubble-bg: var(--cp-gold-main);
  --cp-user-bubble-border: #b88a37;

  --cp-footer-bg: #020617;

  --cp-input-bg: rgba(10, 15, 30, 0.85);
  --cp-input-border: #ffffff;
  --cp-placeholder: rgba(180, 192, 210, 0.55);

  --cp-powered-text: #6b7280;

  /* Gradientes de fondo */
  --cp-window-gradient: radial-gradient(
    circle at top,
    var(--cp-bg-main) 0%,
    var(--cp-bg-main) 30%,
    var(--cp-bg-alt) 70%,
    var(--cp-bg-main) 100%
  );

  --cp-body-gradient: radial-gradient(
    circle at top,
    var(--cp-bg-main) 0%,
    var(--cp-bg-main) 25%,
    var(--cp-bg-main) 70%,
    var(--cp-bg-main) 100%
  );

  /* Acentos para mic, audio, etc. adaptados a Carlos Pedrol */
  --vy-main-button-bg: #ffffff;                       /* fondo dorado del botón */
  --vy-main-button-shadow-main: #ffffff;
  --vy-main-button-shadow-alt: rgba(0, 0, 0, 0.55);

  /* gradiente cuando está grabando (estado .vy-chat-main-button-recording) */
  --vy-gradient-start: #f8f2be;
  --vy-gradient-mid:   #e0b66a;
  --vy-gradient-end:   #cc9f53;

  /* color de las barras de la onda */
  --vy-wave-bar: #f8f2be;
  --vy-recording-dot: #ef4444;
  --vy-recording-dot-shadow: rgba(248, 113, 113, 0.9);
}

/* =========================
   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: var(--cp-gold-soft);
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cp-bg-main);
  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: var(--cp-window-gradient);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.75);
  overflow: hidden;
  display: none;
  flex-direction: column;
  color: var(--cp-chat-text);
  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: var(--cp-gold-main);
  color: var(--cp-header-text);
}

/* 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: var(--cp-avatar-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--cp-avatar-ring);
  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: var(--cp-status-online);
  box-shadow: 0 0 0 3px var(--cp-status-ring);
  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: var(--cp-chat-text);
  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: var(--cp-body-gradient);
}

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

/* FILA DE MENSAJE */
.vy-message-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.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: #ffffff;
  color: var(--cp-bg-main);
  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;
}

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

.vy-message-bot {
  background: var(--cp-bot-bubble-bg);
  border-radius: 1.1rem;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--cp-bot-bubble-border);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.5);
  color: var(--cp-chat-text);
}

.vy-message-user {
  max-width: 78%;
  background: var(--cp-user-bubble-bg);
  border-radius: 1.1rem 1.1rem 0.3rem 1.1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--cp-user-bubble-border);
  color: var(--cp-user-text);
  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;
}

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

/* 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;
  /* antes: height: 46px; sin padding y overflow: hidden */
  height: 50px;
  padding: 6px 1rem;          /* añade aire arriba/abajo y a los lados */
  box-sizing: border-box;
  border-radius: 9999px;
  background: rgba(10, 15, 30, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  overflow: visible;          /* importante: que no recorte el cursor ni las letras */
}

/* Input */
.vy-chat-input-wrapper input {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: #ffffff;
  font-size: 16px;
  line-height: 1.3;
  padding: 0;                 /* el padding lo tiene el wrapper */
  margin: 0;
}
/* Contenedor del icono de voz (lo mantengo igual que lo tenías) */
#vy-voice-container {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.vy-chat-input-wrapper input::placeholder {
  color: var(--cp-placeholder);
}

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

/* =========================
   BOTÓN PRINCIPAL (MIC / ENVIAR) – VERSIÓN COMPACTA
   ========================= */
#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: var(--vy-main-button-bg);

  box-shadow:
    0 0 12px var(--vy-main-button-shadow-main),
    0 8px 16px var(--vy-main-button-shadow-alt) !important;

  transition:
    transform 0.18s ease-out,
    box-shadow 0.18s ease-out;
  overflow: hidden;
}

/* Icono dentro del botón – versión compacta */
#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 var(--vy-main-button-shadow-main),
    0 10px 20px var(--vy-main-button-shadow-alt) !important;
}

/* Estado grabando */
#vectoryal-chat .vy-chat-main-button.vy-chat-main-button-recording {
  background: linear-gradient(
    135deg,
    var(--vy-gradient-start) 0%,
    var(--vy-gradient-mid) 40%,
    var(--vy-gradient-end) 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: var(--cp-powered-text);
  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(204, 159, 83, 0.35),  /* dorado sutil en vez de azul */
      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: var(--vy-recording-dot);
  box-shadow: 0 0 0 0 var(--vy-recording-dot-shadow);
  animation: vy-recording-blink 1.2s infinite;
}

.vy-recording-time {
  color: var(--cp-chat-text);
  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: var(--vy-wave-bar);
  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 var(--vy-recording-dot-shadow);
  }
  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 var(--vy-recording-dot-shadow);
  }
}

/* =========================
   BURBUJA MENSAJE DE VOZ
   ========================= */
.vy-message-user-audio .vy-voice-bubble {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  padding: 10px 14px;
  border-radius: 18px;
  max-width: 240px;
  color: var(--cp-user-text);
  font-weight: 500;
  font-size: 14px;
}

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

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