"use client";

/*
 * Root-level error boundary. Renders only when the root layout itself
 * crashes, so it must include its own <html> / <body>. No AppShell here —
 * the Providers that wrap AppShell are also above the crash boundary and
 * may themselves be the thing that failed.
 */
export default function GlobalError({
  error,
  reset,
}: {
  error: Error & { digest?: string };
  reset: () => void;
}) {
  return (
    <html lang="he" dir="rtl">
      <body
        style={{
          fontFamily: "system-ui, sans-serif",
          background: "#f5f1e8",
          color: "#1a1a2e",
          minHeight: "100vh",
          display: "flex",
          alignItems: "center",
          justifyContent: "center",
          padding: "2rem",
        }}
      >
        <div style={{ maxWidth: 520, textAlign: "center" }}>
          <h1 style={{ color: "#0f172a", fontSize: "2rem", marginBottom: 8 }}>
            שגיאה חמורה
          </h1>
          <p style={{ color: "#6b7280", lineHeight: 1.6, marginBottom: 16 }}>
            האפליקציה נכשלה לטעון. נסה לרענן את הדף.
          </p>
          {error.digest && (
            <p style={{ fontSize: 12, color: "#9ca3af", marginBottom: 16 }}>
              error id: {error.digest}
            </p>
          )}
          <button
            onClick={reset}
            style={{
              background: "#0f172a",
              color: "#fbf8f0",
              border: 0,
              padding: "0.6rem 1.25rem",
              borderRadius: 6,
              cursor: "pointer",
              fontSize: "0.95rem",
            }}
          >
            נסה שוב
          </button>
        </div>
      </body>
    </html>
  );
}
