import { Server, Box, GitCommit, GitMerge, GitPullRequest, GitBranch } from 'lucide-react';

export const MiniServerRack = () => (
  <div className="h-full flex flex-col gap-0.5">
    {[...Array(6)].map((_, i) => (
      <div key={i} className="flex items-center gap-1 bg-secondary/30 rounded px-1 py-0.5">
        <Server className="w-2.5 h-2.5 text-primary" />
        <span className="text-[6px] flex-1">SRV-{String(i + 1).padStart(2, '0')}</span>
        <div className={`w-1 h-1 rounded-full ${i < 5 ? 'bg-green-400' : 'bg-red-400'}`} />
      </div>
    ))}
  </div>
);

export const MiniDeploymentPipeline = () => (
  <div className="h-full flex items-center justify-between px-2">
    {['Build', 'Test', 'Stage', 'Prod'].map((stage, i) => (
      <div key={stage} className="flex flex-col items-center gap-1">
        <div className={`w-6 h-6 rounded-full flex items-center justify-center text-[8px] ${
          i < 2 ? 'bg-green-500/20 text-green-400' : i === 2 ? 'bg-yellow-500/20 text-yellow-400 animate-pulse' : 'bg-secondary/30 text-muted-foreground'
        }`}>{i < 2 ? '✓' : i === 2 ? '...' : '○'}</div>
        <span className="text-[6px] text-muted-foreground">{stage}</span>
      </div>
    ))}
  </div>
);

export const MiniKubernetes = () => (
  <div className="h-full grid grid-cols-3 gap-1">
    {['Pod-1', 'Pod-2', 'Pod-3', 'Pod-4', 'Pod-5', 'Pod-6'].map((pod, i) => (
      <div key={pod} className={`flex flex-col items-center justify-center rounded p-1 ${i < 5 ? 'bg-primary/20' : 'bg-red-500/20'}`}>
        <Box className={`w-3 h-3 ${i < 5 ? 'text-primary' : 'text-red-400'}`} />
        <span className="text-[5px] text-muted-foreground">{pod}</span>
      </div>
    ))}
  </div>
);

export const MiniContainerStats = () => (
  <div className="h-full flex flex-col gap-1 justify-center">
    {[
      { name: 'nginx', cpu: 12, mem: 45 },
      { name: 'redis', cpu: 8, mem: 32 },
      { name: 'postgres', cpu: 25, mem: 68 },
    ].map(c => (
      <div key={c.name} className="flex items-center gap-2 text-[7px]">
        <span className="w-10 text-muted-foreground truncate">{c.name}</span>
        <div className="flex-1 h-1.5 bg-secondary rounded-full overflow-hidden">
          <div className="h-full bg-primary" style={{ width: `${c.cpu}%` }} />
        </div>
        <span className="text-primary w-6">{c.cpu}%</span>
      </div>
    ))}
  </div>
);

export const MiniGitActivity = () => (
  <div className="h-full flex flex-col gap-1">
    {[
      { icon: GitCommit, msg: 'Fix auth bug', time: '2m' },
      { icon: GitMerge, msg: 'Merge PR #42', time: '15m' },
      { icon: GitPullRequest, msg: 'New feature', time: '1h' },
    ].map(({ icon: Icon, msg, time }, i) => (
      <div key={i} className="flex items-center gap-2 text-[7px]">
        <Icon className="w-3 h-3 text-primary" />
        <span className="flex-1 truncate text-muted-foreground">{msg}</span>
        <span className="text-primary/70">{time}</span>
      </div>
    ))}
  </div>
);

export const MiniCICD = () => (
  <div className="h-full flex flex-col gap-1">
    {[
      { name: 'main', status: 'success' },
      { name: 'develop', status: 'running' },
      { name: 'feature/x', status: 'failed' },
    ].map(b => (
      <div key={b.name} className="flex items-center gap-2 text-[7px] bg-secondary/20 rounded px-1.5 py-0.5">
        <GitBranch className="w-2.5 h-2.5 text-muted-foreground" />
        <span className="flex-1 truncate">{b.name}</span>
        <div className={`w-1.5 h-1.5 rounded-full ${
          b.status === 'success' ? 'bg-green-400' : b.status === 'running' ? 'bg-yellow-400 animate-pulse' : 'bg-red-400'
        }`} />
      </div>
    ))}
  </div>
);

export const MiniLogStream = () => (
  <div className="h-full font-mono text-[6px] bg-secondary/30 rounded p-1 overflow-hidden">
    {[
      { level: 'INFO', msg: 'Server started on :3000' },
      { level: 'DEBUG', msg: 'Processing request...' },
      { level: 'WARN', msg: 'Cache miss for key_x' },
      { level: 'ERROR', msg: 'Connection timeout' },
    ].map((l, i) => (
      <div key={i} className="truncate">
        <span className={`${l.level === 'ERROR' ? 'text-red-400' : l.level === 'WARN' ? 'text-yellow-400' : l.level === 'DEBUG' ? 'text-blue-400' : 'text-green-400'}`}>[{l.level}]</span>
        <span className="text-muted-foreground ml-1">{l.msg}</span>
      </div>
    ))}
  </div>
);

export const MiniAPILatency = () => (
  <div className="h-full flex items-end gap-0.5 pb-2">
    {[45, 52, 38, 67, 42, 55, 48, 62, 44, 51].map((v, i) => (
      <div key={i} className="flex-1 flex flex-col items-center gap-0.5">
        <div className={`w-full rounded-t ${v > 60 ? 'bg-red-400' : v > 50 ? 'bg-yellow-400' : 'bg-green-400'}`} style={{ height: `${v}%` }} />
        <span className="text-[5px] text-muted-foreground">{v}</span>
      </div>
    ))}
  </div>
);
