/* ══ VICore PWA-Chrome ══════════════════════════════════════════════════════
   Kleine, additive UI-Elemente für die installierte App: Offline-Hinweisleiste,
   „App installieren"-Banner und „Neue Version"-Hinweis. Werden von einem
   Inline-Skript in index.html erzeugt (window.viPWA).
   Farben/Typografie/Abstände/Radien/Schatten ausschließlich über Design-Tokens.
   Wenige feste px sind bewusst gesetzt: Komponenten-Geometrie (Indikator-Punkt,
   Icon-Fläche) bzw. barrierefreie Mindest-Touchflächen (≥ 40/44/48 px).
   Namespace: .vi-pwa- · IDs: #vi-pwa-*
   ═════════════════════════════════════════════════════════════════════════ */

/* ── Offline-Leiste (oben, schlank) ─────────────────────────────────────── */
#vi-pwa-offline-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9300;
  display: none;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  padding-top: calc(var(--space-1) + env(safe-area-inset-top, 0px));
  background: var(--color-danger);
  color: var(--text-inverse);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: .01em;
  text-align: center;
  box-shadow: var(--shadow-md);
}
body.vi-offline #vi-pwa-offline-bar { display: flex; }
#vi-pwa-offline-bar .vi-pwa-dot {
  width: 7px; height: 7px; border-radius: var(--radius-full);  /* Indikator-Punkt: feste Geometrie */
  background: currentColor; opacity: .85;
  animation: viPwaPulse 1.4s ease-in-out infinite;
}
@keyframes viPwaPulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #vi-pwa-offline-bar .vi-pwa-dot { animation: none; } }

/* ── „App installieren"-Banner (unten) ──────────────────────────────────── */
#vi-pwa-install {
  position: fixed;
  left: 50%;
  bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(8px);
  z-index: 9300;
  display: none;
  align-items: center;
  gap: var(--space-3);
  max-width: min(440px, calc(100vw - 24px));
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  font-family: var(--font-body);
  opacity: 0;
  transition: opacity .22s ease, transform .22s ease;
}
#vi-pwa-install.is-show { display: flex; opacity: 1; transform: translateX(-50%) translateY(0); }
#vi-pwa-install .vi-pwa-ic {
  flex: 0 0 auto; width: 34px; height: 34px;  /* feste Icon-Fläche */
  border-radius: var(--radius-md);
  display: grid; place-items: center;
  background: var(--color-forest-soft); color: var(--color-forest);
}
#vi-pwa-install .vi-pwa-txt { flex: 1 1 auto; min-width: 0; line-height: 1.3; }
#vi-pwa-install .vi-pwa-title { font-size: var(--text-sm); font-weight: 700; }
#vi-pwa-install .vi-pwa-sub { font-size: var(--text-xs); color: var(--text-secondary); overflow-wrap: anywhere; }
#vi-pwa-install .vi-pwa-actions { flex: 0 0 auto; display: flex; align-items: center; gap: var(--space-1); }
.vi-pwa-btn {
  font-family: var(--font-body); font-size: var(--text-sm); font-weight: 600;
  min-height: 40px; padding: 0 var(--space-3);  /* 40 px = barrierefreie Mindest-Touchfläche */
  border-radius: var(--radius-md);
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
}
.vi-pwa-btn-primary { background: var(--color-forest); color: var(--text-inverse); }
.vi-pwa-btn-primary:hover { background: var(--color-forest-hover); }
.vi-pwa-btn-ghost {
  background: transparent; color: var(--text-secondary);
  min-height: 40px; width: 40px; padding: 0; display: grid; place-items: center;
  border-radius: var(--radius-md); font-size: var(--text-lg); line-height: 1;
}
.vi-pwa-btn-ghost:hover { background: var(--color-slate-100); }

/* ── „Neue Version verfügbar"-Hinweis (unten, dezent) ───────────────────── */
#vi-pwa-update {
  position: fixed;
  left: 50%;
  bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(8px);
  z-index: 9350;
  display: none;
  align-items: center;
  gap: var(--space-3);
  max-width: min(440px, calc(100vw - 24px));
  padding: var(--space-2) var(--space-4);
  background: var(--color-forest);
  color: var(--text-inverse);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  font-family: var(--font-body);
}
#vi-pwa-update.is-show { display: flex; }
#vi-pwa-update .vi-pwa-title { font-size: var(--text-sm); font-weight: 600; }
#vi-pwa-update .vi-pwa-btn-primary { background: var(--text-inverse); color: var(--color-forest); }
#vi-pwa-update .vi-pwa-btn-primary:hover { background: var(--color-cream); }
/* ── Feedback #3 §8.2: Ladezustand, Fehlerzustand und Erfolgsmeldung ────────
   Ein Update ist ein Vorgang mit Dauer — er braucht einen sichtbaren Zustand.
   Der Ring dreht sich nur, solange wirklich gewartet wird; „erfolgreich“ erscheint
   erst nach dem Neustart, also wenn die neue Fassung tatsächlich läuft. */
#vi-pwa-update .vi-pwa-spin {
  width: 16px; height: 16px; flex: 0 0 auto;
  border: 2px solid color-mix(in srgb, var(--text-inverse) 35%, transparent);
  border-top-color: var(--text-inverse);
  border-radius: 50%;
  animation: vi-pwa-spin 0.9s linear infinite;
}
#vi-pwa-update .vi-pwa-spin[hidden] { display: none; }
/* Der Knopf IST ein <button>, und `button, .btn { display: inline-flex }` aus dem
   Designsystem schlaegt das UA-`[hidden] { display: none }` (0,1,1 gegen 0,0,0).
   Ohne diese Zeile blieb „Aktualisieren" waehrend des Ladezustands sichtbar,
   obwohl `btn.hidden = true` gesetzt war (Fehlerbild 28.08.2026). Gleiche Falle,
   gleiche Loesung wie bei `.vi-confirm-actions button[hidden]` in components.css. */
#vi-pwa-update .vi-pwa-btn[hidden] { display: none; }
#vi-pwa-update[data-state="error"] { background: var(--color-danger, #B3261E); }
@keyframes vi-pwa-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #vi-pwa-update .vi-pwa-spin { animation-duration: 2.4s; } }

#vi-pwa-updated {
  position: fixed;
  left: 50%;
  bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(8px);
  z-index: 9350;
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  max-width: min(440px, calc(100vw - 24px));
  padding: var(--space-2) var(--space-4);
  background: var(--color-forest);
  color: var(--text-inverse);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  font-family: var(--font-body);
}
#vi-pwa-updated.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }
#vi-pwa-updated .vi-pwa-title { font-size: var(--text-sm); font-weight: 600; }

/* Auf kleinen Geräten Platz für die Bottom-Navigation lassen. */
@media (max-width: 767px) {
  #vi-pwa-install, #vi-pwa-update, #vi-pwa-updated { bottom: calc(78px + env(safe-area-inset-bottom, 0px)); }
}
