/* ============================================================
   Valentina · Chat con IA del catálogo (prototipo)
   Colores de marca: negro #000 · dorado #d4a017 · crema #f2f2f0
   ============================================================ */

#vzRoot {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 2500;
  font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: 0.7rem;
}

/* ---- Botón flotante ---- */
.vz-fab {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid #d4a017;
  background: #fff;
  padding: 5px;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  touch-action: manipulation;
}
.vz-fab:hover { transform: scale(1.06); }
.vz-fab:active { transform: scale(0.96); }
.vz-fab:focus-visible { outline: 2px solid #d4a017; outline-offset: 3px; }
.vz-fab img { width: 100%; height: 100%; border-radius: 50%; display: block; }
.vz-fab .vz-fab-orb { animation: vzFloat 3.6s ease-in-out infinite; display: block; width: 100%; height: 100%; }
.vz-fab.speaking .vz-fab-orb { animation: vzTalk 0.55s ease-in-out infinite alternate; }

.vz-fab-ping {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid #d4a017;
  opacity: 0;
  animation: vzPing 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes vzPing {
  0% { transform: scale(0.9); opacity: 0.7; }
  70% { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}
@keyframes vzFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes vzTalk {
  0% { transform: scale(1); }
  100% { transform: scale(1.12); }
}
.vz-spark { transform-origin: center; animation: vzSpin 8s linear infinite; }
@keyframes vzSpin { to { transform: rotate(360deg); } }

/* ---- Panel ---- */
.vz-panel {
  position: fixed;
  right: 18px;
  bottom: 92px;
  width: min(372px, calc(100vw - 24px));
  height: min(620px, calc(100vh - 110px));
  height: min(620px, calc(100dvh - 110px));
  background: #fdfbf5;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.32);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 0.78rem;
  color: #1a1a1a;
}
.vz-panel[hidden] { display: none; }

.vz-head {
  background: #000;
  color: #fff;
  padding: 0.7rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 0 0 auto;
}
.vz-head img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(212, 160, 23, 0.7);
  background: #fff;
}
.vz-head-txt { flex: 1; min-width: 0; }
.vz-head-txt strong {
  display: block;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
}
.vz-head-txt strong em { font-style: normal; color: #d4a017; }
.vz-status {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-top: 2px;
}
.vz-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #35c46a;
}
.vz-icobtn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  touch-action: manipulation;
}
.vz-icobtn:hover { background: rgba(255, 255, 255, 0.22); }
.vz-icobtn:focus-visible { outline: 2px solid #d4a017; outline-offset: 2px; }
.vz-icobtn.off { opacity: 0.45; }

/* ---- Mensajes ---- */
.vz-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  overscroll-behavior: contain;
}
.vz-msg {
  max-width: 84%;
  padding: 0.55rem 0.75rem;
  border-radius: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  text-wrap: pretty;
  animation: vzMsgIn 0.22s ease-out;
}
@keyframes vzMsgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.vz-msg.bot {
  align-self: flex-start;
  background: #f2efe4;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-bottom-left-radius: 4px;
}
.vz-msg.user {
  align-self: flex-end;
  background: #000;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.vz-msg .vz-msg-label {
  display: block;
  font-size: 0.52rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.5;
  margin-bottom: 2px;
}
.vz-msg.bot .vz-msg-label { color: #a8740a; }
.vz-msg.user .vz-msg-label { color: #d4a017; }
.vz-msg.sys {
  align-self: center;
  background: transparent;
  border: 0;
  color: rgba(0, 0, 0, 0.45);
  font-size: 0.58rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  padding: 0.15rem 0.3rem;
  max-width: 92%;
}

/* botón de ayuda junto al ícono del chat */
.vz-helpwrap {
  position: relative;
  display: flex;
  align-items: center;
}
.vz-helpwrap[hidden] { display: none; }
.vz-help {
  padding: 0.62rem 1rem;
  border: 1.5px solid #d4a017;
  border-radius: 999px;
  background: #000;
  color: #fff;
  font-family: inherit;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
  transition: transform 0.15s, background 0.15s;
  touch-action: manipulation;
  white-space: nowrap;
}
.vz-help:hover { transform: scale(1.04); background: #161616; }
.vz-help:active { transform: scale(0.97); }
.vz-help:focus-visible { outline: 2px solid #d4a017; outline-offset: 2px; }
/* X para quitar la opción "Déjame ayudarte" */
.vz-help-x {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1.5px solid #d4a017;
  border-radius: 50%;
  background: #000;
  color: #fff;
  font-size: 0.72rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s, background 0.15s;
  touch-action: manipulation;
}
.vz-help-x:hover { transform: scale(1.15); background: #161616; }
.vz-help-x:focus-visible { outline: 2px solid #d4a017; outline-offset: 2px; }
#vzRoot.panel-open .vz-helpwrap { display: none; }

/* indicador "escribiendo" */
.vz-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 0.7rem 0.85rem;
  background: #f2efe4;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.vz-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a8740a;
  animation: vzDot 1s ease-in-out infinite;
}
.vz-typing span:nth-child(2) { animation-delay: 0.16s; }
.vz-typing span:nth-child(3) { animation-delay: 0.32s; }
@keyframes vzDot { 0%, 100% { opacity: 0.25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

/* ---- Vista previa del diseño ---- */
.vz-design {
  flex: 0 0 auto;
  margin: 0 0.7rem 0.65rem;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.09);
  border-radius: 14px;
  padding: 0.7rem;
}
.vz-design[hidden] { display: none; }
.vz-design-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #a8740a;
  font-weight: 700;
  margin-bottom: 0.45rem;
  text-align: center;
}
/* Botón para minimizar el visualizador: deja ver la conversación */
.vz-design-toggle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: #fff;
  color: #a8740a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex: 0 0 auto;
  transition: transform 0.12s, background 0.15s;
}
.vz-design-toggle:hover { background: #fbf3d9; }
.vz-design-toggle:active { transform: scale(0.9); }
.vz-design-toggle svg { display: block; transition: transform 0.18s; }
.vz-design-toggle.min svg { transform: rotate(180deg); }
.vz-design-toggle:focus-visible { outline: 2px solid #d4a017; outline-offset: 1px; }
/* Minimizado: queda solo la barra de título, el diseño se oculta */
.vz-design.min { padding-bottom: 0.3rem; }
.vz-design.min .vz-design-stage,
.vz-design.min .vz-photo-thumb,
.vz-design.min .vz-design-meta,
.vz-design.min .vz-design-status,
.vz-design.min .vz-design-actions { display: none; }
.vz-design-stage {
  height: 150px;
  min-height: 96px;
  background: repeating-conic-gradient(#f6f3e8 0% 25%, #fff 0% 50%) 50% / 18px 18px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.6rem;
}
.vz-design-stage { position: relative; }
.vz-design-stage img { max-width: 70%; object-fit: contain; }
.vz-design-stage .vz-dtext {
  text-align: center;
  line-height: 1.15;
  word-break: break-word;
  color: #000;
  max-width: 86%;
}
/* La preview del chat es editable: el texto y el dibujo se mueven libremente
   (arrastrar con el dedo o el mouse) y se escalan con −/+ o la rueda. */
.vz-design-stage .vz-dtext,
.vz-design-stage img.vz-dimg {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: move;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 3;
}
.vz-design-stage .vz-dtext.dragging,
.vz-design-stage img.vz-dimg.dragging { outline: 2px dashed #d4a017; outline-offset: 3px; border-radius: 4px; }
.vz-design-stage.size-sutil img.vz-dimg { max-height: 46px; }
.vz-design-stage.size-sutil .vz-dtext { font-size: 15px; }
.vz-design-stage.size-medio img.vz-dimg { max-height: 68px; }
.vz-design-stage.size-medio .vz-dtext { font-size: 26px; }
.vz-design-stage.size-grande img.vz-dimg { max-height: 92px; }
.vz-design-stage.size-grande .vz-dtext { font-size: 40px; }
.vz-dplaceholder { color: #999; font-size: 0.68rem; }
/* Mini controles de la preview editable */
.vz-stage-hint {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 0.5rem;
  color: #b58a12;
  background: #fbf3d9;
  border: 1px solid #e8d9a0;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  z-index: 4;
  pointer-events: none;
}
.vz-stage-tools {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 0.25rem;
  align-items: center;
  z-index: 4;
}
.vz-stage-tools button {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.2);
  background: #fff;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
}
.vz-stage-tools button:active { background: #f0e6c8; }
.vz-stage-scale {
  font-size: 0.5rem;
  color: #666;
  min-width: 30px;
  text-align: center;
}

.vz-design-meta {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.vz-design-status {
  margin-top: 0.45rem;
  font-size: 0.62rem;
  color: #8a7a3c;
  background: #fbf3d9;
  border: 1px solid #e8d9a0;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  text-align: center;
}
.vz-design-actions button:disabled,
.vz-design-actions button.locked {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.vz-chip {
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  color: #444;
  background: #fbf9f2;
}
.vz-chip.gold { border-color: #000; color: #1c1c1c; font-weight: 700; }

.vz-design-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.vz-design-actions button {
  padding: 0.6rem 0.4rem;
  border-radius: 999px;
  border: 1px solid #000;
  background: #000;
  color: #fff;
  font-family: inherit;
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s, background 0.15s;
  min-height: 38px;
}
.vz-design-actions button:hover { background: #222; }
.vz-design-actions button:active { transform: scale(0.97); }
.vz-design-actions button:focus-visible { outline: 2px solid #d4a017; outline-offset: 2px; }
.vz-design-actions button.full { grid-column: 1 / -1; }
.vz-design-actions button.gold {
  background: #000;
  border-color: #000;
  color: #fff;
  font-weight: 700;
}
.vz-design-actions button.gold:hover { background: #1c1c1c; }
.vz-design-actions button.ghost {
  background: none;
  color: #000;
}

/* miniatura de la foto del producto adjuntada */
.vz-photo-thumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.55rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 10px;
  background: #faf7ef;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #444;
}
.vz-photo-thumb span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.vz-photo-thumb[hidden] { display: none; }
.vz-photo-thumb img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.15);
}

/* destello para guiar al cliente a la sección de personalización */
#personalizacion.vz-flash {
  animation: vzFlash 1.6s ease;
}
@keyframes vzFlash {
  0% { box-shadow: 0 0 0 0 rgba(212, 160, 23, 0.85); }
  70% { box-shadow: 0 0 0 14px rgba(212, 160, 23, 0); }
  100% { box-shadow: 0 0 0 0 rgba(212, 160, 23, 0); }
}

/* ---- Formulario ---- */
.vz-form {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.65rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: #fdfbf5;
}
.vz-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(0, 0, 0, 0.25);
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  font-family: inherit;
  font-size: 0.8rem;
  background: #fff;
  color: #1a1a1a;
}
.vz-form input:focus { outline: none; border-color: #000; }
.vz-form input:focus-visible { outline: 2px solid #d4a017; outline-offset: 1px; }
.vz-mic, .vz-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  touch-action: manipulation;
  transition: transform 0.1s, background 0.15s;
}
.vz-mic { background: #f2efe4; color: #000; }
.vz-mic[hidden] { display: none; }
.vz-mic.on { background: #000; color: #ffd34d; animation: vzMicOnPulse 1s ease-in-out infinite; }
@keyframes vzMicOnPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(212, 160, 23, 0.55); } 50% { box-shadow: 0 0 0 10px rgba(212, 160, 23, 0); } }
.vz-send { background: #000; color: #fff; }
.vz-send:hover { background: #222; }
.vz-mic:active, .vz-send:active { transform: scale(0.94); }
.vz-mic:focus-visible, .vz-send:focus-visible { outline: 2px solid #d4a017; outline-offset: 2px; }

/* advertencia de cuero/color (siempre visible) */
.vz-warn {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: 0.58rem;
  text-align: left;
  line-height: 1.4;
  color: #6b5b2e;
  background: #faf7ef;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding: 0.45rem 0.8rem;
  letter-spacing: 0.01em;
}
.vz-warn .vz-warn-ic {
  flex: 0 0 auto;
  margin-top: 0.05rem;
  color: #8a6a08;
}

/* nota de modo local (prototipo sin IA configurada) */
.vz-mode-note {
  flex: 0 0 auto;
  font-size: 0.55rem;
  text-align: center;
  color: #a8740a;
  padding: 0.2rem 0.6rem 0.35rem;
  letter-spacing: 0.06em;
}
.vz-voice-banner {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-size: 0.62rem;
  text-align: center;
  color: #fff;
  background: #000;
  border: 1px solid #d4a017;
  border-radius: 12px;
  padding: 0.5rem 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-sizing: border-box;
  animation: vzMicOnPulse 1.4s ease-in-out infinite;
}
.vz-voice-banner[hidden] { display: none; }
.vz-voice-banner b { color: #ffd34d; }
.vz-voice-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff5252;
  flex: 0 0 auto;
  animation: vzDotBlink 1.1s ease-in-out infinite;
}
@keyframes vzDotBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ---- Responsive: pantallas pequeñas ----
   Incluye los Android de 540px (1080px a 2x), los iPhones y demás.
   En móvil el chat es una hoja inferior a ancho completo con safe-area. */
@media (max-width: 560px) {
  #vzRoot { right: 12px; bottom: 12px; left: auto; }
  #vzRoot.panel-open .vz-fab { display: none; }
  #vzRoot.panel-open .vz-helpwrap { display: none; }
  .vz-fab { width: 58px; height: 58px; }
  .vz-help { font-size: 0.62rem; padding: 0.55rem 0.9rem; }
  .vz-panel {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: min(85dvh, 100dvh);
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    max-height: 100dvh;
  }
  .vz-panel::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 44px;
    height: 4px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.18);
  }
  .vz-head { padding-top: 0.95rem; }
  /* Modo voz en pantallas pequeñas: banner ancho y legible, input cómodo */
  .vz-voice-banner {
    font-size: 0.68rem;
    padding: 0.55rem 0.6rem;
    gap: 0.4rem;
  }
  .vz-form { gap: 0.4rem; padding: 0.55rem 0.5rem; }
  .vz-form input { font-size: 0.85rem; }
  /* El diseño nunca debe robarle el espacio a la conversación en móvil:
     panel un poco más alto, diseño con alto máximo y scroll interno */
  .vz-panel { height: min(92dvh, 100dvh); }
  .vz-design {
    margin-left: 0.5rem;
    margin-right: 0.5rem;
    max-height: 46vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .vz-design-stage { height: 112px; }
  .vz-design-actions button { min-height: 34px; padding: 0.5rem 0.3rem; }
}

/* Tablet angosta / pantallas medianas: tarjeta flotante un poco más ancha */
@media (min-width: 561px) and (max-width: 820px) {
  .vz-panel { width: min(400px, calc(100vw - 28px)); }
}

/* ---- Galería visual dentro del chat (fuentes, íconos, diseños) ---- */
.vz-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.vz-g-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  background: #fff;
  text-align: center;
}
.vz-g-font-sample {
  font-size: 24px;
  line-height: 1.15;
  color: #1a1a1a;
  word-break: break-word;
  max-width: 100%;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vz-g-font-name,
.vz-g-icon-name {
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.vz-g-icon-img,
.vz-g-design img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vz-g-icon-img img {
  max-width: 100%;
  max-height: 100%;
}
.vz-g-design img {
  filter: grayscale(1) contrast(1.1) brightness(0.78);
}
.vz-g-icon-name { margin-top: 3px; }

@media (max-width: 380px) {
  .vz-gallery { grid-template-columns: repeat(3, 1fr); }
}
