"use client";
import React from "react";
import { useAppSelector } from "@/redux/store";

export default function GlobalActivityOverlay() {
  const anyLoop = useAppSelector((s) => s.deviceEvents.anyLoopActive);
  const anyTdr = useAppSelector((s) => s.deviceEvents.anyTdrActive);
  const anyAlign = useAppSelector((s) => s.deviceEvents.anyAlignmentActive);

  const active = anyLoop || anyTdr || anyAlign;
  if (!active) return null;

  const messages: string[] = [];
  if (anyLoop) messages.push("Schleifenmessung läuft…");
  if (anyTdr) messages.push("TDR-Messung läuft…");
  if (anyAlign) messages.push("Abgleich läuft…");

  return (
    <div className="fixed inset-0 z-[2000] flex items-center justify-center bg-white/70 backdrop-blur-sm">
      <div className="p-4 rounded-md shadow bg-white border border-gray-200">
        <div className="font-semibold mb-2">Bitte warten…</div>
        <div className="text-sm text-gray-700">{messages.join(" · ")}</div>
      </div>
    </div>
  );
}
