export const RSRP_THRESHOLDS = {
  EXCELLENT: -70,
  GOOD: -85,
  FAIR: -100,
  POOR: -110,
  WEAK: -120,
  NO_SERVICE: -120,
} as const;

export type SignalQuality = 'excellent' | 'good' | 'fair' | 'poor' | 'weak' | 'no-service';

export function getSignalQuality(rsrp: number): SignalQuality {
  if (rsrp >= RSRP_THRESHOLDS.EXCELLENT) return 'excellent';
  if (rsrp >= RSRP_THRESHOLDS.GOOD) return 'good';
  if (rsrp >= RSRP_THRESHOLDS.FAIR) return 'fair';
  if (rsrp >= RSRP_THRESHOLDS.POOR) return 'poor';
  if (rsrp >= RSRP_THRESHOLDS.WEAK) return 'weak';
  return 'no-service';
}

// New color scheme: cold = weak, warm = strong
export const SIGNAL_COLORS: Record<string, string> = {
  excellent: '#f44336',   // Red (very strong)
  good: '#ff9800',        // Orange (strong)
  fair: '#ffeb3b',        // Yellow (acceptable)
  poor: '#4caf50',        // Green (weak)
  weak: '#00bcd4',        // Cyan (very weak)
  'no-service': '#0d47a1', // Dark Blue (no coverage)
} as const;

export function getRSRPColor(rsrp: number): string {
  return SIGNAL_COLORS[getSignalQuality(rsrp)] ?? '#0d47a1';
}

export const RSRP_LEGEND = [
  { label: 'Excellent', range: '> -70 dBm', color: '#f44336', description: 'Very strong signal', min: -70 },
  { label: 'Good', range: '-70 to -85 dBm', color: '#ff9800', description: 'Strong signal', min: -85 },
  { label: 'Fair', range: '-85 to -100 dBm', color: '#ffeb3b', description: 'Acceptable signal', min: -100 },
  { label: 'Poor', range: '-100 to -110 dBm', color: '#4caf50', description: 'Weak signal', min: -110 },
  { label: 'Weak', range: '-110 to -120 dBm', color: '#00bcd4', description: 'Very weak signal', min: -120 },
  { label: 'No Service', range: '< -120 dBm', color: '#0d47a1', description: 'No coverage', min: -140 },
] as const;
