export type Json =
  | string
  | number
  | boolean
  | null
  | { [key: string]: Json | undefined }
  | Json[];

export interface Database {
  public: {
    Tables: {
      teams: {
        Row: {
          id: string;
          name: string;
          is_admin_team: boolean | null;
          created_at: string | null;
        };
        Insert: {
          id?: string;
          name: string;
          is_admin_team?: boolean | null;
          created_at?: string | null;
        };
        Update: {
          id?: string;
          name?: string;
          is_admin_team?: boolean | null;
          created_at?: string | null;
        };
        Relationships: [];
      };
      profiles: {
        Row: {
          id: string;
          team_id: string;
          display_name: string | null;
          is_admin: boolean | null;
          created_at: string | null;
        };
        Insert: {
          id: string;
          team_id: string;
          display_name?: string | null;
          is_admin?: boolean | null;
          created_at?: string | null;
        };
        Update: {
          id?: string;
          team_id?: string;
          display_name?: string | null;
          is_admin?: boolean | null;
          created_at?: string | null;
        };
        Relationships: [
          {
            foreignKeyName: "profiles_id_fkey";
            columns: ["id"];
            isOneToOne: true;
            referencedRelation: "users";
            referencedColumns: ["id"];
          },
          {
            foreignKeyName: "profiles_team_id_fkey";
            columns: ["team_id"];
            isOneToOne: false;
            referencedRelation: "teams";
            referencedColumns: ["id"];
          }
        ];
      };
      canvas_data: {
        Row: {
          id: string;
          team_id: string;
          canvas_id: string;
          fields: Json | null;
          elements: Json | null;
          metadata: Json | null;
          created_at: string | null;
          updated_at: string | null;
        };
        Insert: {
          id?: string;
          team_id: string;
          canvas_id: string;
          fields?: Json | null;
          elements?: Json | null;
          metadata?: Json | null;
          created_at?: string | null;
          updated_at?: string | null;
        };
        Update: {
          id?: string;
          team_id?: string;
          canvas_id?: string;
          fields?: Json | null;
          elements?: Json | null;
          metadata?: Json | null;
          created_at?: string | null;
          updated_at?: string | null;
        };
        Relationships: [
          {
            foreignKeyName: "canvas_data_team_id_fkey";
            columns: ["team_id"];
            isOneToOne: false;
            referencedRelation: "teams";
            referencedColumns: ["id"];
          }
        ];
      };
      week_locks: {
        Row: {
          id: string;
          week: number;
          is_locked: boolean;
          locked_by: string | null;
          locked_at: string | null;
          updated_at: string | null;
        };
        Insert: {
          id?: string;
          week: number;
          is_locked?: boolean;
          locked_by?: string | null;
          locked_at?: string | null;
          updated_at?: string | null;
        };
        Update: {
          id?: string;
          week?: number;
          is_locked?: boolean;
          locked_by?: string | null;
          locked_at?: string | null;
          updated_at?: string | null;
        };
        Relationships: [];
      };
    };
    Views: Record<string, never>;
    Functions: {
      get_user_team_id: {
        Args: Record<string, never>;
        Returns: string;
      };
      is_user_admin: {
        Args: Record<string, never>;
        Returns: boolean;
      };
    };
    Enums: Record<string, never>;
  };
}

// Helper types for easier access
export type Team = Database["public"]["Tables"]["teams"]["Row"];
export type Profile = Database["public"]["Tables"]["profiles"]["Row"];
export type CanvasDataRow = Database["public"]["Tables"]["canvas_data"]["Row"];
