.vioagents-widget-root {
  --vw-accent: #8b5cf6;
  --vw-accent-soft: rgba(139, 92, 246, 0.18);
  --vw-bg: rgba(8, 13, 26, 0.96);
  --vw-bg-strong: rgba(8, 13, 26, 0.985);
  --vw-text: #f8fafc;
  --vw-text-soft: #cbd5e1;
  --vw-border: rgba(255, 255, 255, 0.12);
  --vw-shadow: 0 24px 55px rgba(0, 0, 0, 0.5);
  --vw-radius: 24px;
  --vw-transition: 220ms ease;
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: auto;
  max-width: none;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.4;
}

.vioagents-widget-root *,
.vioagents-widget-root *::before,
.vioagents-widget-root *::after {
  box-sizing: border-box;
}

.vioagents-widget-root button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
}

.vioagents-widget-root a {
  color: inherit;
}

.vioagents-widget-trigger-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  width: fit-content;
  max-width: min(280px, calc(100vw - 24px));
}

.vioagents-widget-launcher,
.vioagents-widget-panel,
.vioagents-widget-backdrop,
.vioagents-widget-teaser,
.vioagents-widget-teaser-close,
.vioagents-widget-teaser-body {
  pointer-events: auto;
}

.vioagents-widget-launcher {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 14px 16px;
  border-radius: 999px;
  background: var(--vw-bg);
  border: 1px solid var(--vw-border);
  box-shadow: var(--vw-shadow);
  color: var(--vw-text);
  transition: transform var(--vw-transition), box-shadow var(--vw-transition), border-color var(--vw-transition);
}

.vioagents-widget-launcher:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.2);
}

.vioagents-widget-launcher-icon {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--vw-accent), #22c55e);
  color: white;
  flex-shrink: 0;
  position: relative;
}

.vioagents-widget-launcher-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  text-align: left;
}

.vioagents-widget-launcher-copy strong {
  font-size: 14px;
  line-height: 1.1;
}

.vioagents-widget-launcher-copy span {
  font-size: 11px;
  color: var(--vw-text-soft);
}

.vioagents-widget-pulse {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  right: 16px;
  top: 14px;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45);
  animation: vioagentsWidgetPulse 2s infinite;
}

@keyframes vioagentsWidgetPulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45); }
  70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.vioagents-widget-teaser {
  max-width: 280px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px;
  border-radius: 16px 16px 4px 16px;
  background: var(--vw-bg);
  border: 1px solid var(--vw-border);
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.32);
  transition: transform var(--vw-transition), border-color var(--vw-transition), opacity var(--vw-transition);
}

.vioagents-widget-teaser:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.2);
}

.vioagents-widget-teaser-body {
  flex: 1;
  text-align: left;
  color: var(--vw-text);
  font-size: 13px;
  line-height: 1.45;
  padding: 3px 4px 3px 6px;
}

.vioagents-widget-teaser-body strong {
  display: block;
  margin-bottom: 2px;
}

.vioagents-widget-teaser-close {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.vioagents-widget-teaser-close:hover {
  color: var(--vw-text);
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
}

.vioagents-widget-root.is-open .vioagents-widget-teaser {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.vioagents-widget-root.is-teaser-hidden .vioagents-widget-teaser {
  display: none;
}

.vioagents-widget-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.52);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--vw-transition), visibility var(--vw-transition);
}

.vioagents-widget-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  width: min(440px, calc(100vw - 24px));
  height: min(680px, calc(100vh - 96px));
  background: var(--vw-bg-strong);
  border: 1px solid var(--vw-border);
  border-radius: var(--vw-radius);
  overflow: hidden;
  box-shadow: 0 35px 90px rgba(0, 0, 0, 0.58);
  transform: translateY(14px) scale(0.97);
  opacity: 0;
  visibility: hidden;
  transition: transform 240ms ease, opacity 240ms ease, visibility 240ms ease;
  display: grid;
  grid-template-rows: auto 1fr;
  pointer-events: none;
}

.vioagents-widget-root:not(.is-open) .vioagents-widget-panel,
.vioagents-widget-root:not(.is-open) .vioagents-widget-backdrop {
  display: none;
}

.vioagents-widget-root.is-open .vioagents-widget-panel,
.vioagents-widget-root.is-open .vioagents-widget-backdrop {
  display: block;
  opacity: 1;
  visibility: visible;
}

.vioagents-widget-root.is-open .vioagents-widget-panel {
  display: grid;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.vioagents-widget-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
}

.vioagents-widget-header-copy {
  flex: 1;
  min-width: 0;
}

.vioagents-widget-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--vw-accent);
  margin-bottom: 6px;
}

.vioagents-widget-eyebrow::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--vw-accent);
  box-shadow: 0 0 12px var(--vw-accent);
}

.vioagents-widget-title {
  font-size: 20px;
  line-height: 1.1;
  font-weight: 800;
  color: var(--vw-text);
  margin-bottom: 4px;
}

.vioagents-widget-subtitle {
  font-size: 13px;
  line-height: 1.5;
  color: var(--vw-text-soft);
}

.vioagents-widget-close {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.vioagents-widget-close:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
}

.vioagents-widget-body {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.vioagents-widget-note {
  font-size: 12px;
  line-height: 1.5;
  color: var(--vw-text-soft);
  padding: 12px 16px 0;
}

.vioagents-widget-note strong {
  color: var(--vw-text);
}

.vioagents-widget-iframe-wrap {
  min-height: 0;
  padding: 12px 12px 12px;
  display: flex;
  flex-direction: column;
}

.vioagents-widget-iframe {
  width: 100%;
  height: 100%;
  flex: 1;
  min-height: 480px;
  border: 0;
  border-radius: 18px;
  background: white;
  display: block;
}

.vioagents-widget-root[data-accent="green"] {
  --vw-accent: #10b981;
}

.vioagents-widget-root[data-accent="orange"] {
  --vw-accent: #f97316;
}

.vioagents-widget-root[data-accent="blue"] {
  --vw-accent: #3b82f6;
}

.vioagents-widget-root[data-accent="purple"] {
  --vw-accent: #8b5cf6;
}

@media (max-width: 767px) {
  .vioagents-widget-root {
    right: max(13px, env(safe-area-inset-right));
    bottom: max(13px, env(safe-area-inset-bottom));
  }

  .vioagents-widget-trigger-stack {
    max-width: min(260px, calc(100vw - 1.25rem));
  }

  .vioagents-widget-launcher {
    min-height: 58px;
    padding: 12px 14px;
    border-radius: 20px;
  }

  .vioagents-widget-launcher-copy strong {
    font-size: 13px;
  }

  .vioagents-widget-teaser {
    max-width: min(240px, calc(100vw - 1.25rem));
  }

  /* Panel fullscreen en móvil — idéntico al widget viejo */
  .vioagents-widget-panel {
    position: fixed;
    inset: 0;
    top: var(--vw-top, 0px);
    width: 100%;
    height: var(--vw-height, 100dvh);
    max-height: var(--vw-height, 100dvh);
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    transform: translateY(100%);
  }

  .vioagents-widget-root.is-open .vioagents-widget-panel {
    transform: translateY(0);
  }

  /* Safe area en header para notch de iPhone */
  .vioagents-widget-header {
    padding-top: calc(16px + env(safe-area-inset-top));
  }

  .vioagents-widget-iframe-wrap {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .vioagents-widget-iframe {
    min-height: 0;
  }
}

/* ─── Modo compacto (botón circular, sin texto) ──────────────── */
/* Activar con data-compact="true" en el script tag             */

.vioagents-widget-root[data-compact="true"] .vioagents-widget-launcher {
  width: 60px;
  height: 60px;
  min-height: 60px;
  padding: 0;
  border-radius: 50%;
  justify-content: center;
  gap: 0;
}

.vioagents-widget-root[data-compact="true"] .vioagents-widget-launcher-copy {
  display: none;
}

.vioagents-widget-root[data-compact="true"] .vioagents-widget-launcher-icon {
  width: 60px;
  height: 60px;
}

.vioagents-widget-root[data-compact="true"] .vioagents-widget-pulse {
  display: none;
}

@media (max-width: 767px) {
  .vioagents-widget-root[data-compact="true"] .vioagents-widget-launcher {
    width: 58px;
    height: 58px;
    min-height: 58px;
  }
}


/* ─── Entrada animada ─────────────────────────────────────────── */

.vioagents-widget-root .vioagents-widget-trigger-stack {
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.vioagents-widget-root.is-entering .vioagents-widget-trigger-stack {
  opacity: 0;
  transform: translateY(28px);
  pointer-events: none;
}

/* ─── Glow en ícono ───────────────────────────────────────────── */

.vioagents-widget-launcher-icon {
  box-shadow: 0 0 18px rgba(139, 92, 246, 0.3);
  transition: box-shadow var(--vw-transition), transform var(--vw-transition);
}

.vioagents-widget-launcher:hover .vioagents-widget-launcher-icon {
  box-shadow: 0 0 30px rgba(139, 92, 246, 0.55);
  transform: scale(1.06);
}

.vioagents-widget-root[data-accent="blue"] .vioagents-widget-launcher-icon {
  box-shadow: 0 0 18px rgba(59, 130, 246, 0.35);
}
.vioagents-widget-root[data-accent="blue"] .vioagents-widget-launcher:hover .vioagents-widget-launcher-icon {
  box-shadow: 0 0 30px rgba(59, 130, 246, 0.6);
}
.vioagents-widget-root[data-accent="green"] .vioagents-widget-launcher-icon {
  box-shadow: 0 0 18px rgba(16, 185, 129, 0.35);
}
.vioagents-widget-root[data-accent="orange"] .vioagents-widget-launcher-icon {
  box-shadow: 0 0 18px rgba(249, 115, 22, 0.35);
}

/* ─── Shimmer en launcher hover ───────────────────────────────── */

.vioagents-widget-launcher {
  overflow: hidden;
  position: relative;
}

.vioagents-widget-launcher::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.07) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
  pointer-events: none;
}

.vioagents-widget-launcher:hover::after {
  transform: translateX(100%);
}

/* ─── Nudge animation (idle 25s) ─────────────────────────────── */

@keyframes vioagentsWidgetNudge {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  15%       { transform: translateX(-5px) rotate(-2deg); }
  30%       { transform: translateX(5px) rotate(2deg); }
  45%       { transform: translateX(-4px) rotate(-1deg); }
  60%       { transform: translateX(4px) rotate(1deg); }
  75%       { transform: translateX(-2px); }
}

.vioagents-widget-launcher.is-nudging {
  animation: vioagentsWidgetNudge 0.65s ease;
}

/* ─── Typing dots en teaser ───────────────────────────────────── */

.vioagents-widget-teaser-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.vioagents-widget-teaser-content strong {
  display: block;
  margin-bottom: 1px;
}

.vioagents-widget-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-bottom: 5px;
}

.vioagents-widget-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--vw-accent);
  opacity: 0.3;
  animation: vioagentsTypingDot 1.4s infinite ease-in-out;
}

.vioagents-widget-typing span:nth-child(2) { animation-delay: 0.2s; }
.vioagents-widget-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes vioagentsTypingDot {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30%            { opacity: 1;    transform: translateY(-4px); }
}

/* ─── Iframe loading spinner ─────────────────────────────────── */

.vioagents-widget-root.is-iframe-loading .vioagents-widget-iframe-wrap {
  position: relative;
}

.vioagents-widget-root.is-iframe-loading .vioagents-widget-iframe-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 18px;
  background: rgba(8, 13, 26, 0.85);
  z-index: 1;
}

.vioagents-widget-root.is-iframe-loading .vioagents-widget-iframe-wrap::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--vw-accent);
  animation: vioagentsWidgetSpin 0.75s linear infinite;
  z-index: 2;
}

@keyframes vioagentsWidgetSpin {
  to { transform: rotate(360deg); }
}
