import { PaletteOptions } from '@mui/material';

/*
 * Raw hex values that mirror tokens.css.
 * Keep these in sync: tokens.css is what the browser renders,
 * BRAND + LIGHT/DARK_PALETTE are what MUI uses to generate --mui-palette-* variables.
 */
export const BRAND = {
  teal:              '#1d4a40',
  tealLight:         '#2f6b5e',
  tealDark:          '#123029',
  tealContrast:      '#f3efe9',
  terracotta:        '#d98c6a',
  terracottaLight:   '#e6a98a',
  terracottaDark:    '#bf6f4d',
  terracottaContrast:'#2a1a12',
  cream:             '#faf9f5',
  creamSoft:         '#f3efe9',
  ink:               '#1b2521',
  // Dark-mode surface & lifted brand
  tealOnDark:        '#6fc0ac',
  tealOnDarkLight:   '#8fd2c1',
  tealOnDarkDark:    '#3f8a78',
  tealOnDarkContrast:'#06120f',
  tealDeep:          '#0f1c19',
  tealSurface:       '#16302a',
} as const;

/*
 * Semantic feedback colors — mirrors tokens.css --bal-{success,error,warning,info}.
 * Feeds MUI's palette.{success,error,warning,info} so Alert/Chip/Badge/LinearProgress
 * render brand-harmonized instead of MUI's stock green/red — the same colors the
 * notistack toasts already use (NotistackProvider reads the CSS tokens directly).
 */
const LIGHT_FEEDBACK: PaletteOptions = {
  success: { main: '#1f6b50', contrastText: '#f3efe9' },
  error:   { main: '#a8392a', contrastText: '#f3efe9' },
  warning: { main: '#8a6418', contrastText: '#f3efe9' },
  info:    { main: '#1d4a40', contrastText: '#f3efe9' },
};

const DARK_FEEDBACK: PaletteOptions = {
  success: { main: '#257659', contrastText: '#f3efe9' },
  error:   { main: '#b5402f', contrastText: '#f3efe9' },
  warning: { main: '#97701f', contrastText: '#f3efe9' },
  info:    { main: '#2f6b5e', contrastText: '#f3efe9' },
};

export const LIGHT_PALETTE: PaletteOptions = {
  primary: {
    main:         BRAND.teal,
    light:        BRAND.tealLight,
    dark:         BRAND.tealDark,
    contrastText: BRAND.tealContrast,
  },
  secondary: {
    main:         BRAND.terracotta,
    light:        BRAND.terracottaLight,
    dark:         BRAND.terracottaDark,
    contrastText: BRAND.terracottaContrast,
  },
  background: {
    default: BRAND.cream,
    paper:   '#ffffff',
  },
  text: {
    primary:   BRAND.ink,
    secondary: '#5b655f',
  },
  divider: 'rgba(29, 74, 64, 0.14)',
  ...LIGHT_FEEDBACK,
};

export const DARK_PALETTE: PaletteOptions = {
  primary: {
    main:         BRAND.tealOnDark,
    light:        BRAND.tealOnDarkLight,
    dark:         BRAND.tealOnDarkDark,
    contrastText: BRAND.tealOnDarkContrast,
  },
  secondary: {
    main:         BRAND.terracottaLight,
    light:        '#f0bfa3',
    dark:         BRAND.terracotta,
    contrastText: BRAND.terracottaContrast,
  },
  background: {
    default: BRAND.tealDeep,
    paper:   BRAND.tealSurface,
  },
  text: {
    primary:   BRAND.creamSoft,
    secondary: '#9fb0a9',
  },
  divider: 'rgba(243, 239, 233, 0.14)',
  ...DARK_FEEDBACK,
};
