/* [Pulso-Supabase] ✨ Fluidez (ver fluidez.js). Todo el movimiento depende de html.cf-mov (interruptor de animaciones). */

/* ── carga con la marca: línea de pulso + siluetas mientras el módulo dice "Cargando…" ── */
#cf-panel-body.cf-carga-pulso { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; min-height: 280px; text-align: center; }
#cf-panel-body.cf-carga-pulso > * { color: var(--t2); font-weight: 600; }
#cf-panel-body.cf-carga-pulso::before {
  content: ''; width: min(360px, 80%); height: 48px; order: -1;
  background: linear-gradient(90deg, transparent 0%, #f43f5e 30%, #a855f7 55%, transparent 80%) 0 0 / 220% 100%;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 360 48'%3E%3Cpath d='M0 24h120l10-14 12 30 12-36 12 34 10-14h184' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 360 48'%3E%3Cpath d='M0 24h120l10-14 12 30 12-36 12 34 10-14h184' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  filter: drop-shadow(0 0 10px rgba(232, 121, 249, .55)); opacity: .9;
}
#cf-panel-body.cf-carga-pulso::after {
  content: ''; width: min(560px, 92%); height: 110px; border-radius: 14px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--t2) 10%, transparent) 25%, color-mix(in srgb, var(--t2) 20%, transparent) 40%, color-mix(in srgb, var(--t2) 10%, transparent) 60%) 0 0 / 300% 100%;
  -webkit-mask: linear-gradient(#000 0 0) 0 0 / 100% 22px no-repeat, linear-gradient(#000 0 0) 0 44px / 82% 22px no-repeat, linear-gradient(#000 0 0) 0 88px / 64% 22px no-repeat;
  mask: linear-gradient(#000 0 0) 0 0 / 100% 22px no-repeat, linear-gradient(#000 0 0) 0 44px / 82% 22px no-repeat, linear-gradient(#000 0 0) 0 88px / 64% 22px no-repeat;
}
html.cf-mov #cf-panel-body.cf-carga-pulso::before { animation: cf-fx-ecg 1.4s linear infinite; }
html.cf-mov #cf-panel-body.cf-carga-pulso::after { animation: cf-fx-brillo 1.6s ease-in-out infinite; }
@keyframes cf-fx-ecg { from { background-position: 120% 0; } to { background-position: -120% 0; } }
@keyframes cf-fx-brillo { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ── cambio de módulo: deslizamiento suave + el ícono del módulo late una vez ── */
html.cf-mov #cf-panel-body.cf-cambio { animation: cf-fx-cambio .32s cubic-bezier(.2, .8, .2, 1); }
@keyframes cf-fx-cambio { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
html.cf-mov #cf-app .cf-header-actions .cf-btn.cf-hx-actual::before { animation: cf-fx-latido .7s ease-out 1; }
@keyframes cf-fx-latido { 0%, 100% { transform: scale(1); } 25% { transform: scale(1.28); } 50% { transform: scale(.94); } 70% { transform: scale(1.1); } }

/* ── toque con respuesta en los botones principales ── */
html.cf-mov .cf-toque { animation: cf-fx-toque .5s ease-out; }
@keyframes cf-fx-toque { 0% { box-shadow: 0 0 0 0 rgba(232, 121, 249, .6); filter: brightness(1.18); } 100% { box-shadow: 0 0 0 12px rgba(232, 121, 249, 0); filter: none; } }

/* ── pedido nuevo: el avatar late dos veces con un anillo (además del brillo que ya tenía) ── */
html.cf-mov .cf-card.cf-entra .cf-card-av { animation: cf-fx-av 1.05s ease-out 2; }
@keyframes cf-fx-av { 0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(244, 63, 94, .7); } 18% { transform: scale(1.16); } 32% { transform: scale(.96); } 46% { transform: scale(1.08); } 100% { transform: scale(1); box-shadow: 0 0 0 12px rgba(168, 85, 247, 0); } }

/* ── huella: el anillo se llena al abrir el pedido ── */
@property --p { syntax: '<number>'; inherits: true; initial-value: 0; }
html.cf-mov .cf-huc-anillo { animation: cf-fx-huella 1s cubic-bezier(.2, .8, .2, 1); }
@keyframes cf-fx-huella { from { --p: 0; } }

/* ── en Pulso ahora: anillo verde en el nombre del asesor ── */
.cf-chip.cf-chip-vivo { box-shadow: inset 0 0 0 1.5px #22c55e, 0 0 12px -4px rgba(34, 197, 94, .8); }
.cf-chip.cf-chip-vivo.cf-chip-on { box-shadow: 0 0 0 2px #22c55e, 0 0 14px -2px rgba(34, 197, 94, .8); }

/* ── estados vacíos de Configuración con ícono ── */
.cf-cfg-vacio { position: relative; padding-left: 52px !important; }
.cf-cfg-vacio::before { content: ''; position: absolute; left: 14px; top: 50%; width: 26px; height: 26px; transform: translateY(-50%); border-radius: 8px; background: linear-gradient(135deg, #f43f5e, #a855f7);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 8v8M8 12h8'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 8v8M8 12h8'/%3E%3C/svg%3E") center / contain no-repeat; }

/* ── número que acaba de cambiar: destello verde si sube, rojo si baja ── */
html.cf-mov .cf-fx-sube { animation: cf-fx-sube 1.2s ease-out; }
html.cf-mov .cf-fx-baja { animation: cf-fx-baja 1.2s ease-out; }
@keyframes cf-fx-sube { 0% { filter: brightness(1.45) drop-shadow(0 0 14px rgba(34, 197, 94, .95)); scale: 1.06; } 35% { scale: 1; } 100% { filter: none; } }
@keyframes cf-fx-baja { 0% { filter: brightness(1.3) drop-shadow(0 0 14px rgba(244, 63, 94, .9)); } 100% { filter: none; } }

/* ── botones que se hunden un poco al tocarlos ── */
html.cf-mov :is(.cf-btn, .cf-chip, .cf-motivo-chip, .cf-hr-chip, .cf-lg-tab, .cf-cfg-tab, .cf-ojo, .cf-ojo-v, .cf-panel-flota button):active:not(:disabled) { scale: .96; transition: scale .08s ease-out; }

/* ── cambio de pestaña: el contenido entra desde el lado de la pestaña elegida ── */
html.cf-mov .cf-fx-pestana { animation: cf-fx-pestana .28s cubic-bezier(.2, .8, .2, 1); }
@keyframes cf-fx-pestana { from { opacity: 0; translate: var(--cf-dx, 0) 4px; } to { opacity: 1; translate: none; } }

/* ── Métricas, Análisis y Dueño cargando: la silueta tiene la forma de lo que viene (4 cifras y una gráfica) ── */
.cf-panel:is([data-tipo="metricas"], [data-tipo="analisis"], [data-tipo="dueno"]) #cf-panel-body.cf-carga-pulso::after {
  width: min(760px, 94%); height: 210px;
  -webkit-mask: linear-gradient(#000 0 0) 0 0 / 23.4% 70px no-repeat, linear-gradient(#000 0 0) 33.333% 0 / 23.4% 70px no-repeat,
    linear-gradient(#000 0 0) 66.667% 0 / 23.4% 70px no-repeat, linear-gradient(#000 0 0) 100% 0 / 23.4% 70px no-repeat, linear-gradient(#000 0 0) 0 88px / 100% 122px no-repeat;
  mask: linear-gradient(#000 0 0) 0 0 / 23.4% 70px no-repeat, linear-gradient(#000 0 0) 33.333% 0 / 23.4% 70px no-repeat,
    linear-gradient(#000 0 0) 66.667% 0 / 23.4% 70px no-repeat, linear-gradient(#000 0 0) 100% 0 / 23.4% 70px no-repeat, linear-gradient(#000 0 0) 0 88px / 100% 122px no-repeat;
}

/* Métricas: debajo de "Leyendo Meta…" va la misma silueta (4 cifras y una gráfica) */
.cf-sil-met::after { content: ''; display: block; height: 210px; margin-top: 14px; border-radius: 14px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--t2) 10%, transparent) 25%, color-mix(in srgb, var(--t2) 20%, transparent) 40%, color-mix(in srgb, var(--t2) 10%, transparent) 60%) 0 0 / 300% 100%;
  -webkit-mask: linear-gradient(#000 0 0) 0 0 / 23.4% 70px no-repeat, linear-gradient(#000 0 0) 33.333% 0 / 23.4% 70px no-repeat,
    linear-gradient(#000 0 0) 66.667% 0 / 23.4% 70px no-repeat, linear-gradient(#000 0 0) 100% 0 / 23.4% 70px no-repeat, linear-gradient(#000 0 0) 0 88px / 100% 122px no-repeat;
  mask: linear-gradient(#000 0 0) 0 0 / 23.4% 70px no-repeat, linear-gradient(#000 0 0) 33.333% 0 / 23.4% 70px no-repeat,
    linear-gradient(#000 0 0) 66.667% 0 / 23.4% 70px no-repeat, linear-gradient(#000 0 0) 100% 0 / 23.4% 70px no-repeat, linear-gradient(#000 0 0) 0 88px / 100% 122px no-repeat; }
html.cf-mov .cf-sil-met::after { animation: cf-fx-brillo 1.6s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  .cf-sil-met::after,
  .cf-fx-sube, .cf-fx-baja, .cf-fx-pestana { animation: none !important; }
  #cf-panel-body.cf-carga-pulso::before, #cf-panel-body.cf-carga-pulso::after, #cf-panel-body.cf-cambio, .cf-toque, .cf-card.cf-entra .cf-card-av, .cf-huc-anillo,
  #cf-app .cf-header-actions .cf-btn.cf-hx-actual::before { animation: none !important; }
}

/* ───────── [Pulso-Supabase] pulido visual (oct 2026) ───────── */
/* ✕ flotante dentro de los paneles: aparece al bajar, así cerrar siempre queda a la mano */
.cf-panel-flota { position: sticky; top: 8px; z-index: 30; height: 0; display: flex; justify-content: flex-end; pointer-events: none; }
.cf-panel-flota button { pointer-events: auto; width: 40px; height: 40px; border-radius: 50%; border: 1px solid color-mix(in srgb, #a855f7 35%, var(--border)); cursor: pointer;
  background: color-mix(in srgb, var(--surface) 88%, #a855f7 12%); color: var(--t1); font-size: 17px; font-weight: 700; display: grid; place-items: center;
  box-shadow: 0 10px 24px -10px rgba(0, 0, 0, .6); opacity: 0; transform: translateY(-6px) scale(.9); visibility: hidden;
  transition: opacity .18s ease, transform .18s ease, visibility 0s linear .18s; }
.cf-panel.cf-p-bajo .cf-panel-flota button { opacity: 1; transform: none; visibility: visible; transition: opacity .18s ease, transform .18s ease; }
.cf-panel-flota button:hover { background: color-mix(in srgb, var(--surface) 70%, #a855f7 30%); }
.cf-panel-flota button:focus-visible { outline: 2px solid #c084fc; outline-offset: 2px; }
.cf-panel[data-tipo="tv"] .cf-panel-flota { display: none; }
/* el scroll del panel no arrastra la página de atrás; en celular la página queda quieta */
.cf-panel { overscroll-behavior: contain; }
@media (max-width: 899px) { html:has(#cf-panel.cf-open) { overflow: hidden; } }

/* logo y herramientas de arriba: en pantallas medianas, Conexiones y Configuración quedan solo con ícono */
@media (min-width: 701px) and (max-width: 1180px) {
  html.cf-hx-listo #cf-app .cf-hx-util #cf-btn-admin, html.cf-hx-listo #cf-app .cf-hx-util #cf-btn-integ { width: 40px; padding: 0; justify-content: center; }
  html.cf-hx-listo #cf-app .cf-hx-util #cf-btn-admin .cf-hide-sm, html.cf-hx-listo #cf-app .cf-hx-util #cf-btn-integ .cf-hide-sm { display: none !important; }
  html.cf-hx-listo #cf-app .cf-hx-util { gap: 2px; }
}

/* ojito de ventas: no tapa los filtros de fecha */
#cf-envivo .cf-hero-l .cf-hero-rango { padding-right: 40px; }

/* Hoy / Ayer / Antier junto a la fecha: píldoras del mismo alto, no círculos */
.cf-motivos:has(> input[type="date"]) { align-items: stretch; }
.cf-motivos:has(> input[type="date"]) > .cf-motivo-chip { padding: 0 18px; border-radius: 14px; min-width: 64px; }

/* títulos que se pliegan: la flecha nunca se aplasta */
.cf-plg-chev { flex-shrink: 0; }

/* Productos: botones con aire y el de unificar con su ícono a la izquierda */
.cf-panel[data-tipo="productos"] .cf-ig-acc { margin: 12px 0; align-items: center; }

/* filas que se desplazan de lado: se desvanecen en el borde para que se note que hay más */
@property --cf-fi { syntax: '<length>'; inherits: false; initial-value: 0px; }
@property --cf-fd { syntax: '<length>'; inherits: false; initial-value: 0px; }
@keyframes cf-borde-x { 0% { --cf-fi: 0px; --cf-fd: 28px; } 8% { --cf-fi: 28px; } 92% { --cf-fd: 28px; } 100% { --cf-fi: 28px; --cf-fd: 0px; } }
@supports (animation-timeline: scroll(self inline)) {
  .cf-chips-scroll, .cf-vista-sel, .cf-lg-tabs, .cf-cfg-nav, .cf-ad2-tabs,
  .cf-panel .cf-met-bar .cf-chips, .cf-panel .cf-ana-rango .cf-chips {
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--cf-fi), #000 calc(100% - var(--cf-fd)), transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0, #000 var(--cf-fi), #000 calc(100% - var(--cf-fd)), transparent 100%);
    animation: cf-borde-x linear both; animation-timeline: scroll(self inline);
  }
}
.cf-pr-uni-b { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 1px; align-items: center; padding: 10px 14px; }
.cf-pr-uni-b > .cf-ic { grid-row: span 2; width: 22px; height: 22px; }
.cf-pr-uni-b > small { grid-column: 2; }
