/**
 * theme.ts — one design system for the whole app.
 * Home surfaces read light & clean; call surfaces go immersive dark like the
 * native iOS/Android phone apps. Keeping tokens here makes the UI feel cohesive.
 */
export const colors = {
  // Brand
  primary: '#0A84FF',        // iOS system blue
  primaryDark: '#0060DF',

  // Call actions
  answer: '#34C759',         // green
  answerDark: '#248A3D',
  decline: '#FF3B30',        // red
  declineDark: '#C42B22',

  // Home (light)
  bg: '#FFFFFF',
  bgSecondary: '#F2F2F7',
  card: '#FFFFFF',
  text: '#1C1C1E',
  textSecondary: '#8E8E93',
  separator: '#E5E5EA',

  // Call (dark immersive)
  callBg: '#1C1C22',
  callBgGradientTop: '#2C2C36',
  callSurface: 'rgba(255,255,255,0.14)',
  callSurfaceActive: '#FFFFFF',
  callText: '#FFFFFF',
  callTextSecondary: 'rgba(235,235,245,0.6)',

  white: '#FFFFFF',
  black: '#000000',
};

export const spacing = {
  xs: 4,
  sm: 8,
  md: 16,
  lg: 24,
  xl: 32,
  xxl: 48,
};

export const radius = {
  sm: 8,
  md: 14,
  lg: 22,
  pill: 999,
};

export const typography = {
  largeTitle: { fontSize: 34, fontWeight: '700' as const },
  title: { fontSize: 28, fontWeight: '700' as const },
  callerName: { fontSize: 34, fontWeight: '600' as const, letterSpacing: 0.3 },
  status: { fontSize: 17, fontWeight: '400' as const },
  body: { fontSize: 17, fontWeight: '400' as const },
  digit: { fontSize: 36, fontWeight: '300' as const },
  digitLetters: { fontSize: 10, fontWeight: '600' as const, letterSpacing: 2 },
  label: { fontSize: 13, fontWeight: '500' as const },
  button: { fontSize: 17, fontWeight: '600' as const },
};

/** Deterministic avatar colour from a name/number — no two feel random. */
export function avatarColor(seed: string): string {
  const palette = ['#FF9500', '#FF2D55', '#5856D6', '#34C759', '#0A84FF', '#AF52DE', '#FF6482'];
  let h = 0;
  for (let i = 0; i < seed.length; i++) h = (h * 31 + seed.charCodeAt(i)) & 0xffffff;
  return palette[Math.abs(h) % palette.length];
}

/** "Arun Field" -> "AF", "+15551234567" -> "#". */
export function initials(name: string): string {
  const clean = (name || '').trim();
  if (!clean) return '?';
  if (/^[+\d]/.test(clean)) return '#';
  const parts = clean.split(/\s+/);
  return (parts[0][0] + (parts[1]?.[0] || '')).toUpperCase();
}
