/* ============================================================
   OSP App-Launcher — Shared Popover (alle Apps & Systeme)
   Roll-out in jeder App:
     <link rel="stylesheet" href="/shared/app-launcher.css">
     <script defer src="/shared/app-launcher.js"></script>
   + Trigger-Button mit id="app-launcher-btn" in den Header.
   Eigenständig gestylt (keine App-spezifischen Variablen nötig).
   ============================================================ */

/* ── Trigger (beliebiger Button/Link mit id="app-launcher-btn") ──
   Größe/Aussehen steuert die Host-App (z.B. .hdr-app-favicon-link
   mit 40px-Icon). Hier nur neutraler Button-Reset + Aktiv-Zustand. */
.osp-launcher-trigger {
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.osp-launcher-trigger[aria-expanded="true"] {
  box-shadow: 0 0 0 2px var(--as-accent, #DC500F);
}

/* ── Overlay + Backdrop ─────────────────────────────────────── */
.osp-launcher-overlay {
  position: fixed;
  inset: 0;
  z-index: 11000;
  display: none;
}
.osp-launcher-overlay.open { display: block; }

.osp-launcher-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8,20,33,.30);
  opacity: 0;
  transition: opacity .18s ease;
}
.osp-launcher-overlay.open .osp-launcher-backdrop { opacity: 1; }

/* ── Panel ──────────────────────────────────────────────────── */
.osp-launcher-panel {
  position: absolute;
  width: min(444px, calc(100vw - 24px));
  max-height: min(74vh, 660px);
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #e6e9ef;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(8,20,33,.28), 0 8px 20px rgba(8,20,33,.12);
  padding: 12px 14px 16px;
  opacity: 0;
  transform: translateY(-6px) scale(.985);
  transition: opacity .18s ease, transform .18s cubic-bezier(.22,1,.36,1);
  font-family: 'Open Sans', system-ui, -apple-system, sans-serif;
  -webkit-overflow-scrolling: touch;
}
.osp-launcher-overlay.open .osp-launcher-panel { opacity: 1; transform: none; }

/* ── Kopf ───────────────────────────────────────────────────── */
.osp-launcher-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 4px 10px;
  border-bottom: 1px solid #eef1f5;
}
.osp-launcher-head .osp-l-logo {
  width: 32px; height: 32px;
  border-radius: 9px;
  object-fit: contain;
  flex-shrink: 0;
}
.osp-launcher-head .osp-l-ttl {
  font-family: 'Montserrat', system-ui, sans-serif;
  font-weight: 800;
  font-size: .98rem;
  color: #0f2233;
  line-height: 1.15;
}
.osp-launcher-head .osp-l-sub {
  font-size: .72rem;
  color: #64748b;
  margin-top: 1px;
}
.osp-launcher-close {
  margin-left: auto;
  width: 30px; height: 30px;
  border: none;
  background: #f1f4f8;
  color: #475569;
  border-radius: 8px;
  cursor: pointer;
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.osp-launcher-close:hover { background: #e2e8f0; color: #0f2233; }
.osp-launcher-close svg { width: 16px; height: 16px; }

/* ── Gruppen ────────────────────────────────────────────────── */
.osp-launcher-group-title {
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #94a3b8;
  padding: 14px 4px 8px;
}
.osp-launcher-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

/* ── Kachel ─────────────────────────────────────────────────── */
.osp-launcher-item {
  --it-accent: #0080C9;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 13px 8px 11px;
  border-radius: 13px;
  text-decoration: none;
  color: #0f2233;
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
  position: relative;
}
.osp-launcher-item:hover {
  background: color-mix(in srgb, var(--it-accent) 9%, #fff);
  border-color: color-mix(in srgb, var(--it-accent) 32%, #e6e9ef);
  transform: translateY(-2px);
  text-decoration: none;
  color: #0f2233;
}
.osp-launcher-item:focus-visible {
  outline: 2px solid var(--it-accent);
  outline-offset: 2px;
}
.osp-launcher-item .osp-l-ic {
  width: 44px; height: 44px;
  border-radius: 12px;
  object-fit: contain;
  display: grid; place-items: center;
  font-size: 23px;
  line-height: 1;
  background: color-mix(in srgb, var(--it-accent) 12%, #fff);
  box-shadow: 0 4px 12px -5px color-mix(in srgb, var(--it-accent) 55%, transparent);
}
.osp-launcher-item img.osp-l-ic { background: transparent; box-shadow: 0 5px 13px -6px color-mix(in srgb, var(--it-accent) 60%, transparent); }
.osp-launcher-item .osp-l-ic svg { width: 23px; height: 23px; }
.osp-launcher-item .osp-l-nm {
  font-size: .745rem;
  font-weight: 700;
  line-height: 1.18;
}

/* Aktive App (Pfad-Match) hervorheben */
.osp-launcher-item.is-active {
  background: color-mix(in srgb, var(--it-accent) 13%, #fff);
  border-color: color-mix(in srgb, var(--it-accent) 45%, #e6e9ef);
}
.osp-launcher-item.is-active::after {
  content: '';
  position: absolute;
  top: 8px; right: 8px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--it-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--it-accent) 22%, transparent);
}

/* "Bald verfügbar"-Kacheln */
.osp-launcher-item.is-soon { cursor: default; }
.osp-launcher-item.is-soon:hover { transform: none; background: transparent; border-color: transparent; }
.osp-launcher-item.is-soon .osp-l-ic { filter: grayscale(.9); opacity: .7; }
.osp-launcher-item.is-soon .osp-l-nm { color: #94a3b8; }
.osp-l-soon-tag {
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: #64748b;
  background: #eef1f5;
  border-radius: 999px;
  padding: 1px 7px;
  margin-top: 1px;
}

/* ── Dark Mode ──────────────────────────────────────────────── */
html.dark .osp-launcher-panel {
  background: #111c2e;
  border-color: #25344a;
  box-shadow: 0 24px 60px rgba(0,0,0,.55), 0 8px 20px rgba(0,0,0,.4);
}
html.dark .osp-launcher-head { border-bottom-color: #25344a; }
html.dark .osp-launcher-head .osp-l-ttl { color: #f1f5f9; }
html.dark .osp-launcher-head .osp-l-sub { color: #94a3b8; }
html.dark .osp-launcher-close { background: #1e2c42; color: #cbd5e1; }
html.dark .osp-launcher-close:hover { background: #2a3b56; color: #fff; }
html.dark .osp-launcher-item { color: #e8eef6; }
html.dark .osp-launcher-item:hover { background: color-mix(in srgb, var(--it-accent) 20%, #111c2e); }
html.dark .osp-launcher-item .osp-l-ic { background: color-mix(in srgb, var(--it-accent) 22%, #111c2e); }
html.dark .osp-launcher-item img.osp-l-ic { background: transparent; }
html.dark .osp-launcher-item.is-active { background: color-mix(in srgb, var(--it-accent) 24%, #111c2e); }
html.dark .osp-launcher-item.is-soon .osp-l-nm { color: #64748b; }
html.dark .osp-l-soon-tag { background: #1e2c42; color: #94a3b8; }

/* ── Mobil: Bottom-Sheet ────────────────────────────────────── */
@media (max-width: 520px) {
  .osp-launcher-panel {
    width: auto !important;
    left: 10px !important;
    right: 10px !important;
    bottom: 10px !important;
    top: auto !important;
    max-height: 80vh;
  }
  .osp-launcher-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .osp-launcher-panel, .osp-launcher-backdrop, .osp-launcher-item { transition: none; }
}
