/**
 * Theme types — cross-platform theme configuration for iOS, Android, Desktop.
 */

import { z } from 'zod';

export interface PlatformTheme {
  primary: string;
  secondary: string;
  accent: string;
  background: string;
  surface: string;
  error: string;
  warning: string;
  success: string;
  idle?: string;
  listening?: string;
  processing?: string;
  offline?: string;
}

export interface ThemeDoc {
  id: string;
  productId: string;
  name: string;
  description: string | null;
  ios: PlatformTheme;
  android: PlatformTheme;
  desktop: PlatformTheme;
  is_active: boolean;
  is_default: boolean;
  version: string;
  created_at: string;
  updated_at: string;
  created_by: string | null;
  type: 'theme';
}

const PlatformThemeSchema = z.object({
  primary: z.string().optional(),
  secondary: z.string().optional(),
  accent: z.string().optional(),
  background: z.string().optional(),
  surface: z.string().optional(),
  error: z.string().optional(),
  warning: z.string().optional(),
  success: z.string().optional(),
  idle: z.string().optional(),
  listening: z.string().optional(),
  processing: z.string().optional(),
  offline: z.string().optional(),
});

export const CreateThemeSchema = z.object({
  name: z.string().min(1),
  description: z.string().nullable().optional(),
  ios: PlatformThemeSchema.optional(),
  android: PlatformThemeSchema.optional(),
  desktop: PlatformThemeSchema.optional(),
  is_active: z.boolean().optional(),
  is_default: z.boolean().optional(),
});

export const UpdateThemeSchema = z.object({
  name: z.string().min(1).optional(),
  description: z.string().nullable().optional(),
  ios: PlatformThemeSchema.optional(),
  android: PlatformThemeSchema.optional(),
  desktop: PlatformThemeSchema.optional(),
  is_active: z.boolean().optional(),
});
