import { z } from 'zod';

const envSchema = z.object({
  PORT: z.coerce.number().default(4007),
  HOST: z.string().default('0.0.0.0'),
  NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
  CORS_ORIGIN: z.string().optional(),
  LOG_LEVEL: z.enum(['trace', 'debug', 'info', 'warn', 'error', 'fatal']).default('info'),
  JWT_SECRET: z.string().min(1, 'JWT_SECRET is required'),
  PLATFORM_SERVICE_URL: z.string().default('http://localhost:4003'),
  EXTRACTION_SERVICE_URL: z.string().default('http://localhost:4005'),
  /** Product-specific backend URLs */
  MINDLYST_BACKEND_URL: z.string().default('http://localhost:4014'),
  LYSNRAI_BACKEND_URL: z.string().default('http://localhost:4015'),
  JARVISJR_BACKEND_URL: z.string().default('http://localhost:4012'),
  CHRONOMIND_BACKEND_URL: z.string().default('http://localhost:4011'),
  NOMGAP_BACKEND_URL: z.string().default('http://localhost:4013'),
  NOTELETT_BACKEND_URL: z.string().default('http://localhost:4016'),
  PEAKPULSE_BACKEND_URL: z.string().default('http://localhost:4010'),
  BYTELYST_NOTES_BACKEND_URL: z.string().default('http://localhost:4016'),
  /** Max items returned per tool call query (hard cap) */
  QUERY_MAX_LIMIT: z.coerce.number().default(100),
  /** Default items per tool call query */
  QUERY_DEFAULT_LIMIT: z.coerce.number().default(20),
});

export const config = envSchema.parse(process.env);
