'use client';

import { Card } from '@/ui/Card';
import { Heading } from '@/ui/Heading';
import { Icon } from '@/ui/Icon';
import { Text } from '@/ui/Text';
import { Box } from '@/ui/Box';
import { Stack } from '@/ui/Stack';
import { Surface } from '@/ui/Surface';
import { AlertTriangle } from 'lucide-react';
import React from 'react';

interface ServerErrorPanelProps {
  message?: string;
  incidentId?: string;
}

/**
 * ServerErrorPanel
 * 
 * Displays the primary error information in an "instrument-grade" style.
 * Part of the 500 route redesign.
 */
export function ServerErrorPanel({ message, incidentId }: ServerErrorPanelProps) {
  return (
    <Stack alignItems="center" gap={6} fullWidth>
      {/* Status Indicator */}
      <Surface 
        padding={4} 
        rounded="full" 
        bg="rgba(255, 190, 77, 0.1)" 
        border="1px solid rgba(255, 190, 77, 0.3)"
        display="flex"
        alignItems="center"
        justifyContent="center"
      >
        <Icon icon={AlertTriangle} size={8} intent="warning" />
      </Surface>

      {/* Primary Message */}
      <Stack alignItems="center" gap={2}>
        <Heading level={1} weight="bold">
          CRITICAL_SYSTEM_FAILURE
        </Heading>
        <Text variant="low" align="center" style={{ maxWidth: '32rem' }}>
          The application engine encountered an unrecoverable state. 
          Telemetry has been dispatched to engineering.
        </Text>
      </Stack>

      {/* Technical Summary */}
      <Box fullWidth>
        <Card variant="outline">
          <Stack gap={2}>
            <Text font="mono" size="sm" variant="warning" block>
              STATUS: 500_INTERNAL_SERVER_ERROR
            </Text>
            {message && (
              <Text font="mono" size="xs" variant="low" block>
                EXCEPTION: {message}
              </Text>
            )}
            {incidentId && (
              <Text font="mono" size="xs" variant="low" block>
                INCIDENT_ID: {incidentId}
              </Text>
            )}
          </Stack>
        </Card>
      </Box>
    </Stack>
  );
}
