/* ===========================================================================
   Monova · botón flotante y pantalla de llamada
   ---------------------------------------------------------------------------
   La pantalla imita una llamada de contacto real: avatar circular con el logo,
   nombre, estado, y fila de controles. Se lee al instante porque todo el mundo
   ha visto esa pantalla antes.

   Verde de llamada propio (#1FD65F), NO el #25D366 de marca de WhatsApp.
   Elevación por luz, no por sombra: sobre #050B14 una sombra negra no se ve.
   Sólo se animan transform y opacity.
   =========================================================================== */

.mv-call {
  --mv-green:    #1FD65F;
  --mv-green-dk: #12A34A;
  --mv-green-lt: #5CF08C;
  --mv-red:      #E5484D;
  --mv-red-lt:   #FF6B6B;

  --mv-ground:   #050B14;
  --mv-deep:     #081C38;
  --mv-surface:  #0D2B52;
  --mv-cyan:     #0EA5E9;
  --mv-blue:     #2563EB;
  --mv-gold:     #F2C94C;
  --mv-ink:      #E6EDF7;
  --mv-ink-dim:  #9DB0CC;
  --mv-line:     rgba(14, 165, 233, .16);

  --mv-size: 66px;
  --mv-edge: 24px;

  position: fixed;
  right:  max(var(--mv-edge), env(safe-area-inset-right, 0px));
  bottom: max(var(--mv-edge), env(safe-area-inset-bottom, 0px));
  z-index: 2147483000;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------------------------------------------------------------- BOTÓN --- */

.mv-call__btn {
  position: relative;
  display: grid; place-items: center;
  width: var(--mv-size); height: var(--mv-size);
  padding: 0; border: 0; border-radius: 50%;
  cursor: pointer; color: #04140A;
  background: linear-gradient(145deg, var(--mv-green-lt) 0%, var(--mv-green) 42%, var(--mv-green-dk) 100%);
  box-shadow:
    0 0 0 1px rgba(31, 214, 95, .5),
    0 0 34px rgba(31, 214, 95, .42),
    0 18px 40px -14px rgba(31, 214, 95, .55);
  transition: transform .22s cubic-bezier(.22, 1, .36, 1);
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
}
.mv-call__btn:hover,
.mv-call__btn:focus-visible { transform: scale(1.07); }
.mv-call__btn:active        { transform: scale(.96); }
.mv-call__btn:focus-visible { outline: 3px solid var(--mv-cyan); outline-offset: 4px; }

.mv-call__icon { width: 30px; height: 30px; display: block; transform: rotate(-8deg); }

.mv-call__pulse {
  position: absolute; inset: 0;
  border-radius: 50%; border: 2px solid var(--mv-green);
  opacity: 0; pointer-events: none;
  animation: mv-pulse 2.8s cubic-bezier(.22, 1, .36, 1) infinite;
}
.mv-call__pulse--b { animation-delay: 1.4s; }
@keyframes mv-pulse {
  0%   { transform: scale(1);    opacity: .65; }
  70%,
  100% { transform: scale(1.85); opacity: 0; }
}
.mv-call.is-quiet .mv-call__pulse { animation: none; opacity: 0; }

.mv-call__label {
  position: absolute; right: calc(100% + 14px); top: 50%;
  white-space: nowrap; padding: 9px 15px; border-radius: 999px;
  font-size: .87rem; font-weight: 600; color: var(--mv-ink);
  background: var(--mv-deep); border: 1px solid var(--mv-line);
  opacity: 0; transform: translateY(-50%) translateX(10px);
  transition: opacity .22s ease, transform .22s cubic-bezier(.22, 1, .36, 1);
  pointer-events: none;
}
.mv-call__btn:hover + .mv-call__label,
.mv-call__btn:focus-visible + .mv-call__label { opacity: 1; transform: translateY(-50%) translateX(0); }

/* En llamada el botón se vuelve rojo y el auricular gira: colgar. */
.mv-call.is-live .mv-call__btn {
  background: linear-gradient(145deg, var(--mv-red-lt) 0%, var(--mv-red) 55%, #B4262B 100%);
  box-shadow:
    0 0 0 1px rgba(229, 72, 77, .5),
    0 0 34px rgba(229, 72, 77, .40),
    0 18px 40px -14px rgba(229, 72, 77, .5);
  color: #fff;
}
.mv-call.is-live .mv-call__icon { transform: rotate(133deg); }

/* ---------------------------------------------------------------- PANEL --- */

.mv-call__panel {
  position: absolute; right: 0; bottom: calc(var(--mv-size) + 16px);
  width: min(320px, calc(100vw - 32px));
  border-radius: 20px; overflow: hidden;
  background:
    radial-gradient(420px 260px at 50% -8%, rgba(37, 99, 235, .26), transparent 68%),
    var(--mv-deep);
  border: 1px solid var(--mv-line);
  box-shadow: 0 0 0 1px rgba(14, 165, 233, .08), 0 30px 70px -28px rgba(0, 0, 0, .95);
  color: var(--mv-ink);
  opacity: 0; transform: translateY(10px) scale(.97);
  transform-origin: bottom right;
  transition: opacity .24s ease, transform .24s cubic-bezier(.22, 1, .36, 1);
  pointer-events: none;
}
.mv-call.is-open .mv-call__panel { opacity: 1; transform: none; pointer-events: auto; }

/* ----------------------------------------------------------- CONSENTIM. --- */

.mv-call__consent { padding: 20px; }

.mv-call__title { margin: 0 0 6px; font-size: 1.02rem; font-weight: 700; letter-spacing: -.01em; }
.mv-call__text  { margin: 0 0 14px; font-size: .85rem; line-height: 1.6; color: var(--mv-ink-dim); }
.mv-call__text strong { color: var(--mv-ink); font-weight: 600; }
.mv-call__text a      { color: var(--mv-cyan); }

/* El oro marca el dato que importa. Rol semántico único. */
.mv-call__notice {
  margin: 0 0 16px; padding: 11px 13px;
  border-left: 2px solid var(--mv-gold);
  background: rgba(242, 201, 76, .07);
  border-radius: 0 6px 6px 0;
  font-size: .78rem; line-height: 1.55; color: var(--mv-ink-dim);
}
.mv-call__notice b { color: var(--mv-ink); font-weight: 600; }

.mv-call__actions { display: flex; flex-direction: column; gap: 8px; }

.mv-call__cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 18px; border: 0; border-radius: 12px;
  font-family: inherit; font-size: .92rem; font-weight: 650; color: #04140A;
  background: linear-gradient(145deg, var(--mv-green) 0%, var(--mv-green-dk) 100%);
  cursor: pointer; transition: transform .18s cubic-bezier(.22, 1, .36, 1);
}
.mv-call__cta:hover  { transform: translateY(-2px); }
.mv-call__cta svg    { width: 18px; height: 18px; }

.mv-call__ghost {
  height: 40px; border: 1px solid var(--mv-line); border-radius: 12px;
  background: transparent; color: var(--mv-ink-dim);
  font-family: inherit; font-size: .85rem; cursor: pointer;
  transition: color .18s ease;
}
.mv-call__ghost:hover { color: var(--mv-ink); }

.mv-call__error {
  display: none; padding: 11px 13px; margin-bottom: 14px;
  border-left: 2px solid var(--mv-red);
  background: rgba(229, 72, 77, .09); border-radius: 0 6px 6px 0;
  font-size: .8rem; line-height: 1.55; color: var(--mv-ink-dim);
}
.mv-call.has-error .mv-call__error { display: block; }

/* ------------------------------------------------- PANTALLA DE LLAMADA --- */

.mv-call__screen { display: none; padding: 30px 20px 22px; text-align: center; }
.mv-call.is-live .mv-call__consent { display: none; }
.mv-call.is-live .mv-call__screen  { display: block; }

.mv-call__avatar-wrap {
  position: relative;
  width: 108px; height: 108px;
  margin: 0 auto 18px;
  display: grid; place-items: center;
}

/* Anillos concéntricos: la señal universal de "llamando". */
.mv-call__ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(14, 165, 233, .5);
  opacity: 0;
  animation: mv-ring 2.6s cubic-bezier(.22, 1, .36, 1) infinite;
}
.mv-call__ring--b { animation-delay: .85s; }
.mv-call__ring--c { animation-delay: 1.7s; }
@keyframes mv-ring {
  0%   { transform: scale(.86); opacity: .75; }
  75%,
  100% { transform: scale(1.5); opacity: 0; }
}
/* Ya conectados, los anillos sobran: es una llamada en curso, no sonando. */
.mv-call.is-connected .mv-call__ring { animation: none; opacity: 0; }

/* --- Preloader de conexión ------------------------------------------------
   Anillo de carga girando alrededor del avatar mientras se establece la
   llamada. Sólo visible mientras NO hay conexión: en cuanto conecta,
   desaparece y entran los anillos de "sonando". */

.mv-call__loader {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  border-top-color: var(--mv-cyan);
  border-right-color: rgba(14, 165, 233, .35);
  opacity: 0;
  animation: mv-spin 1s linear infinite;
  pointer-events: none;
}
.mv-call.is-connecting .mv-call__loader { opacity: 1; }
@keyframes mv-spin { to { transform: rotate(360deg); } }

/* Señal baja: el anillo pasa a oro y frena. Comunica "va lento", no "falló". */
.mv-call.is-slow .mv-call__loader {
  border-top-color: var(--mv-gold);
  border-right-color: rgba(242, 201, 76, .35);
  animation-duration: 2.2s;
}
.mv-call.has-failed .mv-call__loader {
  border-top-color: var(--mv-red);
  border-right-color: rgba(229, 72, 77, .35);
  animation: none;
  opacity: 1;
}

/* Mientras conecta, el avatar respira: la llamada está viva aunque no suene. */
.mv-call.is-connecting .mv-call__avatar { animation: mv-breathe 2.4s ease-in-out infinite; }
@keyframes mv-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(.955); }
}

/* Barra de progreso de conexión: se llena por etapas reales, no por tiempo. */
.mv-call__progress {
  display: none;
  height: 3px; width: 148px; margin: 0 auto 14px;
  border-radius: 2px; overflow: hidden;
  background: rgba(14, 165, 233, .14);
}
.mv-call.is-connecting .mv-call__progress,
.mv-call.has-failed .mv-call__progress { display: block; }
.mv-call__progress i {
  display: block; height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, var(--mv-blue), var(--mv-cyan));
  transform: scaleX(0); transform-origin: left;
  transition: transform .5s cubic-bezier(.22, 1, .36, 1);
}
.mv-call.is-slow  .mv-call__progress i { background: linear-gradient(90deg, #A8801F, var(--mv-gold)); }
.mv-call.has-failed .mv-call__progress i { background: var(--mv-red); }

/* Reintentar, cuando la conexión no llegó a establecerse. */
.mv-call__retry {
  display: none;
  margin: 0 auto 14px;
  height: 40px; padding: 0 20px;
  border: 1px solid var(--mv-line); border-radius: 12px;
  background: rgba(13, 43, 82, .55);
  color: var(--mv-ink); font-family: inherit; font-size: .86rem; font-weight: 600;
  cursor: pointer;
  transition: transform .18s cubic-bezier(.22, 1, .36, 1);
}
.mv-call.has-failed .mv-call__retry { display: block; }
.mv-call__retry:hover { transform: translateY(-2px); }

/* Mientras conecta no hay nada que silenciar ni ningún altavoz que subir. */
.mv-call.is-connecting .mv-call__ctrl--mute,
.mv-call.is-connecting .mv-call__ctrl--speaker,
.mv-call.has-failed .mv-call__ctrl--mute,
.mv-call.has-failed .mv-call__ctrl--speaker { opacity: .35; pointer-events: none; }

.mv-call__avatar {
  position: relative;
  width: 92px; height: 92px;
  border-radius: 50%;
  display: grid; place-items: center;
  overflow: hidden;
  /* Gradiente firma de Monova. Aparece aquí y en el CTA principal: en ningún
     otro sitio de la página. */
  background: linear-gradient(100deg, var(--mv-blue), var(--mv-cyan));
  box-shadow:
    0 0 0 1px rgba(14, 165, 233, .35),
    0 0 34px rgba(14, 165, 233, .35),
    0 16px 36px -16px rgba(0, 0, 0, .9);
}
.mv-call__avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
/* Sustituto tipográfico mientras no haya logo optimizado. Ver README. */
.mv-call__avatar-letter {
  font-size: 2.5rem; font-weight: 800; color: #fff;
  letter-spacing: -.04em; line-height: 1;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .3);
}

.mv-call__name  { margin: 0; font-size: 1.3rem; font-weight: 700; letter-spacing: -.02em; }
.mv-call__org   { margin: 2px 0 12px; font-size: .82rem; color: var(--mv-ink-dim); }

.mv-call__state {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  font-size: .92rem; font-variant-numeric: tabular-nums;
  color: var(--mv-ink-dim); min-height: 22px; margin-bottom: 14px;
}
.mv-call__dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--mv-green);
  animation: mv-blink 1.6s ease-in-out infinite;
}
@keyframes mv-blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* Barra de nivel: se mueve con la voz real del agente, no es decorativa. */
.mv-call__level {
  height: 3px; width: 116px; margin: 0 auto 18px;
  border-radius: 2px; overflow: hidden;
  background: rgba(14, 165, 233, .14);
}
.mv-call__level i {
  display: block; height: 100%; width: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--mv-green-dk), var(--mv-green-lt));
  transform: scaleX(0); transform-origin: left;
  transition: transform .09s linear;
}

/* Aviso de volumen: aparece sólo si se infiere que no oye. */
.mv-call__hint {
  display: none;
  margin: 0 0 16px; padding: 10px 12px;
  border-left: 2px solid var(--mv-gold);
  background: rgba(242, 201, 76, .09);
  border-radius: 0 6px 6px 0;
  font-size: .78rem; line-height: 1.5; color: var(--mv-ink-dim);
  text-align: left;
}
.mv-call.needs-volume .mv-call__hint { display: block; }
.mv-call__hint b { color: var(--mv-gold); font-weight: 650; }

/* --------------------------------------------------------- CONTROLES --- */

.mv-call__controls {
  display: flex; align-items: center; justify-content: center; gap: 16px;
}

.mv-call__ctrl {
  position: relative;
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border: 1px solid var(--mv-line); border-radius: 50%;
  background: rgba(13, 43, 82, .55);
  color: var(--mv-ink); cursor: pointer;
  transition: transform .18s cubic-bezier(.22, 1, .36, 1), background .18s ease;
}
.mv-call__ctrl:hover { transform: translateY(-2px); background: rgba(13, 43, 82, .9); }
.mv-call__ctrl:focus-visible { outline: 2px solid var(--mv-cyan); outline-offset: 3px; }
.mv-call__ctrl svg { width: 22px; height: 22px; }

/* Activo = altavoz encendido o micrófono silenciado */
.mv-call__ctrl[aria-pressed="true"] {
  background: var(--mv-cyan); color: #03121E; border-color: var(--mv-cyan);
}
.mv-call__ctrl--mute[aria-pressed="true"] {
  background: var(--mv-gold); color: #1A1300; border-color: var(--mv-gold);
}

.mv-call__ctrl--hangup {
  width: 60px; height: 60px;
  border: 0; color: #fff;
  background: linear-gradient(145deg, var(--mv-red-lt), var(--mv-red));
  box-shadow: 0 0 26px rgba(229, 72, 77, .38);
}
.mv-call__ctrl--hangup svg { width: 26px; height: 26px; transform: rotate(133deg); }
.mv-call__ctrl--hangup:hover { background: linear-gradient(145deg, var(--mv-red-lt), #B4262B); }

.mv-call__ctrl-label {
  position: absolute; top: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  font-size: .62rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--mv-ink-dim); white-space: nowrap; pointer-events: none;
}

/* ------------------------------------------------------ ACCESIBILIDAD --- */

@media (prefers-reduced-motion: reduce) {
  .mv-call__pulse, .mv-call__ring, .mv-call__dot { animation: none; opacity: 0; }
  .mv-call__dot { opacity: 1; }
  .mv-call__btn, .mv-call__panel, .mv-call__label,
  .mv-call__cta, .mv-call__ctrl, .mv-call__level i { transition: none; }
  .mv-call__btn:hover, .mv-call__ctrl:hover { transform: none; }
}

@media (max-width: 480px) {
  .mv-call { --mv-size: 60px; --mv-edge: 16px; }
  .mv-call__label { display: none; }
  .mv-call__panel { width: calc(100vw - 32px); right: -4px; }
  .mv-call__avatar-wrap { width: 96px; height: 96px; }
  .mv-call__avatar { width: 82px; height: 82px; }
}

@media (prefers-color-scheme: light) {
  .mv-call:not([data-theme="dark"]) {
    --mv-deep: #FFFFFF;
    --mv-ink: #07182C;
    --mv-ink-dim: #4A5F7A;
    --mv-line: rgba(7, 24, 44, .12);
  }
}
