/* =========================================================
   Live-Anfragen aus TemForms (in sich geschlossen)
   Entfernen: diese Datei und assets/js/leads-live.js aus index.html
   nehmen. Die data-leads-*-Attribute stören dann nicht; die drei
   Hero-Kärtchen mit data-leads-stat bleiben aber unsichtbar und
   sollten dann ebenfalls gelöscht oder ersetzt werden.
   ========================================================= */

/* ---------- Zahlen in den Hero-Kärtchen ---------- */
.float[data-leads-stat] { opacity: 0; visibility: hidden; filter: blur(6px); transition: opacity .7s ease, filter .7s ease, visibility 0s .7s, border-color .5s, box-shadow .5s; }
.float[data-leads-stat].is-ready { opacity: 1; visibility: visible; filter: none; transition: opacity .7s ease, filter .7s ease, border-color .5s, box-shadow .5s; }
.float--b[data-leads-stat].is-ready { transition-delay: .15s; }
.float--c[data-leads-stat].is-ready { transition-delay: .3s; }
.lstat__num { display: inline-block; min-width: 1ch; font-variant-numeric: tabular-nums; color: var(--text); }
.lstat__dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--green); vertical-align: 1px; animation: lPulse 2s ease-out infinite; }
@keyframes lPulse { 0% { box-shadow: 0 0 0 0 rgba(72, 189, 128, .6); } 70%, 100% { box-shadow: 0 0 0 7px rgba(72, 189, 128, 0); } }

/* neuer Lead: Kärtchen leuchtet kurz auf, „+1“ steigt auf */
.float[data-leads-stat].is-bump { border-color: rgba(72, 189, 128, .7); box-shadow: 0 0 0 4px rgba(72, 189, 128, .14), 0 20px 50px -12px rgba(72, 189, 128, .55); }
.float.is-bump .lstat__num { color: var(--green); }
.lstat__plus { position: absolute; right: 12px; top: -6px; padding: 3px 8px; border-radius: 99px; background: var(--green); color: var(--green-ink); font-size: 11px; font-weight: 800; pointer-events: none; animation: lPlus 1.6s cubic-bezier(.2, .7, .2, 1) forwards; }
@keyframes lPlus { 0% { opacity: 0; transform: translateY(8px) scale(.6); } 15% { opacity: 1; transform: translateY(0) scale(1.08); } 30% { transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-22px); } }

/* ---------- Listen (Hero-Portal und CRM-Kachel) ---------- */
.leads-livehead { display: flex; justify-content: space-between; align-items: center; margin: 2px 2px 6px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.portal__rows .lead { padding: 6px 10px; margin-top: 5px; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 9px; }
.portal__rows .lead b, .portal__rows .lead small { display: block; line-height: 1.3; }
.portal__rows .leads-livehead + .lead { margin-top: 0; }
.portal__rows .lead__av { width: 28px; height: 28px; font-size: 11px; }
.portal__rows .lead b { font-size: 12.5px; }
.portal__rows .lead small { font-size: 10.5px; }
.portal__chart svg { height: 64px; }
.lead time { font-variant-numeric: tabular-nums; }
.lead b, .lead small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* neue Zeile klappt oben auf, älteste klappt unten zu */
.lead.is-enter { animation: lIn .75s cubic-bezier(.2, .8, .2, 1) both, lFlash 2.4s ease .2s; }
.lead.is-enter .lead__av { animation: lPop .6s cubic-bezier(.3, 1.6, .5, 1) .15s both; }
.lead.is-leave { animation: lOut .45s ease forwards; }
@keyframes lIn { from { opacity: 0; max-height: 0; margin-top: 0; padding-top: 0; padding-bottom: 0; transform: translateY(-10px) scale(.97); } to { opacity: 1; max-height: 70px; transform: none; } }
@keyframes lOut { from { opacity: 1; max-height: 70px; } to { opacity: 0; max-height: 0; margin-top: 0; padding-top: 0; padding-bottom: 0; transform: scale(.97); } }
@keyframes lFlash { 0%, 40% { border-color: rgba(72, 189, 128, .6); box-shadow: inset 0 0 0 1px rgba(72, 189, 128, .25), 0 0 26px -6px rgba(72, 189, 128, .55); } 100% { border-color: var(--line); box-shadow: none; } }
@keyframes lPop { from { transform: scale(0); } }
.lead em.is-new { padding: 3px 8px; font-size: 10px; font-weight: 700; letter-spacing: .02em; background: rgba(72, 189, 128, .12); color: var(--green-2); box-shadow: inset 0 0 0 1px rgba(72, 189, 128, .28); animation: lPlus2 .5s ease both; }
@keyframes lPlus2 { from { opacity: 0; transform: scale(.6); } }

/* ---------- Ladezustand: Skelett statt Beispieldaten ---------- */
/* je Zeile: Kreis + ein Balken (der Textblock selbst, damit die Höhe exakt stimmt) */
.is-loading .lead__av, .is-loading .lead > div,
[data-leads-kpi].is-loading small, [data-leads-kpi].is-loading b, .portal__live.is-loading {
  color: transparent !important; border-radius: 8px; user-select: none;
  background: linear-gradient(90deg, rgba(255, 255, 255, .05) 20%, rgba(255, 255, 255, .13) 50%, rgba(255, 255, 255, .05) 80%) 0 0 / 220% 100%;
  animation: lSkel 1.5s linear infinite;
}
.is-loading .lead__av { border-radius: 50%; }
.is-loading .lead > div { width: 68%; }
.is-loading .lead:nth-of-type(2n) > div { width: 52%; }
.is-loading .lead:nth-of-type(3n) > div { width: 60%; }
.is-loading .lead > div *, .portal__live.is-loading * { color: transparent !important; }
[data-leads-kpi].is-loading small, [data-leads-kpi].is-loading b { display: block; width: fit-content; }
[data-leads-kpi].is-loading small { margin-bottom: 6px; }
[data-leads-kpi].is-loading b { min-width: 55%; }
.is-loading .lead em { display: none; }
.lead--skel { pointer-events: none; }
@keyframes lSkel { from { background-position: 100% 0; } to { background-position: -120% 0; } }

/* sanft einblenden, sobald die echten Daten da sind */
.is-loaded > .lead { animation: lReveal .65s cubic-bezier(.2, .8, .2, 1) both; animation-delay: var(--d, 0s); }
[data-leads-kpi].is-loaded small, [data-leads-kpi].is-loaded b, .portal__live.is-loaded { animation: lReveal .6s cubic-bezier(.2, .8, .2, 1) both; }
[data-leads-kpi="avg"].is-loaded b { animation-delay: .1s; }
@keyframes lReveal { from { opacity: 0; transform: translateY(6px); filter: blur(4px); } }

/* Kacheln „Letzte Anfrage“ / „Ø pro Tag“ */
.portal__live.is-live { color: var(--text-2); }
.portal__dot { display: inline-block; margin-right: 2px; color: var(--green); animation: lBlink 2s ease-in-out infinite; }
@keyframes lBlink { 50% { opacity: .35; } }
[data-leads-kpi] b { font-variant-numeric: tabular-nums; }
[data-leads-kpi].is-flash { animation: lFlash 2.4s ease; }
[data-leads-kpi].is-flash b { animation: lKpi .6s cubic-bezier(.3, 1.4, .5, 1); color: var(--green); }
[data-leads-kpi] b { transition: color 1s ease; }
@keyframes lKpi { from { transform: translateY(6px); opacity: 0; } }

/* ---------- Live-Hinweis unten links ---------- */
.lead-toast { position: fixed; left: 20px; bottom: 20px; z-index: 60; pointer-events: none; }
.lead-toast__item { display: flex; align-items: center; gap: 10px; padding: 11px 16px 11px 13px; border-radius: 999px; background: rgba(28, 32, 35, .94); border: 1px solid rgba(72, 189, 128, .35); box-shadow: 0 18px 40px -14px rgba(0, 0, 0, .8), 0 0 30px -10px rgba(72, 189, 128, .45); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); font-size: 14px; font-weight: 700; color: var(--text); opacity: 0; transform: translateY(16px) scale(.96); transition: opacity .45s ease, transform .55s cubic-bezier(.2, .8, .2, 1); }
.lead-toast__item.is-in { opacity: 1; transform: none; }
.lead-toast__item.is-out { opacity: 0; transform: translateY(10px) scale(.97); transition-duration: .35s; }
.lead-toast__dot { position: relative; width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex: 0 0 auto; animation: lPulse 1.6s ease-out infinite; }
/* Kärtchen so setzen, dass Namen und Kennzahlen frei bleiben */
@media (min-width: 961px) {
  .float--a[data-leads-stat] { top: -16px; }
  .float--b[data-leads-stat] { top: 168px; }
  .float--c[data-leads-stat] { left: auto; right: -30px; bottom: 30px; }
}
@media (max-width: 960px) {
  .lead-toast { left: 12px; bottom: 12px; }
}
@media (max-width: 640px) {
  .lead-toast { bottom: 84px; } /* über dem mobilen Erstgespräch-Button */
}
@media (max-width: 640px) {
  .portal__rows .lead:nth-of-type(n+5) { display: none; } /* Handy: 3 Zeilen */
}

@media (prefers-reduced-motion: reduce) {
  .float[data-leads-stat], .float[data-leads-stat].is-ready, .lead-toast__item { transition: none; filter: none; }
  .lead.is-enter, .lead.is-enter .lead__av, .lead.is-leave, .lstat__plus, .lstat__dot, .lead-toast__dot, .portal__dot, .is-loaded > .lead, [data-leads-kpi].is-loaded b, [data-leads-kpi].is-loaded small, .portal__live.is-loaded { animation: none; }
  .is-loading .lead__av, .is-loading .lead > div, [data-leads-kpi].is-loading small, [data-leads-kpi].is-loading b, .portal__live.is-loading { animation: none; }
  .lead-toast__item { transform: none; }
}
